aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim F. Storm2005-05-15 23:03:36 +0000
committerKim F. Storm2005-05-15 23:03:36 +0000
commitae9d279d44394f1689ffc9c3eec0d95026d75339 (patch)
tree2844701f908a30d9d2521cc7d4e9ab144135e40b
parentbffc3c6ed9c98c1177f3fb70ef55d5af9476e45f (diff)
downloademacs-ae9d279d44394f1689ffc9c3eec0d95026d75339.tar.gz
emacs-ae9d279d44394f1689ffc9c3eec0d95026d75339.zip
(ido-magic-forward-char, ido-magic-backward-char)
(ido-magic-delete-char): New commands for C-f, C-b, C-d. (ido-wide-find-dir-or-delete-dir): New command for M-d. (ido-define-mode-map): Bind them. Add C-x prefix to fallback commands. (ido-read-file-name): Handle commands with ido property value equal to find-file as reading a file name, to allow C-d to enter dired. (ibuffer-find-file): Add ido property with value find-file.
-rw-r--r--lisp/ido.el77
1 files changed, 70 insertions, 7 deletions
diff --git a/lisp/ido.el b/lisp/ido.el
index 519d57cbb88..d7c0c8aa9ea 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -1392,10 +1392,15 @@ This function also adds a hook to the minibuffer."
1392 (define-key map [left] 'ido-prev-match) 1392 (define-key map [left] 'ido-prev-match)
1393 (define-key map "?" 'ido-completion-help) 1393 (define-key map "?" 'ido-completion-help)
1394 1394
1395 ;; Magic commands.
1396 (define-key map "\C-b" 'ido-magic-backward-char)
1397 (define-key map "\C-f" 'ido-magic-forward-char)
1398 (define-key map "\C-d" 'ido-magic-delete-char)
1399
1395 (when (memq ido-cur-item '(file dir)) 1400 (when (memq ido-cur-item '(file dir))
1396 (define-key map "\C-b" (or ido-context-switch-command 'ido-enter-switch-buffer)) 1401 (define-key map "\C-x\C-b" (or ido-context-switch-command 'ido-enter-switch-buffer))
1397 (define-key map "\C-d" (or (and ido-context-switch-command 'ignore) 'ido-enter-dired)) 1402 (define-key map "\C-x\C-f" 'ido-fallback-command)
1398 (define-key map "\C-f" 'ido-fallback-command) 1403 (define-key map "\C-x\C-d" (or (and ido-context-switch-command 'ignore) 'ido-enter-dired))
1399 (define-key map [down] 'ido-next-match-dir) 1404 (define-key map [down] 'ido-next-match-dir)
1400 (define-key map [up] 'ido-prev-match-dir) 1405 (define-key map [up] 'ido-prev-match-dir)
1401 (define-key map [(meta up)] 'ido-prev-work-directory) 1406 (define-key map [(meta up)] 'ido-prev-work-directory)
@@ -1405,7 +1410,7 @@ This function also adds a hook to the minibuffer."
1405 (define-key map [(meta backspace)] 'ido-delete-backward-word-updir) 1410 (define-key map [(meta backspace)] 'ido-delete-backward-word-updir)
1406 (define-key map [(control backspace)] 'ido-up-directory) 1411 (define-key map [(control backspace)] 'ido-up-directory)
1407 (define-key map "\C-l" 'ido-reread-directory) 1412 (define-key map "\C-l" 'ido-reread-directory)
1408 (define-key map [(meta ?d)] 'ido-wide-find-dir) 1413 (define-key map [(meta ?d)] 'ido-wide-find-dir-or-delete-dir)
1409 (define-key map [(meta ?b)] 'ido-push-dir) 1414 (define-key map [(meta ?b)] 'ido-push-dir)
1410 (define-key map [(meta ?f)] 'ido-wide-find-file-or-pop-dir) 1415 (define-key map [(meta ?f)] 'ido-wide-find-file-or-pop-dir)
1411 (define-key map [(meta ?k)] 'ido-forget-work-directory) 1416 (define-key map [(meta ?k)] 'ido-forget-work-directory)
@@ -1426,8 +1431,8 @@ This function also adds a hook to the minibuffer."
1426 ) 1431 )
1427 1432
1428 (when (eq ido-cur-item 'buffer) 1433 (when (eq ido-cur-item 'buffer)
1429 (define-key map "\C-f" (or ido-context-switch-command 'ido-enter-find-file)) 1434 (define-key map "\C-x\C-f" (or ido-context-switch-command 'ido-enter-find-file))
1430 (define-key map "\C-b" 'ido-fallback-command) 1435 (define-key map "\C-x\C-b" 'ido-fallback-command)
1431 (define-key map "\C-k" 'ido-kill-buffer-at-head) 1436 (define-key map "\C-k" 'ido-kill-buffer-at-head)
1432 ) 1437 )
1433 1438
@@ -2258,6 +2263,52 @@ If no merge has yet taken place, toggle automatic merging option."
2258 ((not ido-use-merged-list) 2263 ((not ido-use-merged-list)
2259 (ido-merge-work-directories)))) 2264 (ido-merge-work-directories))))
2260 2265
2266;;; Magic C-f
2267
2268(defun ido-magic-forward-char ()
2269 "Move forward in user input or perform magic action.
2270If no user input is present, perform magic actions:
2271C-x C-f C-f fallback to non-ido find-file.
2272C-x C-d C-f fallback to non-ido brief dired.
2273C-x d C-f fallback to non-ido dired."
2274 (interactive)
2275 (cond
2276 ((not (eobp))
2277 (forward-char 1))
2278 ((and (= (length ido-text) 0)
2279 (memq ido-cur-item '(file dir)))
2280 (ido-fallback-command))))
2281
2282;;; Magic C-b
2283
2284(defun ido-magic-backward-char ()
2285 "Move backward in user input or perform magic action.
2286If no user input is present, perform magic actions:
2287C-x C-b C-b fallback to non-ido switch-to-buffer."
2288 (interactive)
2289 (cond
2290 ((> (length ido-text) 0)
2291 (if (> (point) (minibuffer-prompt-end))
2292 (forward-char -1)))
2293 ((eq ido-cur-item 'buffer)
2294 (ido-fallback-command))))
2295
2296;;; Magic C-d
2297
2298(defun ido-magic-delete-char ()
2299 "Delete following char in user input or perform magic action.
2300If at end of user input, perform magic actions:
2301C-x C-f ... C-d enter dired on current directory."
2302 (interactive)
2303 (cond
2304 ((not (eobp))
2305 (delete-char 1))
2306 (ido-context-switch-command
2307 nil)
2308 ((memq ido-cur-item '(file dir))
2309 (ido-enter-dired))))
2310
2311
2261;;; TOGGLE FUNCTIONS 2312;;; TOGGLE FUNCTIONS
2262 2313
2263(defun ido-toggle-case () 2314(defun ido-toggle-case ()
@@ -2505,6 +2556,14 @@ If no buffer or file exactly matching the prompt exists, maybe create a new one.
2505 (setq ido-rotate-temp t) 2556 (setq ido-rotate-temp t)
2506 (exit-minibuffer))) 2557 (exit-minibuffer)))
2507 2558
2559(defun ido-wide-find-dir-or-delete-dir (&optional dir)
2560 "Prompt for DIR to search for using find, starting from current directory.
2561If input stack is non-empty, delete current directory component."
2562 (interactive)
2563 (if ido-input-stack
2564 (ido-delete-backward-word-updir 1)
2565 (ido-wide-find-dir)))
2566
2508(defun ido-push-dir () 2567(defun ido-push-dir ()
2509 "Move to previous directory in file name, push current input on stack." 2568 "Move to previous directory in file name, push current input on stack."
2510 (interactive) 2569 (interactive)
@@ -4077,6 +4136,7 @@ For details of keybindings, do `\\[describe-function] ido-find-file'."
4077;;; Helper functions for other programs 4136;;; Helper functions for other programs
4078 4137
4079(put 'dired-do-rename 'ido 'ignore) 4138(put 'dired-do-rename 'ido 'ignore)
4139(put 'ibuffer-find-file 'ido 'find-file)
4080 4140
4081;;;###autoload 4141;;;###autoload
4082(defun ido-read-buffer (prompt &optional default require-match) 4142(defun ido-read-buffer (prompt &optional default require-match)
@@ -4111,7 +4171,8 @@ See `read-file-name' for additional parameters."
4111 (not (memq this-command ido-read-file-name-non-ido)) 4171 (not (memq this-command ido-read-file-name-non-ido))
4112 (or (null predicate) (eq predicate 'file-exists-p))) 4172 (or (null predicate) (eq predicate 'file-exists-p)))
4113 (let* (ido-saved-vc-hb 4173 (let* (ido-saved-vc-hb
4114 (ido-context-switch-command 'ignore) 4174 (ido-context-switch-command
4175 (if (eq (get this-command 'ido) 'find-file) nil 'ignore))
4115 (vc-handled-backends (and (boundp 'vc-handled-backends) vc-handled-backends)) 4176 (vc-handled-backends (and (boundp 'vc-handled-backends) vc-handled-backends))
4116 (ido-current-directory (ido-expand-directory dir)) 4177 (ido-current-directory (ido-expand-directory dir))
4117 (ido-directory-nonreadable (not (file-readable-p ido-current-directory))) 4178 (ido-directory-nonreadable (not (file-readable-p ido-current-directory)))
@@ -4126,6 +4187,8 @@ See `read-file-name' for additional parameters."
4126 (cond 4187 (cond
4127 ((eq ido-exit 'fallback) 4188 ((eq ido-exit 'fallback)
4128 (setq filename 'fallback)) 4189 (setq filename 'fallback))
4190 ((eq ido-exit 'dired)
4191 (setq filename ido-current-directory))
4129 (filename 4192 (filename
4130 (setq filename 4193 (setq filename
4131 (concat ido-current-directory filename)))))) 4194 (concat ido-current-directory filename))))))