comparison lisp/ido.el @ 67362:ca155a6d12ad

(ido-completion-map): Renamed from ido-mode-map. (ido-common-completion-map, ido-file-completion-map) (ido-file-dir-completion-map, ido-buffer-completion-map): Renamed from ido-mode-....-map. (ido-init-completion-maps): Renamed from ido-init-mode-maps. (ido-setup-completion-map): Renamed from ido-define-mode-map. (ido-read-internal): Bind minibuffer-local-filename-completion-map to ido-completion-map.
author Kim F. Storm <storm@cua.dk>
date Wed, 07 Dec 2005 09:22:53 +0000
parents bb428fcd0e86
children d90725ea1fdb
comparison
equal deleted inserted replaced
67361:ffb9f78665a0 67362:ca155a6d12ad
250 ;; To modify the keybindings, use the ido-setup-hook. For example: 250 ;; To modify the keybindings, use the ido-setup-hook. For example:
251 ;;(add-hook 'ido-setup-hook 'ido-my-keys) 251 ;;(add-hook 'ido-setup-hook 'ido-my-keys)
252 ;; 252 ;;
253 ;;(defun ido-my-keys () 253 ;;(defun ido-my-keys ()
254 ;; "Add my keybindings for ido." 254 ;; "Add my keybindings for ido."
255 ;; (define-key ido-mode-map " " 'ido-next-match) 255 ;; (define-key ido-completion-map " " 'ido-next-match)
256 ;; ) 256 ;; )
257 257
258 ;; Seeing all the matching buffers or files 258 ;; Seeing all the matching buffers or files
259 ;; ---------------------------------------- 259 ;; ----------------------------------------
260 ;; 260 ;;
714 714
715 (defcustom ido-setup-hook nil 715 (defcustom ido-setup-hook nil
716 "*Hook run after the ido variables and keymap have been setup. 716 "*Hook run after the ido variables and keymap have been setup.
717 The dynamic variable `ido-cur-item' contains the current type of item that 717 The dynamic variable `ido-cur-item' contains the current type of item that
718 is read by ido, possible values are file, dir, buffer, and list. 718 is read by ido, possible values are file, dir, buffer, and list.
719 Additional keys can be defined in `ido-mode-map'." 719 Additional keys can be defined in `ido-completion-map'."
720 :type 'hook 720 :type 'hook
721 :group 'ido) 721 :group 'ido)
722 722
723 (defcustom ido-separator nil 723 (defcustom ido-separator nil
724 "*String used by ido to separate the alternatives in the minibuffer. 724 "*String used by ido to separate the alternatives in the minibuffer.
896 896
897 ;;; Internal Variables 897 ;;; Internal Variables
898 898
899 ;; Persistent variables 899 ;; Persistent variables
900 900
901 (defvar ido-mode-map nil 901 (defvar ido-completion-map nil
902 "Currently active keymap for ido commands.") 902 "Currently active keymap for ido commands.")
903 903
904 (defvar ido-mode-common-map nil 904 (defvar ido-common-completion-map nil
905 "Keymap for all ido commands.") 905 "Keymap for all ido commands.")
906 906
907 (defvar ido-mode-file-map nil 907 (defvar ido-file-completion-map nil
908 "Keymap for ido file commands.") 908 "Keymap for ido file commands.")
909 909
910 (defvar ido-mode-file-dir-map nil 910 (defvar ido-file-dir-completion-map nil
911 "Keymap for ido file and directory commands.") 911 "Keymap for ido file and directory commands.")
912 912
913 (defvar ido-mode-buffer-map nil 913 (defvar ido-buffer-completion-map nil
914 "Keymap for ido buffer commands.") 914 "Keymap for ido buffer commands.")
915 915
916 (defvar ido-file-history nil 916 (defvar ido-file-history nil
917 "History of files selected using `ido-find-file'.") 917 "History of files selected using `ido-find-file'.")
918 918
1343 ((> (prefix-numeric-value arg) 0) 'both) 1343 ((> (prefix-numeric-value arg) 0) 'both)
1344 (t nil))) 1344 (t nil)))
1345 1345
1346 (ido-everywhere (if ido-everywhere 1 -1)) 1346 (ido-everywhere (if ido-everywhere 1 -1))
1347 (when ido-mode 1347 (when ido-mode
1348 (ido-init-mode-maps)) 1348 (ido-init-completion-maps))
1349 1349
1350 (when ido-mode 1350 (when ido-mode
1351 (add-hook 'minibuffer-setup-hook 'ido-minibuffer-setup) 1351 (add-hook 'minibuffer-setup-hook 'ido-minibuffer-setup)
1352 (add-hook 'choose-completion-string-functions 'ido-choose-completion-string) 1352 (add-hook 'choose-completion-string-functions 'ido-choose-completion-string)
1353 (ido-load-history) 1353 (ido-load-history)
1354 1354
1355 (add-hook 'kill-emacs-hook 'ido-kill-emacs-hook) 1355 (add-hook 'kill-emacs-hook 'ido-kill-emacs-hook)
1356 1356
1357 (if ido-minor-mode-map-entry 1357 (let ((map (make-sparse-keymap)))
1358 (setcdr ido-minor-mode-map-entry (make-sparse-keymap))
1359 (setq ido-minor-mode-map-entry (cons 'ido-mode (make-sparse-keymap)))
1360 (add-to-list 'minor-mode-map-alist ido-minor-mode-map-entry))
1361
1362 (let ((map (cdr ido-minor-mode-map-entry)))
1363 (when (memq ido-mode '(file both)) 1358 (when (memq ido-mode '(file both))
1364 (define-key map [remap find-file] 'ido-find-file) 1359 (define-key map [remap find-file] 'ido-find-file)
1365 (define-key map [remap find-file-read-only] 'ido-find-file-read-only) 1360 (define-key map [remap find-file-read-only] 'ido-find-file-read-only)
1366 (define-key map [remap find-alternate-file] 'ido-find-alternate-file) 1361 (define-key map [remap find-alternate-file] 'ido-find-alternate-file)
1367 (define-key map [remap write-file] 'ido-write-file) 1362 (define-key map [remap write-file] 'ido-write-file)
1377 (define-key map [remap switch-to-buffer] 'ido-switch-buffer) 1372 (define-key map [remap switch-to-buffer] 'ido-switch-buffer)
1378 (define-key map [remap switch-to-buffer-other-window] 'ido-switch-buffer-other-window) 1373 (define-key map [remap switch-to-buffer-other-window] 'ido-switch-buffer-other-window)
1379 (define-key map [remap switch-to-buffer-other-frame] 'ido-switch-buffer-other-frame) 1374 (define-key map [remap switch-to-buffer-other-frame] 'ido-switch-buffer-other-frame)
1380 (define-key map [remap insert-buffer] 'ido-insert-buffer) 1375 (define-key map [remap insert-buffer] 'ido-insert-buffer)
1381 (define-key map [remap kill-buffer] 'ido-kill-buffer) 1376 (define-key map [remap kill-buffer] 'ido-kill-buffer)
1382 (define-key map [remap display-buffer] 'ido-display-buffer))))) 1377 (define-key map [remap display-buffer] 'ido-display-buffer))
1378
1379 (if ido-minor-mode-map-entry
1380 (setcdr ido-minor-mode-map-entry map)
1381 (setq ido-minor-mode-map-entry (cons 'ido-mode map))
1382 (add-to-list 'minor-mode-map-alist ido-minor-mode-map-entry)))))
1383
1383 1384
1384 (defun ido-everywhere (arg) 1385 (defun ido-everywhere (arg)
1385 "Toggle using ido speed-ups everywhere file and directory names are read. 1386 "Toggle using ido speed-ups everywhere file and directory names are read.
1386 With ARG, turn ido speed-up on if arg is positive, off otherwise." 1387 With ARG, turn ido speed-up on if arg is positive, off otherwise."
1387 (interactive "P") 1388 (interactive "P")
1402 (put 'ido-everywhere 'buffer (cons read-buffer-function nil)) 1403 (put 'ido-everywhere 'buffer (cons read-buffer-function nil))
1403 (setq read-buffer-function 'ido-read-buffer)))) 1404 (setq read-buffer-function 'ido-read-buffer))))
1404 1405
1405 1406
1406 ;;; IDO KEYMAP 1407 ;;; IDO KEYMAP
1407 (defun ido-init-mode-maps () 1408 (defun ido-init-completion-maps ()
1408 "Set up the keymaps used by `ido'." 1409 "Set up the completion keymaps used by `ido'."
1409 1410
1410 ;; Common map 1411 ;; Common map
1411 (let ((map (make-sparse-keymap))) 1412 (let ((map (make-sparse-keymap)))
1412 (define-key map "\C-a" 'ido-toggle-ignore) 1413 (define-key map "\C-a" 'ido-toggle-ignore)
1413 (define-key map "\C-c" 'ido-toggle-case) 1414 (define-key map "\C-c" 'ido-toggle-case)
1429 ;; Magic commands. 1430 ;; Magic commands.
1430 (define-key map "\C-b" 'ido-magic-backward-char) 1431 (define-key map "\C-b" 'ido-magic-backward-char)
1431 (define-key map "\C-f" 'ido-magic-forward-char) 1432 (define-key map "\C-f" 'ido-magic-forward-char)
1432 (define-key map "\C-d" 'ido-magic-delete-char) 1433 (define-key map "\C-d" 'ido-magic-delete-char)
1433 (set-keymap-parent map minibuffer-local-map) 1434 (set-keymap-parent map minibuffer-local-map)
1434 (setq ido-mode-common-map map)) 1435 (setq ido-common-completion-map map))
1435 1436
1436 ;; File and directory map 1437 ;; File and directory map
1437 (let ((map (make-sparse-keymap))) 1438 (let ((map (make-sparse-keymap)))
1438 (define-key map "\C-x\C-b" 'ido-enter-switch-buffer) 1439 (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-f" 'ido-fallback-command)
1455 (define-key map [(meta ?n)] 'ido-next-work-directory) 1456 (define-key map [(meta ?n)] 'ido-next-work-directory)
1456 (define-key map [(meta ?o)] 'ido-prev-work-file) 1457 (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 control ?o)] 'ido-next-work-file)
1458 (define-key map [(meta ?p)] 'ido-prev-work-directory) 1459 (define-key map [(meta ?p)] 'ido-prev-work-directory)
1459 (define-key map [(meta ?s)] 'ido-merge-work-directories) 1460 (define-key map [(meta ?s)] 'ido-merge-work-directories)
1460 (set-keymap-parent map ido-mode-common-map) 1461 (set-keymap-parent map ido-common-completion-map)
1461 (setq ido-mode-file-dir-map map)) 1462 (setq ido-file-dir-completion-map map))
1462 1463
1463 ;; File only map 1464 ;; File only map
1464 (let ((map (make-sparse-keymap))) 1465 (let ((map (make-sparse-keymap)))
1465 (define-key map "\C-k" 'ido-delete-file-at-head) 1466 (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-o" 'ido-copy-current-word)
1467 (define-key map "\C-w" 'ido-copy-current-file-name) 1468 (define-key map "\C-w" 'ido-copy-current-file-name)
1468 (define-key map [(meta ?l)] 'ido-toggle-literal) 1469 (define-key map [(meta ?l)] 'ido-toggle-literal)
1469 (define-key map "\C-v" 'ido-toggle-vc) 1470 (define-key map "\C-v" 'ido-toggle-vc)
1470 (set-keymap-parent map ido-mode-file-dir-map) 1471 (set-keymap-parent map ido-file-dir-completion-map)
1471 (setq ido-mode-file-map map)) 1472 (setq ido-file-completion-map map))
1472 1473
1473 ;; Buffer map 1474 ;; Buffer map
1474 (let ((map (make-sparse-keymap))) 1475 (let ((map (make-sparse-keymap)))
1475 (define-key map "\C-x\C-f" 'ido-enter-find-file) 1476 (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-x\C-b" 'ido-fallback-command)
1477 (define-key map "\C-k" 'ido-kill-buffer-at-head) 1478 (define-key map "\C-k" 'ido-kill-buffer-at-head)
1478 (set-keymap-parent map ido-mode-common-map) 1479 (set-keymap-parent map ido-common-completion-map)
1479 (setq ido-mode-buffer-map map))) 1480 (setq ido-buffer-completion-map map)))
1480 1481
1481 1482
1482 (defun ido-define-mode-map () 1483 (defun ido-setup-completion-map ()
1483 "Set up the keymap for `ido'." 1484 "Set up the keymap for `ido'."
1484 1485
1485 ;; generated every time so that it can inherit new functions. 1486 ;; generated every time so that it can inherit new functions.
1486 (let ((map (make-sparse-keymap)) 1487 (let ((map (make-sparse-keymap))
1487 (viper-p (if (boundp 'viper-mode) viper-mode))) 1488 (viper-p (if (boundp 'viper-mode) viper-mode)))
1498 (define-key map [remap viper-backward-char] 'ido-delete-backward-updir) 1499 (define-key map [remap viper-backward-char] 'ido-delete-backward-updir)
1499 (define-key map [remap viper-del-backward-char-in-insert] 'ido-delete-backward-updir) 1500 (define-key map [remap viper-del-backward-char-in-insert] 'ido-delete-backward-updir)
1500 (define-key map [remap viper-delete-backward-word] 'ido-delete-backward-word-updir)) 1501 (define-key map [remap viper-delete-backward-word] 'ido-delete-backward-word-updir))
1501 (set-keymap-parent map 1502 (set-keymap-parent map
1502 (if (eq ido-cur-item 'file) 1503 (if (eq ido-cur-item 'file)
1503 ido-mode-file-map 1504 ido-file-completion-map
1504 ido-mode-file-dir-map))) 1505 ido-file-dir-completion-map)))
1505 1506
1506 ((eq ido-cur-item 'buffer) 1507 ((eq ido-cur-item 'buffer)
1507 (when ido-context-switch-command 1508 (when ido-context-switch-command
1508 (define-key map "\C-x\C-f" ido-context-switch-command)) 1509 (define-key map "\C-x\C-f" ido-context-switch-command))
1509 (set-keymap-parent map ido-mode-buffer-map)) 1510 (set-keymap-parent map ido-buffer-completion-map))
1510 1511
1511 (t 1512 (t
1512 (set-keymap-parent map ido-mode-common-map))) 1513 (set-keymap-parent map ido-common-completion-map)))
1513 1514
1514 (setq ido-mode-map map))) 1515 (setq ido-completion-map map)))
1515 1516
1516 (defun ido-final-slash (dir &optional fix-it) 1517 (defun ido-final-slash (dir &optional fix-it)
1517 ;; return DIR if DIR has final slash. 1518 ;; return DIR if DIR has final slash.
1518 ;; else if FIX-IT is non-nil, return DIR/ 1519 ;; else if FIX-IT is non-nil, return DIR/
1519 ;; else return nil. 1520 ;; else return nil.
1681 (ido-case-fold ido-case-fold) 1682 (ido-case-fold ido-case-fold)
1682 (ido-enable-prefix ido-enable-prefix) 1683 (ido-enable-prefix ido-enable-prefix)
1683 (ido-enable-regexp ido-enable-regexp) 1684 (ido-enable-regexp ido-enable-regexp)
1684 ) 1685 )
1685 1686
1686 (ido-define-mode-map) 1687 (ido-setup-completion-map)
1687 (setq ido-text-init initial) 1688 (setq ido-text-init initial)
1688 (setq ido-input-stack nil) 1689 (setq ido-input-stack nil)
1689 1690
1690 (run-hooks 'ido-setup-hook) 1691 (run-hooks 'ido-setup-hook)
1691 1692
1786 1787
1787 (ido-set-matches) 1788 (ido-set-matches)
1788 (if (and ido-matches (eq ido-try-merged-list 'auto)) 1789 (if (and ido-matches (eq ido-try-merged-list 'auto))
1789 (setq ido-try-merged-list t)) 1790 (setq ido-try-merged-list t))
1790 (let 1791 (let
1791 ((minibuffer-local-completion-map ido-mode-map) 1792 ((minibuffer-local-completion-map ido-completion-map)
1793 (minibuffer-local-filename-completion-map ido-completion-map)
1792 (max-mini-window-height (or ido-max-window-height 1794 (max-mini-window-height (or ido-max-window-height
1793 (and (boundp 'max-mini-window-height) max-mini-window-height))) 1795 (and (boundp 'max-mini-window-height) max-mini-window-height)))
1794 (ido-completing-read t) 1796 (ido-completing-read t)
1795 (ido-require-match require-match) 1797 (ido-require-match require-match)
1796 (ido-use-mycompletion-depth (1+ (minibuffer-depth))) 1798 (ido-use-mycompletion-depth (1+ (minibuffer-depth)))
3668 3670
3669 As you type in a string, all of the buffers matching the string are 3671 As you type in a string, all of the buffers matching the string are
3670 displayed if substring-matching is used \(default). Look at 3672 displayed if substring-matching is used \(default). Look at
3671 `ido-enable-prefix' and `ido-toggle-prefix'. When you have found the 3673 `ido-enable-prefix' and `ido-toggle-prefix'. When you have found the
3672 buffer you want, it can then be selected. As you type, most keys have 3674 buffer you want, it can then be selected. As you type, most keys have
3673 their normal keybindings, except for the following: \\<ido-mode-buffer-map> 3675 their normal keybindings, except for the following: \\<ido-buffer-completion-map>
3674 3676
3675 RET Select the buffer at the front of the list of matches. If the 3677 RET Select the buffer at the front of the list of matches. If the
3676 list is empty, possibly prompt to create new buffer. 3678 list is empty, possibly prompt to create new buffer.
3677 3679
3678 \\[ido-select-text] Select the current prompt as the buffer. 3680 \\[ido-select-text] Select the current prompt as the buffer.
3756 The file name is selected interactively by typing a substring. As you 3758 The file name is selected interactively by typing a substring. As you
3757 type in a string, all of the filenames matching the string are displayed 3759 type in a string, all of the filenames matching the string are displayed
3758 if substring-matching is used \(default). Look at `ido-enable-prefix' and 3760 if substring-matching is used \(default). Look at `ido-enable-prefix' and
3759 `ido-toggle-prefix'. When you have found the filename you want, it can 3761 `ido-toggle-prefix'. When you have found the filename you want, it can
3760 then be selected. As you type, most keys have their normal keybindings, 3762 then be selected. As you type, most keys have their normal keybindings,
3761 except for the following: \\<ido-mode-file-map> 3763 except for the following: \\<ido-file-completion-map>
3762 3764
3763 RET Select the file at the front of the list of matches. If the 3765 RET Select the file at the front of the list of matches. If the
3764 list is empty, possibly prompt to create new file. 3766 list is empty, possibly prompt to create new file.
3765 3767
3766 \\[ido-select-text] Select the current prompt as the buffer or file. 3768 \\[ido-select-text] Select the current prompt as the buffer or file.