comparison lisp/ido.el @ 83405:1955a4462bf9

Merged from miles@gnu.org--gnu-2005 (patch 659-663) Patches applied: * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-659 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-660 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-661 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-662 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-663 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-445
author Karoly Lorentey <lorentey@elte.hu>
date Sat, 03 Dec 2005 14:25:50 +0000
parents bb428fcd0e86
children ca155a6d12ad
comparison
equal deleted inserted replaced
83404:69e184bbba16 83405:1955a4462bf9
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-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'.")
906 918
907 (defvar ido-buffer-history nil 919 (defvar ido-buffer-history nil
1299 (setq e (car l) l (cdr l)) 1311 (setq e (car l) l (cdr l))
1300 (if (listp e) 1312 (if (listp e)
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 ()
1309 ;; ido kill emacs hook 1320 ;; ido kill emacs hook
1310 (ido-save-history)) 1321 (ido-save-history))
1331 ((memq arg '(file buffer both)) arg) 1342 ((memq arg '(file buffer both)) arg)
1332 ((> (prefix-numeric-value arg) 0) 'both) 1343 ((> (prefix-numeric-value arg) 0) 'both)
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)
1339 (add-hook 'choose-completion-string-functions 'ido-choose-completion-string) 1352 (add-hook 'choose-completion-string-functions 'ido-choose-completion-string)
1340 (ido-load-history) 1353 (ido-load-history)
1389 (put 'ido-everywhere 'buffer (cons read-buffer-function nil)) 1402 (put 'ido-everywhere 'buffer (cons read-buffer-function nil))
1390 (setq read-buffer-function 'ido-read-buffer)))) 1403 (setq read-buffer-function 'ido-read-buffer))))
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) 1409
1397 ;; generated every time so that it can inherit new functions. 1410 ;; Common map
1398 1411 (let ((map (make-sparse-keymap)))
1399 (setq map (copy-keymap minibuffer-local-map))
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)
1403 (define-key map "\t" 'ido-complete) 1415 (define-key map "\t" 'ido-complete)
1404 (define-key map " " 'ido-complete-space) 1416 (define-key map " " 'ido-complete-space)
1412 (define-key map [(control ?\s)] 'ido-restrict-to-matches) 1424 (define-key map [(control ?\s)] 'ido-restrict-to-matches)
1413 (define-key map [(control ?@)] 'ido-restrict-to-matches) 1425 (define-key map [(control ?@)] 'ido-restrict-to-matches)
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)
1422 1433 (set-keymap-parent map minibuffer-local-map)
1423 (when (memq ido-cur-item '(file dir)) 1434 (setq ido-mode-common-map map))
1424 (define-key map "\C-x\C-b" (or ido-context-switch-command 'ido-enter-switch-buffer)) 1435
1425 (define-key map "\C-x\C-f" 'ido-fallback-command) 1436 ;; File and directory map
1426 (define-key map "\C-x\C-d" (or (and ido-context-switch-command 'ignore) 'ido-enter-dired)) 1437 (let ((map (make-sparse-keymap)))
1427 (define-key map [down] 'ido-next-match-dir) 1438 (define-key map "\C-x\C-b" 'ido-enter-switch-buffer)
1428 (define-key map [up] 'ido-prev-match-dir) 1439 (define-key map "\C-x\C-f" 'ido-fallback-command)
1429 (define-key map [(meta up)] 'ido-prev-work-directory) 1440 (define-key map "\C-x\C-d" 'ido-enter-dired)
1430 (define-key map [(meta down)] 'ido-next-work-directory) 1441 (define-key map [down] 'ido-next-match-dir)
1431 (define-key map [backspace] 'ido-delete-backward-updir) 1442 (define-key map [up] 'ido-prev-match-dir)
1432 (define-key map "\d" 'ido-delete-backward-updir) 1443 (define-key map [(meta up)] 'ido-prev-work-directory)
1433 (define-key map [(meta backspace)] 'ido-delete-backward-word-updir) 1444 (define-key map [(meta down)] 'ido-next-work-directory)
1434 (define-key map [(control backspace)] 'ido-up-directory) 1445 (define-key map [backspace] 'ido-delete-backward-updir)
1435 (define-key map "\C-l" 'ido-reread-directory) 1446 (define-key map "\d" 'ido-delete-backward-updir)
1436 (define-key map [(meta ?d)] 'ido-wide-find-dir-or-delete-dir) 1447 (define-key map [(meta backspace)] 'ido-delete-backward-word-updir)
1437 (define-key map [(meta ?b)] 'ido-push-dir) 1448 (define-key map [(control backspace)] 'ido-up-directory)
1438 (define-key map [(meta ?f)] 'ido-wide-find-file-or-pop-dir) 1449 (define-key map "\C-l" 'ido-reread-directory)
1439 (define-key map [(meta ?k)] 'ido-forget-work-directory) 1450 (define-key map [(meta ?d)] 'ido-wide-find-dir-or-delete-dir)
1440 (define-key map [(meta ?m)] 'ido-make-directory) 1451 (define-key map [(meta ?b)] 'ido-push-dir)
1441 (define-key map [(meta ?n)] 'ido-next-work-directory) 1452 (define-key map [(meta ?f)] 'ido-wide-find-file-or-pop-dir)
1442 (define-key map [(meta ?o)] 'ido-prev-work-file) 1453 (define-key map [(meta ?k)] 'ido-forget-work-directory)
1443 (define-key map [(meta control ?o)] 'ido-next-work-file) 1454 (define-key map [(meta ?m)] 'ido-make-directory)
1444 (define-key map [(meta ?p)] 'ido-prev-work-directory) 1455 (define-key map [(meta ?n)] 'ido-next-work-directory)
1445 (define-key map [(meta ?s)] 'ido-merge-work-directories) 1456 (define-key map [(meta ?o)] 'ido-prev-work-file)
1446 ) 1457 (define-key map [(meta control ?o)] 'ido-next-work-file)
1447 1458 (define-key map [(meta ?p)] 'ido-prev-work-directory)
1448 (when (eq ido-cur-item 'file) 1459 (define-key map [(meta ?s)] 'ido-merge-work-directories)
1449 (define-key map "\C-k" 'ido-delete-file-at-head) 1460 (set-keymap-parent map ido-mode-common-map)
1450 (define-key map "\C-o" 'ido-copy-current-word) 1461 (setq ido-mode-file-dir-map map))
1451 (define-key map "\C-w" 'ido-copy-current-file-name) 1462
1452 (define-key map [(meta ?l)] 'ido-toggle-literal) 1463 ;; File only map
1453 (define-key map "\C-v" 'ido-toggle-vc) 1464 (let ((map (make-sparse-keymap)))
1454 ) 1465 (define-key map "\C-k" 'ido-delete-file-at-head)
1455 1466 (define-key map "\C-o" 'ido-copy-current-word)
1456 (when (eq ido-cur-item 'buffer) 1467 (define-key map "\C-w" 'ido-copy-current-file-name)
1457 (define-key map "\C-x\C-f" (or ido-context-switch-command 'ido-enter-find-file)) 1468 (define-key map [(meta ?l)] 'ido-toggle-literal)
1458 (define-key map "\C-x\C-b" 'ido-fallback-command) 1469 (define-key map "\C-v" 'ido-toggle-vc)
1459 (define-key map "\C-k" 'ido-kill-buffer-at-head) 1470 (set-keymap-parent map ido-mode-file-dir-map)
1460 ) 1471 (setq ido-mode-file-map map))
1461 1472
1462 (when (if (boundp 'viper-mode) viper-mode) 1473 ;; Buffer map
1463 (define-key map [remap viper-intercept-ESC-key] 'ignore) 1474 (let ((map (make-sparse-keymap)))
1464 (when (memq ido-cur-item '(file dir)) 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)))
1480
1481
1482 (defun ido-define-mode-map ()
1483 "Set up the keymap for `ido'."
1484
1485 ;; generated every time so that it can inherit new functions.
1486 (let ((map (make-sparse-keymap))
1487 (viper-p (if (boundp 'viper-mode) viper-mode)))
1488
1489 (when viper-p
1490 (define-key map [remap viper-intercept-ESC-key] 'ignore))
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
1471 (defun ido-final-slash (dir &optional fix-it) 1516 (defun ido-final-slash (dir &optional fix-it)
1472 ;; return DIR if DIR has final slash. 1517 ;; return DIR if DIR has final slash.
3623 3668
3624 As you type in a string, all of the buffers matching the string are 3669 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.
3632 3677
3633 \\[ido-select-text] Select the current prompt as the buffer. 3678 \\[ido-select-text] Select the current prompt as the buffer.
3711 The file name is selected interactively by typing a substring. As you 3756 The file name is selected interactively by typing a substring. As you
3712 type in a string, all of the filenames matching the string are displayed 3757 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.
3720 3765
3721 \\[ido-select-text] Select the current prompt as the buffer or file. 3766 \\[ido-select-text] Select the current prompt as the buffer or file.
3730 \\[ido-edit-input] Edit input string (including directory). 3775 \\[ido-edit-input] Edit input string (including directory).
3731 \\[ido-prev-work-directory] or \\[ido-next-work-directory] go to previous/next directory in work directory history. 3776 \\[ido-prev-work-directory] or \\[ido-next-work-directory] go to previous/next directory in work directory history.
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.
3739 \\[ido-toggle-prefix] Toggle between substring and prefix matching. 3784 \\[ido-toggle-prefix] Toggle between substring and prefix matching.
3740 \\[ido-toggle-case] Toggle case-sensitive searching of file names. 3785 \\[ido-toggle-case] Toggle case-sensitive searching of file names.