Re: [PATCH] introduce new.rename_tags for renamed (moved) messages

2018-09-07 Thread David Bremner
Michael J Gruber  writes:

>
> Introduce new.rename_tags (default: not set) which are added by `notmuch
> new` to renamed messages. This allows to act upon renames, e.g. to keep
> the IMAP folder structure in sync with tags with a tool like `afew` or
> homecooked scripts simply by filtering for this tag in the same ways as
> one would filter for new messages using new.tags.

The idea seems OK to me. I was hoping for some more feedback from
others, but here we are.

> +const char **tag;
>   add_files_state->renamed_messages++;
> + notmuch_message_freeze (message);
> +
> + for (tag = add_files_state->rename_tags; tag != NULL && *tag != NULL; 
> tag++) {
> + notmuch_message_add_tag (message, *tag);
> + }
> +
> +

extra blank line

>   if (add_files_state->synchronize_flags == true)
>   notmuch_message_maildir_flags_to_tags (message);
> + notmuch_message_thaw (message);

Did you have a specific reason for putting the _thaw after the existing
maildir_flags_to_tags? It's probably not important, but if there's no
good reason it seems more natural before.

As a new feature this needs some tests before it can be merged.  You can
start by looking at the tests for new.tags for inspiration I guess
(T050-new.sh and T340-maildir-sync.sh).  One case that occured to me is
that when duplicate files (with the same message-id) exist, deleting one
of them is detected as a rename.
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v1 2/2] notmuch: Database paths without a leading / are relative to $HOME

2018-09-07 Thread David Bremner
David Edmondson  writes:

> If the database path specified in the configuration file does *not*
> start with a /, presume that it is relative to $HOME and modify the
> path used to open the database accordingly.
> ---
>  notmuch-config.c | 14 +-
>  1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/notmuch-config.c b/notmuch-config.c
> index e1b16609..bf77cc9d 100644
> --- a/notmuch-config.c
> +++ b/notmuch-config.c
> @@ -660,7 +660,19 @@ _config_set_list (notmuch_config_t *config,
>  const char *
>  notmuch_config_get_database_path (notmuch_config_t *config)
>  {
> -return _config_get (config, >database_path, "database", "path");
> +char *db_path = (char *)_config_get (config, >database_path, 
> "database", "path");
> +
> +if (db_path && *db_path != '/') {
> + /* If the path in the configuration file begins with any
> +  * character other than /, presume that it is relative to
> +  * $HOME and update as appropriate.
> +  */
> + char *abs_path = talloc_asprintf (config, "%s/%s", getenv ("HOME"), 
> db_path);
> + talloc_free (db_path);
> + db_path = config->database_path = abs_path;
> +}

In the unlikely event that HOME is not set, it would be nicer to print a
message to that effect, rather than

  configuration file (null)/.notmuch-config not found.
  Try running 'notmuch setup' to create a configuration.

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v1 1/2] test: Absolute and relative directory paths.

2018-09-07 Thread David Bremner
David Edmondson  writes:

> ---
>  test/T030-config.sh | 10 ++
>  1 file changed, 10 insertions(+)
>
> diff --git a/test/T030-config.sh b/test/T030-config.sh
> index e91c3659..f36695c6 100755
> --- a/test/T030-config.sh
> +++ b/test/T030-config.sh
> @@ -99,4 +99,14 @@ test_expect_equal "$(notmuch --config=alt-config-link 
> config get user.name)" \
>  test_begin_subtest "Writing config file through symlink follows symlink"
>  test_expect_equal "$(readlink alt-config-link)" "alt-config"
>  
> +test_begin_subtest "Absolute database path returned"
> +notmuch config set database.path ${HOME}/Maildir
> +test_expect_equal "$(notmuch config get database.path)" \
> +   "${HOME}/Maildir"
> +
> +test_begin_subtest "Relative database path properly expanded"
> +notmuch config set database.path Maildir
> +test_expect_equal "$(notmuch config get database.path)" \
> +   "${HOME}/Maildir"
> +
>  test_done
> -- 

We want the test suite to pass after every commit, so you need to either
squash the second test into the next commit, or mark it with
test_subtest_known_broken. I'm fine with either option.

d
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: notmuch.readthedocs.org

2018-09-07 Thread David Bremner
Ben Gamari  writes:

> Justus Winter <4win...@informatik.uni-hamburg.de> writes:
>
>> Hey Sebastian,
>>
>> Quoting Sebastian Spaeth (2014-11-18 09:44:15)
>>> Let me know if I should be deleting the site. Or hand it over, or
>>> something :-).
>>
>> If I remember correctly, you handed notmuch.rtfd.org over to me.  Or
>> you deleted the project, and I created a new one in its place, I don't
>> recall.
>>
>> Ben, I added you as maintainer.  I cannot, however, seem to be able to
>> remove myself as maintainer.
>>
> No worries.
>
> I've updated the description and added notmuch-python as a
> subproject. For what it's worth the notmuch-python documentation can now
> be accessed at
> http://notmuch.rtfd.org/projects/notmuch-python/en/latest/ in addition
> to its usual home at http://notmuch-python.rtfd.org/
>
> - Ben

Hi Justus, Hi Ben;

I notice these are a bit stale again. Is one of you planning on
updating, or should we pass on maintence (or shut it down?)

d
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 1/1] RFC: add attachment checks

2018-09-07 Thread Antoine Beaupré
On 2018-09-07 10:14:46, David Edmondson wrote:
> Antoine, are you happy to have this marked as super-ceded by
> id:20180906181456.21719-2-...@dme.org?

Absolutely.

-- 
Cyberspace. A consensual hallucination experienced daily by billions
of legitimate operators, in every nation, by children being taught
mathematical concepts...
   - William Gibson
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: feature request: fetch missing keys in the background

2018-09-07 Thread David Edmondson
On Tuesday, 2018-09-04 at 10:12:00 -04, Antoine Beaupré wrote:

> So I tried that and it works, if I really don't touch anything. It's
> certainly an improvement over the previous behavior. Once the "message"
> is gone (ie. as soon as anything else is done in Emacs), it's a little
> hard to figure out what is happening without going through the status
> buffer.
>
> Maybe that's fine, but it would be nice if the button would immediately
> update with that status. For example, the text could change to
> "... updating" or something. Of course, we're back to the same place
> that it can't be updated without shuffling the buffer around if the
> point moved, but at least the UI would "remember" there was some change
> in the status (it's not just "Failure" but "We're working on it").

v2 of the patch does this.

dme.
-- 
When I grow up I'll be stable.
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v2 4/4] emacs: Improve the reporting of key activity

2018-09-07 Thread David Edmondson
Improve the information provided about key retrieval and key validity.
---
 emacs/notmuch-crypto.el | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index 760461e8..4629c233 100644
--- a/emacs/notmuch-crypto.el
+++ b/emacs/notmuch-crypto.el
@@ -147,13 +147,16 @@ by user FROM."
   (insert "\n"))
 
 (defun notmuch-crypto-sigstatus-good-callback (button)
-  (let* ((sigstatus (button-get button :notmuch-sigstatus))
+  (let* ((id (notmuch-show-get-message-id))
+(sigstatus (button-get button :notmuch-sigstatus))
 (fingerprint (concat "0x" (plist-get sigstatus :fingerprint)))
 (buffer (get-buffer-create "*notmuch-crypto-gpg-out*"))
 (window (display-buffer buffer)))
 (with-selected-window window
   (with-current-buffer buffer
(goto-char (point-max))
+   (insert (format "-- Key %s in message %s:\n"
+   fingerprint id))
(call-process notmuch-crypto-gpg-program nil t t "--list-keys" 
fingerprint))
   (recenter -1
 
@@ -205,10 +208,14 @@ corresponding key when the status button is pressed."
(progn
  (notmuch-crypto--set-button-label
   button (format "Retrieving key %s asynchronously..." keyid))
+ (with-current-buffer buffer
+   (goto-char (point-max))
+   (insert (format "--- Retrieving key %s:\n" keyid)))
  (let ((p (make-process :name "notmuch GPG key retrieval"
+:connection-type 'pipe
 :buffer buffer
+:stderr buffer
 :command (list notmuch-crypto-gpg-program 
"--recv-keys" keyid)
-:connection-type 'pipe
 :sentinel #'notmuch-crypto--async-key-sentinel
 ;; Create the process stopped so that
 ;; we have time to store the key id,
@@ -224,6 +231,7 @@ corresponding key when the status button is pressed."
(with-selected-window window
  (with-current-buffer buffer
(goto-char (point-max))
+   (insert (format "--- Retrieving key %s:\n" keyid))
(call-process notmuch-crypto-gpg-program nil t t "--recv-keys" 
keyid)
(insert "\n")
(call-process notmuch-crypto-gpg-program nil t t "--list-keys" 
keyid))
-- 
2.11.0

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v2 2/4] emacs: Minor refactoring of crypto code

2018-09-07 Thread David Edmondson
---
 emacs/notmuch-crypto.el | 96 +
 1 file changed, 50 insertions(+), 46 deletions(-)

diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index ddb447a6..81c0eca0 100644
--- a/emacs/notmuch-crypto.el
+++ b/emacs/notmuch-crypto.el
@@ -96,36 +96,40 @@ mode."
   :supertype 'notmuch-button-type)
 
 (defun notmuch-crypto-insert-sigstatus-button (sigstatus from)
+  "Insert a button describing the signature status SIGSTATUS sent
+by user FROM."
   (let* ((status (plist-get sigstatus :status))
-(help-msg nil)
-(label "Signature not processed")
 (face 'notmuch-crypto-signature-unknown)
-(button-action (lambda (button) (message (button-get button 
'help-echo)
+(button-action (lambda (button) (message (button-get button 
'help-echo
+(keyid (concat "0x" (plist-get sigstatus :keyid)))
+label help-msg)
 (cond
  ((string= status "good")
-  (let ((fingerprint (concat "0x" (plist-get sigstatus :fingerprint
-   ;; if userid present, userid has full or greater validity
-   (if (plist-member sigstatus :userid)
-   (let ((userid (plist-get sigstatus :userid)))
- (setq label (concat "Good signature by: " userid))
- (setq face 'notmuch-crypto-signature-good))
- (progn
-   (setq label (concat "Good signature by key: " fingerprint))
-   (setq face 'notmuch-crypto-signature-good-key)))
-   (setq button-action 'notmuch-crypto-sigstatus-good-callback)
-   (setq help-msg (concat "Click to list key ID 0x" fingerprint "."
+  (let ((fingerprint (concat "0x" (plist-get sigstatus :fingerprint)))
+   (userid (plist-get sigstatus :userid)))
+   ;; If userid is present it has full or greater validity.
+   (if userid
+   (setq label (concat "Good signature by: " userid)
+ face 'notmuch-crypto-signature-good)
+ (setq label (concat "Good signature by key: " fingerprint)
+   face 'notmuch-crypto-signature-good-key))
+   (setq button-action 'notmuch-crypto-sigstatus-good-callback
+ help-msg (concat "Click to list key ID 0x" fingerprint "."
+
  ((string= status "error")
-  (let ((keyid (concat "0x" (plist-get sigstatus :keyid
-   (setq label (concat "Unknown key ID " keyid " or unsupported 
algorithm"))
-   (setq button-action 'notmuch-crypto-sigstatus-error-callback)
-   (setq help-msg (concat "Click to retrieve key ID " keyid " from 
keyserver and redisplay."
+  (setq label (concat "Unknown key ID " keyid " or unsupported algorithm")
+   button-action 'notmuch-crypto-sigstatus-error-callback
+   help-msg (concat "Click to retrieve key ID " keyid
+" from keyserver and redisplay.")))
+
  ((string= status "bad")
-  (let ((keyid (concat "0x" (plist-get sigstatus :keyid
-   (setq label (concat "Bad signature (claimed key ID " keyid ")"))
-   (setq face 'notmuch-crypto-signature-bad)))
+  (setq label (concat "Bad signature (claimed key ID " keyid ")")
+   face 'notmuch-crypto-signature-bad))
+
  (t
   (setq label (concat "Unknown signature status"
  (if status (concat ": " status))
+
 (insert-button
  (concat "[ " label " ]")
  :type 'notmuch-crypto-status-button-type
@@ -134,22 +138,22 @@ mode."
  'mouse-face face
  'action button-action
  :notmuch-sigstatus sigstatus
- :notmuch-from from)
-(insert "\n")))
-
-(declare-function notmuch-show-refresh-view "notmuch-show" ( 
reset-state))
+ :notmuch-from from))
+  (insert "\n"))
 
 (defun notmuch-crypto-sigstatus-good-callback (button)
   (let* ((sigstatus (button-get button :notmuch-sigstatus))
 (fingerprint (concat "0x" (plist-get sigstatus :fingerprint)))
 (buffer (get-buffer-create "*notmuch-crypto-gpg-out*"))
-(window (display-buffer buffer t nil)))
+(window (display-buffer buffer)))
 (with-selected-window window
   (with-current-buffer buffer
(goto-char (point-max))
(call-process epg-gpg-program nil t t "--list-keys" fingerprint))
   (recenter -1
 
+(declare-function notmuch-show-refresh-view "notmuch-show" ( 
reset-state))
+
 (defun notmuch-crypto--async-key-sentinel (process event)
   "When the user asks for a GPG key to be retrieved
 asynchronously, handle completion of that task."
@@ -187,6 +191,8 @@ asynchronously, handle completion of that task."
   (insert label
 
 (defun notmuch-crypto-sigstatus-error-callback (button)
+  "When signature validation has failed, try to retrieve the
+corresponding key when the status button is pressed."
   (let* ((sigstatus (button-get button :notmuch-sigstatus))
 (keyid (concat "0x" (plist-get sigstatus :keyid)))
 (buffer (get-buffer-create "*notmuch-crypto-gpg-out*")))
@@ -208,7 +214,7 @@ 

[PATCH v2 1/4] emacs: Asynchronous retrieval of GPG keys

2018-09-07 Thread David Edmondson
Rather than blocking emacs while gpg does its' thing, by default run
key retrieval asynchronously, possibly updating the display of the
message on successful completion.
---
 emacs/notmuch-crypto.el | 79 ++---
 1 file changed, 69 insertions(+), 10 deletions(-)

diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index fc2b5301..ddb447a6 100644
--- a/emacs/notmuch-crypto.el
+++ b/emacs/notmuch-crypto.el
@@ -43,6 +43,11 @@ mode."
   :package-version '(notmuch . "0.25")
   :group 'notmuch-crypto)
 
+(defcustom notmuch-crypto-get-keys-asynchronously t
+  "Retrieve gpg keys asynchronously."
+  :type 'boolean
+  :group 'notmuch-crypto)
+
 (defface notmuch-crypto-part-header
   'class color)
   (background dark))
@@ -145,19 +150,73 @@ mode."
(call-process epg-gpg-program nil t t "--list-keys" fingerprint))
   (recenter -1
 
+(defun notmuch-crypto--async-key-sentinel (process event)
+  "When the user asks for a GPG key to be retrieved
+asynchronously, handle completion of that task."
+  (let ((status (process-status process))
+   (exit-status (process-exit-status process))
+   (keyid (process-get process :gpg-key-id)))
+(when (memq status '(exit signal))
+  (message "Getting the GPG key %s asynchronously...%s."
+  keyid
+  (if (= exit-status 0)
+  "completed"
+"failed"))
+  ;; If the original buffer is still alive and point didn't move
+  ;; (i.e. the user didn't move on or away), refresh the buffer to
+  ;; show the updated signature status.
+  (let ((show-buffer (process-get process :notmuch-show-buffer))
+   (show-point (process-get process :notmuch-show-point)))
+   (when (and (bufferp show-buffer)
+  (buffer-live-p show-buffer)
+  (= show-point
+ (with-current-buffer show-buffer
+   (point
+ (with-current-buffer show-buffer
+   (notmuch-show-refresh-view)))
+
+(defun notmuch-crypto--set-button-label (button label)
+  "Set the text displayed in BUTTON to LABEL."
+  (save-excursion
+(let ((inhibit-read-only t))
+  ;; This knows rather too much about how we typically format
+  ;; buttons.
+  (goto-char (button-start button))
+  (forward-char 2)
+  (delete-region (point) (- (button-end button) 2))
+  (insert label
+
 (defun notmuch-crypto-sigstatus-error-callback (button)
   (let* ((sigstatus (button-get button :notmuch-sigstatus))
 (keyid (concat "0x" (plist-get sigstatus :keyid)))
-(buffer (get-buffer-create "*notmuch-crypto-gpg-out*"))
-(window (display-buffer buffer t nil)))
-(with-selected-window window
-  (with-current-buffer buffer
-   (goto-char (point-max))
-   (call-process epg-gpg-program nil t t "--recv-keys" keyid)
-   (insert "\n")
-   (call-process epg-gpg-program nil t t "--list-keys" keyid))
-  (recenter -1))
-(notmuch-show-refresh-view)))
+(buffer (get-buffer-create "*notmuch-crypto-gpg-out*")))
+(if notmuch-crypto-get-keys-asynchronously
+   (progn
+ (notmuch-crypto--set-button-label
+  button (format "Retrieving key %s asynchronously..." keyid))
+ (let ((p (make-process :name "notmuch GPG key retrieval"
+:buffer buffer
+:command (list epg-gpg-program "--recv-keys" 
keyid)
+:connection-type 'pipe
+:sentinel #'notmuch-crypto--async-key-sentinel
+;; Create the process stopped so that
+;; we have time to store the key id,
+;; etc. on it.
+:stop t)))
+   (process-put p :gpg-key-id keyid)
+   (process-put p :notmuch-show-buffer (current-buffer))
+   (process-put p :notmuch-show-point (point))
+   (message "Getting the GPG key %s asynchronously..." keyid)
+   (continue-process p)))
+  (let ((window (display-buffer buffer t nil)))
+   (with-selected-window window
+ (with-current-buffer buffer
+   (goto-char (point-max))
+   (call-process epg-gpg-program nil t t "--recv-keys" keyid)
+   (insert "\n")
+   (call-process epg-gpg-program nil t t "--list-keys" keyid))
+ (recenter -1))
+   (notmuch-show-refresh-view)
 
 (defun notmuch-crypto-insert-encstatus-button (encstatus)
   (let* ((status (plist-get encstatus :status))
-- 
2.11.0

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v2 0/4] Retrieve GPG keys asynchronously.

2018-09-07 Thread David Edmondson

Retrieve GPG keys asynchronously.

v2:
- Update the label on buttons when they are used to request
  asyncronous key retrieval.
- Always update the buffer when key retrieval completes, even if the
  retrieval failed, so that the label is properly re-generated.


David Edmondson (4):
  emacs: Asynchronous retrieval of GPG keys
  emacs: Minor refactoring of crypto code
  emacs: Add notmuch-crypto-gpg-program and use it
  emacs: Improve the reporting of key activity

 emacs/notmuch-crypto.el | 191 +---
 1 file changed, 134 insertions(+), 57 deletions(-)

-- 
2.11.0

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v2 3/4] emacs: Add notmuch-crypto-gpg-program and use it

2018-09-07 Thread David Edmondson
Allow the user to specify the gpg program to use when retriving keys,
etc., defaulting to the value of `epg-gpg-program'.
---
 emacs/notmuch-crypto.el | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index 81c0eca0..760461e8 100644
--- a/emacs/notmuch-crypto.el
+++ b/emacs/notmuch-crypto.el
@@ -48,6 +48,11 @@ mode."
   :type 'boolean
   :group 'notmuch-crypto)
 
+(defcustom notmuch-crypto-gpg-program epg-gpg-program
+  "The gpg executable."
+  :type 'string
+  :group 'notmuch-crypto)
+
 (defface notmuch-crypto-part-header
   'class color)
   (background dark))
@@ -149,7 +154,7 @@ by user FROM."
 (with-selected-window window
   (with-current-buffer buffer
(goto-char (point-max))
-   (call-process epg-gpg-program nil t t "--list-keys" fingerprint))
+   (call-process notmuch-crypto-gpg-program nil t t "--list-keys" 
fingerprint))
   (recenter -1
 
 (declare-function notmuch-show-refresh-view "notmuch-show" ( 
reset-state))
@@ -202,7 +207,7 @@ corresponding key when the status button is pressed."
   button (format "Retrieving key %s asynchronously..." keyid))
  (let ((p (make-process :name "notmuch GPG key retrieval"
 :buffer buffer
-:command (list epg-gpg-program "--recv-keys" 
keyid)
+:command (list notmuch-crypto-gpg-program 
"--recv-keys" keyid)
 :connection-type 'pipe
 :sentinel #'notmuch-crypto--async-key-sentinel
 ;; Create the process stopped so that
@@ -214,13 +219,14 @@ corresponding key when the status button is pressed."
(process-put p :notmuch-show-point (point))
(message "Getting the GPG key %s asynchronously..." keyid)
(continue-process p)))
+
   (let ((window (display-buffer buffer)))
(with-selected-window window
  (with-current-buffer buffer
(goto-char (point-max))
-   (call-process epg-gpg-program nil t t "--recv-keys" keyid)
+   (call-process notmuch-crypto-gpg-program nil t t "--recv-keys" 
keyid)
(insert "\n")
-   (call-process epg-gpg-program nil t t "--list-keys" keyid))
+   (call-process notmuch-crypto-gpg-program nil t t "--list-keys" 
keyid))
  (recenter -1))
(notmuch-show-refresh-view)
 
-- 
2.11.0

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 1/1] RFC: add attachment checks

2018-09-07 Thread David Edmondson
Antoine, are you happy to have this marked as super-ceded by
id:20180906181456.21719-2-...@dme.org?

dme.
-- 
It's alright, we told you what to dream.
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch