notmuch-show-message-resend v3

Tomi Ollila tomi.ollila at iki.fi
Sat May 7 12:03:10 PDT 2016


V3 of notmuch-show-message-resend feature

v2: id:1441204482-26509-3-git-send-email-tomi.ollila at iki.fi

id:87pozza0dw.fsf at qmul.ac.uk has been consulted while doing
these changes (iirc ;)

I tried to get company mode also work while reading email
addresses from minibuffer -- and got something to function,
but not anything really working. Therefore this currently
uses minibuffer (with tab completion) working.

The following diff shows what I tried to do to get it working.
In addition to work poorly it breaks "normal" address tab
completion (as it was crafted to work with minibuffer completion
tests only)


diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 7defed3..7a8424e 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -256,12 +256,11 @@ (defun notmuch-address-from-minibuffer (prompt)
       ;; "Original" minibuffer keymap is restored just before calling
       ;; notmuch-address-expand-name as it may also use minibuffer-local-map
       ;; (completing-read probably does not but if something else is used there).
-      (define-key rmap (kbd "TAB") (lambda ()
-				     (interactive)
-				     (let ((enable-recursive-minibuffers t)
-					   (minibuffer-local-map omap))
-				       (notmuch-address-expand-name))))
-      (let ((minibuffer-local-map rmap))
+      (define-key rmap (kbd "TAB") #'company-manual-begin)
+
+      (let ((minibuffer-local-map rmap)
+	    (minibuffer-setup-hook minibuffer-setup-hook))
+	(add-hook 'minibuffer-setup-hook #'notmuch-company-setup)
 	(read-string prompt)))))
 
 ;;
diff --git a/emacs/notmuch-company.el b/emacs/notmuch-company.el
index add3161..210175a 100644
--- a/emacs/notmuch-company.el
+++ b/emacs/notmuch-company.el
@@ -45,7 +45,7 @@ (defvar notmuch-address-completion-headers-regexp)
 
 ;;;###autoload
 (defun notmuch-company-setup ()
-  (company-mode)
+  (company-mode 1)
   (make-local-variable 'company-backends)
   (setq company-backends '(notmuch-company)))
 
@@ -58,10 +58,7 @@ (defun notmuch-company (command &optional arg &rest _ignore)
 	(completion-ignore-case t))
     (case command
       (interactive (company-begin-backend 'notmuch-company))
-      (prefix (and (derived-mode-p 'message-mode)
-		   (looking-back (concat notmuch-address-completion-headers-regexp ".*")
-				 (line-beginning-position))
-		   (setq notmuch-company-last-prefix (company-grab "[:,][ \t]*\\(.*\\)" 1 (point-at-bol)))))
+      (prefix (setq notmuch-company-last-prefix (company-grab "[:,][ \t]*\\(.*\\)" 1)))
       (candidates (cond
 		   (notmuch-address-full-harvest-finished
 		    ;; Update harvested addressed from time to time
@@ -82,5 +79,15 @@ (defun notmuch-company (command &optional arg &rest _ignore)
 	       0))
       (no-cache t))))
 
+;; (partial) code snipped someone(tm) doing some company-minubuffer stuff
+;; (defun company--posn-col-row (posn)
+;;     (let ((col (car (posn-col-row posn)))
+;;           ;; `posn-col-row' doesn't work well with lines of different height.
+;;           ;; `posn-actual-col-row' doesn't handle multiple-width characters.
+;;           (row (cdr (posn-actual-col-row posn))))
+;;       (when (and header-line-format (version< emacs-version "24.3.93.3"))
+;;         ;; http://debbugs.gnu.org/18384
+;;         (cl-decf row))
+;;       (cons (+ col (window-hscroll) company-col-offset) (+ row company-row-offset))))
 
 (provide 'notmuch-company)
-- 
1.9.3




More information about the notmuch mailing list