comparison lisp/ido.el @ 76148:d38be8d45087

(ido-buffer-internal): Set this-command to fallback command. Add selected buffer to buffer-name-history. (ido-file-internal): Set this-command to fallback command. Add file names to to file-name-history.
author Kim F. Storm <storm@cua.dk>
date Sun, 25 Feb 2007 23:48:54 +0000
parents 514805720b93
children a5db78ff7104 dd7c098af727
comparison
equal deleted inserted replaced
76147:541294beb87c 76148:d38be8d45087
2161 ((eq ido-exit 'insert-file) 2161 ((eq ido-exit 'insert-file)
2162 (ido-file-internal 'insert 'insert-file nil "Insert file: " nil ido-text 'ido-enter-insert-buffer)) 2162 (ido-file-internal 'insert 'insert-file nil "Insert file: " nil ido-text 'ido-enter-insert-buffer))
2163 2163
2164 ((eq ido-exit 'fallback) 2164 ((eq ido-exit 'fallback)
2165 (let ((read-buffer-function nil)) 2165 (let ((read-buffer-function nil))
2166 (run-hook-with-args 'ido-before-fallback-functions 2166 (setq this-command (or fallback 'switch-to-buffer))
2167 (or fallback 'switch-to-buffer)) 2167 (run-hook-with-args 'ido-before-fallback-functions this-command)
2168 (call-interactively (or fallback 'switch-to-buffer)))) 2168 (call-interactively this-command)))
2169 2169
2170 ;; Check buf is non-nil. 2170 ;; Check buf is non-nil.
2171 ((not buf) nil) 2171 ((not buf) nil)
2172 ((= (length buf) 0) nil) 2172 ((= (length buf) 0) nil)
2173 2173
2174 ;; View buffer if it exists 2174 ;; View buffer if it exists
2175 ((get-buffer buf) 2175 ((get-buffer buf)
2176 (add-to-history 'buffer-name-history buf)
2176 (if (eq method 'insert) 2177 (if (eq method 'insert)
2177 (progn 2178 (progn
2178 (ido-record-command 'insert-buffer buf) 2179 (ido-record-command 'insert-buffer buf)
2179 (push-mark 2180 (push-mark
2180 (save-excursion 2181 (save-excursion
2190 (not (y-or-n-p (format "No buffer matching `%s', create one? " buf)))) 2191 (not (y-or-n-p (format "No buffer matching `%s', create one? " buf))))
2191 nil) 2192 nil)
2192 2193
2193 ;; create a new buffer 2194 ;; create a new buffer
2194 (t 2195 (t
2196 (add-to-history 'buffer-name-history buf)
2195 (setq buf (get-buffer-create buf)) 2197 (setq buf (get-buffer-create buf))
2196 (if (fboundp 'set-buffer-major-mode) 2198 (if (fboundp 'set-buffer-major-mode)
2197 (set-buffer-major-mode buf)) 2199 (set-buffer-major-mode buf))
2198 (ido-visit-buffer buf method t)))))) 2200 (ido-visit-buffer buf method t))))))
2199 2201
2302 ((eq ido-exit 'fallback) 2304 ((eq ido-exit 'fallback)
2303 ;; Need to guard setting of default-directory here, since 2305 ;; Need to guard setting of default-directory here, since
2304 ;; we don't want to change directory of current buffer. 2306 ;; we don't want to change directory of current buffer.
2305 (let ((default-directory ido-current-directory) 2307 (let ((default-directory ido-current-directory)
2306 (read-file-name-function nil)) 2308 (read-file-name-function nil))
2307 (run-hook-with-args 'ido-before-fallback-functions 2309 (setq this-command (or fallback 'find-file))
2308 (or fallback 'find-file)) 2310 (run-hook-with-args 'ido-before-fallback-functions this-command)
2309 (call-interactively (or fallback 'find-file)))) 2311 (call-interactively this-command)))
2310 2312
2311 ((eq ido-exit 'switch-to-buffer) 2313 ((eq ido-exit 'switch-to-buffer)
2312 (ido-buffer-internal ido-default-buffer-method nil nil nil ido-text)) 2314 (ido-buffer-internal ido-default-buffer-method nil nil nil ido-text))
2313 2315
2314 ((eq ido-exit 'insert-buffer) 2316 ((eq ido-exit 'insert-buffer)
2361 (t (error "No such directory"))))) 2363 (t (error "No such directory")))))
2362 2364
2363 ((eq method 'write) 2365 ((eq method 'write)
2364 (ido-record-work-file filename) 2366 (ido-record-work-file filename)
2365 (setq default-directory ido-current-directory) 2367 (setq default-directory ido-current-directory)
2366 (ido-record-command 'write-file (concat ido-current-directory filename)) 2368 (setq filename (concat ido-current-directory filename))
2369 (ido-record-command 'write-file filename)
2370 (add-to-history 'file-name-history filename)
2367 (ido-record-work-directory) 2371 (ido-record-work-directory)
2368 (write-file (concat ido-current-directory filename))) 2372 (write-file filename))
2369 2373
2370 ((eq method 'read-only) 2374 ((eq method 'read-only)
2371 (ido-record-work-file filename) 2375 (ido-record-work-file filename)
2372 (setq filename (concat ido-current-directory filename)) 2376 (setq filename (concat ido-current-directory filename))
2373 (ido-record-command fallback filename) 2377 (ido-record-command fallback filename)
2379 (ido-record-work-file filename) 2383 (ido-record-work-file filename)
2380 (setq filename (concat ido-current-directory filename)) 2384 (setq filename (concat ido-current-directory filename))
2381 (ido-record-command 2385 (ido-record-command
2382 (if ido-find-literal 'insert-file-literally 'insert-file) 2386 (if ido-find-literal 'insert-file-literally 'insert-file)
2383 filename) 2387 filename)
2388 (add-to-history 'file-name-history filename)
2384 (ido-record-work-directory) 2389 (ido-record-work-directory)
2385 (insert-file-1 filename 2390 (insert-file-1 filename
2386 (if ido-find-literal 2391 (if ido-find-literal
2387 #'insert-file-contents-literally 2392 #'insert-file-contents-literally
2388 #'insert-file-contents))) 2393 #'insert-file-contents)))
2389 2394
2390 (filename 2395 (filename
2391 (ido-record-work-file filename) 2396 (ido-record-work-file filename)
2392 (setq filename (concat ido-current-directory filename)) 2397 (setq filename (concat ido-current-directory filename))
2393 (ido-record-command 'find-file filename) 2398 (ido-record-command 'find-file filename)
2399 (add-to-history 'file-name-history filename)
2394 (ido-record-work-directory) 2400 (ido-record-work-directory)
2395 (ido-visit-buffer (find-file-noselect filename nil ido-find-literal) method)))))) 2401 (ido-visit-buffer (find-file-noselect filename nil ido-find-literal) method))))))
2396 2402
2397 (defun ido-existing-item-p () 2403 (defun ido-existing-item-p ()
2398 ;; Return non-nil if there is a matching item 2404 ;; Return non-nil if there is a matching item