1646 |
(l (ido-make-merged-file-list ido-text-init |
(l (ido-make-merged-file-list ido-text-init |
1647 |
(eq ido-use-merged-list 'auto) |
(eq ido-use-merged-list 'auto) |
1648 |
(eq ido-try-merged-list 'wide)))) |
(eq ido-try-merged-list 'wide)))) |
1649 |
|
(ido-trace "merged" l) |
1650 |
(cond |
(cond |
1651 |
((not l) |
((not l) |
1652 |
(if (eq ido-try-merged-list 'wide) |
(if (eq ido-try-merged-list 'wide) |
1666 |
ido-use-merged-list nil))) |
ido-use-merged-list nil))) |
1667 |
((eq l t) |
((eq l t) |
1668 |
(setq ido-use-merged-list nil)) |
(setq ido-use-merged-list nil)) |
1669 |
|
((eq l 'input-pending-p) |
1670 |
|
(setq ido-try-merged-list t |
1671 |
|
ido-use-merged-list nil)) |
1672 |
(t |
(t |
1673 |
(setq ido-pre-merge-state |
(setq ido-pre-merge-state |
1674 |
(list ido-text-init ido-current-directory olist oign omat)) |
(list ido-text-init ido-current-directory olist oign omat)) |
2497 |
(file-directory-p dir) |
(file-directory-p dir) |
2498 |
(or (not must-match) |
(or (not must-match) |
2499 |
;; TODO. check for nonreadable and too-big. |
;; TODO. check for nonreadable and too-big. |
2500 |
(ido-set-matches1 |
(ido-set-matches-1 |
2501 |
(if (eq ido-cur-item 'file) |
(if (eq ido-cur-item 'file) |
2502 |
(ido-make-file-list1 dir) |
(ido-make-file-list-1 dir) |
2503 |
(ido-make-dir-list1 dir))))) |
(ido-make-dir-list-1 dir))))) |
2504 |
(setq j n) |
(setq j n) |
2505 |
(setq dir nil))) |
(setq dir nil))) |
2506 |
(if dir |
(if dir |
2790 |
(ido-directory-too-big nil)) |
(ido-directory-too-big nil)) |
2791 |
(cond |
(cond |
2792 |
((eq ido-cur-item 'file) |
((eq ido-cur-item 'file) |
2793 |
(ido-make-file-list1 ido-current-directory)) |
(ido-make-file-list-1 ido-current-directory)) |
2794 |
((eq ido-cur-item 'dir) |
((eq ido-cur-item 'dir) |
2795 |
(ido-make-dir-list1 ido-current-directory)) |
(ido-make-dir-list-1 ido-current-directory)) |
2796 |
((eq ido-cur-item 'buffer) |
((eq ido-cur-item 'buffer) |
2797 |
(ido-make-buffer-list1)) |
(ido-make-buffer-list-1)) |
2798 |
((eq ido-cur-item 'list) |
((eq ido-cur-item 'list) |
2799 |
ido-choice-list) |
ido-choice-list) |
2800 |
(t nil)))) |
(t nil)))) |
2912 |
(setq items (cdr items))) |
(setq items (cdr items))) |
2913 |
res)) |
res)) |
2914 |
|
|
2915 |
(defun ido-make-merged-file-list (text auto wide) |
|
2916 |
|
(defun ido-make-merged-file-list-1 (text auto wide) |
2917 |
(let (res) |
(let (res) |
2918 |
(message "Searching for `%s'...." text) |
(if (and (ido-final-slash text) ido-dir-file-cache) |
2919 |
(condition-case nil |
(if wide |
2920 |
(if (and (ido-final-slash text) ido-dir-file-cache) |
(setq res (ido-wide-find-dirs-or-files |
2921 |
(if wide |
ido-current-directory (substring text 0 -1) ido-enable-prefix t)) |
2922 |
(setq res (ido-wide-find-dirs-or-files |
;; Use list of cached directories |
2923 |
ido-current-directory (substring text 0 -1) ido-enable-prefix t)) |
(let ((re (concat (regexp-quote (substring text 0 -1)) "[^/:]*/\\'")) |
2924 |
;; Use list of cached directories |
(dirs ido-dir-file-cache) |
2925 |
(let ((re (concat (regexp-quote (substring text 0 -1)) "[^/:]*/\\'")) |
dir b d f) |
2926 |
(dirs ido-dir-file-cache) |
(if nil ;; simple |
2927 |
dir b d f) |
(while dirs |
2928 |
(if nil ;; simple |
(setq dir (car (car dirs)) |
2929 |
(while dirs |
dirs (cdr dirs)) |
2930 |
(setq dir (car (car dirs)) |
(when (and (string-match re dir) |
2931 |
dirs (cdr dirs)) |
(not (ido-ignore-item-p dir ido-ignore-directories-merge)) |
2932 |
(when (and (string-match re dir) |
(file-directory-p dir)) |
2933 |
(not (ido-ignore-item-p dir ido-ignore-directories-merge)) |
(setq b (substring dir 0 -1) |
2934 |
(file-directory-p dir)) |
f (concat (file-name-nondirectory b) "/") |
2935 |
(setq b (substring dir 0 -1) |
d (file-name-directory b) |
2936 |
f (concat (file-name-nondirectory b) "/") |
res (cons (cons f d) res)))) |
|
d (file-name-directory b) |
|
|
res (cons (cons f d) res)))) |
|
|
(while dirs |
|
|
(setq dir (car dirs) |
|
|
d (car dir) |
|
|
dirs (cdr dirs)) |
|
|
(when (not (ido-ignore-item-p d ido-ignore-directories-merge)) |
|
|
(setq dir (cdr (cdr dir))) |
|
|
(while dir |
|
|
(setq f (car dir) |
|
|
dir (cdr dir)) |
|
|
(if (and (string-match re f) |
|
|
(not (ido-ignore-item-p f ido-ignore-directories))) |
|
|
(setq res (cons (cons f d) res))))) |
|
|
(if (and auto (input-pending-p)) |
|
|
(setq dirs nil |
|
|
res t)))))) |
|
|
(if wide |
|
|
(setq res (ido-wide-find-dirs-or-files |
|
|
ido-current-directory text ido-enable-prefix nil)) |
|
|
(let ((ido-text text) |
|
|
(dirs ido-work-directory-list) |
|
|
(must-match (and text (> (length text) 0))) |
|
|
dir fl) |
|
|
(if (and auto (not (member ido-current-directory dirs))) |
|
|
(setq dirs (cons ido-current-directory dirs))) |
|
2937 |
(while dirs |
(while dirs |
2938 |
(setq dir (car dirs) |
(setq dir (car dirs) |
2939 |
|
d (car dir) |
2940 |
dirs (cdr dirs)) |
dirs (cdr dirs)) |
2941 |
(when (and dir (stringp dir) |
(when (not (ido-ignore-item-p d ido-ignore-directories-merge)) |
2942 |
(or ido-merge-ftp-work-directories |
(setq dir (cdr (cdr dir))) |
2943 |
(not (ido-is-ftp-directory dir))) |
(while dir |
2944 |
(file-directory-p dir) |
(setq f (car dir) |
2945 |
;; TODO. check for nonreadable and too-big. |
dir (cdr dir)) |
2946 |
(setq fl (if (eq ido-cur-item 'file) |
(if (and (string-match re f) |
2947 |
(ido-make-file-list1 dir t) |
(not (ido-ignore-item-p f ido-ignore-directories))) |
2948 |
(ido-make-dir-list1 dir t)))) |
(setq res (cons (cons f d) res))))) |
|
(if must-match |
|
|
(setq fl (ido-set-matches1 fl))) |
|
|
(if fl |
|
|
(setq res (nconc fl res)))) |
|
2949 |
(if (and auto (input-pending-p)) |
(if (and auto (input-pending-p)) |
2950 |
(setq dirs nil |
(setq dirs nil |
2951 |
res t)))))) |
res t)))))) |
2952 |
(quit (setq res t))) |
(if wide |
2953 |
(if (and res (not (eq res t))) |
(setq res (ido-wide-find-dirs-or-files |
2954 |
(setq res (ido-sort-merged-list res auto))) |
ido-current-directory text ido-enable-prefix nil)) |
2955 |
|
(let ((ido-text text) |
2956 |
|
(dirs ido-work-directory-list) |
2957 |
|
(must-match (and text (> (length text) 0))) |
2958 |
|
dir fl) |
2959 |
|
(if (and auto (not (member ido-current-directory dirs))) |
2960 |
|
(setq dirs (cons ido-current-directory dirs))) |
2961 |
|
(while dirs |
2962 |
|
(setq dir (car dirs) |
2963 |
|
dirs (cdr dirs)) |
2964 |
|
(when (and dir (stringp dir) |
2965 |
|
(or ido-merge-ftp-work-directories |
2966 |
|
(not (ido-is-ftp-directory dir))) |
2967 |
|
(file-directory-p dir) |
2968 |
|
;; TODO. check for nonreadable and too-big. |
2969 |
|
(setq fl (if (eq ido-cur-item 'file) |
2970 |
|
(ido-make-file-list-1 dir t) |
2971 |
|
(ido-make-dir-list-1 dir t)))) |
2972 |
|
(if must-match |
2973 |
|
(setq fl (ido-set-matches-1 fl))) |
2974 |
|
(if fl |
2975 |
|
(setq res (nconc fl res)))) |
2976 |
|
(if (and auto (input-pending-p)) |
2977 |
|
(setq dirs nil |
2978 |
|
res t)))))) |
2979 |
|
res)) |
2980 |
|
|
2981 |
|
(defun ido-make-merged-file-list (text auto wide) |
2982 |
|
(let (res) |
2983 |
|
(message "Searching for `%s'...." text) |
2984 |
|
(condition-case nil |
2985 |
|
(unless (catch 'input-pending-p |
2986 |
|
(let ((throw-on-input 'input-pending-p)) |
2987 |
|
(setq res (ido-make-merged-file-list-1 text auto wide)) |
2988 |
|
t)) |
2989 |
|
(setq res 'input-pending-p)) |
2990 |
|
(quit |
2991 |
|
(setq res t |
2992 |
|
ido-try-merged-list nil |
2993 |
|
ido-use-merged-list nil))) |
2994 |
|
(when (and res (listp res)) |
2995 |
|
(setq res (ido-sort-merged-list res auto))) |
2996 |
(when (and (or ido-rotate-temp ido-rotate-file-list-default) |
(when (and (or ido-rotate-temp ido-rotate-file-list-default) |
2997 |
(listp res) |
(listp res) |
2998 |
(> (length text) 0)) |
(> (length text) 0)) |
3003 |
(message nil) |
(message nil) |
3004 |
res)) |
res)) |
3005 |
|
|
3006 |
(defun ido-make-buffer-list1 (&optional frame visible) |
(defun ido-make-buffer-list-1 (&optional frame visible) |
3007 |
;; Return list of non-ignored buffer names |
;; Return list of non-ignored buffer names |
3008 |
(delq nil |
(delq nil |
3009 |
(mapcar |
(mapcar |
3021 |
;; 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, |
3022 |
;; it is put to the start of the list. |
;; it is put to the start of the list. |
3023 |
(let* ((ido-current-buffers (ido-get-buffers-in-frames 'current)) |
(let* ((ido-current-buffers (ido-get-buffers-in-frames 'current)) |
3024 |
(ido-temp-list (ido-make-buffer-list1 (selected-frame) ido-current-buffers))) |
(ido-temp-list (ido-make-buffer-list-1 (selected-frame) ido-current-buffers))) |
3025 |
(if ido-temp-list |
(if ido-temp-list |
3026 |
(nconc ido-temp-list ido-current-buffers) |
(nconc ido-temp-list ido-current-buffers) |
3027 |
(setq ido-temp-list ido-current-buffers)) |
(setq ido-temp-list ido-current-buffers)) |
3058 |
(nconc ido-temp-list items) |
(nconc ido-temp-list items) |
3059 |
(setq ido-temp-list items))) |
(setq ido-temp-list items))) |
3060 |
|
|
3061 |
(defun ido-file-name-all-completions1 (dir) |
(defun ido-file-name-all-completions-1 (dir) |
3062 |
(cond |
(cond |
3063 |
((ido-nonreadable-directory-p dir) '()) |
((ido-nonreadable-directory-p dir) '()) |
3064 |
;; do not check (ido-directory-too-big-p dir) here. |
;; do not check (ido-directory-too-big-p dir) here. |
3115 |
(if (and ftp (file-readable-p dir)) |
(if (and ftp (file-readable-p dir)) |
3116 |
(setq mtime (cons 'ftp (ido-time-stamp)))) |
(setq mtime (cons 'ftp (ido-time-stamp)))) |
3117 |
(if mtime |
(if mtime |
3118 |
(setq cached (cons dir (cons mtime (ido-file-name-all-completions1 dir))) |
(setq cached (cons dir (cons mtime (ido-file-name-all-completions-1 dir))) |
3119 |
ido-dir-file-cache (cons cached ido-dir-file-cache))) |
ido-dir-file-cache (cons cached ido-dir-file-cache))) |
3120 |
(if (> (length ido-dir-file-cache) ido-max-dir-file-cache) |
(if (> (length ido-dir-file-cache) ido-max-dir-file-cache) |
3121 |
(setcdr (nthcdr (1- ido-max-dir-file-cache) ido-dir-file-cache) nil))) |
(setcdr (nthcdr (1- ido-max-dir-file-cache) ido-dir-file-cache) nil))) |
3122 |
(and cached |
(and cached |
3123 |
(cdr (cdr cached)))) |
(cdr (cdr cached)))) |
3124 |
(ido-file-name-all-completions1 dir))) |
(ido-file-name-all-completions-1 dir))) |
3125 |
|
|
3126 |
(defun ido-remove-cached-dir (dir) |
(defun ido-remove-cached-dir (dir) |
3127 |
;; Remove dir from ido-dir-file-cache |
;; Remove dir from ido-dir-file-cache |
3132 |
(setq ido-dir-file-cache (delq cached ido-dir-file-cache)))))) |
(setq ido-dir-file-cache (delq cached ido-dir-file-cache)))))) |
3133 |
|
|
3134 |
|
|
3135 |
(defun ido-make-file-list1 (dir &optional merged) |
(defun ido-make-file-list-1 (dir &optional merged) |
3136 |
;; Return list of non-ignored files in DIR |
;; Return list of non-ignored files in DIR |
3137 |
;; If MERGED is non-nil, each file is cons'ed with DIR |
;; If MERGED is non-nil, each file is cons'ed with DIR |
3138 |
(and (or (ido-is-tramp-root dir) (file-directory-p dir)) |
(and (or (ido-is-tramp-root dir) (file-directory-p dir)) |
3149 |
;; 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 |
3150 |
;; 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 |
3151 |
;; in this list. |
;; in this list. |
3152 |
(let ((ido-temp-list (ido-make-file-list1 ido-current-directory))) |
(let ((ido-temp-list (ido-make-file-list-1 ido-current-directory))) |
3153 |
(setq ido-temp-list (sort ido-temp-list |
(setq ido-temp-list (sort ido-temp-list |
3154 |
(if ido-file-extensions-order |
(if ido-file-extensions-order |
3155 |
#'ido-file-extension-lessp |
#'ido-file-extension-lessp |
3185 |
(run-hooks 'ido-make-file-list-hook) |
(run-hooks 'ido-make-file-list-hook) |
3186 |
ido-temp-list)) |
ido-temp-list)) |
3187 |
|
|
3188 |
(defun ido-make-dir-list1 (dir &optional merged) |
(defun ido-make-dir-list-1 (dir &optional merged) |
3189 |
;; Return list of non-ignored subdirs in DIR |
;; Return list of non-ignored subdirs in DIR |
3190 |
;; If MERGED is non-nil, each subdir is cons'ed with DIR |
;; If MERGED is non-nil, each subdir is cons'ed with DIR |
3191 |
(and (or (ido-is-tramp-root dir) (file-directory-p dir)) |
(and (or (ido-is-tramp-root dir) (file-directory-p dir)) |
3201 |
;; 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 |
3202 |
;; created to allow the user to further modify the order of the |
;; created to allow the user to further modify the order of the |
3203 |
;; directory names in this list. |
;; directory names in this list. |
3204 |
(let ((ido-temp-list (ido-make-dir-list1 ido-current-directory))) |
(let ((ido-temp-list (ido-make-dir-list-1 ido-current-directory))) |
3205 |
(setq ido-temp-list (sort ido-temp-list #'ido-file-lessp)) |
(setq ido-temp-list (sort ido-temp-list #'ido-file-lessp)) |
3206 |
(ido-to-end ;; move . files to end |
(ido-to-end ;; move . files to end |
3207 |
(delq nil (mapcar |
(delq nil (mapcar |
3255 |
|
|
3256 |
;;; FIND MATCHING ITEMS |
;;; FIND MATCHING ITEMS |
3257 |
|
|
3258 |
(defun ido-set-matches1 (items &optional do-full) |
(defun ido-set-matches-1 (items &optional do-full) |
3259 |
;; Return list of matches in items |
;; Return list of matches in items |
3260 |
(let* ((case-fold-search ido-case-fold) |
(let* ((case-fold-search ido-case-fold) |
3261 |
(slash (and (not ido-enable-prefix) (ido-final-slash ido-text))) |
(slash (and (not ido-enable-prefix) (ido-final-slash ido-text))) |
3313 |
(defun ido-set-matches () |
(defun ido-set-matches () |
3314 |
;; Set `ido-matches' to the list of items matching prompt |
;; Set `ido-matches' to the list of items matching prompt |
3315 |
(when ido-rescan |
(when ido-rescan |
3316 |
(setq ido-matches (ido-set-matches1 (reverse ido-cur-list) (not ido-rotate)) |
(setq ido-matches (ido-set-matches-1 (reverse ido-cur-list) (not ido-rotate)) |
3317 |
ido-rotate nil))) |
ido-rotate nil))) |
3318 |
|
|
3319 |
(defun ido-ignore-item-p (name re-list &optional ignore-ext) |
(defun ido-ignore-item-p (name re-list &optional ignore-ext) |