unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH v2 0/2] scaffolding for autocrypt support
@ 2021-02-21 15:21 David Edmondson
  2021-02-21 15:21 ` [PATCH v2 1/2] emacs: with-current-notmuch-show-message should return the result of body David Edmondson
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: David Edmondson @ 2021-02-21 15:21 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.

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.

v2:
- Rebased on master (bremner).

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.30.0

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

* [PATCH v2 1/2] emacs: with-current-notmuch-show-message should return the result of body
  2021-02-21 15:21 [PATCH v2 0/2] scaffolding for autocrypt support David Edmondson
@ 2021-02-21 15:21 ` David Edmondson
  2021-02-21 15:21 ` [PATCH v2 2/2] emacs: Add notmuch-show-insert-msg-hook David Edmondson
  2021-02-23  2:02 ` [PATCH v2 0/2] scaffolding for autocrypt support Daniel Kahn Gillmor
  2 siblings, 0 replies; 7+ messages in thread
From: David Edmondson @ 2021-02-21 15:21 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 ba93febb..761be252 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -273,11 +273,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.30.0

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

* [PATCH v2 2/2] emacs: Add notmuch-show-insert-msg-hook
  2021-02-21 15:21 [PATCH v2 0/2] scaffolding for autocrypt support David Edmondson
  2021-02-21 15:21 ` [PATCH v2 1/2] emacs: with-current-notmuch-show-message should return the result of body David Edmondson
@ 2021-02-21 15:21 ` David Edmondson
  2021-02-23  2:02 ` [PATCH v2 0/2] scaffolding for autocrypt support Daniel Kahn Gillmor
  2 siblings, 0 replies; 7+ messages in thread
From: David Edmondson @ 2021-02-21 15:21 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 761be252..cda0bfe0 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -113,6 +113,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.
 
@@ -1112,7 +1118,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)))
 
 ;;; Toggle commands
 
-- 
2.30.0

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

* Re: [PATCH v2 0/2] scaffolding for autocrypt support
  2021-02-21 15:21 [PATCH v2 0/2] scaffolding for autocrypt support David Edmondson
  2021-02-21 15:21 ` [PATCH v2 1/2] emacs: with-current-notmuch-show-message should return the result of body David Edmondson
  2021-02-21 15:21 ` [PATCH v2 2/2] emacs: Add notmuch-show-insert-msg-hook David Edmondson
@ 2021-02-23  2:02 ` Daniel Kahn Gillmor
  2021-04-16 12:05   ` David Bremner
  2 siblings, 1 reply; 7+ messages in thread
From: Daniel Kahn Gillmor @ 2021-02-23  2:02 UTC (permalink / raw)
  To: David Edmondson, notmuch


[-- Attachment #1.1: Type: text/plain, Size: 4950 bytes --]

Hi David, all--

On Sun 2021-02-21 15:21:30 +0000, David Edmondson wrote:
> I started looking at how to add autocrypt support based on
> https://git.sr.ht/~zge/autocrypt.

Thanks for this work, i'm glad to see the interest in autocrypt!

I tend to think that the autocrypt handling belongs in libnotmuch, and
not just in the emacs frontend, so i'm a bit concerned about what we'll
have to prune out of the emacs frontend if we do manage to land the
features in libnotmuch itself.

I want it in libnotmuch and in the cli because:

 a) i want the database to hold the autocrypt tables, so that it can be
    dumped/restored between notmuch-based clients

 b) i want non-emacs frontends of notmuch to be able to make use of it
    relatively easily.

that said, i've failed to get the code into shape for libnotmuch yet,
and i also don't want to block this work -- i want to see more autocrypt
adoption generally, and i'm feeling guilty for having been so tardy in
getting ito into notmuch.

My general outline for getting autocrypt into notmuch is the following
list of steps.  it's a fairly long list, but each step shouldn't be a
huge amount of work.

 0) augment the database so that it can store the autocrypt "peers"
    table and the autocrypt "accounts" table, and they can be dumped and
    restored.  see
    https://autocrypt.org/level1.html#autocrypt-internal-state

 1) add a configuration option that affects "notmuch
    {new,insert,reindex}" that ingests the loading of autocrypt headers
    according to the standard policy for updating the peer state (see
    https://autocrypt.org/level1.html#updating-autocrypt-peer-state)

 2) add a configuration option that affects "notmuch
    {new,insert,reindex}" that enables detection of any Autocrypt Setup
    Message from another client sharing the same inbox, and adjusts the
    "accounts" table appropriately.

 3) add a "notmuch autocrypt" subcommand with its own subsubcommands:
    "notmuch autocrypt enable <addr> [mutual]" and "notmuch autocrypt
    disable <addr>" -- these subsubcommands update the "accounts" table
    as well.

 4) add "notmuch autocrypt generate-setup-message" subsubcommand for
    enabled accounts that produces its own self-targeted Autocrypt Setup
    Message on stdout, which can be injected into the mailsystem
    by the user's notmuch setup.

 5) Add "notmuch autocrypt prune" subsubcommand which clears accumulated
    cruft from the autocrypt peers table

 6) in libnotmuch, if <from> is a source e-mail address, and <to> is a
    set of destination addresses, add <is_replying_to_encrypted> is a
    boolean, a new function notmuch_autocrypt_recommendation(<from>,
    <to>, <is_replying_to_encrypted>) that returns an Autocrypt
    Recommendation (ui-recommendation and a set of target-keys, see
    https://autocrypt.org/level1.html#provide-a-recommendation-for-message-encryption)

 7) add a new subsubcommand that exposes
    notmuch_autocrypt_recommendation() to the cli.

 8) emacs frontend work during message composition (i have no idea how
    to do this) -- dynamically adjust the message composition buffer as
    the from, to, cc, and bcc fields change to show the current
    autocrypt recommendation status, in combination with the ability for
    the user to manually turn on encryption (if available) or off (if on
    by default).

 9) more emacs frontend work -- at send time (at the end of composition)
    if the autocrypt recommendation is encrypt, or if it's available and
    the user has manually turned it on, encrypt the message using
    standard autocrypt format (which is just PGP/MIME, using the
    recommended keys).

It's possible that (9) could be replaced with a new subcommand like
"notmuch send" which could have a "--autocrypt-checked" argument, such
that the notmuch cli actually does the full encryption for the user, or
acts as some sort of filter for the outgoing message.  there might also
be some library-level work that could use notmuch and gmime to translate
the message this way; I haven't really pieced those things together, or
how they would integrate into the emacs frontend, but the steps laid out
above seem to be necessary for that to happen in either case.

I'd love any collaboration on this -- especially for the parts that i
don't know how to do at all, like the emacs composition window frontend
-- but also on the earlier parts, as i've been procrastinating on it for
too long.

David, do you think this plan will collide with the series you're
proposing?  do you see problems or downsides with the plan sketched here
(other than it not existing 😛)?

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

https://autocrypt.org and the #autocrypt channel on freenode are both
good resources for understanding autocrypt in more detail, fwiw.

     --dkg

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [PATCH v2 0/2] scaffolding for autocrypt support
  2021-02-23  2:02 ` [PATCH v2 0/2] scaffolding for autocrypt support Daniel Kahn Gillmor
@ 2021-04-16 12:05   ` David Bremner
  2021-04-19  8:53     ` David Edmondson
  2021-07-07 11:02     ` Philip Kaludercic
  0 siblings, 2 replies; 7+ messages in thread
From: David Bremner @ 2021-04-16 12:05 UTC (permalink / raw)
  To: Daniel Kahn Gillmor, David Edmondson, notmuch

Daniel Kahn Gillmor <dkg@fifthhorseman.net> writes:

> Hi David, all--
>
> On Sun 2021-02-21 15:21:30 +0000, David Edmondson wrote:
>> I started looking at how to add autocrypt support based on
>> https://git.sr.ht/~zge/autocrypt.
>
> Thanks for this work, i'm glad to see the interest in autocrypt!
>
> I tend to think that the autocrypt handling belongs in libnotmuch, and
> not just in the emacs frontend, so i'm a bit concerned about what we'll
> have to prune out of the emacs frontend if we do manage to land the
> features in libnotmuch itself.

FTR, I'm waiting for the two of you to come to some concensus before
proceding with these patches.

d

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

* Re: [PATCH v2 0/2] scaffolding for autocrypt support
  2021-04-16 12:05   ` David Bremner
@ 2021-04-19  8:53     ` David Edmondson
  2021-07-07 11:02     ` Philip Kaludercic
  1 sibling, 0 replies; 7+ messages in thread
From: David Edmondson @ 2021-04-19  8:53 UTC (permalink / raw)
  To: David Bremner, Daniel Kahn Gillmor, notmuch

On Friday, 2021-04-16 at 09:05:29 -03, David Bremner wrote:

> Daniel Kahn Gillmor <dkg@fifthhorseman.net> writes:
>
>> Hi David, all--
>>
>> On Sun 2021-02-21 15:21:30 +0000, David Edmondson wrote:
>>> I started looking at how to add autocrypt support based on
>>> https://git.sr.ht/~zge/autocrypt.
>>
>> Thanks for this work, i'm glad to see the interest in autocrypt!
>>
>> I tend to think that the autocrypt handling belongs in libnotmuch, and
>> not just in the emacs frontend, so i'm a bit concerned about what we'll
>> have to prune out of the emacs frontend if we do manage to land the
>> features in libnotmuch itself.
>
> FTR, I'm waiting for the two of you to come to some concensus before
> proceding with these patches.

At the moment I don't really have time to make any progress, sorry.

dme.
-- 
Welcome to Conditioning.

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

* Re: [PATCH v2 0/2] scaffolding for autocrypt support
  2021-04-16 12:05   ` David Bremner
  2021-04-19  8:53     ` David Edmondson
@ 2021-07-07 11:02     ` Philip Kaludercic
  1 sibling, 0 replies; 7+ messages in thread
From: Philip Kaludercic @ 2021-07-07 11:02 UTC (permalink / raw)
  To: david; +Cc: notmuch


Hi,

I just wanted to note that the backend system in autocrypt.el was
reworked, and that this patch should probably be adapted, in case the
maintainers are still interested.

The details are documented here[0]. The intention is to make extensions
like these simpler, and removing direct dependencies on autocrypt.el.

[0] https://git.sr.ht/~pkal/autocrypt#extending-codeautocryptelcode

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

end of thread, other threads:[~2021-07-31  0:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-21 15:21 [PATCH v2 0/2] scaffolding for autocrypt support David Edmondson
2021-02-21 15:21 ` [PATCH v2 1/2] emacs: with-current-notmuch-show-message should return the result of body David Edmondson
2021-02-21 15:21 ` [PATCH v2 2/2] emacs: Add notmuch-show-insert-msg-hook David Edmondson
2021-02-23  2:02 ` [PATCH v2 0/2] scaffolding for autocrypt support Daniel Kahn Gillmor
2021-04-16 12:05   ` David Bremner
2021-04-19  8:53     ` David Edmondson
2021-07-07 11:02     ` Philip Kaludercic

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).