Mercurial > emacs
comparison lisp/ido.el @ 72488:a1eb31579f05
(ido-set-matches-1): Fix full matching for subdirs.
Add suffix matching for subdirs.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Tue, 22 Aug 2006 09:45:13 +0000 |
parents | d35d3efc3d99 |
children | 5d8f8bf05df4 6823a91487f2 |
comparison
equal
deleted
inserted
replaced
72487:6659d5e5ce4c | 72488:a1eb31579f05 |
---|---|
1838 (and ido-enable-last-directory-history | 1838 (and ido-enable-last-directory-history |
1839 (let ((d (assoc ido-current-directory ido-last-directory-list))) | 1839 (let ((d (assoc ido-current-directory ido-last-directory-list))) |
1840 (and d (cdr d))))))) | 1840 (and d (cdr d))))))) |
1841 (if (member ido-default-item ido-ignore-item-temp-list) | 1841 (if (member ido-default-item ido-ignore-item-temp-list) |
1842 (setq ido-default-item nil)) | 1842 (setq ido-default-item nil)) |
1843 (ido-trace "new default" ido-default-item) | |
1843 (setq ido-set-default-item nil)) | 1844 (setq ido-set-default-item nil)) |
1844 | 1845 |
1845 (if ido-process-ignore-lists-inhibit | 1846 (if ido-process-ignore-lists-inhibit |
1846 (setq ido-process-ignore-lists nil)) | 1847 (setq ido-process-ignore-lists nil)) |
1847 | 1848 |
3526 (defun ido-set-matches-1 (items &optional do-full) | 3527 (defun ido-set-matches-1 (items &optional do-full) |
3527 ;; Return list of matches in items | 3528 ;; Return list of matches in items |
3528 (let* ((case-fold-search ido-case-fold) | 3529 (let* ((case-fold-search ido-case-fold) |
3529 (slash (and (not ido-enable-prefix) (ido-final-slash ido-text))) | 3530 (slash (and (not ido-enable-prefix) (ido-final-slash ido-text))) |
3530 (text (if slash (substring ido-text 0 -1) ido-text)) | 3531 (text (if slash (substring ido-text 0 -1) ido-text)) |
3531 (rexq (concat (if ido-enable-regexp text (regexp-quote text)) (if slash ".*/" ""))) | 3532 (rex0 (if ido-enable-regexp text (regexp-quote text))) |
3533 (rexq (concat rex0 (if slash ".*/" ""))) | |
3532 (re (if ido-enable-prefix (concat "\\`" rexq) rexq)) | 3534 (re (if ido-enable-prefix (concat "\\`" rexq) rexq)) |
3533 (full-re (and do-full (not ido-enable-regexp) (not (string-match "\$\\'" re)) | 3535 (full-re (and do-full (not ido-enable-regexp) (not (string-match "\$\\'" rex0)) |
3534 (concat "\\`" re "\\'"))) | 3536 (concat "\\`" rex0 (if slash "/" "") "\\'"))) |
3537 (suffix-re (and do-full slash | |
3538 (not ido-enable-regexp) (not (string-match "\$\\'" rex0)) | |
3539 (concat rex0 "/\\'"))) | |
3535 (prefix-re (and full-re (not ido-enable-prefix) | 3540 (prefix-re (and full-re (not ido-enable-prefix) |
3536 (concat "\\`" rexq))) | 3541 (concat "\\`" rexq))) |
3537 (non-prefix-dot (or (not ido-enable-dot-prefix) | 3542 (non-prefix-dot (or (not ido-enable-dot-prefix) |
3538 (not ido-process-ignore-lists) | 3543 (not ido-process-ignore-lists) |
3539 ido-enable-prefix | 3544 ido-enable-prefix |
3540 (= (length ido-text) 0))) | 3545 (= (length ido-text) 0))) |
3541 | 3546 full-matches suffix-matches prefix-matches matches) |
3542 full-matches | |
3543 prefix-matches | |
3544 matches) | |
3545 (setq ido-incomplete-regexp nil) | 3547 (setq ido-incomplete-regexp nil) |
3546 (condition-case error | 3548 (condition-case error |
3547 (mapcar | 3549 (mapcar |
3548 (lambda (item) | 3550 (lambda (item) |
3549 (let ((name (ido-name item))) | 3551 (let ((name (ido-name item))) |
3550 (if (and (or non-prefix-dot | 3552 (if (and (or non-prefix-dot |
3551 (if (= (aref ido-text 0) ?.) | 3553 (if (= (aref ido-text 0) ?.) |
3552 (= (aref name 0) ?.) | 3554 (= (aref name 0) ?.) |
3553 (/= (aref name 0) ?.))) | 3555 (/= (aref name 0) ?.))) |
3554 (string-match re name)) | 3556 (string-match re name)) |
3555 (cond | 3557 (cond |
3556 ((and full-re (string-match full-re name)) | 3558 ((and full-re (string-match full-re name)) |
3557 (setq full-matches (cons item full-matches))) | 3559 (setq full-matches (cons item full-matches))) |
3558 ((and prefix-re (string-match prefix-re name)) | 3560 ((and suffix-re (string-match suffix-re name)) |
3559 (setq prefix-matches (cons item prefix-matches))) | 3561 (setq suffix-matches (cons item suffix-matches))) |
3560 (t (setq matches (cons item matches)))))) | 3562 ((and prefix-re (string-match prefix-re name)) |
3561 t) | 3563 (setq prefix-matches (cons item prefix-matches))) |
3564 (t (setq matches (cons item matches)))))) | |
3565 t) | |
3562 items) | 3566 items) |
3563 (invalid-regexp | 3567 (invalid-regexp |
3564 (setq ido-incomplete-regexp t | 3568 (setq ido-incomplete-regexp t |
3565 ;; Consider the invalid regexp message internally as a | 3569 ;; Consider the invalid regexp message internally as a |
3566 ;; special-case single match, and handle appropriately | 3570 ;; special-case single match, and handle appropriately |
3567 ;; elsewhere. | 3571 ;; elsewhere. |
3568 matches (cdr error)))) | 3572 matches (cdr error)))) |
3569 (if prefix-matches | 3573 (when prefix-matches |
3570 (setq matches (nconc prefix-matches matches))) | 3574 (ido-trace "prefix match" prefix-matches) |
3571 (if full-matches | 3575 (setq matches (nconc prefix-matches matches))) |
3572 (setq matches (nconc full-matches matches))) | 3576 (when suffix-matches |
3577 (ido-trace "suffix match" (list text suffix-re suffix-matches)) | |
3578 (setq matches (nconc suffix-matches matches))) | |
3579 (when full-matches | |
3580 (ido-trace "full match" (list text full-re full-matches)) | |
3581 (setq matches (nconc full-matches matches))) | |
3573 (when (and (null matches) | 3582 (when (and (null matches) |
3574 ido-enable-flex-matching | 3583 ido-enable-flex-matching |
3575 (> (length ido-text) 1) | 3584 (> (length ido-text) 1) |
3576 (not ido-enable-regexp)) | 3585 (not ido-enable-regexp)) |
3577 (setq re (mapconcat #'regexp-quote (split-string ido-text "") ".*")) | 3586 (setq re (mapconcat #'regexp-quote (split-string ido-text "") ".*")) |
4094 (let ((contents (buffer-substring-no-properties (minibuffer-prompt-end) (point-max))) | 4103 (let ((contents (buffer-substring-no-properties (minibuffer-prompt-end) (point-max))) |
4095 (buffer-undo-list t) | 4104 (buffer-undo-list t) |
4096 try-single-dir-match | 4105 try-single-dir-match |
4097 refresh) | 4106 refresh) |
4098 | 4107 |
4099 (ido-trace "\nexhibit" this-command) | 4108 (when ido-trace-enable |
4100 (ido-trace "dir" ido-current-directory) | 4109 (ido-trace "\nexhibit" this-command) |
4101 (ido-trace "contents" contents) | 4110 (ido-trace "dir" ido-current-directory) |
4102 (ido-trace "list" ido-cur-list) | 4111 (ido-trace "contents" contents) |
4103 (ido-trace "matches" ido-matches) | 4112 (ido-trace "list" ido-cur-list) |
4104 (ido-trace "rescan" ido-rescan) | 4113 (ido-trace "matches" ido-matches) |
4114 (ido-trace "rescan" ido-rescan)) | |
4105 | 4115 |
4106 (save-excursion | 4116 (save-excursion |
4107 (goto-char (point-max)) | 4117 (goto-char (point-max)) |
4108 ;; Register the end of input, so we know where the extra stuff (match-status info) begins: | 4118 ;; Register the end of input, so we know where the extra stuff (match-status info) begins: |
4109 (unless (boundp 'ido-eoinput) | 4119 (unless (boundp 'ido-eoinput) |