Mercurial > emacs
comparison lisp/ido.el @ 90182:f042e7c0fe20
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-53
Merge from emacs--cvs-trunk--0
Patches applied:
* emacs--cvs-trunk--0 (patch 302-319)
- Update from CVS
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 69)
- Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Fri, 20 May 2005 04:22:05 +0000 |
parents | 62afea0771d8 43a311177040 |
children | 01137c1fdbe9 |
comparison
equal
deleted
inserted
replaced
90181:0c828e2b0b6f | 90182:f042e7c0fe20 |
---|---|
1390 (define-key map [(control ?@)] 'ido-restrict-to-matches) | 1390 (define-key map [(control ?@)] 'ido-restrict-to-matches) |
1391 (define-key map [right] 'ido-next-match) | 1391 (define-key map [right] 'ido-next-match) |
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) |
1402 (define-key map [(meta down)] 'ido-next-work-directory) | 1407 (define-key map [(meta down)] 'ido-next-work-directory) |
1403 (define-key map [backspace] 'ido-delete-backward-updir) | 1408 (define-key map [backspace] 'ido-delete-backward-updir) |
1404 (define-key map "\d" 'ido-delete-backward-updir) | 1409 (define-key map "\d" 'ido-delete-backward-updir) |
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) |
1412 (define-key map [(meta ?m)] 'ido-make-directory) | 1417 (define-key map [(meta ?m)] 'ido-make-directory) |
1413 (define-key map [(meta ?n)] 'ido-next-work-directory) | 1418 (define-key map [(meta ?n)] 'ido-next-work-directory) |
1424 (define-key map [(meta ?l)] 'ido-toggle-literal) | 1429 (define-key map [(meta ?l)] 'ido-toggle-literal) |
1425 (define-key map "\C-v" 'ido-toggle-vc) | 1430 (define-key map "\C-v" 'ido-toggle-vc) |
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 |
1434 (when (if (boundp 'viper-mode) viper-mode) | 1439 (when (if (boundp 'viper-mode) viper-mode) |
1435 (define-key map [remap viper-intercept-ESC-key] 'ignore) | 1440 (define-key map [remap viper-intercept-ESC-key] 'ignore) |
2256 (ido-matches | 2261 (ido-matches |
2257 (setq ido-try-merged-list t)) | 2262 (setq ido-try-merged-list t)) |
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. | |
2270 If no user input is present or at end of input, perform magic actions: | |
2271 C-x C-b ... C-f switch to ido-find-file. | |
2272 C-x C-f ... C-f fallback to non-ido find-file. | |
2273 C-x C-d ... C-f fallback to non-ido brief dired. | |
2274 C-x d ... C-f fallback to non-ido dired." | |
2275 (interactive) | |
2276 (cond | |
2277 ((not (eobp)) | |
2278 (forward-char 1)) | |
2279 ((memq ido-cur-item '(file dir)) | |
2280 (ido-fallback-command)) | |
2281 (ido-context-switch-command | |
2282 (call-interactively ido-context-switch-command)) | |
2283 ((eq ido-cur-item 'buffer) | |
2284 (ido-enter-find-file)))) | |
2285 | |
2286 ;;; Magic C-b | |
2287 | |
2288 (defun ido-magic-backward-char () | |
2289 "Move backward in user input or perform magic action. | |
2290 If no user input is present, or at start of input, perform magic actions: | |
2291 C-x C-f C-b switch to ido-switch-buffer. | |
2292 C-x C-d C-b switch to ido-switch-buffer. | |
2293 C-x d C-b switch to ido-switch-buffer. | |
2294 C-x C-b C-b fallback to non-ido switch-to-buffer." | |
2295 (interactive) | |
2296 (cond | |
2297 ((> (point) (minibuffer-prompt-end)) | |
2298 (forward-char -1)) | |
2299 ((eq ido-cur-item 'buffer) | |
2300 (ido-fallback-command)) | |
2301 (ido-context-switch-command | |
2302 (call-interactively ido-context-switch-command)) | |
2303 (t | |
2304 (ido-enter-switch-buffer)))) | |
2305 | |
2306 ;;; Magic C-d | |
2307 | |
2308 (defun ido-magic-delete-char () | |
2309 "Delete following char in user input or perform magic action. | |
2310 If at end of user input, perform magic actions: | |
2311 C-x C-f ... C-d enter dired on current directory." | |
2312 (interactive) | |
2313 (cond | |
2314 ((not (eobp)) | |
2315 (delete-char 1)) | |
2316 (ido-context-switch-command | |
2317 nil) | |
2318 ((memq ido-cur-item '(file dir)) | |
2319 (ido-enter-dired)))) | |
2320 | |
2321 | |
2261 ;;; TOGGLE FUNCTIONS | 2322 ;;; TOGGLE FUNCTIONS |
2262 | 2323 |
2263 (defun ido-toggle-case () | 2324 (defun ido-toggle-case () |
2264 "Toggle the value of `ido-case-fold'." | 2325 "Toggle the value of `ido-case-fold'." |
2265 (interactive) | 2326 (interactive) |
2502 (setq ido-use-merged-list t ido-try-merged-list 'wide) | 2563 (setq ido-use-merged-list t ido-try-merged-list 'wide) |
2503 (setq ido-exit 'refresh) | 2564 (setq ido-exit 'refresh) |
2504 (setq ido-text-init (ido-final-slash dir t)) | 2565 (setq ido-text-init (ido-final-slash dir t)) |
2505 (setq ido-rotate-temp t) | 2566 (setq ido-rotate-temp t) |
2506 (exit-minibuffer))) | 2567 (exit-minibuffer))) |
2568 | |
2569 (defun ido-wide-find-dir-or-delete-dir (&optional dir) | |
2570 "Prompt for DIR to search for using find, starting from current directory. | |
2571 If input stack is non-empty, delete current directory component." | |
2572 (interactive) | |
2573 (if ido-input-stack | |
2574 (ido-delete-backward-word-updir 1) | |
2575 (ido-wide-find-dir))) | |
2507 | 2576 |
2508 (defun ido-push-dir () | 2577 (defun ido-push-dir () |
2509 "Move to previous directory in file name, push current input on stack." | 2578 "Move to previous directory in file name, push current input on stack." |
2510 (interactive) | 2579 (interactive) |
2511 (setq ido-exit 'push) | 2580 (setq ido-exit 'push) |
4075 (ido-to-end summaries))) | 4144 (ido-to-end summaries))) |
4076 | 4145 |
4077 ;;; Helper functions for other programs | 4146 ;;; Helper functions for other programs |
4078 | 4147 |
4079 (put 'dired-do-rename 'ido 'ignore) | 4148 (put 'dired-do-rename 'ido 'ignore) |
4149 (put 'ibuffer-find-file 'ido 'find-file) | |
4080 | 4150 |
4081 ;;;###autoload | 4151 ;;;###autoload |
4082 (defun ido-read-buffer (prompt &optional default require-match) | 4152 (defun ido-read-buffer (prompt &optional default require-match) |
4083 "Ido replacement for the built-in `read-buffer'. | 4153 "Ido replacement for the built-in `read-buffer'. |
4084 Return the name of a buffer selected. | 4154 Return the name of a buffer selected. |
4109 (ido-read-directory-name prompt dir default-filename mustmatch initial))) | 4179 (ido-read-directory-name prompt dir default-filename mustmatch initial))) |
4110 ((and (not (eq (get this-command 'ido) 'ignore)) | 4180 ((and (not (eq (get this-command 'ido) 'ignore)) |
4111 (not (memq this-command ido-read-file-name-non-ido)) | 4181 (not (memq this-command ido-read-file-name-non-ido)) |
4112 (or (null predicate) (eq predicate 'file-exists-p))) | 4182 (or (null predicate) (eq predicate 'file-exists-p))) |
4113 (let* (ido-saved-vc-hb | 4183 (let* (ido-saved-vc-hb |
4114 (ido-context-switch-command 'ignore) | 4184 (ido-context-switch-command |
4185 (if (eq (get this-command 'ido) 'find-file) nil 'ignore)) | |
4115 (vc-handled-backends (and (boundp 'vc-handled-backends) vc-handled-backends)) | 4186 (vc-handled-backends (and (boundp 'vc-handled-backends) vc-handled-backends)) |
4116 (ido-current-directory (ido-expand-directory dir)) | 4187 (ido-current-directory (ido-expand-directory dir)) |
4117 (ido-directory-nonreadable (not (file-readable-p ido-current-directory))) | 4188 (ido-directory-nonreadable (not (file-readable-p ido-current-directory))) |
4118 (ido-directory-too-big (and (not ido-directory-nonreadable) | 4189 (ido-directory-too-big (and (not ido-directory-nonreadable) |
4119 (ido-directory-too-big-p ido-current-directory))) | 4190 (ido-directory-too-big-p ido-current-directory))) |
4124 (setq filename | 4195 (setq filename |
4125 (ido-read-internal 'file prompt 'ido-file-history default-filename mustmatch initial)) | 4196 (ido-read-internal 'file prompt 'ido-file-history default-filename mustmatch initial)) |
4126 (cond | 4197 (cond |
4127 ((eq ido-exit 'fallback) | 4198 ((eq ido-exit 'fallback) |
4128 (setq filename 'fallback)) | 4199 (setq filename 'fallback)) |
4200 ((eq ido-exit 'dired) | |
4201 (setq filename ido-current-directory)) | |
4129 (filename | 4202 (filename |
4130 (setq filename | 4203 (setq filename |
4131 (concat ido-current-directory filename)))))) | 4204 (concat ido-current-directory filename)))))) |
4132 (t | 4205 (t |
4133 (setq filename 'fallback))) | 4206 (setq filename 'fallback))) |