message.el: Use completion-at-point.
authorStefan Monnier <monnier@iro.umontreal.ca>
Tue, 7 Dec 2010 04:05:42 +0000 (04:05 +0000)
committerKatsumi Yamaoka <yamaoka@jpl.org>
Tue, 7 Dec 2010 04:05:42 +0000 (04:05 +0000)
 (message-completion-function): New fun, extracted from message-tab.
 (message-mode): Use it for completion-at-point-functions.
 (message-tab): Use it and completion-at-point.

lisp/ChangeLog
lisp/message.el

index bb4f914..2483ca7 100644 (file)
@@ -1,3 +1,10 @@
+2010-12-07  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * message.el: Use completion-at-point.
+       (message-completion-function): New fun, extracted from message-tab.
+       (message-mode): Use it for completion-at-point-functions.
+       (message-tab): Use it and completion-at-point.
+
 2010-12-07  Katsumi Yamaoka  <yamaoka@jpl.org>
 
        * shr.el (shr-find-fill-point): Don't break a line after a kinsoku-bol
index 5b10f5d..1313f56 100644 (file)
@@ -281,7 +281,7 @@ This is a list of regexps and regexp matches."
                 regexp))
 
 (defcustom message-ignored-mail-headers
-  "^[GF]cc:\\|^Resent-Fcc:\\|^Xref:\\|^X-Draft-From:\\|^X-Gnus-Agent-Meta-Information:"
+  "^\\([GF]cc\\|Resent-Fcc\\|Xref\\|X-Draft-From\\|X-Gnus-Agent-Meta-Information\\):"
   "*Regexp of headers to be removed unconditionally before mailing."
   :group 'message-mail
   :group 'message-headers
@@ -2958,6 +2958,7 @@ M-RET    `message-newline-and-reformat' (break the line and reformat)."
          (mail-aliases-setup))))
    ((message-mail-alias-type-p 'ecomplete)
     (ecomplete-setup)))
+  (add-hook 'completion-at-point-functions 'message-completion-function nil t)
   (unless buffer-file-name
     (message-set-auto-save-file-name))
   (unless (buffer-base-buffer)
@@ -7787,7 +7788,7 @@ When FORCE, rebuild the tool bar."
   :type '(alist :key-type regexp :value-type function))
 
 (defcustom message-expand-name-databases
-  (list 'bbdb 'eudc)
+  '(bbdb eudc)
   "List of databases to try for name completion (`message-expand-name').
 Each element is a symbol and can be `bbdb' or `eudc'."
   :group 'message
@@ -7809,15 +7810,25 @@ If nil, the function bound in `text-mode-map' or `global-map' is executed."
 Execute function specified by `message-tab-body-function' when not in
 those headers."
   (interactive)
+  (cond
+   ((if (and (boundp 'completion-fail-discreetly)
+             (fboundp 'completion-at-point))
+        (let ((completion-fail-discreetly t)) (completion-at-point))
+      (funcall (or (message-completion-function) #'ignore)))
+    ;; Completion was performed; nothing else to do.
+    nil)
+   (message-tab-body-function (funcall message-tab-body-function))
+   (t (funcall (or (lookup-key text-mode-map "\t")
+                   (lookup-key global-map "\t")
+                   'indent-relative)))))
+
+(defun message-completion-function ()
   (let ((alist message-completion-alist))
     (while (and alist
                (let ((mail-abbrev-mode-regexp (caar alist)))
                  (not (mail-abbrev-in-expansion-header-p))))
       (setq alist (cdr alist)))
-    (funcall (or (cdar alist) message-tab-body-function
-                (lookup-key text-mode-map "\t")
-                (lookup-key global-map "\t")
-                'indent-relative))))
+    (cdar alist)))
 
 (eval-and-compile
   (condition-case nil