[PATCH] Fix non internal cases for notmuch-address-command

Mark Walters markwalters1009 at gmail.com
Sat Oct 24 16:09:36 PDT 2015


This makes tab completion do nothing when notmuch-address-command is
nil.

It also stops company mode from being used when an external command is
specified, which was giving rise to some strange behaviour.
---

This patch is only really a 3 line patch (if you do a word-diff): the
rest is a whitespace change.

Best wishes

Mark

emacs/notmuch-address.el | 53 ++++++++++++++++++++++++------------------------
 emacs/notmuch-mua.el     |  1 +
 2 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 2a748ec..d82c2aa 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -98,32 +98,33 @@ (defun notmuch-address-options (original)
     (process-lines notmuch-address-command original))))
 
 (defun notmuch-address-expand-name ()
-  (let* ((end (point))
-	 (beg (save-excursion
-		(re-search-backward "\\(\\`\\|[\n:,]\\)[ \t]*")
-		(goto-char (match-end 0))
-		(point)))
-	 (orig (buffer-substring-no-properties beg end))
-	 (completion-ignore-case t)
-	 (options (with-temp-message "Looking for completion candidates..."
-		    (notmuch-address-options orig)))
-	 (num-options (length options))
-	 (chosen (cond
-		  ((eq num-options 0)
-		   nil)
-		  ((eq num-options 1)
-		   (car options))
-		  (t
-		   (funcall notmuch-address-selection-function
-			    (format "Address (%s matches): " num-options)
-			    (cdr options) (car options))))))
-    (if chosen
-	(progn
-	  (push chosen notmuch-address-history)
-	  (delete-region beg end)
-	  (insert chosen))
-      (message "No matches.")
-      (ding))))
+  (when notmuch-address-command
+    (let* ((end (point))
+	   (beg (save-excursion
+		  (re-search-backward "\\(\\`\\|[\n:,]\\)[ \t]*")
+		  (goto-char (match-end 0))
+		  (point)))
+	   (orig (buffer-substring-no-properties beg end))
+	   (completion-ignore-case t)
+	   (options (with-temp-message "Looking for completion candidates..."
+		      (notmuch-address-options orig)))
+	   (num-options (length options))
+	   (chosen (cond
+		    ((eq num-options 0)
+		     nil)
+		    ((eq num-options 1)
+		     (car options))
+		    (t
+		     (funcall notmuch-address-selection-function
+			      (format "Address (%s matches): " num-options)
+			      (cdr options) (car options))))))
+      (if chosen
+	  (progn
+	    (push chosen notmuch-address-history)
+	    (delete-region beg end)
+	    (insert chosen))
+	(message "No matches.")
+	(ding)))))
 
 ;; Copied from `w3m-which-command'.
 (defun notmuch-address-locate-command (command)
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 3feea29..63fc8db 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -280,6 +280,7 @@ (define-derived-mode notmuch-message-mode message-mode "Message[Notmuch]"
       (setq message-completion-alist
 	    (push notmuch-address-message-alist-member message-completion-alist))))
   (when (and notmuch-message-use-company
+	     (eq notmuch-address-command 'internal)
 	     (require 'company nil t))
     (notmuch-company-setup)))
 
-- 
2.1.4



More information about the notmuch mailing list