emacs: replace use of notmuch-address-message-insinuate

This allows e.g. Gnus users to load this file without changing
message-mode behaviour.

This will disable completion for those that did not customize the
variable but relied on the existence of a file named "notmuch-addresses"
in their path. In the next commit the default behaviour will change to
use a "workalike" internal completion mechanism.
This commit is contained in:
David Bremner 2015-10-27 00:22:47 +01:00
parent 6814a1cf73
commit 0e671478c6
2 changed files with 11 additions and 12 deletions

View file

@ -23,11 +23,13 @@
;; ;;
(defcustom notmuch-address-command "notmuch-addresses" (defcustom notmuch-address-command nil
"The command which generates possible addresses. It must take a "The command which generates possible addresses. It must take a
single argument and output a list of possible matches, one per single argument and output a list of possible matches, one per
line." line. The default value of nil disables address completion."
:type 'string :type '(radio
(const :tag "Disable address completion" nil)
(string :tag "Use external completion command" "notmuch-addresses"))
:group 'notmuch-send :group 'notmuch-send
:group 'notmuch-external) :group 'notmuch-external)
@ -55,10 +57,12 @@ to know how address selection is made by default."
(defvar notmuch-address-history nil) (defvar notmuch-address-history nil)
(defun notmuch-address-message-insinuate () (defun notmuch-address-message-insinuate ()
(message "calling notmuch-address-message-insinuate is no longer needed"))
(defun notmuch-address-setup ()
(unless (memq notmuch-address-message-alist-member message-completion-alist) (unless (memq notmuch-address-message-alist-member message-completion-alist)
(setq message-completion-alist (setq message-completion-alist
(push notmuch-address-message-alist-member message-completion-alist)))) (push notmuch-address-message-alist-member message-completion-alist))))
(defun notmuch-address-options (original) (defun notmuch-address-options (original)
(process-lines notmuch-address-command original)) (process-lines notmuch-address-command original))
@ -109,11 +113,4 @@ to know how address selection is made by default."
(not (file-directory-p bin)))) (not (file-directory-p bin))))
(throw 'found-command bin)))))))) (throw 'found-command bin))))))))
;; If we can find the program specified by `notmuch-address-command',
;; insinuate ourselves into `message-mode'.
(when (notmuch-address-locate-command notmuch-address-command)
(notmuch-address-message-insinuate))
;;
(provide 'notmuch-address) (provide 'notmuch-address)

View file

@ -269,7 +269,9 @@ Note that these functions use `mail-citation-hook' if that is non-nil."
(set-buffer-modified-p nil)) (set-buffer-modified-p nil))
(define-derived-mode notmuch-message-mode message-mode "Message[Notmuch]" (define-derived-mode notmuch-message-mode message-mode "Message[Notmuch]"
"Notmuch message composition mode. Mostly like `message-mode'") "Notmuch message composition mode. Mostly like `message-mode'"
(when notmuch-address-command
(notmuch-address-setup)))
(define-key notmuch-message-mode-map (kbd "C-c C-c") #'notmuch-mua-send-and-exit) (define-key notmuch-message-mode-map (kbd "C-c C-c") #'notmuch-mua-send-and-exit)
(define-key notmuch-message-mode-map (kbd "C-c C-s") #'notmuch-mua-send) (define-key notmuch-message-mode-map (kbd "C-c C-s") #'notmuch-mua-send)