unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / Atom feed
* [PATCH 0/2] scaffolding for autocrypt support
@ 2021-01-08 18:40 David Edmondson
  2021-01-08 18:40 ` [PATCH 1/2] emacs: with-current-notmuch-show-message should return the result of body David Edmondson
  2021-01-08 18:40 ` [PATCH 2/2] emacs: Add notmuch-show-insert-msg-hook David Edmondson
  0 siblings, 2 replies; 4+ messages in thread
From: David Edmondson @ 2021-01-08 18:40 UTC (permalink / raw)
  To: notmuch; +Cc: David Edmondson

I started looking at how to add autocrypt support based on
https://git.sr.ht/~zge/autocrypt.

Sending seems straightforward, as far as I understand autocrypt, at
least.

Dealing with inbound messages requires a few framework changes in the
existing notmuch emacs code, which is these two patches. They are not
autocrypt specific, and could be generally useful.

I'll send autocrypt patches after some more testing and
improvement. Currently things are pretty inefficient -
autocrypt-notmuch-header will request the raw message on every call,
which is expensive if the message is large.

David Edmondson (2):
  emacs: with-current-notmuch-show-message should return the result of
    body
  emacs: Add notmuch-show-insert-msg-hook

 emacs/notmuch-show.el | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

-- 
2.29.2

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

* [PATCH 1/2] emacs: with-current-notmuch-show-message should return the result of body
  2021-01-08 18:40 [PATCH 0/2] scaffolding for autocrypt support David Edmondson
@ 2021-01-08 18:40 ` David Edmondson
  2021-01-08 18:40 ` [PATCH 2/2] emacs: Add notmuch-show-insert-msg-hook David Edmondson
  1 sibling, 0 replies; 4+ messages in thread
From: David Edmondson @ 2021-01-08 18:40 UTC (permalink / raw)
  To: notmuch; +Cc: David Edmondson

Rather than returning the result of kill-buffer,
with-current-notmuch-show-message should return the result of calling
the passed body.
---
 emacs/notmuch-show.el | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index b08ceb97..222c9dae 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -272,11 +272,12 @@ position of the message in the thread."
   `(save-excursion
      (let ((id (notmuch-show-get-message-id)))
        (let ((buf (generate-new-buffer (concat "*notmuch-msg-" id "*"))))
-	 (with-current-buffer buf
-	   (let ((coding-system-for-read 'no-conversion))
-	     (call-process notmuch-command nil t nil "show" "--format=raw" id))
-	   ,@body)
-	 (kill-buffer buf)))))
+	 (prog1
+	  (with-current-buffer buf
+	    (let ((coding-system-for-read 'no-conversion))
+	      (call-process notmuch-command nil t nil "show" "--format=raw" id))
+	    ,@body)
+	  (kill-buffer buf))))))
 
 (defun notmuch-show-turn-on-visual-line-mode ()
   "Enable Visual Line mode."
-- 
2.29.2

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

* [PATCH 2/2] emacs: Add notmuch-show-insert-msg-hook
  2021-01-08 18:40 [PATCH 0/2] scaffolding for autocrypt support David Edmondson
  2021-01-08 18:40 ` [PATCH 1/2] emacs: with-current-notmuch-show-message should return the result of body David Edmondson
@ 2021-01-08 18:40 ` David Edmondson
  2021-02-15 21:24   ` David Bremner
  1 sibling, 1 reply; 4+ messages in thread
From: David Edmondson @ 2021-01-08 18:40 UTC (permalink / raw)
  To: notmuch; +Cc: David Edmondson

Add a hook called after inserting each message into the buffer showing
messages.
---
 emacs/notmuch-show.el | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 222c9dae..292677bc 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -111,6 +111,12 @@ visible for any given message."
   :group 'notmuch-show
   :group 'notmuch-hooks)
 
+(defcustom notmuch-show-insert-msg-hook nil
+  "Functions called after inserting a message."
+  :type 'hook
+  :group 'notmuch-show
+  :group 'notmuch-hooks)
+
 (defcustom notmuch-show-max-text-part-size 100000
   "Maximum size of a text part to be shown by default in characters.
 
@@ -1104,7 +1110,9 @@ is t, hide the part initially and show the button."
     ;; Message visibility depends on whether it matched the search
     ;; criteria.
     (notmuch-show-message-visible msg (and (plist-get msg :match)
-					   (not (plist-get msg :excluded))))))
+					   (not (plist-get msg :excluded))))
+
+    (run-hooks 'notmuch-show-insert-msg-hook)))
 
 (defun notmuch-show-toggle-process-crypto ()
   "Toggle the processing of cryptographic MIME parts."
-- 
2.29.2

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

* Re: [PATCH 2/2] emacs: Add notmuch-show-insert-msg-hook
  2021-01-08 18:40 ` [PATCH 2/2] emacs: Add notmuch-show-insert-msg-hook David Edmondson
@ 2021-02-15 21:24   ` David Bremner
  0 siblings, 0 replies; 4+ messages in thread
From: David Bremner @ 2021-02-15 21:24 UTC (permalink / raw)
  To: David Edmondson, notmuch; +Cc: David Edmondson

David Edmondson <dme@dme.org> writes:

> Add a hook called after inserting each message into the buffer showing
> messages.

first patch is fine, second no longer applies.

d

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

end of thread, other threads:[~2021-02-15 21:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-08 18:40 [PATCH 0/2] scaffolding for autocrypt support David Edmondson
2021-01-08 18:40 ` [PATCH 1/2] emacs: with-current-notmuch-show-message should return the result of body David Edmondson
2021-01-08 18:40 ` [PATCH 2/2] emacs: Add notmuch-show-insert-msg-hook David Edmondson
2021-02-15 21:24   ` David Bremner

unofficial mirror of notmuch@notmuchmail.org

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/notmuch/0 notmuch/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 notmuch notmuch/ https://yhetil.org/notmuch \
		notmuch@notmuchmail.org
	public-inbox-index notmuch

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.mail.notmuch.general
	nntp://news.gmane.io/gmane.mail.notmuch.general


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git