diff options
| author | Kim F. Storm | 2005-06-15 22:44:09 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2005-06-15 22:44:09 +0000 |
| commit | 665ed61ac2142bc0d36d1201146d5512b57701e5 (patch) | |
| tree | c4e8c1d8d21e1d1f110f9054abbe545dd3cd11b2 | |
| parent | e6838581835c1715ee76bfddc9a0ac86f5f452aa (diff) | |
| download | emacs-665ed61ac2142bc0d36d1201146d5512b57701e5.tar.gz emacs-665ed61ac2142bc0d36d1201146d5512b57701e5.zip | |
2005-06-15 Matt Hodges <MPHodges@member.fsf.org>
* ido.el (ido-incomplete-regexp): New variable.
(ido-set-matches-1): Handle invalid-regexp error and set
ido-incomplete-regexp.
(ido-incomplete-regexp): New face.
(ido-completions): Use it.
(ido-complete, ido-exit-minibuffer, ido-completions): Handle
incomplete regexps.
(ido-completions): Add check for complete match when entering a
regexp.
| -rw-r--r-- | lisp/ido.el | 82 |
1 files changed, 56 insertions, 26 deletions
diff --git a/lisp/ido.el b/lisp/ido.el index 2d9313bb0ea..f5941bf4ef2 100644 --- a/lisp/ido.el +++ b/lisp/ido.el | |||
| @@ -770,6 +770,12 @@ subdirs in the alternatives." | |||
| 770 | "*Font used by ido for highlighting its indicators." | 770 | "*Font used by ido for highlighting its indicators." |
| 771 | :group 'ido) | 771 | :group 'ido) |
| 772 | 772 | ||
| 773 | (defface ido-incomplete-regexp | ||
| 774 | '((t | ||
| 775 | (:inherit font-lock-warning-face))) | ||
| 776 | "Ido face for indicating incomplete regexps." | ||
| 777 | :group 'ido) | ||
| 778 | |||
| 773 | (defcustom ido-make-file-list-hook nil | 779 | (defcustom ido-make-file-list-hook nil |
| 774 | "*List of functions to run when the list of matching files is created. | 780 | "*List of functions to run when the list of matching files is created. |
| 775 | Each function on the list may modify the dynamically bound variable | 781 | Each function on the list may modify the dynamically bound variable |
| @@ -959,6 +965,8 @@ selected.") | |||
| 959 | Is set by ido functions to the current minibuffer-depth, so that | 965 | Is set by ido functions to the current minibuffer-depth, so that |
| 960 | it doesn't interfere with other minibuffer usage.") | 966 | it doesn't interfere with other minibuffer usage.") |
| 961 | 967 | ||
| 968 | (defvar ido-incomplete-regexp nil | ||
| 969 | "Non-nil if an incomplete regexp is entered.") | ||
| 962 | 970 | ||
| 963 | ;;; Variables with dynamic bindings. | 971 | ;;; Variables with dynamic bindings. |
| 964 | ;;; Declared here to keep the byte compiler quiet. | 972 | ;;; Declared here to keep the byte compiler quiet. |
| @@ -2170,6 +2178,9 @@ If INITIAL is non-nil, it specifies the initial input string." | |||
| 2170 | (interactive) | 2178 | (interactive) |
| 2171 | (let (res) | 2179 | (let (res) |
| 2172 | (cond | 2180 | (cond |
| 2181 | (ido-incomplete-regexp | ||
| 2182 | ;; Do nothing | ||
| 2183 | ) | ||
| 2173 | ((and (memq ido-cur-item '(file dir)) | 2184 | ((and (memq ido-cur-item '(file dir)) |
| 2174 | (string-match "[$]" ido-text)) | 2185 | (string-match "[$]" ido-text)) |
| 2175 | (let ((evar (substitute-in-file-name (concat ido-current-directory ido-text)))) | 2186 | (let ((evar (substitute-in-file-name (concat ido-current-directory ido-text)))) |
| @@ -2394,8 +2405,9 @@ timestamp has not changed (e.g. with ftp or on Windows)." | |||
| 2394 | (defun ido-exit-minibuffer () | 2405 | (defun ido-exit-minibuffer () |
| 2395 | "Exit minibuffer, but make sure we have a match if one is needed." | 2406 | "Exit minibuffer, but make sure we have a match if one is needed." |
| 2396 | (interactive) | 2407 | (interactive) |
| 2397 | (if (or (not ido-require-match) | 2408 | (if (and (or (not ido-require-match) |
| 2398 | (ido-existing-item-p)) | 2409 | (ido-existing-item-p)) |
| 2410 | (not ido-incomplete-regexp)) | ||
| 2399 | (exit-minibuffer))) | 2411 | (exit-minibuffer))) |
| 2400 | 2412 | ||
| 2401 | (defun ido-select-text () | 2413 | (defun ido-select-text () |
| @@ -3275,22 +3287,30 @@ for first matching file." | |||
| 3275 | full-matches | 3287 | full-matches |
| 3276 | prefix-matches | 3288 | prefix-matches |
| 3277 | matches) | 3289 | matches) |
| 3278 | (mapcar | 3290 | (setq ido-incomplete-regexp nil) |
| 3279 | (lambda (item) | 3291 | (condition-case error |
| 3280 | (let ((name (ido-name item))) | 3292 | (mapcar |
| 3281 | (if (and (or non-prefix-dot | 3293 | (lambda (item) |
| 3282 | (if (= (aref ido-text 0) ?.) | 3294 | (let ((name (ido-name item))) |
| 3283 | (= (aref name 0) ?.) | 3295 | (if (and (or non-prefix-dot |
| 3284 | (/= (aref name 0) ?.))) | 3296 | (if (= (aref ido-text 0) ?.) |
| 3285 | (string-match re name)) | 3297 | (= (aref name 0) ?.) |
| 3286 | (cond | 3298 | (/= (aref name 0) ?.))) |
| 3287 | ((and full-re (string-match full-re name)) | 3299 | (string-match re name)) |
| 3288 | (setq full-matches (cons item full-matches))) | 3300 | (cond |
| 3289 | ((and prefix-re (string-match prefix-re name)) | 3301 | ((and full-re (string-match full-re name)) |
| 3290 | (setq prefix-matches (cons item prefix-matches))) | 3302 | (setq full-matches (cons item full-matches))) |
| 3291 | (t (setq matches (cons item matches)))))) | 3303 | ((and prefix-re (string-match prefix-re name)) |
| 3292 | t) | 3304 | (setq prefix-matches (cons item prefix-matches))) |
| 3293 | items) | 3305 | (t (setq matches (cons item matches)))))) |
| 3306 | t) | ||
| 3307 | items) | ||
| 3308 | (invalid-regexp | ||
| 3309 | (setq ido-incomplete-regexp t | ||
| 3310 | ;; Consider the invalid regexp message internally as a | ||
| 3311 | ;; special-case single match, and handle appropriately | ||
| 3312 | ;; elsewhere. | ||
| 3313 | matches (cdr error)))) | ||
| 3294 | (if prefix-matches | 3314 | (if prefix-matches |
| 3295 | (setq matches (nconc prefix-matches matches))) | 3315 | (setq matches (nconc prefix-matches matches))) |
| 3296 | (if full-matches | 3316 | (if full-matches |
| @@ -4048,7 +4068,9 @@ For details of keybindings, do `\\[describe-function] ido-find-file'." | |||
| 4048 | (setq first (format "%s" fn)) | 4068 | (setq first (format "%s" fn)) |
| 4049 | (put-text-property 0 ln 'face | 4069 | (put-text-property 0 ln 'face |
| 4050 | (if (= (length comps) 1) | 4070 | (if (= (length comps) 1) |
| 4051 | 'ido-only-match | 4071 | (if ido-incomplete-regexp |
| 4072 | 'ido-incomplete-regexp | ||
| 4073 | 'ido-only-match) | ||
| 4052 | 'ido-first-match) | 4074 | 'ido-first-match) |
| 4053 | first) | 4075 | first) |
| 4054 | (if ind (setq first (concat first ind))) | 4076 | (if ind (setq first (concat first ind))) |
| @@ -4063,14 +4085,22 @@ For details of keybindings, do `\\[describe-function] ido-find-file'." | |||
| 4063 | (ido-report-no-match | 4085 | (ido-report-no-match |
| 4064 | (nth 6 ido-decorations)) ;; [No match] | 4086 | (nth 6 ido-decorations)) ;; [No match] |
| 4065 | (t ""))) | 4087 | (t ""))) |
| 4066 | 4088 | (ido-incomplete-regexp | |
| 4089 | (concat " " (car comps))) | ||
| 4067 | ((null (cdr comps)) ;one match | 4090 | ((null (cdr comps)) ;one match |
| 4068 | (concat (if (> (length (ido-name (car comps))) (length name)) | 4091 | (concat (if (if (not ido-enable-regexp) |
| 4069 | ;; when there is one match, show the matching file name in full | 4092 | (= (length (ido-name (car comps))) (length name)) |
| 4070 | (concat (nth 4 ido-decorations) ;; [ ... ] | 4093 | ;; We can't rely on the length of the input |
| 4071 | (ido-name (car comps)) | 4094 | ;; for regexps, so explicitly check for a |
| 4072 | (nth 5 ido-decorations)) | 4095 | ;; complete match |
| 4073 | "") | 4096 | (string-match name (ido-name (car comps))) |
| 4097 | (string-equal (match-string 0 (ido-name (car comps))) | ||
| 4098 | (ido-name (car comps)))) | ||
| 4099 | "" | ||
| 4100 | ;; when there is one match, show the matching file name in full | ||
| 4101 | (concat (nth 4 ido-decorations) ;; [ ... ] | ||
| 4102 | (ido-name (car comps)) | ||
| 4103 | (nth 5 ido-decorations))) | ||
| 4074 | (if (not ido-use-faces) (nth 7 ido-decorations)))) ;; [Matched] | 4104 | (if (not ido-use-faces) (nth 7 ido-decorations)))) ;; [Matched] |
| 4075 | (t ;multiple matches | 4105 | (t ;multiple matches |
| 4076 | (let* ((items (if (> ido-max-prospects 0) (1+ ido-max-prospects) 999)) | 4106 | (let* ((items (if (> ido-max-prospects 0) (1+ ido-max-prospects) 999)) |