666 |
:type 'integer |
:type 'integer |
667 |
:group 'ido) |
:group 'ido) |
668 |
|
|
669 |
|
(defcustom ido-max-directory-size 30000 |
670 |
|
"*Maximum size (in bytes) for directories to use ido completion. |
671 |
|
If you enter a directory with a size larger than this size, ido will |
672 |
|
not provide the normal completion. To show the completions, use C-a." |
673 |
|
:type '(choice (const :tag "No limit" nil) |
674 |
|
(integer :tag "Size in bytes" 30000)) |
675 |
|
:group 'ido) |
676 |
|
|
677 |
(defcustom ido-rotate-file-list-default nil |
(defcustom ido-rotate-file-list-default nil |
678 |
"*Non-nil means that `ido' will always rotate file list to get default in front." |
"*Non-nil means that `ido' will always rotate file list to get default in front." |
679 |
:type 'boolean |
:type 'boolean |
707 |
:type '(choice string (const nil)) |
:type '(choice string (const nil)) |
708 |
:group 'ido) |
:group 'ido) |
709 |
|
|
710 |
(defcustom ido-decorations '( "{" "}" " | " " | ..." "[" "]" " [No match]" " [Matched]" " [Not readable]") |
(defcustom ido-decorations '( "{" "}" " | " " | ..." "[" "]" " [No match]" " [Matched]" " [Not readable]" " [Too big]") |
711 |
"*List of strings used by ido to display the alternatives in the minibuffer. |
"*List of strings used by ido to display the alternatives in the minibuffer. |
712 |
There are 9 elements in this list: |
There are 10 elements in this list: |
713 |
1st and 2nd elements are used as brackets around the prospect list, |
1st and 2nd elements are used as brackets around the prospect list, |
714 |
3rd element is the separator between prospects (ignored if ido-separator is set), |
3rd element is the separator between prospects (ignored if ido-separator is set), |
715 |
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, |
717 |
can be completed using TAB, |
can be completed using TAB, |
718 |
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 |
719 |
8th element is displayed if there is a single match (and faces are not used). |
8th element is displayed if there is a single match (and faces are not used). |
720 |
9th element is displayed when the current directory is non-readable." |
9th element is displayed when the current directory is non-readable. |
721 |
|
10th element is displayed when directory exceeds `ido-max-directory-size'." |
722 |
:type '(repeat string) |
:type '(repeat string) |
723 |
:group 'ido) |
:group 'ido) |
724 |
|
|
961 |
;; Remember if current directory is non-readable (so we cannot do completion). |
;; Remember if current directory is non-readable (so we cannot do completion). |
962 |
(defvar ido-directory-nonreadable) |
(defvar ido-directory-nonreadable) |
963 |
|
|
964 |
|
;; Remember if current directory is 'huge' (so we don't want to do completion). |
965 |
|
(defvar ido-directory-too-big) |
966 |
|
|
967 |
;; Keep current item list if non-nil. |
;; Keep current item list if non-nil. |
968 |
(defvar ido-keep-item-list) |
(defvar ido-keep-item-list) |
969 |
|
|
1094 |
(defun ido-may-cache-directory (&optional dir) |
(defun ido-may-cache-directory (&optional dir) |
1095 |
(setq dir (or dir ido-current-directory)) |
(setq dir (or dir ido-current-directory)) |
1096 |
(cond |
(cond |
1097 |
|
((ido-directory-too-big-p dir) |
1098 |
|
nil) |
1099 |
((and (ido-is-root-directory dir) |
((and (ido-is-root-directory dir) |
1100 |
(or ido-enable-tramp-completion |
(or ido-enable-tramp-completion |
1101 |
(memq system-type '(windows-nt ms-dos)))) |
(memq system-type '(windows-nt ms-dos)))) |
1439 |
(file-directory-p dir) |
(file-directory-p dir) |
1440 |
(not (file-readable-p dir))))) |
(not (file-readable-p dir))))) |
1441 |
|
|
1442 |
|
(defun ido-directory-too-big-p (dir) |
1443 |
|
;; Return t if dir is a directory, but too big to show |
1444 |
|
;; Do not check for non-readable directories via tramp, as this causes a premature |
1445 |
|
;; connect on incomplete tramp paths (after entring just method:). |
1446 |
|
(let ((ido-enable-tramp-completion nil)) |
1447 |
|
(and (numberp ido-max-directory-size) |
1448 |
|
(ido-final-slash dir) |
1449 |
|
(file-directory-p dir) |
1450 |
|
(> (nth 7 (file-attributes dir)) ido-max-directory-size)))) |
1451 |
|
|
1452 |
(defun ido-set-current-directory (dir &optional subdir no-merge) |
(defun ido-set-current-directory (dir &optional subdir no-merge) |
1453 |
;; Set ido's current directory to DIR or DIR/SUBDIR |
;; Set ido's current directory to DIR or DIR/SUBDIR |
1454 |
(setq dir (ido-final-slash dir t)) |
(setq dir (ido-final-slash dir t)) |
1463 |
(if (get-buffer ido-completion-buffer) |
(if (get-buffer ido-completion-buffer) |
1464 |
(kill-buffer ido-completion-buffer)) |
(kill-buffer ido-completion-buffer)) |
1465 |
(setq ido-directory-nonreadable (ido-nonreadable-directory-p dir)) |
(setq ido-directory-nonreadable (ido-nonreadable-directory-p dir)) |
1466 |
|
(setq ido-directory-too-big (and (not ido-directory-nonreadable) |
1467 |
|
(ido-directory-too-big-p dir))) |
1468 |
t)) |
t)) |
1469 |
|
|
1470 |
(defun ido-set-current-home (&optional dir) |
(defun ido-set-current-home (&optional dir) |
1649 |
ido-rescan nil)) |
ido-rescan nil)) |
1650 |
((eq ido-cur-item 'file) |
((eq ido-cur-item 'file) |
1651 |
(setq ido-ignored-list nil |
(setq ido-ignored-list nil |
1652 |
ido-cur-list (ido-make-file-list ido-default-item))) |
ido-cur-list (and (not ido-directory-nonreadable) |
1653 |
|
(not ido-directory-too-big) |
1654 |
|
(ido-make-file-list ido-default-item)))) |
1655 |
((eq ido-cur-item 'dir) |
((eq ido-cur-item 'dir) |
1656 |
(setq ido-ignored-list nil |
(setq ido-ignored-list nil |
1657 |
ido-cur-list (ido-make-dir-list ido-default-item))) |
ido-cur-list (and (not ido-directory-nonreadable) |
1658 |
|
(not ido-directory-too-big) |
1659 |
|
(ido-make-dir-list ido-default-item)))) |
1660 |
((eq ido-cur-item 'buffer) |
((eq ido-cur-item 'buffer) |
1661 |
(setq ido-ignored-list nil |
(setq ido-ignored-list nil |
1662 |
ido-cur-list (ido-make-buffer-list ido-default-item))) |
ido-cur-list (ido-make-buffer-list ido-default-item))) |
1832 |
(if (not ido-mode) |
(if (not ido-mode) |
1833 |
(call-interactively (or fallback 'switch-to-buffer)) |
(call-interactively (or fallback 'switch-to-buffer)) |
1834 |
(let* ((ido-context-switch-command switch-cmd) |
(let* ((ido-context-switch-command switch-cmd) |
1835 |
(buf (ido-read-buffer (or prompt "Buffer: ") default nil initial))) |
(ido-current-directory nil) |
1836 |
|
(ido-directory-nonreadable nil) |
1837 |
|
(ido-directory-too-big nil) |
1838 |
|
(buf (ido-read-internal 'buffer (or prompt "Buffer: ") 'ido-buffer-history default nil initial))) |
1839 |
|
|
1840 |
;; Choose the buffer name: either the text typed in, or the head |
;; Choose the buffer name: either the text typed in, or the head |
1841 |
;; of the list of matches |
;; of the list of matches |
1878 |
(set-buffer-major-mode buf)) |
(set-buffer-major-mode buf)) |
1879 |
(ido-visit-buffer buf method t)))))) |
(ido-visit-buffer buf method t)))))) |
1880 |
|
|
|
;;;###autoload |
|
|
(defun ido-read-buffer (prompt &optional default require-match initial) |
|
|
"Replacement for the built-in `read-buffer'. |
|
|
Return the name of a buffer selected. |
|
|
PROMPT is the prompt to give to the user. DEFAULT if given is the default |
|
|
buffer to be selected, which will go to the front of the list. |
|
|
If REQUIRE-MATCH is non-nil, an existing-buffer must be selected. |
|
|
If INITIAL is non-nil, it specifies the initial input string." |
|
|
(let ((ido-current-directory nil) |
|
|
(ido-directory-nonreadable nil) |
|
|
(ido-context-switch-command (if (boundp 'ido-context-switch-command) ido-context-switch-command 'ignore))) |
|
|
(ido-read-internal 'buffer prompt 'ido-buffer-history default require-match initial))) |
|
|
|
|
1881 |
(defun ido-record-work-directory (&optional dir) |
(defun ido-record-work-directory (&optional dir) |
1882 |
(when (and (numberp ido-max-work-directory-list) (> ido-max-work-directory-list 0)) |
(when (and (numberp ido-max-work-directory-list) (> ido-max-work-directory-list 0)) |
1883 |
(if (and (setq dir (or dir ido-current-directory)) (> (length dir) 0)) |
(if (and (setq dir (or dir ido-current-directory)) (> (length dir) 0)) |
1925 |
(setq item 'file)) |
(setq item 'file)) |
1926 |
(let* ((ido-current-directory (ido-expand-directory default)) |
(let* ((ido-current-directory (ido-expand-directory default)) |
1927 |
(ido-directory-nonreadable (ido-nonreadable-directory-p ido-current-directory)) |
(ido-directory-nonreadable (ido-nonreadable-directory-p ido-current-directory)) |
1928 |
|
(ido-directory-too-big (and (not ido-directory-nonreadable) |
1929 |
|
(ido-directory-too-big-p ido-current-directory))) |
1930 |
(ido-context-switch-command switch-cmd) |
(ido-context-switch-command switch-cmd) |
1931 |
filename) |
filename) |
1932 |
|
|
2101 |
(setq ido-exit 'refresh) |
(setq ido-exit 'refresh) |
2102 |
(exit-minibuffer)))) |
(exit-minibuffer)))) |
2103 |
|
|
2104 |
|
(ido-directory-too-big |
2105 |
|
(setq ido-directory-too-big nil) |
2106 |
|
(setq ido-text-init ido-text) |
2107 |
|
(setq ido-exit 'refresh) |
2108 |
|
(exit-minibuffer)) |
2109 |
|
|
2110 |
((not ido-matches) |
((not ido-matches) |
2111 |
(when ido-completion-buffer |
(when ido-completion-buffer |
2112 |
(call-interactively (setq this-command ido-cannot-complete-command)))) |
(call-interactively (setq this-command ido-cannot-complete-command)))) |
2210 |
(defun ido-toggle-ignore () |
(defun ido-toggle-ignore () |
2211 |
"Toggle ignoring files specified with `ido-ignore-files'." |
"Toggle ignoring files specified with `ido-ignore-files'." |
2212 |
(interactive) |
(interactive) |
2213 |
(setq ido-process-ignore-lists (not ido-process-ignore-lists)) |
(if ido-directory-too-big |
2214 |
|
(setq ido-directory-too-big nil) |
2215 |
|
(setq ido-process-ignore-lists (not ido-process-ignore-lists))) |
2216 |
(setq ido-text-init ido-text) |
(setq ido-text-init ido-text) |
2217 |
(setq ido-exit 'refresh) |
(setq ido-exit 'refresh) |
2218 |
(exit-minibuffer)) |
(exit-minibuffer)) |
2354 |
(not (equal dir ido-current-directory)) |
(not (equal dir ido-current-directory)) |
2355 |
(file-directory-p dir) |
(file-directory-p dir) |
2356 |
(or (not must-match) |
(or (not must-match) |
2357 |
|
;; TODO. check for nonreadable and too-big. |
2358 |
(ido-set-matches1 |
(ido-set-matches1 |
2359 |
(if (eq ido-cur-item 'file) |
(if (eq ido-cur-item 'file) |
2360 |
(ido-make-file-list1 dir) |
(ido-make-file-list1 dir) |
2612 |
|
|
2613 |
(defun ido-all-completions () |
(defun ido-all-completions () |
2614 |
;; Return unsorted list of all competions. |
;; Return unsorted list of all competions. |
2615 |
(let ((ido-process-ignore-lists nil)) |
(let ((ido-process-ignore-lists nil) |
2616 |
|
(ido-directory-too-big nil)) |
2617 |
(cond |
(cond |
2618 |
((eq ido-cur-item 'file) |
((eq ido-cur-item 'file) |
2619 |
(ido-make-file-list1 ido-current-directory)) |
(ido-make-file-list1 ido-current-directory)) |
2732 |
(or ido-merge-ftp-work-directories |
(or ido-merge-ftp-work-directories |
2733 |
(not (ido-is-ftp-directory dir))) |
(not (ido-is-ftp-directory dir))) |
2734 |
(file-directory-p dir) |
(file-directory-p dir) |
2735 |
|
;; TODO. check for nonreadable and too-big. |
2736 |
(setq fl (if (eq ido-cur-item 'file) |
(setq fl (if (eq ido-cur-item 'file) |
2737 |
(ido-make-file-list1 dir t) |
(ido-make-file-list1 dir t) |
2738 |
(ido-make-dir-list1 dir t)))) |
(ido-make-dir-list1 dir t)))) |
2813 |
(defun ido-file-name-all-completions1 (dir) |
(defun ido-file-name-all-completions1 (dir) |
2814 |
(cond |
(cond |
2815 |
((ido-nonreadable-directory-p dir) '()) |
((ido-nonreadable-directory-p dir) '()) |
2816 |
|
;; do not check (ido-directory-too-big-p dir) here. |
2817 |
|
;; Caller must have done that if necessary. |
2818 |
((and ido-enable-tramp-completion |
((and ido-enable-tramp-completion |
2819 |
(string-match "\\`/\\([^/:]+:\\([^/:@]+@\\)?\\)\\'" dir)) |
(string-match "\\`/\\([^/:]+:\\([^/:@]+@\\)?\\)\\'" dir)) |
2820 |
|
|
3651 |
(expand-file-name "/" ido-current-directory) |
(expand-file-name "/" ido-current-directory) |
3652 |
"/")) |
"/")) |
3653 |
(setq refresh t)) |
(setq refresh t)) |
3654 |
((and ido-directory-nonreadable |
((and (or ido-directory-nonreadable ido-directory-too-big) |
3655 |
(file-directory-p (concat ido-current-directory (file-name-directory contents)))) |
(file-directory-p (concat ido-current-directory (file-name-directory contents)))) |
3656 |
(ido-set-current-directory |
(ido-set-current-directory |
3657 |
(concat ido-current-directory (file-name-directory contents))) |
(concat ido-current-directory (file-name-directory contents))) |
3713 |
|
|
3714 |
(when (and (not ido-matches) |
(when (and (not ido-matches) |
3715 |
(not ido-directory-nonreadable) |
(not ido-directory-nonreadable) |
3716 |
|
(not ido-directory-too-big) |
3717 |
;; ido-rescan ? |
;; ido-rescan ? |
3718 |
ido-process-ignore-lists |
ido-process-ignore-lists |
3719 |
ido-ignored-list) |
ido-ignored-list) |
3737 |
(not (ido-is-root-directory)) |
(not (ido-is-root-directory)) |
3738 |
(> (length contents) 1) |
(> (length contents) 1) |
3739 |
(not (string-match "[$]" contents)) |
(not (string-match "[$]" contents)) |
3740 |
(not ido-directory-nonreadable)) |
(not ido-directory-nonreadable) |
3741 |
|
(not ido-directory-too-big)) |
3742 |
(ido-trace "merge?") |
(ido-trace "merge?") |
3743 |
(if ido-use-merged-list |
(if ido-use-merged-list |
3744 |
(ido-undo-merge-work-directory contents nil) |
(ido-undo-merge-work-directory contents nil) |
3803 |
(cond |
(cond |
3804 |
(ido-directory-nonreadable |
(ido-directory-nonreadable |
3805 |
(or (nth 8 ido-decorations) " [Not readable]")) |
(or (nth 8 ido-decorations) " [Not readable]")) |
3806 |
|
(ido-directory-too-big |
3807 |
|
(or (nth 9 ido-decorations) " [Too big]")) |
3808 |
(ido-report-no-match |
(ido-report-no-match |
3809 |
(nth 6 ido-decorations)) ;; [No match] |
(nth 6 ido-decorations)) ;; [No match] |
3810 |
(t ""))) |
(t ""))) |
3911 |
(put 'dired-do-rename 'ido 'ignore) |
(put 'dired-do-rename 'ido 'ignore) |
3912 |
|
|
3913 |
;;;###autoload |
;;;###autoload |
3914 |
|
(defun ido-read-buffer (prompt &optional default require-match) |
3915 |
|
"Ido replacement for the built-in `read-buffer'. |
3916 |
|
Return the name of a buffer selected. |
3917 |
|
PROMPT is the prompt to give to the user. DEFAULT if given is the default |
3918 |
|
buffer to be selected, which will go to the front of the list. |
3919 |
|
If REQUIRE-MATCH is non-nil, an existing-buffer must be selected." |
3920 |
|
(let* ((ido-current-directory nil) |
3921 |
|
(ido-directory-nonreadable nil) |
3922 |
|
(ido-directory-too-big nil) |
3923 |
|
(ido-context-switch-command 'ignore) |
3924 |
|
(buf (ido-read-internal 'buffer prompt 'ido-buffer-history default require-match))) |
3925 |
|
(if (eq ido-exit 'fallback) |
3926 |
|
(let ((read-buffer-function nil)) |
3927 |
|
(read-buffer prompt default require-match)) |
3928 |
|
buf))) |
3929 |
|
|
3930 |
|
;;;###autoload |
3931 |
(defun ido-read-file-name (prompt &optional dir default-filename mustmatch initial predicate) |
(defun ido-read-file-name (prompt &optional dir default-filename mustmatch initial predicate) |
3932 |
"Read file name, prompting with PROMPT and completing in directory DIR. |
"Ido replacement for the built-in `read-file-name'. |
3933 |
|
Read file name, prompting with PROMPT and completing in directory DIR. |
3934 |
See `read-file-name' for additional parameters." |
See `read-file-name' for additional parameters." |
3935 |
(let (filename) |
(let (filename) |
3936 |
(cond |
(cond |
3947 |
(vc-handled-backends (and (boundp 'vc-handled-backends) vc-handled-backends)) |
(vc-handled-backends (and (boundp 'vc-handled-backends) vc-handled-backends)) |
3948 |
(ido-current-directory (ido-expand-directory dir)) |
(ido-current-directory (ido-expand-directory dir)) |
3949 |
(ido-directory-nonreadable (not (file-readable-p ido-current-directory))) |
(ido-directory-nonreadable (not (file-readable-p ido-current-directory))) |
3950 |
|
(ido-directory-too-big (and (not ido-directory-nonreadable) |
3951 |
|
(ido-directory-too-big-p ido-current-directory))) |
3952 |
(ido-work-directory-index -1) |
(ido-work-directory-index -1) |
3953 |
(ido-work-file-index -1) |
(ido-work-file-index -1) |
3954 |
(ido-find-literal nil)) |
(ido-find-literal nil)) |
3970 |
|
|
3971 |
;;;###autoload |
;;;###autoload |
3972 |
(defun ido-read-directory-name (prompt &optional dir default-dirname mustmatch initial) |
(defun ido-read-directory-name (prompt &optional dir default-dirname mustmatch initial) |
3973 |
"Read directory name, prompting with PROMPT and completing in directory DIR. |
"Ido replacement for the built-in `read-directory-name'. |
3974 |
See `read-file-name' for additional parameters." |
Read directory name, prompting with PROMPT and completing in directory DIR. |
3975 |
|
See `read-directory-name' for additional parameters." |
3976 |
(let* (filename |
(let* (filename |
3977 |
(ido-context-switch-command 'ignore) |
(ido-context-switch-command 'ignore) |
3978 |
ido-saved-vc-hb |
ido-saved-vc-hb |
3979 |
(ido-current-directory (ido-expand-directory dir)) |
(ido-current-directory (ido-expand-directory dir)) |
3980 |
(ido-directory-nonreadable (not (file-readable-p ido-current-directory))) |
(ido-directory-nonreadable (not (file-readable-p ido-current-directory))) |
3981 |
|
(ido-directory-too-big (and (not ido-directory-nonreadable) |
3982 |
|
(ido-directory-too-big-p ido-current-directory))) |
3983 |
(ido-work-directory-index -1) |
(ido-work-directory-index -1) |
3984 |
(ido-work-file-index -1)) |
(ido-work-file-index -1)) |
3985 |
(setq filename |
(setq filename |
3991 |
|
|
3992 |
;;;###autoload |
;;;###autoload |
3993 |
(defun ido-completing-read (prompt choices &optional predicate require-match initial-input hist def) |
(defun ido-completing-read (prompt choices &optional predicate require-match initial-input hist def) |
3994 |
"Read a string in the minibuffer with ido-style completion. |
"Ido replacement for the built-in `completing-read'. |
3995 |
|
Read a string in the minibuffer with ido-style completion. |
3996 |
PROMPT is a string to prompt with; normally it ends in a colon and a space. |
PROMPT is a string to prompt with; normally it ends in a colon and a space. |
3997 |
CHOICES is a list of strings which are the possible completions. |
CHOICES is a list of strings which are the possible completions. |
3998 |
PREDICATE is currently ignored; it is included to be compatible |
PREDICATE is currently ignored; it is included to be compatible |
4007 |
DEF, if non-nil, is the default value." |
DEF, if non-nil, is the default value." |
4008 |
(let ((ido-current-directory nil) |
(let ((ido-current-directory nil) |
4009 |
(ido-directory-nonreadable nil) |
(ido-directory-nonreadable nil) |
4010 |
|
(ido-directory-too-big nil) |
4011 |
(ido-context-switch-command 'ignore) |
(ido-context-switch-command 'ignore) |
4012 |
(ido-choice-list choices)) |
(ido-choice-list choices)) |
4013 |
(ido-read-internal 'list prompt hist def require-match initial-input))) |
(ido-read-internal 'list prompt hist def require-match initial-input))) |