26 |
;;; Acknowledgements |
;;; Acknowledgements |
27 |
|
|
28 |
;; Infinite amounts of gratitude goes to Stephen Eglen <stephen@cns.ed.ac.uk> |
;; Infinite amounts of gratitude goes to Stephen Eglen <stephen@cns.ed.ac.uk> |
29 |
;; who wrote iswitch-buffer mode - from which I ripped off 99% of the code |
;; who wrote iswitch-buffer mode - from which I ripped off 99% of the code |
30 |
;; for ido-switch-buffer and found the inspiration for ido-find-file. |
;; for ido-switch-buffer and found the inspiration for ido-find-file. |
31 |
;; The ido package would never have existed without his work. |
;; The ido package would never have existed without his work. |
32 |
|
|
92 |
;; most recent, when I use ido-switch-buffer, I first of all get |
;; most recent, when I use ido-switch-buffer, I first of all get |
93 |
;; presented with the list of all the buffers |
;; presented with the list of all the buffers |
94 |
;; |
;; |
95 |
;; Buffer: {123456,123} |
;; Buffer: {123456,123} |
96 |
;; |
;; |
97 |
;; If I then press 2: |
;; If I then press 2: |
98 |
;; Buffer: 2[3]{123456,123} |
;; Buffer: 2[3]{123456,123} |
156 |
;; drive, enter X:/ where X is the drive letter. You can also visit |
;; drive, enter X:/ where X is the drive letter. You can also visit |
157 |
;; files on other hosts using the ange-ftp notations `/host:' and |
;; files on other hosts using the ange-ftp notations `/host:' and |
158 |
;; `/user@host:'. See the variable `ido-slow-ftp-hosts' if you want |
;; `/user@host:'. See the variable `ido-slow-ftp-hosts' if you want |
159 |
;; to inhibit the ido substring matching for ftp access. |
;; to inhibit the ido substring matching for ftp access. |
160 |
;; |
;; |
161 |
;; If for some reason you cannot specify the proper file using |
;; If for some reason you cannot specify the proper file using |
162 |
;; ido-find-file, you can press C-f to enter the normal find-file. |
;; ido-find-file, you can press C-f to enter the normal find-file. |
345 |
"Determines for which functional group \(buffer and files) ido behavior |
"Determines for which functional group \(buffer and files) ido behavior |
346 |
should be enabled. The following values are possible: |
should be enabled. The following values are possible: |
347 |
- `buffer': Turn only on ido buffer behavior \(switching, killing, |
- `buffer': Turn only on ido buffer behavior \(switching, killing, |
348 |
displaying...) |
displaying...) |
349 |
- `file': Turn only on ido file behavior \(finding, writing, inserting...) |
- `file': Turn only on ido file behavior \(finding, writing, inserting...) |
350 |
- `both': Turn on ido buffer and file behavior. |
- `both': Turn on ido buffer and file behavior. |
351 |
- `nil': Turn off any ido switching. |
- `nil': Turn off any ido switching. |
359 |
:link '(emacs-commentary-link "ido.el") |
:link '(emacs-commentary-link "ido.el") |
360 |
:set-after '(ido-save-directory-list-file) |
:set-after '(ido-save-directory-list-file) |
361 |
:version "21.4" |
:version "21.4" |
362 |
:type '(choice (const :tag "Turn on only buffer" buffer) |
:type '(choice (const :tag "Turn on only buffer" buffer) |
363 |
(const :tag "Turn on only file" file) |
(const :tag "Turn on only file" file) |
364 |
(const :tag "Turn on both buffer and file" both) |
(const :tag "Turn on both buffer and file" both) |
365 |
(const :tag "Switch off all" nil)) |
(const :tag "Switch off all" nil)) |
446 |
frame or in the other frame. |
frame or in the other frame. |
447 |
`always-frame' If a file is visible in another frame, raise that |
`always-frame' If a file is visible in another frame, raise that |
448 |
frame. Otherwise, visit the file in the same window." |
frame. Otherwise, visit the file in the same window." |
449 |
:type '(choice (const samewindow) |
:type '(choice (const samewindow) |
450 |
(const otherwindow) |
(const otherwindow) |
451 |
(const display) |
(const display) |
452 |
(const otherframe) |
(const otherframe) |
453 |
(const maybe-frame) |
(const maybe-frame) |
454 |
(const always-frame)) |
(const always-frame)) |
455 |
:group 'ido) |
:group 'ido) |
457 |
(defcustom ido-default-buffer-method 'always-frame |
(defcustom ido-default-buffer-method 'always-frame |
458 |
"*How to switch to new buffer when using `ido-switch-buffer'. |
"*How to switch to new buffer when using `ido-switch-buffer'. |
459 |
See ido-default-file-method for details." |
See ido-default-file-method for details." |
460 |
:type '(choice (const samewindow) |
:type '(choice (const samewindow) |
461 |
(const otherwindow) |
(const otherwindow) |
462 |
(const display) |
(const display) |
463 |
(const otherframe) |
(const otherframe) |
464 |
(const maybe-frame) |
(const maybe-frame) |
465 |
(const always-frame)) |
(const always-frame)) |
466 |
:group 'ido) |
:group 'ido) |
646 |
(defcustom ido-enter-single-matching-directory 'slash |
(defcustom ido-enter-single-matching-directory 'slash |
647 |
"*Automatically enter sub-directory if it is the only matching item, if non-nil. |
"*Automatically enter sub-directory if it is the only matching item, if non-nil. |
648 |
If value is 'slash, only enter if typing final slash, else do it always." |
If value is 'slash, only enter if typing final slash, else do it always." |
649 |
:type '(choice (const :tag "Never" nil) |
:type '(choice (const :tag "Never" nil) |
650 |
(const :tag "When typing /" slash) |
(const :tag "When typing /" slash) |
651 |
(other :tag "Always" t)) |
(other :tag "Always" t)) |
652 |
:group 'ido) |
:group 'ido) |
655 |
"*Specify whether a new buffer is created if no buffer matches substring. |
"*Specify whether a new buffer is created if no buffer matches substring. |
656 |
Choices are 'always to create new buffers unconditionally, 'prompt to |
Choices are 'always to create new buffers unconditionally, 'prompt to |
657 |
ask user whether to create buffer, or 'never to never create new buffer." |
ask user whether to create buffer, or 'never to never create new buffer." |
658 |
:type '(choice (const always) |
:type '(choice (const always) |
659 |
(const prompt) |
(const prompt) |
660 |
(const never)) |
(const never)) |
661 |
:group 'ido) |
:group 'ido) |
679 |
4th element is the string inserted at the end of a truncated list of prospects, |
4th element is the string inserted at the end of a truncated list of prospects, |
680 |
5th and 6th elements are used as brackets around the common match string which |
5th and 6th elements are used as brackets around the common match string which |
681 |
can be completed using TAB, |
can be completed using TAB, |
682 |
7th element is the string displayed when there are a no matches, and |
7th element is the string displayed when there are a no matches, and |
683 |
8th element displayed if there is a single match (and faces are not used)." |
8th element displayed if there is a single match (and faces are not used)." |
684 |
:type '(repeat string) |
:type '(repeat string) |
685 |
:group 'ido) |
:group 'ido) |
694 |
"*Font used by ido for highlighting first match." |
"*Font used by ido for highlighting first match." |
695 |
:group 'ido) |
:group 'ido) |
696 |
|
|
697 |
(defface ido-only-match-face '((((class color)) |
(defface ido-only-match-face '((((class color)) |
698 |
(:foreground "ForestGreen")) |
(:foreground "ForestGreen")) |
699 |
(t (:italic t))) |
(t (:italic t))) |
700 |
"*Font used by ido for highlighting only match." |
"*Font used by ido for highlighting only match." |
701 |
:group 'ido) |
:group 'ido) |
702 |
|
|
703 |
(defface ido-subdir-face '((((class color)) |
(defface ido-subdir-face '((((class color)) |
704 |
(:foreground "red")) |
(:foreground "red")) |
705 |
(t (:underline t))) |
(t (:underline t))) |
706 |
"*Font used by ido for highlighting subdirs in the alternatives." |
"*Font used by ido for highlighting subdirs in the alternatives." |
707 |
:group 'ido) |
:group 'ido) |
708 |
|
|
709 |
(defface ido-indicator-face '((((class color)) |
(defface ido-indicator-face '((((class color)) |
710 |
(:foreground "yellow" |
(:foreground "yellow" |
711 |
:background "red" |
:background "red" |
712 |
:width condensed)) |
:width condensed)) |
786 |
It is intended for use in customizing ido for interoperation |
It is intended for use in customizing ido for interoperation |
787 |
with other packages. For instance: |
with other packages. For instance: |
788 |
|
|
789 |
\(add-hook 'ido-minibuffer-setup-hook |
\(add-hook 'ido-minibuffer-setup-hook |
790 |
\(function |
\(function |
791 |
\(lambda () |
\(lambda () |
792 |
\(make-local-variable 'max-mini-window-height) |
\(make-local-variable 'max-mini-window-height) |
884 |
(defvar ido-report-no-match t |
(defvar ido-report-no-match t |
885 |
"Report [No Match] when no completions matches ido-text.") |
"Report [No Match] when no completions matches ido-text.") |
886 |
|
|
887 |
(defvar ido-exit nil |
(defvar ido-exit nil |
888 |
"Flag to monitor how `ido-find-file' exits. |
"Flag to monitor how `ido-find-file' exits. |
889 |
If equal to `takeprompt', we use the prompt as the file name to be |
If equal to `takeprompt', we use the prompt as the file name to be |
890 |
selected.") |
selected.") |
891 |
|
|
896 |
"Delay timer for auto merge.") |
"Delay timer for auto merge.") |
897 |
|
|
898 |
(defvar ido-use-mycompletion-depth 0 |
(defvar ido-use-mycompletion-depth 0 |
899 |
"Non-nil means use `ido' completion feedback. |
"Non-nil means use `ido' completion feedback. |
900 |
Is set by ido functions to the current minibuffer-depth, so that |
Is set by ido functions to the current minibuffer-depth, so that |
901 |
it doesn't interfere with other minibuffer usage.") |
it doesn't interfere with other minibuffer usage.") |
902 |
|
|
1008 |
(string-match "\\`/[^:/][^:/]+:\\'" dir)))) |
(string-match "\\`/[^:/][^:/]+:\\'" dir)))) |
1009 |
|
|
1010 |
(defun ido-is-ftp-directory (&optional dir) |
(defun ido-is-ftp-directory (&optional dir) |
1011 |
(string-match |
(string-match |
1012 |
(if ido-enable-tramp-completion |
(if ido-enable-tramp-completion |
1013 |
"\\`/[^/:][^/:]+:" ;; like tramp-file-name-regexp-unified, but doesn't match single drive letters |
"\\`/[^/:][^/:]+:" ;; like tramp-file-name-regexp-unified, but doesn't match single drive letters |
1014 |
"\\`/[^/:][^/:]+:/") |
"\\`/[^/:][^/:]+:/") |
1019 |
(setq dir (or dir ido-current-directory)) |
(setq dir (or dir ido-current-directory)) |
1020 |
;; (featurep 'ange-ftp) |
;; (featurep 'ange-ftp) |
1021 |
;; (ange-ftp-ftp-name dir) |
;; (ange-ftp-ftp-name dir) |
1022 |
(string-match |
(string-match |
1023 |
(if ido-enable-tramp-completion |
(if ido-enable-tramp-completion |
1024 |
"\\`/\\([^/]+[@:]\\)*\\([^@/:][^@/:]+\\):" |
"\\`/\\([^/]+[@:]\\)*\\([^@/:][^@/:]+\\):" |
1025 |
"\\`/\\([^/:]*@\\)?\\([^@/:][^@/:]+\\):/") |
"\\`/\\([^/:]*@\\)?\\([^@/:][^@/:]+\\):/") |
1130 |
(setq r (cons (car l) r))) |
(setq r (cons (car l) r))) |
1131 |
(setq l (cdr l))) |
(setq l (cdr l))) |
1132 |
(nreverse r)))) |
(nreverse r)))) |
1133 |
(setq ido-work-directory-list |
(setq ido-work-directory-list |
1134 |
(and (listp ido-work-directory-list) |
(and (listp ido-work-directory-list) |
1135 |
(let ((l ido-work-directory-list) r) |
(let ((l ido-work-directory-list) r) |
1136 |
(while l |
(while l |
1140 |
(setq r (cons (car l) r))) |
(setq r (cons (car l) r))) |
1141 |
(setq l (cdr l))) |
(setq l (cdr l))) |
1142 |
(nreverse r)))) |
(nreverse r)))) |
1143 |
(setq ido-work-file-list |
(setq ido-work-file-list |
1144 |
(and (listp ido-work-file-list) |
(and (listp ido-work-file-list) |
1145 |
(let ((l ido-work-file-list) r) |
(let ((l ido-work-file-list) r) |
1146 |
(while l |
(while l |
1148 |
(setq r (cons (car l) r))) |
(setq r (cons (car l) r))) |
1149 |
(setq l (cdr l))) |
(setq l (cdr l))) |
1150 |
(nreverse r)))) |
(nreverse r)))) |
1151 |
(setq ido-dir-file-cache |
(setq ido-dir-file-cache |
1152 |
(and (listp ido-dir-file-cache) |
(and (listp ido-dir-file-cache) |
1153 |
(let ((l ido-dir-file-cache) r) |
(let ((l ido-dir-file-cache) r) |
1154 |
(while l |
(while l |
1223 |
"Toggle ido speed-ups on or off. |
"Toggle ido speed-ups on or off. |
1224 |
With ARG, turn ido speed-up on if arg is positive, off otherwise. |
With ARG, turn ido speed-up on if arg is positive, off otherwise. |
1225 |
If second argument NOBIND is non-nil, no keys are rebound; otherwise, |
If second argument NOBIND is non-nil, no keys are rebound; otherwise, |
1226 |
turning on ido-mode will modify the default keybindings for the |
turning on ido-mode will modify the default keybindings for the |
1227 |
find-file and switch-to-buffer families of commands to the ido |
find-file and switch-to-buffer families of commands to the ido |
1228 |
versions of these functions. |
versions of these functions. |
1229 |
However, if second arg equals 'files, bind only for files, or if it |
However, if second arg equals 'files, bind only for files, or if it |
1230 |
equals 'buffers, bind only for buffers. |
equals 'buffers, bind only for buffers. |
1231 |
This function also adds a hook to the minibuffer." |
This function also adds a hook to the minibuffer." |
1232 |
(interactive "P") |
(interactive "P") |
1233 |
(setq ido-mode |
(setq ido-mode |
1234 |
(cond |
(cond |
1235 |
((null arg) (if ido-mode nil 'both)) |
((null arg) (if ido-mode nil 'both)) |
1236 |
((eq arg t) 'both) |
((eq arg t) 'both) |
1237 |
((eq arg 'files) 'file) |
((eq arg 'files) 'file) |
1279 |
"Enable ido everywhere file and directory names are read." |
"Enable ido everywhere file and directory names are read." |
1280 |
(interactive "P") |
(interactive "P") |
1281 |
(setq ido-everywhere (if arg |
(setq ido-everywhere (if arg |
1282 |
(> (prefix-numeric-value arg) 0) |
(> (prefix-numeric-value arg) 0) |
1283 |
(not ido-everywhere))) |
(not ido-everywhere))) |
1284 |
(setq read-file-name-function |
(setq read-file-name-function |
1285 |
(and ido-everywhere (memq ido-mode '(both file)) |
(and ido-everywhere (memq ido-mode '(both file)) |
1286 |
'ido-read-file-name)) |
'ido-read-file-name)) |
1287 |
(setq read-buffer-function |
(setq read-buffer-function |
1289 |
'ido-read-buffer))) |
'ido-read-buffer))) |
1290 |
|
|
1291 |
|
|
1292 |
;;; IDO KEYMAP |
;;; IDO KEYMAP |
1293 |
(defun ido-define-mode-map () |
(defun ido-define-mode-map () |
1294 |
"Set up the keymap for `ido'." |
"Set up the keymap for `ido'." |
1295 |
(let (map) |
(let (map) |
1421 |
(funcall (cdr (car rule)) dirname)))) |
(funcall (cdr (car rule)) dirname)))) |
1422 |
(setq rule (cdr rule)))) |
(setq rule (cdr rule)))) |
1423 |
(run-hooks 'ido-rewrite-file-prompt-functions) |
(run-hooks 'ido-rewrite-file-prompt-functions) |
1424 |
(concat prompt |
(concat prompt |
1425 |
; (if ido-process-ignore-lists "" "&") |
; (if ido-process-ignore-lists "" "&") |
1426 |
(or literal "") |
(or literal "") |
1427 |
(or vc-off "") |
(or vc-off "") |
1428 |
(or prefix "") |
(or prefix "") |
1429 |
(let ((l (length dirname))) |
(let ((l (length dirname))) |
1430 |
(if (and max-width (> max-width 0) (> l max-width)) |
(if (and max-width (> max-width 0) (> l max-width)) |
1431 |
(let* ((s (substring dirname (- max-width))) |
(let* ((s (substring dirname (- max-width))) |
1432 |
(i (string-match "/" s))) |
(i (string-match "/" s))) |
1433 |
(concat "..." (if i (substring s i) s))) |
(concat "..." (if i (substring s i) s))) |
1434 |
dirname))))) |
dirname))))) |
1468 |
|
|
1469 |
(defun ido-read-internal (item prompt history &optional default require-match initial) |
(defun ido-read-internal (item prompt history &optional default require-match initial) |
1470 |
"Perform the ido-read-buffer and ido-read-file-name functions. |
"Perform the ido-read-buffer and ido-read-file-name functions. |
1471 |
Return the name of a buffer or file selected. |
Return the name of a buffer or file selected. |
1472 |
PROMPT is the prompt to give to the user. |
PROMPT is the prompt to give to the user. |
1473 |
DEFAULT if given is the default directory to start with. |
DEFAULT if given is the default directory to start with. |
1474 |
If REQUIRE-MATCH is non-nil, an existing file must be selected. |
If REQUIRE-MATCH is non-nil, an existing file must be selected. |
1512 |
(if (bufferp default) (buffer-name default) default)) |
(if (bufferp default) (buffer-name default) default)) |
1513 |
((stringp default) default) |
((stringp default) default) |
1514 |
((eq item 'file) |
((eq item 'file) |
1515 |
(and ido-enable-last-directory-history |
(and ido-enable-last-directory-history |
1516 |
(let ((d (assoc ido-current-directory ido-last-directory-list))) |
(let ((d (assoc ido-current-directory ido-last-directory-list))) |
1517 |
(and d (cdr d))))))) |
(and d (cdr d))))))) |
1518 |
(if (member ido-default-item ido-ignore-item-temp-list) |
(if (member ido-default-item ido-ignore-item-temp-list) |
1562 |
ido-use-merged-list t) |
ido-use-merged-list t) |
1563 |
(ido-trace "Merged" t) |
(ido-trace "Merged" t) |
1564 |
)))) |
)))) |
1565 |
|
|
1566 |
(cond |
(cond |
1567 |
(ido-keep-item-list |
(ido-keep-item-list |
1568 |
(setq ido-keep-item-list nil |
(setq ido-keep-item-list nil |
1586 |
(ido-set-matches) |
(ido-set-matches) |
1587 |
(if (and ido-matches (eq ido-try-merged-list 'auto)) |
(if (and ido-matches (eq ido-try-merged-list 'auto)) |
1588 |
(setq ido-try-merged-list t)) |
(setq ido-try-merged-list t)) |
1589 |
(let |
(let |
1590 |
((minibuffer-local-completion-map ido-mode-map) |
((minibuffer-local-completion-map ido-mode-map) |
1591 |
(max-mini-window-height (or ido-max-window-height |
(max-mini-window-height (or ido-max-window-height |
1592 |
(and (boundp 'max-mini-window-height) max-mini-window-height))) |
(and (boundp 'max-mini-window-height) max-mini-window-height))) |
1598 |
(setq ido-exit nil) |
(setq ido-exit nil) |
1599 |
(setq ido-final-text |
(setq ido-final-text |
1600 |
(catch 'ido |
(catch 'ido |
1601 |
(completing-read |
(completing-read |
1602 |
(ido-make-prompt item prompt) |
(ido-make-prompt item prompt) |
1603 |
'(("dummy" . 1)) nil nil ; table predicate require-match |
'(("dummy" . 1)) nil nil ; table predicate require-match |
1604 |
(prog1 ido-text-init (setq ido-text-init nil)) ;initial-contents |
(prog1 ido-text-init (setq ido-text-init nil)) ;initial-contents |
1611 |
|
|
1612 |
(cond |
(cond |
1613 |
((eq ido-exit 'refresh) |
((eq ido-exit 'refresh) |
1614 |
(if (and (eq ido-use-merged-list 'auto) |
(if (and (eq ido-use-merged-list 'auto) |
1615 |
(or (input-pending-p))) |
(or (input-pending-p))) |
1616 |
(setq ido-use-merged-list nil |
(setq ido-use-merged-list nil |
1617 |
ido-keep-item-list t)) |
ido-keep-item-list t)) |
1623 |
ido-exit nil)) |
ido-exit nil)) |
1624 |
|
|
1625 |
((memq ido-exit '(edit chdir)) |
((memq ido-exit '(edit chdir)) |
1626 |
(cond |
(cond |
1627 |
((memq ido-cur-item '(file dir)) |
((memq ido-cur-item '(file dir)) |
1628 |
(let* ((process-environment (cons "HOME=/" process-environment)) ;; cheat read-file-name |
(let* ((process-environment (cons "HOME=/" process-environment)) ;; cheat read-file-name |
1629 |
(read-file-name-function nil) |
(read-file-name-function nil) |
1639 |
d (or (file-name-directory new) "/") |
d (or (file-name-directory new) "/") |
1640 |
f (file-name-nondirectory new) |
f (file-name-nondirectory new) |
1641 |
edit t) |
edit t) |
1642 |
(if (or |
(if (or |
1643 |
(file-directory-p d) |
(file-directory-p d) |
1644 |
(and (yes-or-no-p (format "Create directory %s? " d)) |
(and (yes-or-no-p (format "Create directory %s? " d)) |
1645 |
(condition-case nil |
(condition-case nil |
1646 |
(progn (make-directory d t) t) |
(progn (make-directory d t) t) |
1647 |
(error |
(error |
1648 |
(message "Could not create directory") |
(message "Could not create directory") |
1748 |
;; Choose the buffer name: either the text typed in, or the head |
;; Choose the buffer name: either the text typed in, or the head |
1749 |
;; of the list of matches |
;; of the list of matches |
1750 |
|
|
1751 |
(cond |
(cond |
1752 |
((eq ido-exit 'findfile) |
((eq ido-exit 'findfile) |
1753 |
(ido-file-internal ido-default-file-method nil nil nil nil ido-text)) |
(ido-file-internal ido-default-file-method nil nil nil nil ido-text)) |
1754 |
|
|
1786 |
;;;###autoload |
;;;###autoload |
1787 |
(defun ido-read-buffer (prompt &optional default require-match initial) |
(defun ido-read-buffer (prompt &optional default require-match initial) |
1788 |
"Replacement for the built-in `read-buffer'. |
"Replacement for the built-in `read-buffer'. |
1789 |
Return the name of a buffer selected. |
Return the name of a buffer selected. |
1790 |
PROMPT is the prompt to give to the user. DEFAULT if given is the default |
PROMPT is the prompt to give to the user. DEFAULT if given is the default |
1791 |
buffer to be selected, which will go to the front of the list. |
buffer to be selected, which will go to the front of the list. |
1792 |
If REQUIRE-MATCH is non-nil, an existing-buffer must be selected. |
If REQUIRE-MATCH is non-nil, an existing-buffer must be selected. |
1820 |
ido-text-init ido-text |
ido-text-init ido-text |
1821 |
ido-rotate-temp t) |
ido-rotate-temp t) |
1822 |
(exit-minibuffer)))) |
(exit-minibuffer)))) |
1823 |
|
|
1824 |
(defun ido-record-work-file (name) |
(defun ido-record-work-file (name) |
1825 |
;; Save NAME in ido-work-file-list |
;; Save NAME in ido-work-file-list |
1826 |
(when (and (numberp ido-max-work-file-list) (> ido-max-work-file-list 0)) |
(when (and (numberp ido-max-work-file-list) (> ido-max-work-file-list 0)) |
1924 |
((eq method 'insert) |
((eq method 'insert) |
1925 |
(ido-record-work-file filename) |
(ido-record-work-file filename) |
1926 |
(setq filename (concat ido-current-directory filename)) |
(setq filename (concat ido-current-directory filename)) |
1927 |
(ido-record-command |
(ido-record-command |
1928 |
(if ido-find-literal 'insert-file-literally 'insert-file) |
(if ido-find-literal 'insert-file-literally 'insert-file) |
1929 |
filename) |
filename) |
1930 |
(ido-record-work-directory) |
(ido-record-work-directory) |
1962 |
"Try and complete the current pattern amongst the file names." |
"Try and complete the current pattern amongst the file names." |
1963 |
(interactive) |
(interactive) |
1964 |
(let (res) |
(let (res) |
1965 |
(cond |
(cond |
1966 |
((and (memq ido-cur-item '(file dir)) |
((and (memq ido-cur-item '(file dir)) |
1967 |
(string-match "[$]" ido-text)) |
(string-match "[$]" ido-text)) |
1968 |
(let ((evar (substitute-in-file-name (concat ido-current-directory ido-text)))) |
(let ((evar (substitute-in-file-name (concat ido-current-directory ido-text)))) |
1981 |
((not ido-matches) |
((not ido-matches) |
1982 |
(when ido-completion-buffer |
(when ido-completion-buffer |
1983 |
(call-interactively (setq this-command ido-cannot-complete-command)))) |
(call-interactively (setq this-command ido-cannot-complete-command)))) |
1984 |
|
|
1985 |
((and (= 1 (length ido-matches)) |
((and (= 1 (length ido-matches)) |
1986 |
(not (and ido-enable-tramp-completion |
(not (and ido-enable-tramp-completion |
1987 |
(string-equal ido-current-directory "/") |
(string-equal ido-current-directory "/") |
1988 |
(string-match "..[@:]\\'" (car ido-matches))))) |
(string-match "..[@:]\\'" (car ido-matches))))) |
1989 |
;; only one choice, so select it. |
;; only one choice, so select it. |
1990 |
(exit-minibuffer)) |
(exit-minibuffer)) |
1991 |
|
|
1992 |
(t ;; else there could be some completions |
(t ;; else there could be some completions |
1993 |
(setq res ido-common-match-string) |
(setq res ido-common-match-string) |
1994 |
(if (and (not (memq res '(t nil))) |
(if (and (not (memq res '(t nil))) |
2050 |
(setq ido-try-merged-list t)) |
(setq ido-try-merged-list t)) |
2051 |
((not ido-use-merged-list) |
((not ido-use-merged-list) |
2052 |
(ido-merge-work-directories)))) |
(ido-merge-work-directories)))) |
2053 |
|
|
2054 |
;;; TOGGLE FUNCTIONS |
;;; TOGGLE FUNCTIONS |
2055 |
|
|
2056 |
(defun ido-toggle-case () |
(defun ido-toggle-case () |
2087 |
(interactive) |
(interactive) |
2088 |
(if (and ido-mode (eq ido-cur-item 'file)) |
(if (and ido-mode (eq ido-cur-item 'file)) |
2089 |
(progn |
(progn |
2090 |
(setq vc-master-templates |
(setq vc-master-templates |
2091 |
(if vc-master-templates nil ido-saved-vc-mt)) |
(if vc-master-templates nil ido-saved-vc-mt)) |
2092 |
(setq ido-text-init ido-text) |
(setq ido-text-init ido-text) |
2093 |
(setq ido-exit 'keep) |
(setq ido-exit 'keep) |
2323 |
(let* ((bfname (buffer-file-name ido-entry-buffer)) |
(let* ((bfname (buffer-file-name ido-entry-buffer)) |
2324 |
(name (and bfname (file-name-nondirectory bfname)))) |
(name (and bfname (file-name-nondirectory bfname)))) |
2325 |
(when name |
(when name |
2326 |
(setq ido-text-init |
(setq ido-text-init |
2327 |
(if (or all |
(if (or all |
2328 |
(not (equal (file-name-directory bfname) ido-current-directory)) |
(not (equal (file-name-directory bfname) ido-current-directory)) |
2329 |
(not (string-match "\\.[^.]*\\'" name))) |
(not (string-match "\\.[^.]*\\'" name))) |
2330 |
name |
name |
2332 |
(setq ido-exit 'refresh |
(setq ido-exit 'refresh |
2333 |
ido-try-merged-list nil) |
ido-try-merged-list nil) |
2334 |
(exit-minibuffer)))) |
(exit-minibuffer)))) |
2335 |
|
|
2336 |
(defun ido-copy-current-word (all) |
(defun ido-copy-current-word (all) |
2337 |
"Insert current word (file or directory name) from current buffer." |
"Insert current word (file or directory name) from current buffer." |
2338 |
(interactive "P") |
(interactive "P") |
2367 |
ido-exit 'refresh))) |
ido-exit 'refresh))) |
2368 |
(exit-minibuffer)))) |
(exit-minibuffer)))) |
2369 |
|
|
2370 |
(defun ido-next-match () |
(defun ido-next-match () |
2371 |
"Put first element of `ido-matches' at the end of the list." |
"Put first element of `ido-matches' at the end of the list." |
2372 |
(interactive) |
(interactive) |
2373 |
(if ido-matches |
(if ido-matches |
2376 |
(setq ido-rescan t) |
(setq ido-rescan t) |
2377 |
(setq ido-rotate t)))) |
(setq ido-rotate t)))) |
2378 |
|
|
2379 |
(defun ido-prev-match () |
(defun ido-prev-match () |
2380 |
"Put last element of `ido-matches' at the front of the list." |
"Put last element of `ido-matches' at the front of the list." |
2381 |
(interactive) |
(interactive) |
2382 |
(if ido-matches |
(if ido-matches |
2385 |
(setq ido-rescan t) |
(setq ido-rescan t) |
2386 |
(setq ido-rotate t)))) |
(setq ido-rotate t)))) |
2387 |
|
|
2388 |
(defun ido-next-match-dir () |
(defun ido-next-match-dir () |
2389 |
"Find next directory in match list. |
"Find next directory in match list. |
2390 |
If work directories have been merged, cycle through directories for |
If work directories have been merged, cycle through directories for |
2391 |
first matching file." |
first matching file." |
2404 |
(if (< i cnt) |
(if (< i cnt) |
2405 |
(setq ido-cur-list (ido-chop ido-cur-list (nth i ido-matches))))))) |
(setq ido-cur-list (ido-chop ido-cur-list (nth i ido-matches))))))) |
2406 |
|
|
2407 |
(defun ido-prev-match-dir () |
(defun ido-prev-match-dir () |
2408 |
"Find previous directory in match list. |
"Find previous directory in match list. |
2409 |
If work directories have been merged, cycle through directories |
If work directories have been merged, cycle through directories |
2410 |
for first matching file." |
for first matching file." |
2423 |
(if (> i 0) |
(if (> i 0) |
2424 |
(setq ido-cur-list (ido-chop ido-cur-list (nth i ido-matches))))))) |
(setq ido-cur-list (ido-chop ido-cur-list (nth i ido-matches))))))) |
2425 |
|
|
2426 |
(defun ido-restrict-to-matches () |
(defun ido-restrict-to-matches () |
2427 |
"Set current item list to the currently matched items." |
"Set current item list to the currently matched items." |
2428 |
(interactive) |
(interactive) |
2429 |
(when ido-matches |
(when ido-matches |
2492 |
|
|
2493 |
(defun ido-wide-find-dirs-or-files (dir file &optional prefix finddir) |
(defun ido-wide-find-dirs-or-files (dir file &optional prefix finddir) |
2494 |
;; As ido-run-find-command, but returns a list of cons pairs ("file" . "dir") |
;; As ido-run-find-command, but returns a list of cons pairs ("file" . "dir") |
2495 |
(let ((filenames |
(let ((filenames |
2496 |
(split-string |
(split-string |
2497 |
(shell-command-to-string |
(shell-command-to-string |
2498 |
(concat "find " dir " -name \"" (if prefix "" "*") file "*\" -type " (if finddir "d" "f") " -print")))) |
(concat "find " dir " -name \"" (if prefix "" "*") file "*\" -type " (if finddir "d" "f") " -print")))) |
2499 |
filename d f |
filename d f |
2598 |
|
|
2599 |
(defun ido-make-buffer-list1 (&optional frame visible) |
(defun ido-make-buffer-list1 (&optional frame visible) |
2600 |
;; Return list of non-ignored buffer names |
;; Return list of non-ignored buffer names |
2601 |
(delq nil |
(delq nil |
2602 |
(mapcar |
(mapcar |
2603 |
(lambda (x) |
(lambda (x) |
2604 |
(let ((name (buffer-name x))) |
(let ((name (buffer-name x))) |
2609 |
(defun ido-make-buffer-list (default) |
(defun ido-make-buffer-list (default) |
2610 |
;; Return the current list of buffers. |
;; Return the current list of buffers. |
2611 |
;; Currently visible buffers are put at the end of the list. |
;; Currently visible buffers are put at the end of the list. |
2612 |
;; The hook `ido-make-buflist-hook' is run after the list has been |
;; The hook `ido-make-buflist-hook' is run after the list has been |
2613 |
;; created to allow the user to further modify the order of the buffer names |
;; created to allow the user to further modify the order of the buffer names |
2614 |
;; in this list. If DEFAULT is non-nil, and corresponds to an existing buffer, |
;; in this list. If DEFAULT is non-nil, and corresponds to an existing buffer, |
2615 |
;; it is put to the start of the list. |
;; it is put to the start of the list. |
2620 |
(setq ido-temp-list ido-current-buffers)) |
(setq ido-temp-list ido-current-buffers)) |
2621 |
(if default |
(if default |
2622 |
(progn |
(progn |
2623 |
(setq ido-temp-list |
(setq ido-temp-list |
2624 |
(delete default ido-temp-list)) |
(delete default ido-temp-list)) |
2625 |
(setq ido-temp-list |
(setq ido-temp-list |
2626 |
(cons default ido-temp-list)))) |
(cons default ido-temp-list)))) |
2627 |
(run-hooks 'ido-make-buffer-list-hook) |
(run-hooks 'ido-make-buffer-list-hook) |
2628 |
ido-temp-list)) |
ido-temp-list)) |
2629 |
|
|
2630 |
(defun ido-to-end (items) |
(defun ido-to-end (items) |
2631 |
;; Move the elements from ITEMS to the end of `ido-temp-list' |
;; Move the elements from ITEMS to the end of `ido-temp-list' |
2632 |
(mapcar |
(mapcar |
2633 |
(lambda (elem) |
(lambda (elem) |
2634 |
(setq ido-temp-list (delq elem ido-temp-list))) |
(setq ido-temp-list (delq elem ido-temp-list))) |
2635 |
items) |
items) |
2636 |
(if ido-temp-list |
(if ido-temp-list |
2670 |
(stringp dir) (> (length dir) 0) |
(stringp dir) (> (length dir) 0) |
2671 |
(ido-may-cache-directory dir)) |
(ido-may-cache-directory dir)) |
2672 |
(let* ((cached (assoc dir ido-dir-file-cache)) |
(let* ((cached (assoc dir ido-dir-file-cache)) |
2673 |
(ctime (nth 1 cached)) |
(ctime (nth 1 cached)) |
2674 |
(ftp (ido-is-ftp-directory dir)) |
(ftp (ido-is-ftp-directory dir)) |
2675 |
(attr (if ftp nil (file-attributes dir))) |
(attr (if ftp nil (file-attributes dir))) |
2676 |
(mtime (nth 5 attr)) |
(mtime (nth 5 attr)) |
2710 |
;; Return list of non-ignored files in DIR |
;; Return list of non-ignored files in DIR |
2711 |
;; If MERGED is non-nil, each file is cons'ed with DIR |
;; If MERGED is non-nil, each file is cons'ed with DIR |
2712 |
(and (or (ido-is-tramp-root dir) (file-directory-p dir)) |
(and (or (ido-is-tramp-root dir) (file-directory-p dir)) |
2713 |
(delq nil |
(delq nil |
2714 |
(mapcar |
(mapcar |
2715 |
(lambda (name) |
(lambda (name) |
2716 |
(if (not (ido-ignore-item-p name ido-ignore-files t)) |
(if (not (ido-ignore-item-p name ido-ignore-files t)) |
2720 |
(defun ido-make-file-list (default) |
(defun ido-make-file-list (default) |
2721 |
;; Return the current list of files. |
;; Return the current list of files. |
2722 |
;; Currently visible files are put at the end of the list. |
;; Currently visible files are put at the end of the list. |
2723 |
;; The hook `ido-make-file-list-hook' is run after the list has been |
;; The hook `ido-make-file-list-hook' is run after the list has been |
2724 |
;; created to allow the user to further modify the order of the file names |
;; created to allow the user to further modify the order of the file names |
2725 |
;; in this list. |
;; in this list. |
2726 |
(let ((ido-temp-list (ido-make-file-list1 ido-current-directory))) |
(let ((ido-temp-list (ido-make-file-list1 ido-current-directory))) |
2727 |
(setq ido-temp-list (ido-sort-list ido-temp-list)) |
(setq ido-temp-list (ido-sort-list ido-temp-list)) |
2728 |
(let ((default-directory ido-current-directory)) |
(let ((default-directory ido-current-directory)) |
2729 |
(ido-to-end ;; move ftp hosts and visited files to end |
(ido-to-end ;; move ftp hosts and visited files to end |
2730 |
(delq nil (mapcar |
(delq nil (mapcar |
2731 |
(lambda (x) (if (or (string-match "..:\\'" x) |
(lambda (x) (if (or (string-match "..:\\'" x) |
2732 |
(and (not (ido-final-slash x)) |
(and (not (ido-final-slash x)) |
2733 |
(get-file-buffer x))) x)) |
(get-file-buffer x))) x)) |
2734 |
ido-temp-list)))) |
ido-temp-list)))) |
2735 |
(ido-to-end ;; move . files to end |
(ido-to-end ;; move . files to end |
2736 |
(delq nil (mapcar |
(delq nil (mapcar |
2737 |
(lambda (x) (if (string-equal (substring x 0 1) ".") x)) |
(lambda (x) (if (string-equal (substring x 0 1) ".") x)) |
2738 |
ido-temp-list))) |
ido-temp-list))) |
2739 |
(if (and default (member default ido-temp-list)) |
(if (and default (member default ido-temp-list)) |
2746 |
(setcdr l nil) |
(setcdr l nil) |
2747 |
(nconc k ido-temp-list) |
(nconc k ido-temp-list) |
2748 |
(setq ido-temp-list k))) |
(setq ido-temp-list k))) |
2749 |
(setq ido-temp-list |
(setq ido-temp-list |
2750 |
(delete default ido-temp-list)) |
(delete default ido-temp-list)) |
2751 |
(setq ido-temp-list |
(setq ido-temp-list |
2752 |
(cons default ido-temp-list)))) |
(cons default ido-temp-list)))) |
2753 |
(when ido-show-dot-for-dired |
(when ido-show-dot-for-dired |
2754 |
(setq ido-temp-list (delete "." ido-temp-list)) |
(setq ido-temp-list (delete "." ido-temp-list)) |
2760 |
;; Return list of non-ignored subdirs in DIR |
;; Return list of non-ignored subdirs in DIR |
2761 |
;; If MERGED is non-nil, each subdir is cons'ed with DIR |
;; If MERGED is non-nil, each subdir is cons'ed with DIR |
2762 |
(and (or (ido-is-tramp-root dir) (file-directory-p dir)) |
(and (or (ido-is-tramp-root dir) (file-directory-p dir)) |
2763 |
(delq nil |
(delq nil |
2764 |
(mapcar |
(mapcar |
2765 |
(lambda (name) |
(lambda (name) |
2766 |
(and (ido-final-slash name) (not (ido-ignore-item-p name ido-ignore-directories)) |
(and (ido-final-slash name) (not (ido-ignore-item-p name ido-ignore-directories)) |
2769 |
|
|
2770 |
(defun ido-make-dir-list (default) |
(defun ido-make-dir-list (default) |
2771 |
;; Return the current list of directories. |
;; Return the current list of directories. |
2772 |
;; The hook `ido-make-dir-list-hook' is run after the list has been |
;; The hook `ido-make-dir-list-hook' is run after the list has been |
2773 |
;; created to allow the user to further modify the order of the |
;; created to allow the user to further modify the order of the |
2774 |
;; directory names in this list. |
;; directory names in this list. |
2775 |
(let ((ido-temp-list (ido-make-dir-list1 ido-current-directory))) |
(let ((ido-temp-list (ido-make-dir-list1 ido-current-directory))) |
2776 |
(setq ido-temp-list (ido-sort-list ido-temp-list)) |
(setq ido-temp-list (ido-sort-list ido-temp-list)) |
2777 |
(ido-to-end ;; move . files to end |
(ido-to-end ;; move . files to end |
2778 |
(delq nil (mapcar |
(delq nil (mapcar |
2779 |
(lambda (x) (if (string-equal (substring x 0 1) ".") x)) |
(lambda (x) (if (string-equal (substring x 0 1) ".") x)) |
2780 |
ido-temp-list))) |
ido-temp-list))) |
2781 |
(if (and default (member default ido-temp-list)) |
(if (and default (member default ido-temp-list)) |
2788 |
(setcdr l nil) |
(setcdr l nil) |
2789 |
(nconc k ido-temp-list) |
(nconc k ido-temp-list) |
2790 |
(setq ido-temp-list k))) |
(setq ido-temp-list k))) |
2791 |
(setq ido-temp-list |
(setq ido-temp-list |
2792 |
(delete default ido-temp-list)) |
(delete default ido-temp-list)) |
2793 |
(setq ido-temp-list |
(setq ido-temp-list |
2794 |
(cons default ido-temp-list)))) |
(cons default ido-temp-list)))) |
2795 |
(setq ido-temp-list (delete "." ido-temp-list)) |
(setq ido-temp-list (delete "." ido-temp-list)) |
2796 |
(setq ido-temp-list (cons "." ido-temp-list)) |
(setq ido-temp-list (cons "." ido-temp-list)) |
2807 |
;; `ido-all-frames'. |
;; `ido-all-frames'. |
2808 |
(let ((ido-bufs-in-frame nil)) |
(let ((ido-bufs-in-frame nil)) |
2809 |
(walk-windows 'ido-get-bufname nil |
(walk-windows 'ido-get-bufname nil |
2810 |
(if current |
(if current |
2811 |
nil |
nil |
2812 |
ido-all-frames)) |
ido-all-frames)) |
2813 |
ido-bufs-in-frame)) |
ido-bufs-in-frame)) |
2869 |
(setq matches (cons item matches))))) |
(setq matches (cons item matches))))) |
2870 |
items)) |
items)) |
2871 |
matches)) |
matches)) |
2872 |
|
|
2873 |
|
|
2874 |
(defun ido-set-matches () |
(defun ido-set-matches () |
2875 |
;; Set `ido-matches' to the list of items matching prompt |
;; Set `ido-matches' to the list of items matching prompt |
2876 |
(when ido-rescan |
(when ido-rescan |
2877 |
(setq ido-matches (ido-set-matches1 (reverse ido-cur-list) (not ido-rotate)) |
(setq ido-matches (ido-set-matches1 (reverse ido-cur-list) (not ido-rotate)) |
2878 |
ido-rotate nil))) |
ido-rotate nil))) |
2879 |
|
|
2880 |
(defun ido-ignore-item-p (name re-list &optional ignore-ext) |
(defun ido-ignore-item-p (name re-list &optional ignore-ext) |
2881 |
;; Return t if the buffer or file NAME should be ignored. |
;; Return t if the buffer or file NAME should be ignored. |
2882 |
(or (member name ido-ignore-item-temp-list) |
(or (member name ido-ignore-item-temp-list) |
2885 |
(let ((data (match-data)) |
(let ((data (match-data)) |
2886 |
(ext-list (and ignore-ext ido-ignore-extensions |
(ext-list (and ignore-ext ido-ignore-extensions |
2887 |
completion-ignored-extensions)) |
completion-ignored-extensions)) |
2888 |
ignorep nextstr |
ignorep nextstr |
2889 |
(flen (length name)) slen) |
(flen (length name)) slen) |
2890 |
(while ext-list |
(while ext-list |
2891 |
(setq nextstr (car ext-list)) |
(setq nextstr (car ext-list)) |
2941 |
(defun ido-word-matching-substring (word) |
(defun ido-word-matching-substring (word) |
2942 |
;; Return part of WORD before 1st match to `ido-change-word-sub'. |
;; Return part of WORD before 1st match to `ido-change-word-sub'. |
2943 |
;; If `ido-change-word-sub' cannot be found in WORD, return nil. |
;; If `ido-change-word-sub' cannot be found in WORD, return nil. |
2944 |
(let ((case-fold-search ido-case-fold)) |
(let ((case-fold-search ido-case-fold)) |
2945 |
(let ((m (string-match ido-change-word-sub (ido-name word)))) |
(let ((m (string-match ido-change-word-sub (ido-name word)))) |
2946 |
(if m |
(if m |
2947 |
(substring (ido-name word) m) |
(substring (ido-name word) m) |
3009 |
(let ((f 'display-completion-list)) |
(let ((f 'display-completion-list)) |
3010 |
(funcall f completion-list |
(funcall f completion-list |
3011 |
:help-string "ido " |
:help-string "ido " |
3012 |
:activate-callback |
:activate-callback |
3013 |
'(lambda (x y z) (message "doesn't work yet, sorry!")))) |
'(lambda (x y z) (message "doesn't work yet, sorry!")))) |
3014 |
;; else running Emacs |
;; else running Emacs |
3015 |
;;(add-hook 'completion-setup-hook 'completion-setup-function) |
;;(add-hook 'completion-setup-hook 'completion-setup-function) |
3026 |
;; Check if buffer still exists. |
;; Check if buffer still exists. |
3027 |
(if (get-buffer buf) |
(if (get-buffer buf) |
3028 |
;; buffer couldn't be killed. |
;; buffer couldn't be killed. |
3029 |
(setq ido-rescan t) |
(setq ido-rescan t) |
3030 |
;; else buffer was killed so remove name from list. |
;; else buffer was killed so remove name from list. |
3031 |
(setq ido-cur-list (delq buf ido-cur-list)))))) |
(setq ido-cur-list (delq buf ido-cur-list)))))) |
3032 |
|
|
3047 |
;; Check if file still exists. |
;; Check if file still exists. |
3048 |
(if (file-exists-p file) |
(if (file-exists-p file) |
3049 |
;; file could not be deleted |
;; file could not be deleted |
3050 |
(setq ido-rescan t) |
(setq ido-rescan t) |
3051 |
;; else file was killed so remove name from list. |
;; else file was killed so remove name from list. |
3052 |
(setq ido-cur-list (delq (car ido-matches) ido-cur-list)))))) |
(setq ido-cur-list (delq (car ido-matches) ido-cur-list)))))) |
3053 |
|
|
3140 |
|
|
3141 |
\\[ido-next-match] Put the first element at the end of the list. |
\\[ido-next-match] Put the first element at the end of the list. |
3142 |
\\[ido-prev-match] Put the last element at the start of the list. |
\\[ido-prev-match] Put the last element at the start of the list. |
3143 |
\\[ido-complete] Complete a common suffix to the current string that |
\\[ido-complete] Complete a common suffix to the current string that |
3144 |
matches all buffers. If there is only one match, select that buffer. |
matches all buffers. If there is only one match, select that buffer. |
3145 |
If there is no common suffix, show a list of all matching buffers |
If there is no common suffix, show a list of all matching buffers |
3146 |
in a separate window. |
in a separate window. |
3228 |
|
|
3229 |
\\[ido-next-match] Put the first element at the end of the list. |
\\[ido-next-match] Put the first element at the end of the list. |
3230 |
\\[ido-prev-match] Put the last element at the start of the list. |
\\[ido-prev-match] Put the last element at the start of the list. |
3231 |
\\[ido-complete] Complete a common suffix to the current string that |
\\[ido-complete] Complete a common suffix to the current string that |
3232 |
matches all files. If there is only one match, select that file. |
matches all files. If there is only one match, select that file. |
3233 |
If there is no common suffix, show a list of all matching files |
If there is no common suffix, show a list of all matching files |
3234 |
in a separate window. |
in a separate window. |
3429 |
|
|
3430 |
((ido-final-slash contents) ;; xxx/ |
((ido-final-slash contents) ;; xxx/ |
3431 |
(ido-trace "final slash" contents) |
(ido-trace "final slash" contents) |
3432 |
(cond |
(cond |
3433 |
((string-equal contents "~/") |
((string-equal contents "~/") |
3434 |
(ido-set-current-home) |
(ido-set-current-home) |
3435 |
(setq refresh t)) |
(setq refresh t)) |
3458 |
(ido-set-current-directory (file-name-directory contents)) |
(ido-set-current-directory (file-name-directory contents)) |
3459 |
(setq refresh t)) |
(setq refresh t)) |
3460 |
((string-equal (substring contents -2 -1) "/") |
((string-equal (substring contents -2 -1) "/") |
3461 |
(ido-set-current-directory |
(ido-set-current-directory |
3462 |
(if (memq system-type '(windows-nt ms-dos)) |
(if (memq system-type '(windows-nt ms-dos)) |
3463 |
(expand-file-name "/" ido-current-directory) |
(expand-file-name "/" ido-current-directory) |
3464 |
"/")) |
"/")) |
3513 |
(or try-single-dir-match |
(or try-single-dir-match |
3514 |
(eq ido-enter-single-matching-directory t))) |
(eq ido-enter-single-matching-directory t))) |
3515 |
(ido-trace "single match" (car ido-matches)) |
(ido-trace "single match" (car ido-matches)) |
3516 |
(ido-set-current-directory |
(ido-set-current-directory |
3517 |
(concat ido-current-directory (car ido-matches))) |
(concat ido-current-directory (car ido-matches))) |
3518 |
(setq ido-exit 'refresh) |
(setq ido-exit 'refresh) |
3519 |
(exit-minibuffer)) |
(exit-minibuffer)) |
3554 |
(ido-trace "\n*start timer*") |
(ido-trace "\n*start timer*") |
3555 |
(setq ido-auto-merge-timer |
(setq ido-auto-merge-timer |
3556 |
(run-with-timer ido-auto-merge-delay-time nil 'ido-initiate-auto-merge (current-buffer)))))) |
(run-with-timer ido-auto-merge-delay-time nil 'ido-initiate-auto-merge (current-buffer)))))) |
3557 |
|
|
3558 |
(setq ido-rescan t) |
(setq ido-rescan t) |
3559 |
|
|
3560 |
(if (and ido-use-merged-list |
(if (and ido-use-merged-list |
3561 |
ido-matches |
ido-matches |
3562 |
(not (string-equal (car (cdr (car ido-matches))) ido-current-directory))) |
(not (string-equal (car (cdr (car ido-matches))) ido-current-directory))) |
3563 |
(progn |
(progn |
3569 |
|
|
3570 |
;; Insert the match-status information: |
;; Insert the match-status information: |
3571 |
(ido-set-common-completion) |
(ido-set-common-completion) |
3572 |
(let ((inf (ido-completions |
(let ((inf (ido-completions |
3573 |
contents |
contents |
3574 |
minibuffer-completion-table |
minibuffer-completion-table |
3575 |
minibuffer-completion-predicate |
minibuffer-completion-predicate |
3581 |
(defun ido-completions (name candidates predicate require-match) |
(defun ido-completions (name candidates predicate require-match) |
3582 |
;; Return the string that is displayed after the user's text. |
;; Return the string that is displayed after the user's text. |
3583 |
;; Modified from `icomplete-completions'. |
;; Modified from `icomplete-completions'. |
3584 |
|
|
3585 |
(let* ((comps ido-matches) |
(let* ((comps ido-matches) |
3586 |
(ind (and (consp (car comps)) (> (length (cdr (car comps))) 1) |
(ind (and (consp (car comps)) (> (length (cdr (car comps))) 1) |
3587 |
ido-merged-indicator)) |
ido-merged-indicator)) |
3589 |
|
|
3590 |
(if (and ind ido-use-faces) |
(if (and ind ido-use-faces) |
3591 |
(put-text-property 0 1 'face 'ido-indicator-face ind)) |
(put-text-property 0 1 'face 'ido-indicator-face ind)) |
3592 |
|
|
3593 |
(if (and ido-use-faces comps) |
(if (and ido-use-faces comps) |
3594 |
(let* ((fn (ido-name (car comps))) |
(let* ((fn (ido-name (car comps))) |
3595 |
(ln (length fn))) |
(ln (length fn))) |
3619 |
(let* ((items (if (> ido-max-prospects 0) (1+ ido-max-prospects) 999)) |
(let* ((items (if (> ido-max-prospects 0) (1+ ido-max-prospects) 999)) |
3620 |
(alternatives |
(alternatives |
3621 |
(apply |
(apply |
3622 |
#'concat |
#'concat |
3623 |
(cdr (apply |
(cdr (apply |
3624 |
#'nconc |
#'nconc |
3625 |
(mapcar |
(mapcar |
3654 |
(defun ido-minibuffer-setup () |
(defun ido-minibuffer-setup () |
3655 |
"Minibuffer setup hook for `ido'." |
"Minibuffer setup hook for `ido'." |
3656 |
;; Copied from `icomplete-minibuffer-setup-hook'. |
;; Copied from `icomplete-minibuffer-setup-hook'. |
3657 |
(when (and (boundp 'ido-completing-read) |
(when (and (boundp 'ido-completing-read) |
3658 |
(or (featurep 'xemacs) |
(or (featurep 'xemacs) |
3659 |
(= ido-use-mycompletion-depth (minibuffer-depth)))) |
(= ido-use-mycompletion-depth (minibuffer-depth)))) |
3660 |
(add-hook 'pre-command-hook 'ido-tidy nil t) |
(add-hook 'pre-command-hook 'ido-tidy nil t) |
3679 |
(= ido-use-mycompletion-depth (minibuffer-depth))) |
(= ido-use-mycompletion-depth (minibuffer-depth))) |
3680 |
(if (and (boundp 'ido-eoinput) |
(if (and (boundp 'ido-eoinput) |
3681 |
ido-eoinput) |
ido-eoinput) |
3682 |
|
|
3683 |
(if (> ido-eoinput (point-max)) |
(if (> ido-eoinput (point-max)) |
3684 |
;; Oops, got rug pulled out from under us - reinit: |
;; Oops, got rug pulled out from under us - reinit: |
3685 |
(setq ido-eoinput (point-max)) |
(setq ido-eoinput (point-max)) |
3686 |
(let ((buffer-undo-list t)) |
(let ((buffer-undo-list t)) |
3687 |
(delete-region ido-eoinput (point-max)))) |
(delete-region ido-eoinput (point-max)))) |
3688 |
|
|
3689 |
;; Reestablish the local variable 'cause minibuffer-setup is weird: |
;; Reestablish the local variable 'cause minibuffer-setup is weird: |
3690 |
(make-local-variable 'ido-eoinput) |
(make-local-variable 'ido-eoinput) |
3691 |
(setq ido-eoinput 1)))) |
(setq ido-eoinput 1)))) |
3695 |
;; This is an example function which can be hooked on to |
;; This is an example function which can be hooked on to |
3696 |
;; `ido-make-buffer-list-hook'. Any buffer matching the regexps |
;; `ido-make-buffer-list-hook'. Any buffer matching the regexps |
3697 |
;; `Summary' or `output\*$'are put to the end of the list. |
;; `Summary' or `output\*$'are put to the end of the list. |
3698 |
(let ((summaries (delq nil (mapcar |
(let ((summaries (delq nil (mapcar |
3699 |
(lambda (x) |
(lambda (x) |
3700 |
(if (or |
(if (or |
3701 |
(string-match "Summary" x) |
(string-match "Summary" x) |
3702 |
(string-match "output\\*\\'" x)) |
(string-match "output\\*\\'" x)) |
3703 |
x)) |
x)) |