unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* notmuch-show-message-resend v3
@ 2016-05-07 19:03 Tomi Ollila
  2016-05-07 19:03 ` [PATCH 1/2] emacs: add function to resend message to new recipients Tomi Ollila
  2016-05-07 19:03 ` [PATCH 2/2] emacs: bind notmuch-show-resend-message to 'b' in notmuch-show mode Tomi Ollila
  0 siblings, 2 replies; 4+ messages in thread
From: Tomi Ollila @ 2016-05-07 19:03 UTC (permalink / raw)
  To: notmuch; +Cc: tomi.ollila

V3 of notmuch-show-message-resend feature

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

id:87pozza0dw.fsf@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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-05-19 11:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-07 19:03 notmuch-show-message-resend v3 Tomi Ollila
2016-05-07 19:03 ` [PATCH 1/2] emacs: add function to resend message to new recipients Tomi Ollila
2016-05-19 11:06   ` David Bremner
2016-05-07 19:03 ` [PATCH 2/2] emacs: bind notmuch-show-resend-message to 'b' in notmuch-show mode Tomi Ollila

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).