unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Tomi Ollila <tomi.ollila@iki.fi>
To: notmuch@notmuchmail.org
Cc: tomi.ollila@iki.fi
Subject: notmuch-show-message-resend v3
Date: Sat,  7 May 2016 22:03:10 +0300	[thread overview]
Message-ID: <1462647792-25427-1-git-send-email-tomi.ollila@iki.fi> (raw)

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

             reply	other threads:[~2016-05-07 19:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-07 19:03 Tomi Ollila [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1462647792-25427-1-git-send-email-tomi.ollila@iki.fi \
    --to=tomi.ollila@iki.fi \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).