diff options
| author | Kim F. Storm | 2002-07-08 22:03:02 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2002-07-08 22:03:02 +0000 |
| commit | 9066a4d07034c3afacbfd251b95f1eedc02e28c2 (patch) | |
| tree | 298cce29df19e2111fd585d889c604a44d3dbf2c | |
| parent | 79814626bd03940d4720ac1bcf46b3c100452c3c (diff) | |
| download | emacs-9066a4d07034c3afacbfd251b95f1eedc02e28c2.tar.gz emacs-9066a4d07034c3afacbfd251b95f1eedc02e28c2.zip | |
(ido-find-common-substring): Return substring instead of t.
| -rw-r--r-- | lisp/ido.el | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/lisp/ido.el b/lisp/ido.el index 4d9bed04f8d..97aa0d24a09 100644 --- a/lisp/ido.el +++ b/lisp/ido.el | |||
| @@ -1545,7 +1545,7 @@ If INITIAL is non-nil, it specifies the initial input string." | |||
| 1545 | (catch 'ido | 1545 | (catch 'ido |
| 1546 | (completing-read | 1546 | (completing-read |
| 1547 | (ido-make-prompt item prompt) | 1547 | (ido-make-prompt item prompt) |
| 1548 | '(("dummy".1)) nil nil ; table predicate require-match | 1548 | '(("dummy" . 1)) nil nil ; table predicate require-match |
| 1549 | (prog1 ido-text-init (setq ido-text-init nil)) ;initial-contents | 1549 | (prog1 ido-text-init (setq ido-text-init nil)) ;initial-contents |
| 1550 | history)))) | 1550 | history)))) |
| 1551 | (ido-trace "completing-read" ido-final-text) | 1551 | (ido-trace "completing-read" ido-final-text) |
| @@ -2751,7 +2751,7 @@ for first matching file." | |||
| 2751 | ido-enable-flex-matching | 2751 | ido-enable-flex-matching |
| 2752 | (> (length ido-text) 1) | 2752 | (> (length ido-text) 1) |
| 2753 | (not ido-enable-regexp)) | 2753 | (not ido-enable-regexp)) |
| 2754 | (setq re (mapconcat 'regexp-quote (split-string ido-text "") ".*")) | 2754 | (setq re (mapconcat #'regexp-quote (split-string ido-text "") ".*")) |
| 2755 | (if ido-enable-prefix | 2755 | (if ido-enable-prefix |
| 2756 | (setq re (concat "\\`" re))) | 2756 | (setq re (concat "\\`" re))) |
| 2757 | (mapcar | 2757 | (mapcar |
| @@ -2817,14 +2817,16 @@ for first matching file." | |||
| 2817 | (if ido-enable-regexp | 2817 | (if ido-enable-regexp |
| 2818 | subs | 2818 | subs |
| 2819 | (regexp-quote subs))) | 2819 | (regexp-quote subs))) |
| 2820 | (setq res (mapcar 'ido-word-matching-substring items)) | 2820 | (setq res (mapcar #'ido-word-matching-substring items)) |
| 2821 | (setq res (delq nil res)) ;; remove any nil elements (shouldn't happen) | 2821 | (setq res (delq nil res)) ;; remove any nil elements (shouldn't happen) |
| 2822 | (setq alist (mapcar 'ido-makealist res)) ;; could use an OBARRAY | 2822 | (setq alist (mapcar #'ido-makealist res)) ;; could use an OBARRAY |
| 2823 | 2823 | ||
| 2824 | ;; try-completion returns t if there is an exact match. | 2824 | ;; try-completion returns t if there is an exact match. |
| 2825 | (let ((completion-ignore-case ido-case-fold)) | 2825 | (let* ((completion-ignore-case ido-case-fold) |
| 2826 | 2826 | (comp (try-completion subs alist))) | |
| 2827 | (try-completion subs alist)))) | 2827 | (if (eq comp t) |
| 2828 | subs | ||
| 2829 | comp)))) | ||
| 2828 | 2830 | ||
| 2829 | (defun ido-word-matching-substring (word) | 2831 | (defun ido-word-matching-substring (word) |
| 2830 | ;; Return part of WORD before 1st match to `ido-change-word-sub'. | 2832 | ;; Return part of WORD before 1st match to `ido-change-word-sub'. |
| @@ -3499,28 +3501,30 @@ For details of keybindings, do `\\[describe-function] ido-find-file'." | |||
| 3499 | (let* ((items (if (> ido-max-prospects 0) (1+ ido-max-prospects) 999)) | 3501 | (let* ((items (if (> ido-max-prospects 0) (1+ ido-max-prospects) 999)) |
| 3500 | (alternatives | 3502 | (alternatives |
| 3501 | (apply | 3503 | (apply |
| 3502 | (function concat) | 3504 | #'concat |
| 3503 | (cdr (apply | 3505 | (cdr (apply |
| 3504 | (function nconc) | 3506 | #'nconc |
| 3505 | (mapcar '(lambda (com) | 3507 | (mapcar |
| 3506 | (setq com (ido-name com)) | 3508 | (lambda (com) |
| 3507 | (setq items (1- items)) | 3509 | (setq com (ido-name com)) |
| 3508 | (cond | 3510 | (setq items (1- items)) |
| 3509 | ((< items 0) ()) | 3511 | (cond |
| 3510 | ((= items 0) (list (nth 3 ido-decorations))) ; " | ..." | 3512 | ((< items 0) ()) |
| 3511 | (t | 3513 | ((= items 0) (list (nth 3 ido-decorations))) ; " | ..." |
| 3512 | (list (or ido-separator (nth 2 ido-decorations)) ; " | " | 3514 | (t |
| 3513 | (let ((str (substring com 0))) | 3515 | (list (or ido-separator (nth 2 ido-decorations)) ; " | " |
| 3514 | (if (and ido-use-faces | 3516 | (let ((str (substring com 0))) |
| 3515 | (not (string= str first)) | 3517 | (if (and ido-use-faces |
| 3516 | (ido-final-slash str)) | 3518 | (not (string= str first)) |
| 3517 | (put-text-property 0 (length str) 'face 'ido-subdir-face str)) | 3519 | (ido-final-slash str)) |
| 3518 | str))))) | 3520 | (put-text-property 0 (length str) 'face 'ido-subdir-face str)) |
| 3519 | comps)))))) | 3521 | str))))) |
| 3522 | comps)))))) | ||
| 3520 | 3523 | ||
| 3521 | (concat | 3524 | (concat |
| 3522 | ;; put in common completion item -- what you get by pressing tab | 3525 | ;; put in common completion item -- what you get by pressing tab |
| 3523 | (if (> (length ido-common-match-string) (length name)) | 3526 | (if (and (stringp ido-common-match-string) |
| 3527 | (> (length ido-common-match-string) (length name))) | ||
| 3524 | (concat (nth 4 ido-decorations) ;; [ ... ] | 3528 | (concat (nth 4 ido-decorations) ;; [ ... ] |
| 3525 | (substring ido-common-match-string (length name)) | 3529 | (substring ido-common-match-string (length name)) |
| 3526 | (nth 5 ido-decorations))) | 3530 | (nth 5 ido-decorations))) |