aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/mh-e/mh-alias.el
diff options
context:
space:
mode:
authorStefan Monnier <[email protected]>2011-04-28 12:32:28 -0300
committerStefan Monnier <[email protected]>2011-04-28 12:32:28 -0300
commitd1bb66232235211a8383356ef2851f68ac864a3f (patch)
treeca3ca65e7daa640854d7c00ffbe83f691e9b5e9a /lisp/mh-e/mh-alias.el
parentd178f871644d97853be0f89d05a8fc5649e5d620 (diff)
Make MH-E use completion-at-point
* lisp/mh-e/mh-letter.el (mh-letter-completion-at-point): New function, extracted from mh-letter-complete (mh-letter-mode, mh-letter-complete, mh-letter-complete-or-space): Use it. (mh-complete-word): Only use the common-substring arg when it works. (mh-folder-expand-at-point): * lisp/mh-e/mh-alias.el (mh-alias-letter-expand-alias): Return data suitable for completion-at-point-functions. * lisp/mh-e/mh-utils.el (mh-folder-completion-function): Make it work like file-name completion, so partial-completion can do its job. * lisp/minibuffer.el (completion-at-point, completion-help-at-point): Don't presume that a given completion-at-point-function will always use the same calling convention.
Diffstat (limited to 'lisp/mh-e/mh-alias.el')
-rw-r--r--lisp/mh-e/mh-alias.el32
1 files changed, 22 insertions, 10 deletions
diff --git a/lisp/mh-e/mh-alias.el b/lisp/mh-e/mh-alias.el
index 061a5b3dc9..449a8782d0 100644
--- a/lisp/mh-e/mh-alias.el
+++ b/lisp/mh-e/mh-alias.el
@@ -296,16 +296,28 @@ Blind aliases or users from /etc/passwd are not expanded."
(defun mh-alias-letter-expand-alias ()
"Expand mail alias before point."
(mh-alias-reload-maybe)
- (let* ((end (point))
- (begin (mh-beginning-of-word))
- (input (buffer-substring-no-properties begin end)))
- (mh-complete-word input mh-alias-alist begin end)
- (when mh-alias-expand-aliases-flag
- (let* ((end (point))
- (expansion (mh-alias-expand (buffer-substring begin end))))
- (delete-region begin end)
- (insert expansion)))))
-
+ (let* ((begin (mh-beginning-of-word))
+ (end (save-excursion
+ (goto-char begin)
+ (mh-beginning-of-word -1))))
+ (when (>= end (point))
+ (list
+ begin (if (fboundp 'completion-at-point) end (point))
+ (if (not mh-alias-expand-aliases-flag)
+ mh-alias-alist
+ (lambda (string pred action)
+ (case action
+ ((nil)
+ (let ((res (try-completion string mh-alias-alist pred)))
+ (if (or (eq res t)
+ (and (stringp res)
+ (eq t (try-completion res mh-alias-alist pred))))
+ (or (mh-alias-expand (if (stringp res) res string))
+ res)
+ res)))
+ ((t) (all-completions string mh-alias-alist pred))
+ ((lambda) (if (fboundp 'test-completion)
+ (test-completion string mh-alias-alist pred))))))))))
;;; Alias File Updating