diff options
| author | Kim F. Storm | 2005-11-26 19:25:36 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2005-11-26 19:25:36 +0000 |
| commit | 973495ca2555f74e3087edbbed338047e92e61d1 (patch) | |
| tree | 6cb4d3cfe6302a9eb80d7ebd05a28fef93495fe1 | |
| parent | 46801e4c867f9c3ea05f2f0eca2b8f9b34544d86 (diff) | |
| download | emacs-973495ca2555f74e3087edbbed338047e92e61d1.tar.gz emacs-973495ca2555f74e3087edbbed338047e92e61d1.zip | |
(ido-mode-map): Doc fix.
(ido-mode-common-map, ido-mode-file-map)
(ido-mode-file-dir-map, ido-mode-buffer-map): New keymaps.
(ido-define-mode-map): Rewrite. Select one of the new maps as
parent for ido-mode-map instead of building from scratch.
(ido-init-mode-maps): New defun to initialize new maps.
(ido-mode): Call it.
(ido-switch-buffer): Doc fix -- use \<ido-mode-buffer-map>.
(ido-find-file): Doc fix -- use \<ido-mode-file-map>.
| -rw-r--r-- | lisp/ido.el | 149 |
1 files changed, 97 insertions, 52 deletions
diff --git a/lisp/ido.el b/lisp/ido.el index cc4eab4bb4d..a6bd99cdeea 100644 --- a/lisp/ido.el +++ b/lisp/ido.el | |||
| @@ -899,7 +899,19 @@ The fallback command is passed as an argument to the functions." | |||
| 899 | ;; Persistent variables | 899 | ;; Persistent variables |
| 900 | 900 | ||
| 901 | (defvar ido-mode-map nil | 901 | (defvar ido-mode-map nil |
| 902 | "Keymap for `ido-find-file' and `ido-switch-buffer'.") | 902 | "Currently active keymap for ido commands.") |
| 903 | |||
| 904 | (defvar ido-mode-common-map nil | ||
| 905 | "Keymap for all ido commands.") | ||
| 906 | |||
| 907 | (defvar ido-mode-file-map nil | ||
| 908 | "Keymap for ido file commands.") | ||
| 909 | |||
| 910 | (defvar ido-mode-file-dir-map nil | ||
| 911 | "Keymap for ido file and directory commands.") | ||
| 912 | |||
| 913 | (defvar ido-mode-buffer-map nil | ||
| 914 | "Keymap for ido buffer commands.") | ||
| 903 | 915 | ||
| 904 | (defvar ido-file-history nil | 916 | (defvar ido-file-history nil |
| 905 | "History of files selected using `ido-find-file'.") | 917 | "History of files selected using `ido-find-file'.") |
| @@ -1301,8 +1313,7 @@ Removes badly formatted data and ignored directories." | |||
| 1301 | (while e | 1313 | (while e |
| 1302 | (setq d (car e) e (cdr e)) | 1314 | (setq d (car e) e (cdr e)) |
| 1303 | (if (not (consp d)) | 1315 | (if (not (consp d)) |
| 1304 | (set-text-properties 0 (length d) nil d)))))) | 1316 | (set-text-properties 0 (length d) nil d))))))) |
| 1305 | ) | ||
| 1306 | 1317 | ||
| 1307 | 1318 | ||
| 1308 | (defun ido-kill-emacs-hook () | 1319 | (defun ido-kill-emacs-hook () |
| @@ -1333,6 +1344,8 @@ This function also adds a hook to the minibuffer." | |||
| 1333 | (t nil))) | 1344 | (t nil))) |
| 1334 | 1345 | ||
| 1335 | (ido-everywhere (if ido-everywhere 1 -1)) | 1346 | (ido-everywhere (if ido-everywhere 1 -1)) |
| 1347 | (when ido-mode | ||
| 1348 | (ido-init-mode-maps)) | ||
| 1336 | 1349 | ||
| 1337 | (when ido-mode | 1350 | (when ido-mode |
| 1338 | (add-hook 'minibuffer-setup-hook 'ido-minibuffer-setup) | 1351 | (add-hook 'minibuffer-setup-hook 'ido-minibuffer-setup) |
| @@ -1391,12 +1404,11 @@ With ARG, turn ido speed-up on if arg is positive, off otherwise." | |||
| 1391 | 1404 | ||
| 1392 | 1405 | ||
| 1393 | ;;; IDO KEYMAP | 1406 | ;;; IDO KEYMAP |
| 1394 | (defun ido-define-mode-map () | 1407 | (defun ido-init-mode-maps () |
| 1395 | "Set up the keymap for `ido'." | 1408 | "Set up the keymaps used by `ido'." |
| 1396 | (let (map) | ||
| 1397 | ;; generated every time so that it can inherit new functions. | ||
| 1398 | 1409 | ||
| 1399 | (setq map (copy-keymap minibuffer-local-map)) | 1410 | ;; Common map |
| 1411 | (let ((map (make-sparse-keymap))) | ||
| 1400 | (define-key map "\C-a" 'ido-toggle-ignore) | 1412 | (define-key map "\C-a" 'ido-toggle-ignore) |
| 1401 | (define-key map "\C-c" 'ido-toggle-case) | 1413 | (define-key map "\C-c" 'ido-toggle-case) |
| 1402 | (define-key map "\C-e" 'ido-edit-input) | 1414 | (define-key map "\C-e" 'ido-edit-input) |
| @@ -1414,57 +1426,90 @@ With ARG, turn ido speed-up on if arg is positive, off otherwise." | |||
| 1414 | (define-key map [right] 'ido-next-match) | 1426 | (define-key map [right] 'ido-next-match) |
| 1415 | (define-key map [left] 'ido-prev-match) | 1427 | (define-key map [left] 'ido-prev-match) |
| 1416 | (define-key map "?" 'ido-completion-help) | 1428 | (define-key map "?" 'ido-completion-help) |
| 1417 | |||
| 1418 | ;; Magic commands. | 1429 | ;; Magic commands. |
| 1419 | (define-key map "\C-b" 'ido-magic-backward-char) | 1430 | (define-key map "\C-b" 'ido-magic-backward-char) |
| 1420 | (define-key map "\C-f" 'ido-magic-forward-char) | 1431 | (define-key map "\C-f" 'ido-magic-forward-char) |
| 1421 | (define-key map "\C-d" 'ido-magic-delete-char) | 1432 | (define-key map "\C-d" 'ido-magic-delete-char) |
| 1433 | (set-keymap-parent map minibuffer-local-map) | ||
| 1434 | (setq ido-mode-common-map map)) | ||
| 1435 | |||
| 1436 | ;; File and directory map | ||
| 1437 | (let ((map (make-sparse-keymap))) | ||
| 1438 | (define-key map "\C-x\C-b" 'ido-enter-switch-buffer) | ||
| 1439 | (define-key map "\C-x\C-f" 'ido-fallback-command) | ||
| 1440 | (define-key map "\C-x\C-d" 'ido-enter-dired) | ||
| 1441 | (define-key map [down] 'ido-next-match-dir) | ||
| 1442 | (define-key map [up] 'ido-prev-match-dir) | ||
| 1443 | (define-key map [(meta up)] 'ido-prev-work-directory) | ||
| 1444 | (define-key map [(meta down)] 'ido-next-work-directory) | ||
| 1445 | (define-key map [backspace] 'ido-delete-backward-updir) | ||
| 1446 | (define-key map "\d" 'ido-delete-backward-updir) | ||
| 1447 | (define-key map [(meta backspace)] 'ido-delete-backward-word-updir) | ||
| 1448 | (define-key map [(control backspace)] 'ido-up-directory) | ||
| 1449 | (define-key map "\C-l" 'ido-reread-directory) | ||
| 1450 | (define-key map [(meta ?d)] 'ido-wide-find-dir-or-delete-dir) | ||
| 1451 | (define-key map [(meta ?b)] 'ido-push-dir) | ||
| 1452 | (define-key map [(meta ?f)] 'ido-wide-find-file-or-pop-dir) | ||
| 1453 | (define-key map [(meta ?k)] 'ido-forget-work-directory) | ||
| 1454 | (define-key map [(meta ?m)] 'ido-make-directory) | ||
| 1455 | (define-key map [(meta ?n)] 'ido-next-work-directory) | ||
| 1456 | (define-key map [(meta ?o)] 'ido-prev-work-file) | ||
| 1457 | (define-key map [(meta control ?o)] 'ido-next-work-file) | ||
| 1458 | (define-key map [(meta ?p)] 'ido-prev-work-directory) | ||
| 1459 | (define-key map [(meta ?s)] 'ido-merge-work-directories) | ||
| 1460 | (set-keymap-parent map ido-mode-common-map) | ||
| 1461 | (setq ido-mode-file-dir-map map)) | ||
| 1462 | |||
| 1463 | ;; File only map | ||
| 1464 | (let ((map (make-sparse-keymap))) | ||
| 1465 | (define-key map "\C-k" 'ido-delete-file-at-head) | ||
| 1466 | (define-key map "\C-o" 'ido-copy-current-word) | ||
| 1467 | (define-key map "\C-w" 'ido-copy-current-file-name) | ||
| 1468 | (define-key map [(meta ?l)] 'ido-toggle-literal) | ||
| 1469 | (define-key map "\C-v" 'ido-toggle-vc) | ||
| 1470 | (set-keymap-parent map ido-mode-file-dir-map) | ||
| 1471 | (setq ido-mode-file-map map)) | ||
| 1472 | |||
| 1473 | ;; Buffer map | ||
| 1474 | (let ((map (make-sparse-keymap))) | ||
| 1475 | (define-key map "\C-x\C-f" 'ido-enter-find-file) | ||
| 1476 | (define-key map "\C-x\C-b" 'ido-fallback-command) | ||
| 1477 | (define-key map "\C-k" 'ido-kill-buffer-at-head) | ||
| 1478 | (set-keymap-parent map ido-mode-common-map) | ||
| 1479 | (setq ido-mode-buffer-map map))) | ||
| 1422 | 1480 | ||
| 1423 | (when (memq ido-cur-item '(file dir)) | ||
| 1424 | (define-key map "\C-x\C-b" (or ido-context-switch-command 'ido-enter-switch-buffer)) | ||
| 1425 | (define-key map "\C-x\C-f" 'ido-fallback-command) | ||
| 1426 | (define-key map "\C-x\C-d" (or (and ido-context-switch-command 'ignore) 'ido-enter-dired)) | ||
| 1427 | (define-key map [down] 'ido-next-match-dir) | ||
| 1428 | (define-key map [up] 'ido-prev-match-dir) | ||
| 1429 | (define-key map [(meta up)] 'ido-prev-work-directory) | ||
| 1430 | (define-key map [(meta down)] 'ido-next-work-directory) | ||
| 1431 | (define-key map [backspace] 'ido-delete-backward-updir) | ||
| 1432 | (define-key map "\d" 'ido-delete-backward-updir) | ||
| 1433 | (define-key map [(meta backspace)] 'ido-delete-backward-word-updir) | ||
| 1434 | (define-key map [(control backspace)] 'ido-up-directory) | ||
| 1435 | (define-key map "\C-l" 'ido-reread-directory) | ||
| 1436 | (define-key map [(meta ?d)] 'ido-wide-find-dir-or-delete-dir) | ||
| 1437 | (define-key map [(meta ?b)] 'ido-push-dir) | ||
| 1438 | (define-key map [(meta ?f)] 'ido-wide-find-file-or-pop-dir) | ||
| 1439 | (define-key map [(meta ?k)] 'ido-forget-work-directory) | ||
| 1440 | (define-key map [(meta ?m)] 'ido-make-directory) | ||
| 1441 | (define-key map [(meta ?n)] 'ido-next-work-directory) | ||
| 1442 | (define-key map [(meta ?o)] 'ido-prev-work-file) | ||
| 1443 | (define-key map [(meta control ?o)] 'ido-next-work-file) | ||
| 1444 | (define-key map [(meta ?p)] 'ido-prev-work-directory) | ||
| 1445 | (define-key map [(meta ?s)] 'ido-merge-work-directories) | ||
| 1446 | ) | ||
| 1447 | 1481 | ||
| 1448 | (when (eq ido-cur-item 'file) | 1482 | (defun ido-define-mode-map () |
| 1449 | (define-key map "\C-k" 'ido-delete-file-at-head) | 1483 | "Set up the keymap for `ido'." |
| 1450 | (define-key map "\C-o" 'ido-copy-current-word) | ||
| 1451 | (define-key map "\C-w" 'ido-copy-current-file-name) | ||
| 1452 | (define-key map [(meta ?l)] 'ido-toggle-literal) | ||
| 1453 | (define-key map "\C-v" 'ido-toggle-vc) | ||
| 1454 | ) | ||
| 1455 | 1484 | ||
| 1456 | (when (eq ido-cur-item 'buffer) | 1485 | ;; generated every time so that it can inherit new functions. |
| 1457 | (define-key map "\C-x\C-f" (or ido-context-switch-command 'ido-enter-find-file)) | 1486 | (let ((map (make-sparse-keymap)) |
| 1458 | (define-key map "\C-x\C-b" 'ido-fallback-command) | 1487 | (viper-p (if (boundp 'viper-mode) viper-mode))) |
| 1459 | (define-key map "\C-k" 'ido-kill-buffer-at-head) | ||
| 1460 | ) | ||
| 1461 | 1488 | ||
| 1462 | (when (if (boundp 'viper-mode) viper-mode) | 1489 | (when viper-p |
| 1463 | (define-key map [remap viper-intercept-ESC-key] 'ignore) | 1490 | (define-key map [remap viper-intercept-ESC-key] 'ignore)) |
| 1464 | (when (memq ido-cur-item '(file dir)) | 1491 | |
| 1492 | (cond | ||
| 1493 | ((memq ido-cur-item '(file dir)) | ||
| 1494 | (when ido-context-switch-command | ||
| 1495 | (define-key map "\C-x\C-b" ido-context-switch-command) | ||
| 1496 | (define-key map "\C-x\C-d" 'ignore)) | ||
| 1497 | (when viper-p | ||
| 1465 | (define-key map [remap viper-backward-char] 'ido-delete-backward-updir) | 1498 | (define-key map [remap viper-backward-char] 'ido-delete-backward-updir) |
| 1466 | (define-key map [remap viper-del-backward-char-in-insert] 'ido-delete-backward-updir) | 1499 | (define-key map [remap viper-del-backward-char-in-insert] 'ido-delete-backward-updir) |
| 1467 | (define-key map [remap viper-delete-backward-word] 'ido-delete-backward-word-updir))) | 1500 | (define-key map [remap viper-delete-backward-word] 'ido-delete-backward-word-updir)) |
| 1501 | (set-keymap-parent map | ||
| 1502 | (if (eq ido-cur-item 'file) | ||
| 1503 | ido-mode-file-map | ||
| 1504 | ido-mode-file-dir-map))) | ||
| 1505 | |||
| 1506 | ((eq ido-cur-item 'buffer) | ||
| 1507 | (when ido-context-switch-command | ||
| 1508 | (define-key map "\C-x\C-f" ido-context-switch-command)) | ||
| 1509 | (set-keymap-parent map ido-mode-buffer-map)) | ||
| 1510 | |||
| 1511 | (t | ||
| 1512 | (set-keymap-parent map ido-mode-common-map))) | ||
| 1468 | 1513 | ||
| 1469 | (setq ido-mode-map map))) | 1514 | (setq ido-mode-map map))) |
| 1470 | 1515 | ||
| @@ -3625,7 +3670,7 @@ As you type in a string, all of the buffers matching the string are | |||
| 3625 | displayed if substring-matching is used \(default). Look at | 3670 | displayed if substring-matching is used \(default). Look at |
| 3626 | `ido-enable-prefix' and `ido-toggle-prefix'. When you have found the | 3671 | `ido-enable-prefix' and `ido-toggle-prefix'. When you have found the |
| 3627 | buffer you want, it can then be selected. As you type, most keys have | 3672 | buffer you want, it can then be selected. As you type, most keys have |
| 3628 | their normal keybindings, except for the following: \\<ido-mode-map> | 3673 | their normal keybindings, except for the following: \\<ido-mode-buffer-map> |
| 3629 | 3674 | ||
| 3630 | RET Select the buffer at the front of the list of matches. If the | 3675 | RET Select the buffer at the front of the list of matches. If the |
| 3631 | list is empty, possibly prompt to create new buffer. | 3676 | list is empty, possibly prompt to create new buffer. |
| @@ -3713,7 +3758,7 @@ type in a string, all of the filenames matching the string are displayed | |||
| 3713 | if substring-matching is used \(default). Look at `ido-enable-prefix' and | 3758 | if substring-matching is used \(default). Look at `ido-enable-prefix' and |
| 3714 | `ido-toggle-prefix'. When you have found the filename you want, it can | 3759 | `ido-toggle-prefix'. When you have found the filename you want, it can |
| 3715 | then be selected. As you type, most keys have their normal keybindings, | 3760 | then be selected. As you type, most keys have their normal keybindings, |
| 3716 | except for the following: \\<ido-mode-map> | 3761 | except for the following: \\<ido-mode-file-map> |
| 3717 | 3762 | ||
| 3718 | RET Select the file at the front of the list of matches. If the | 3763 | RET Select the file at the front of the list of matches. If the |
| 3719 | list is empty, possibly prompt to create new file. | 3764 | list is empty, possibly prompt to create new file. |
| @@ -3732,7 +3777,7 @@ in a separate window. | |||
| 3732 | \\[ido-merge-work-directories] search for file in the work directory history. | 3777 | \\[ido-merge-work-directories] search for file in the work directory history. |
| 3733 | \\[ido-forget-work-directory] removes current directory from the work directory history. | 3778 | \\[ido-forget-work-directory] removes current directory from the work directory history. |
| 3734 | \\[ido-prev-work-file] or \\[ido-next-work-file] cycle through the work file history. | 3779 | \\[ido-prev-work-file] or \\[ido-next-work-file] cycle through the work file history. |
| 3735 | \\[ido-wide-find-file] and \\[ido-wide-find-dir] prompts and uses find to locate files or directories. | 3780 | \\[ido-wide-find-file-or-pop-dir] and \\[ido-wide-find-dir-or-delete-dir] prompts and uses find to locate files or directories. |
| 3736 | \\[ido-make-directory] prompts for a directory to create in current directory. | 3781 | \\[ido-make-directory] prompts for a directory to create in current directory. |
| 3737 | \\[ido-fallback-command] Fallback to non-ido version of current command. | 3782 | \\[ido-fallback-command] Fallback to non-ido version of current command. |
| 3738 | \\[ido-toggle-regexp] Toggle regexp searching. | 3783 | \\[ido-toggle-regexp] Toggle regexp searching. |