899 |
;; Persistent variables |
;; Persistent variables |
900 |
|
|
901 |
(defvar ido-mode-map nil |
(defvar ido-mode-map nil |
902 |
"Keymap for `ido-find-file' and `ido-switch-buffer'.") |
"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.") |
915 |
|
|
916 |
(defvar ido-file-history nil |
(defvar ido-file-history nil |
917 |
"History of files selected using `ido-find-file'.") |
"History of files selected using `ido-find-file'.") |
1313 |
(while e |
(while e |
1314 |
(setq d (car e) e (cdr e)) |
(setq d (car e) e (cdr e)) |
1315 |
(if (not (consp d)) |
(if (not (consp d)) |
1316 |
(set-text-properties 0 (length d) nil d)))))) |
(set-text-properties 0 (length d) nil d))))))) |
|
) |
|
1317 |
|
|
1318 |
|
|
1319 |
(defun ido-kill-emacs-hook () |
(defun ido-kill-emacs-hook () |
1344 |
(t nil))) |
(t nil))) |
1345 |
|
|
1346 |
(ido-everywhere (if ido-everywhere 1 -1)) |
(ido-everywhere (if ido-everywhere 1 -1)) |
1347 |
|
(when ido-mode |
1348 |
|
(ido-init-mode-maps)) |
1349 |
|
|
1350 |
(when ido-mode |
(when ido-mode |
1351 |
(add-hook 'minibuffer-setup-hook 'ido-minibuffer-setup) |
(add-hook 'minibuffer-setup-hook 'ido-minibuffer-setup) |
1404 |
|
|
1405 |
|
|
1406 |
;;; IDO KEYMAP |
;;; IDO KEYMAP |
1407 |
(defun ido-define-mode-map () |
(defun ido-init-mode-maps () |
1408 |
"Set up the keymap for `ido'." |
"Set up the keymaps used by `ido'." |
|
(let (map) |
|
|
;; generated every time so that it can inherit new functions. |
|
1409 |
|
|
1410 |
(setq map (copy-keymap minibuffer-local-map)) |
;; Common map |
1411 |
|
(let ((map (make-sparse-keymap))) |
1412 |
(define-key map "\C-a" 'ido-toggle-ignore) |
(define-key map "\C-a" 'ido-toggle-ignore) |
1413 |
(define-key map "\C-c" 'ido-toggle-case) |
(define-key map "\C-c" 'ido-toggle-case) |
1414 |
(define-key map "\C-e" 'ido-edit-input) |
(define-key map "\C-e" 'ido-edit-input) |
1426 |
(define-key map [right] 'ido-next-match) |
(define-key map [right] 'ido-next-match) |
1427 |
(define-key map [left] 'ido-prev-match) |
(define-key map [left] 'ido-prev-match) |
1428 |
(define-key map "?" 'ido-completion-help) |
(define-key map "?" 'ido-completion-help) |
|
|
|
1429 |
;; Magic commands. |
;; Magic commands. |
1430 |
(define-key map "\C-b" 'ido-magic-backward-char) |
(define-key map "\C-b" 'ido-magic-backward-char) |
1431 |
(define-key map "\C-f" 'ido-magic-forward-char) |
(define-key map "\C-f" 'ido-magic-forward-char) |
1432 |
(define-key map "\C-d" 'ido-magic-delete-char) |
(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 |
(when (memq ido-cur-item '(file dir)) |
;; File and directory map |
1437 |
(define-key map "\C-x\C-b" (or ido-context-switch-command 'ido-enter-switch-buffer)) |
(let ((map (make-sparse-keymap))) |
1438 |
(define-key map "\C-x\C-f" 'ido-fallback-command) |
(define-key map "\C-x\C-b" 'ido-enter-switch-buffer) |
1439 |
(define-key map "\C-x\C-d" (or (and ido-context-switch-command 'ignore) 'ido-enter-dired)) |
(define-key map "\C-x\C-f" 'ido-fallback-command) |
1440 |
(define-key map [down] 'ido-next-match-dir) |
(define-key map "\C-x\C-d" 'ido-enter-dired) |
1441 |
(define-key map [up] 'ido-prev-match-dir) |
(define-key map [down] 'ido-next-match-dir) |
1442 |
(define-key map [(meta up)] 'ido-prev-work-directory) |
(define-key map [up] 'ido-prev-match-dir) |
1443 |
(define-key map [(meta down)] 'ido-next-work-directory) |
(define-key map [(meta up)] 'ido-prev-work-directory) |
1444 |
(define-key map [backspace] 'ido-delete-backward-updir) |
(define-key map [(meta down)] 'ido-next-work-directory) |
1445 |
(define-key map "\d" 'ido-delete-backward-updir) |
(define-key map [backspace] 'ido-delete-backward-updir) |
1446 |
(define-key map [(meta backspace)] 'ido-delete-backward-word-updir) |
(define-key map "\d" 'ido-delete-backward-updir) |
1447 |
(define-key map [(control backspace)] 'ido-up-directory) |
(define-key map [(meta backspace)] 'ido-delete-backward-word-updir) |
1448 |
(define-key map "\C-l" 'ido-reread-directory) |
(define-key map [(control backspace)] 'ido-up-directory) |
1449 |
(define-key map [(meta ?d)] 'ido-wide-find-dir-or-delete-dir) |
(define-key map "\C-l" 'ido-reread-directory) |
1450 |
(define-key map [(meta ?b)] 'ido-push-dir) |
(define-key map [(meta ?d)] 'ido-wide-find-dir-or-delete-dir) |
1451 |
(define-key map [(meta ?f)] 'ido-wide-find-file-or-pop-dir) |
(define-key map [(meta ?b)] 'ido-push-dir) |
1452 |
(define-key map [(meta ?k)] 'ido-forget-work-directory) |
(define-key map [(meta ?f)] 'ido-wide-find-file-or-pop-dir) |
1453 |
(define-key map [(meta ?m)] 'ido-make-directory) |
(define-key map [(meta ?k)] 'ido-forget-work-directory) |
1454 |
(define-key map [(meta ?n)] 'ido-next-work-directory) |
(define-key map [(meta ?m)] 'ido-make-directory) |
1455 |
(define-key map [(meta ?o)] 'ido-prev-work-file) |
(define-key map [(meta ?n)] 'ido-next-work-directory) |
1456 |
(define-key map [(meta control ?o)] 'ido-next-work-file) |
(define-key map [(meta ?o)] 'ido-prev-work-file) |
1457 |
(define-key map [(meta ?p)] 'ido-prev-work-directory) |
(define-key map [(meta control ?o)] 'ido-next-work-file) |
1458 |
(define-key map [(meta ?s)] 'ido-merge-work-directories) |
(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))) |
1480 |
|
|
|
(when (eq ido-cur-item 'file) |
|
|
(define-key map "\C-k" 'ido-delete-file-at-head) |
|
|
(define-key map "\C-o" 'ido-copy-current-word) |
|
|
(define-key map "\C-w" 'ido-copy-current-file-name) |
|
|
(define-key map [(meta ?l)] 'ido-toggle-literal) |
|
|
(define-key map "\C-v" 'ido-toggle-vc) |
|
|
) |
|
1481 |
|
|
1482 |
(when (eq ido-cur-item 'buffer) |
(defun ido-define-mode-map () |
1483 |
(define-key map "\C-x\C-f" (or ido-context-switch-command 'ido-enter-find-file)) |
"Set up the keymap for `ido'." |
1484 |
(define-key map "\C-x\C-b" 'ido-fallback-command) |
|
1485 |
(define-key map "\C-k" 'ido-kill-buffer-at-head) |
;; 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 |
(when (if (boundp 'viper-mode) viper-mode) |
(cond |
1493 |
(define-key map [remap viper-intercept-ESC-key] 'ignore) |
((memq ido-cur-item '(file dir)) |
1494 |
(when (memq ido-cur-item '(file dir)) |
(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 |
1498 |
(define-key map [remap viper-backward-char] 'ido-delete-backward-updir) |
(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) |
(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))) |
(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))) |
1513 |
|
|
1514 |
(setq ido-mode-map map))) |
(setq ido-mode-map map))) |
1515 |
|
|
3670 |
displayed if substring-matching is used \(default). Look at |
displayed if substring-matching is used \(default). Look at |
3671 |
`ido-enable-prefix' and `ido-toggle-prefix'. When you have found the |
`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 |
buffer you want, it can then be selected. As you type, most keys have |
3673 |
their normal keybindings, except for the following: \\<ido-mode-map> |
their normal keybindings, except for the following: \\<ido-mode-buffer-map> |
3674 |
|
|
3675 |
RET Select the buffer at the front of the list of matches. If the |
RET Select the buffer at the front of the list of matches. If the |
3676 |
list is empty, possibly prompt to create new buffer. |
list is empty, possibly prompt to create new buffer. |
3758 |
if substring-matching is used \(default). Look at `ido-enable-prefix' and |
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 |
`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, |
then be selected. As you type, most keys have their normal keybindings, |
3761 |
except for the following: \\<ido-mode-map> |
except for the following: \\<ido-mode-file-map> |
3762 |
|
|
3763 |
RET Select the file at the front of the list of matches. If the |
RET Select the file at the front of the list of matches. If the |
3764 |
list is empty, possibly prompt to create new file. |
list is empty, possibly prompt to create new file. |
3777 |
\\[ido-merge-work-directories] search for file in the work directory history. |
\\[ido-merge-work-directories] search for file in the work directory history. |
3778 |
\\[ido-forget-work-directory] removes current directory from the work directory history. |
\\[ido-forget-work-directory] removes current directory from the work directory history. |
3779 |
\\[ido-prev-work-file] or \\[ido-next-work-file] cycle through the work file history. |
\\[ido-prev-work-file] or \\[ido-next-work-file] cycle through the work file history. |
3780 |
\\[ido-wide-find-file] and \\[ido-wide-find-dir] prompts and uses find to locate files or directories. |
\\[ido-wide-find-file-or-pop-dir] and \\[ido-wide-find-dir-or-delete-dir] prompts and uses find to locate files or directories. |
3781 |
\\[ido-make-directory] prompts for a directory to create in current directory. |
\\[ido-make-directory] prompts for a directory to create in current directory. |
3782 |
\\[ido-fallback-command] Fallback to non-ido version of current command. |
\\[ido-fallback-command] Fallback to non-ido version of current command. |
3783 |
\\[ido-toggle-regexp] Toggle regexp searching. |
\\[ido-toggle-regexp] Toggle regexp searching. |