diff options
| author | Bill Wohler | 2006-04-17 23:43:03 +0000 |
|---|---|---|
| committer | Bill Wohler | 2006-04-17 23:43:03 +0000 |
| commit | cd35b20a6fe3ff2c3620181481ba5585f633de62 (patch) | |
| tree | ee75e18fafb62fd254ffb5f8b3c2cfa9e7462c61 | |
| parent | 3f489dc760ec721fc098e5916efde3e10677980f (diff) | |
| download | emacs-cd35b20a6fe3ff2c3620181481ba5585f633de62.tar.gz emacs-cd35b20a6fe3ff2c3620181481ba5585f633de62.zip | |
(mh-sub-folders-actual): Mention that folder must have been processed
by mh-normalize-folder-name.
(mh-folder-completion-function): Handle completion of folders with
absolute names. Also, when flag is t, display complete folder name to
provide proper highlighting in Emacs 22 now that
minibuffer-completing-file-name is nil (closes SF #1470518).
(mh-folder-completing-read): No longer set
minibuffer-completing-file-name to t. This was causing "Can't set
current directory errors" when browsing absolute file names. Another
benefit of this change is that SPC can be used for completion
again (closes SF #1470518).
| -rw-r--r-- | lisp/mh-e/ChangeLog | 14 | ||||
| -rw-r--r-- | lisp/mh-e/mh-utils.el | 57 |
2 files changed, 50 insertions, 21 deletions
diff --git a/lisp/mh-e/ChangeLog b/lisp/mh-e/ChangeLog index e67cdd553d0..f313896c7a6 100644 --- a/lisp/mh-e/ChangeLog +++ b/lisp/mh-e/ChangeLog | |||
| @@ -1,3 +1,17 @@ | |||
| 1 | 2006-04-17 Bill Wohler <wohler@newt.com> | ||
| 2 | |||
| 3 | * mh-utils.el (mh-sub-folders-actual): Mention that folder must | ||
| 4 | have been processed by mh-normalize-folder-name. | ||
| 5 | (mh-folder-completion-function): Handle completion of folders with | ||
| 6 | absolute names. Also, when flag is t, display complete folder name | ||
| 7 | to provide proper highlighting in Emacs 22 now that | ||
| 8 | minibuffer-completing-file-name is nil (closes SF #1470518). | ||
| 9 | (mh-folder-completing-read): No longer set | ||
| 10 | minibuffer-completing-file-name to t. This was causing "Can't set | ||
| 11 | current directory errors" when browsing absolute file names. | ||
| 12 | Another benefit of this change is that SPC can be used for | ||
| 13 | completion again (closes SF #1470518). | ||
| 14 | |||
| 1 | 2006-04-15 Bill Wohler <wohler@newt.com> | 15 | 2006-04-15 Bill Wohler <wohler@newt.com> |
| 2 | 16 | ||
| 3 | * mh-compat.el (mh-font-lock-add-keywords): Fix typo in docstring. | 17 | * mh-compat.el (mh-font-lock-add-keywords): Fix typo in docstring. |
diff --git a/lisp/mh-e/mh-utils.el b/lisp/mh-e/mh-utils.el index 46aed35be7b..73a15583165 100644 --- a/lisp/mh-e/mh-utils.el +++ b/lisp/mh-e/mh-utils.el | |||
| @@ -556,10 +556,18 @@ nested folders within them." | |||
| 556 | sub-folders) | 556 | sub-folders) |
| 557 | sub-folders))) | 557 | sub-folders))) |
| 558 | 558 | ||
| 559 | ;; FIXME: This function does not do well if FOLDER does not exist. It | ||
| 560 | ;; then changes the context to that folder which causes problems down | ||
| 561 | ;; the line. Since a folder in the cache could later be deleted, it | ||
| 562 | ;; would be good for mh-sub-folders-actual to return nil in this case | ||
| 563 | ;; so that mh-sub-folders could delete it from the cache. This | ||
| 564 | ;; function could protect itself by using a temporary context. | ||
| 559 | (defun mh-sub-folders-actual (folder) | 565 | (defun mh-sub-folders-actual (folder) |
| 560 | "Execute the command folders to return the sub-folders of FOLDER. | 566 | "Execute the command folders to return the sub-folders of FOLDER. |
| 561 | Filters out the folder names that start with \".\" so that | 567 | Filters out the folder names that start with \".\" so that |
| 562 | directories that aren't usually mail folders are hidden." | 568 | directories that aren't usually mail folders are hidden. |
| 569 | Expects FOLDER to have already been normalized with | ||
| 570 | (mh-normalize-folder-name folder nil nil t)" | ||
| 563 | (let ((arg-list `(,(expand-file-name "folders" mh-progs) | 571 | (let ((arg-list `(,(expand-file-name "folders" mh-progs) |
| 564 | nil (t nil) nil "-noheader" "-norecurse" "-nototal" | 572 | nil (t nil) nil "-noheader" "-norecurse" "-nototal" |
| 565 | ,@(if (stringp folder) (list folder) ()))) | 573 | ,@(if (stringp folder) (list folder) ()))) |
| @@ -683,36 +691,44 @@ This variable should never be set.") | |||
| 683 | (defun mh-folder-completion-function (name predicate flag) | 691 | (defun mh-folder-completion-function (name predicate flag) |
| 684 | "Programmable completion for folder names. | 692 | "Programmable completion for folder names. |
| 685 | NAME is the partial folder name that has been input. PREDICATE if | 693 | NAME is the partial folder name that has been input. PREDICATE if |
| 686 | non-nil is a function that is used to filter the possible choices | 694 | non-nil is a function that is used to filter the possible |
| 687 | and FLAG determines whether the completion is over." | 695 | choices. FLAG is nil to indicate `try-completion', t for |
| 696 | `all-completions', or the symbol lambda for `test-completion'. | ||
| 697 | See Info node `(elisp) Programmed Completion' for details." | ||
| 688 | (let* ((orig-name name) | 698 | (let* ((orig-name name) |
| 699 | ;; After normalization, name is nil, +, or +something. If a | ||
| 700 | ;; trailing slash is present, it is preserved. | ||
| 689 | (name (mh-normalize-folder-name name nil t)) | 701 | (name (mh-normalize-folder-name name nil t)) |
| 690 | (last-slash (mh-search-from-end ?/ name)) | 702 | (last-slash (mh-search-from-end ?/ name)) |
| 691 | (last-complete (if last-slash (substring name 0 last-slash) nil)) | 703 | ;; nil if + or +folder; +folder/ if slash present. |
| 704 | (last-complete (if last-slash (substring name 0 (1+ last-slash)) nil)) | ||
| 705 | ;; Either +folder/remainder, +remainder, or "". | ||
| 692 | (remainder (cond (last-complete (substring name (1+ last-slash))) | 706 | (remainder (cond (last-complete (substring name (1+ last-slash))) |
| 693 | ((and (> (length name) 0) (equal (aref name 0) ?+)) | 707 | (name (substring name 1)) |
| 694 | (substring name 1)) | ||
| 695 | (t "")))) | 708 | (t "")))) |
| 696 | (cond ((eq flag nil) | 709 | (cond ((eq flag nil) |
| 697 | (let ((try-res (try-completion | 710 | (let ((try-res |
| 698 | name | 711 | (try-completion |
| 699 | (mapcar (lambda (x) | 712 | name |
| 700 | (cons (if (not last-complete) | 713 | (mapcar (lambda (x) |
| 701 | (concat "+" (car x)) | 714 | (cons (concat (or last-complete "+") (car x)) |
| 702 | (concat last-complete "/" (car x))) | 715 | (cdr x))) |
| 703 | (cdr x))) | 716 | (mh-sub-folders last-complete t)) |
| 704 | (mh-sub-folders last-complete t)) | 717 | predicate))) |
| 705 | predicate))) | ||
| 706 | (cond ((eq try-res nil) nil) | 718 | (cond ((eq try-res nil) nil) |
| 707 | ((and (eq try-res t) (equal name orig-name)) t) | 719 | ((and (eq try-res t) (equal name orig-name)) t) |
| 708 | ((eq try-res t) name) | 720 | ((eq try-res t) name) |
| 709 | (t try-res)))) | 721 | (t try-res)))) |
| 710 | ((eq flag t) | 722 | ((eq flag t) |
| 711 | (all-completions | 723 | (mapcar (lambda (x) |
| 712 | remainder (mh-sub-folders last-complete t) predicate)) | 724 | (concat (or last-complete "+") x)) |
| 725 | (all-completions | ||
| 726 | remainder (mh-sub-folders last-complete t) predicate))) | ||
| 713 | ((eq flag 'lambda) | 727 | ((eq flag 'lambda) |
| 714 | (let ((path (concat mh-user-path | 728 | (let ((path (concat (unless (and (> (length name) 1) |
| 715 | (substring (mh-normalize-folder-name name) 1)))) | 729 | (eq (aref name 1) ?/)) |
| 730 | mh-user-path) | ||
| 731 | (substring name 1)))) | ||
| 716 | (cond (mh-allow-root-folder-flag (file-exists-p path)) | 732 | (cond (mh-allow-root-folder-flag (file-exists-p path)) |
| 717 | ((equal path mh-user-path) nil) | 733 | ((equal path mh-user-path) nil) |
| 718 | (t (file-exists-p path)))))))) | 734 | (t (file-exists-p path)))))))) |
| @@ -726,8 +742,7 @@ and FLAG determines whether the completion is over." | |||
| 726 | If ALLOW-ROOT-FOLDER-FLAG is non-nil then \"+\" is allowed to be | 742 | If ALLOW-ROOT-FOLDER-FLAG is non-nil then \"+\" is allowed to be |
| 727 | a folder name corresponding to `mh-user-path'." | 743 | a folder name corresponding to `mh-user-path'." |
| 728 | (mh-normalize-folder-name | 744 | (mh-normalize-folder-name |
| 729 | (let ((minibuffer-completing-file-name t) | 745 | (let ((completion-root-regexp "^[+/]") |
| 730 | (completion-root-regexp "^[+/]") | ||
| 731 | (minibuffer-local-completion-map mh-folder-completion-map) | 746 | (minibuffer-local-completion-map mh-folder-completion-map) |
| 732 | (mh-allow-root-folder-flag allow-root-folder-flag)) | 747 | (mh-allow-root-folder-flag allow-root-folder-flag)) |
| 733 | (completing-read prompt 'mh-folder-completion-function nil nil nil | 748 | (completing-read prompt 'mh-folder-completion-function nil nil nil |