Variable used to detect reply prefixes in Subject

2022-01-23 Thread Jonas Bernoulli
Hello,

Please tell me what variable I have to customize to recognize additional
unusual prefixes that some people add to the subject when they send a
reply.

I searched using some strings I would expect to appear in the value of
that variable but either got no results or way too many.

 Thanks!
 Jonas


Ps: Since (I assume) many notmuch users also frequent emacs-devel,
where a frequent commentator uses the prefix "RE: [External] : ",
maybe notmuch could even recognize that by default? (I asked him
to consider not doing that anymore, but even if he agrees, that
would not affect his numerous past replies.)
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH] emacs: notmuch-fcc-header-setup: fix regression

2021-08-04 Thread Jonas Bernoulli
With [1: 16b2db09] we lost the (undocumented) option to use no Fcc
header only for From addresses matching a regexp.  This brings back
that feature and documents it.

1: 2021-01-15 16b2db0986ce0ed7c420a69d0a98bb41e9ca4bd8
   emacs: various cosmetic improvements
---
 emacs/notmuch-maildir-fcc.el | 29 -
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el
index c715532b..7e177bf7 100644
--- a/emacs/notmuch-maildir-fcc.el
+++ b/emacs/notmuch-maildir-fcc.el
@@ -41,16 +41,17 @@ (defcustom notmuch-fcc-dirs "sent"
 - a string: the value of `notmuch-fcc-dirs' is the Fcc header to
   be used.
 
-- a list: the folder is chosen based on the From address of the
-  current message using a list of regular expressions and
-  corresponding folders:
+- an alist: the folder is chosen based on the From address of
+  the current message according to an alist mapping regular
+  expressions to folders or nil:
 
  ((\"sebast...@sspaeth.de\" . \"privat\")
   (\"spa...@sspaeth.de\" . \"OUTBOX.OSS\")
   (\".*\" . \"defaultinbox\"))
 
-  If none of the regular expressions match the From address, no
-  Fcc header will be added.
+  If none of the regular expressions match the From address, or
+  if the cdr of the matching entry is nil, then no Fcc header
+  will be added.
 
 If `notmuch-maildir-use-notmuch-insert' is set (the default) then
 the header should be of the form \"folder +tag1 -tag2\" where
@@ -74,7 +75,8 @@ (defcustom notmuch-fcc-dirs "sent"
  (const :tag "No FCC header" nil)
  (string :tag "A single folder")
  (repeat :tag "A folder based on the From header"
- (cons regexp (string :tag "Folder"
+ (cons regexp (choice (const :tag "No FCC header" nil)
+  (string :tag "Folder")
   :require 'notmuch-fcc-initialization
   :group 'notmuch-send)
 
@@ -105,13 +107,14 @@ (defun notmuch-fcc-header-setup ()
   ;; Old style - no longer works.
   (error "Invalid `notmuch-fcc-dirs' setting (old style)"))
  ((listp notmuch-fcc-dirs)
-  (or (seq-some (let ((from (message-field-value "From")))
-  (pcase-lambda (`(,regexp . ,folder))
-(and (string-match-p regexp from)
- folder)))
-notmuch-fcc-dirs)
-  (progn (message "No Fcc header added.")
- nil)))
+  (if-let ((match (seq-some (let ((from (message-field-value "From")))
+  (pcase-lambda (`(,regexp . ,folder))
+(and (string-match-p regexp from)
+ (cons t folder
+notmuch-fcc-dirs)))
+   (cdr match)
+ (message "No Fcc header added.")
+nil))
  (t
   (error "Invalid `notmuch-fcc-dirs' setting (neither string nor 
list)")
 (when subdir
-- 
2.31.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] emacs: notmuch-tree: mark the initial message at point as read

2021-07-23 Thread Jonas Bernoulli
David Bremner  writes:

> Jonas Bernoulli  writes:
>
>>
>> Please merge the proposed fix; IMO it is sound.  My follow-up, the reply
>> to Tomi, seems quite confused though.  But just because we are uncertain
>> whether there is further room for improvement, that shouldn't keep us
>> from fixing the bug.  Maybe in the future we can improve upon this fix
>> but I probably won't investigate any time soon.
>>
>>  Jonas
>
> Apologies, I should have experimented / asked before. I can't seem to
> duplicate the problem being fixed here. Is it non-deterministic, or
> should I expect it to always happen? If the latter, can you give me a
> further hint / instructions how to reproduce? For me, whether in
> tree-mode or search-mode, if I hit return the message at point is marked
> unread.
>
> d

I can always reproduce it:

1. Perform a search.

2. Visit the tree for a thread that you have previously not
   seen using notmuch-tree-from-search-thread. The default
   binding for that command is M-RET.  You mentioned that you
   pressed RET so maybe that's why you couldn't reproduce
   (i.e. you invoked notmuch-search-show-thread, which
   doesn't have this issue).

3. Press n (notmuch-tree-next-message) a few times until
   you reach the last message in the tree.  Do NOT press
   p (notmuch-tree-prev-message) to move back to the first
   message.

4. All messages should now be shown as "going to be marked
   as read".  In my case that is visualized by the word
   "unread" being striked out.  This DOES include the first
   message, but in this case it's not true.

5. Press q (notmuch-tree-quit) twice to return to the
   search view.

6. Press g (notmuch-refresh-this-buffer).  You would expect
   that to cause the thread at point to be marked read, but
   it is not.

7. Visit the tree for the same thread again using
   notmuch-tree-from-search-thread.  The second and subsequent
   messages are in the read state, the word "unread" is completely
   absent.  The first message however is shown as being in the
   "going to be marked as read", i.e. the word "unread" is shown
   and struck out.

The work around for this is to press RET (notmuch-tree-show-message)
at this point.  The word "unread" is still struck out, but if you
exit now (using q twice), then this change is actually applied.

Note that notmuch-search-show-thread does NOT behave as described
for notmuch-tree-from-search-thread above.  Applying my patch causes
the former to behave like the latter.

 Jonas
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 5/5] emacs: shorten lines in two doc-strings

2021-07-19 Thread Jonas Bernoulli
The byte-compiler wasn't happy about those.
---
 emacs/notmuch-draft.el | 2 +-
 emacs/notmuch-hello.el | 8 +---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-draft.el b/emacs/notmuch-draft.el
index a68b7d8d..aeb6c588 100644
--- a/emacs/notmuch-draft.el
+++ b/emacs/notmuch-draft.el
@@ -42,7 +42,7 @@ (defgroup notmuch-draft nil
   :group 'notmuch)
 
 (defcustom notmuch-draft-tags '("+draft")
-  "List of tags changes to apply to a draft message when it is saved in the 
database.
+  "List of tag changes to apply when saving a draft message in the database.
 
 Tags starting with \"+\" (or not starting with either \"+\" or
 \"-\") in the list will be added, and tags starting with \"-\"
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index c1b67e22..21855b70 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -144,9 +144,11 @@ (defcustom notmuch-saved-searches
Possible values are `oldest-first', `newest-first'
or nil. Nil means use the default sort order.
   :search-type Specify whether to run the search in search-mode,
-   tree mode or unthreaded mode. Set to 'tree to specify tree
-   mode, 'unthreaded to specify unthreaded mode, and set to nil
-   (or anything except tree and unthreaded) to specify search 
mode.
+   tree mode or unthreaded mode. Set to `tree' to
+   specify tree mode, 'unthreaded to specify
+   unthreaded mode, and set to nil (or anything
+   except tree and unthreaded) to specify search
+   mode.
 
 Other accepted forms are a cons cell of the form (NAME . QUERY)
 or a list of the form (NAME QUERY COUNT-QUERY)."
-- 
2.31.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 4/5] emacs: notmuch-show-pipe-message: cosmetics

2021-07-19 Thread Jonas Bernoulli
---
 emacs/notmuch-show.el | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 9a95eb34..b14db1dd 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -2076,19 +2076,19 @@ (defun notmuch-show-pipe-message (entire-thread command)
 (let ((cwd default-directory)
  (buf (get-buffer-create (concat "*notmuch-pipe*"
   (with-current-buffer buf
-   (setq buffer-read-only nil)
-   (erase-buffer)
-   ;; Use the originating buffer's working directory instead of
-   ;; that of the pipe buffer.
-   (cd cwd)
-   (let ((exit-code (call-process-shell-command shell-command nil buf)))
- (goto-char (point-max))
- (set-buffer-modified-p nil)
- (setq buffer-read-only t)
- (unless (zerop exit-code)
-   (pop-to-buffer buf)
-   (message (format "Command '%s' exited abnormally with code %d"
-shell-command exit-code
+   (setq buffer-read-only t)
+   (let ((inhibit-read-only t))
+ (erase-buffer)
+ ;; Use the originating buffer's working directory instead of
+ ;; that of the pipe buffer.
+ (cd cwd)
+ (let ((exit-code (call-process-shell-command shell-command nil buf)))
+   (goto-char (point-max))
+   (set-buffer-modified-p nil)
+   (unless (zerop exit-code)
+ (pop-to-buffer buf)
+ (message (format "Command '%s' exited abnormally with code %d"
+  shell-command exit-code)
 
 (defun notmuch-show-tag-message ( tag-changes)
   "Change tags for the current message.
-- 
2.31.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 3/5] emacs: fix some option type declarations

2021-07-19 Thread Jonas Bernoulli
Also improve their doc-strings.
---
 emacs/notmuch-tree.el | 66 +--
 emacs/notmuch.el  | 13 +
 2 files changed, 47 insertions(+), 32 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index b288c05d..d11ef38c 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -77,21 +77,28 @@ (defun notmuch-tree-show-out ()
 (defcustom notmuch-tree-result-format
   `(("date" . "%12s  ")
 ("authors" . "%-20s")
-((("tree" . "%s")("subject" . "%s")) ." %-54s ")
+((("tree" . "%s")
+  ("subject" . "%s"))
+ . " %-54s ")
 ("tags" . "(%s)"))
-  "Result formatting for tree view. Supported fields are: date,
-authors, subject, tree, tags.  Tree means the thread tree
-box graphics. The field may also be a list in which case
-the formatting rules are applied recursively and then the
-output of all the fields in the list is inserted
-according to format-string.
-
-Note the author string should not contain
-whitespace (put it in the neighbouring fields instead).
-For example:
-(setq notmuch-tree-result-format \(\(\"authors\" . \"%-40s\"\)
-  \(\"subject\" . \"%s\"\)\)\)"
-  :type '(alist :key-type (string) :value-type (string))
+  "Result formatting for tree view.
+
+Supported fields are: date, authors, subject, tree, tags.
+
+Tree means the thread tree box graphics. The field may
+also be a list in which case the formatting rules are
+applied recursively and then the output of all the fields
+in the list is inserted according to format-string.
+
+Note that the author string should not contain whitespace
+\(put it in the neighbouring fields instead). For example:
+(setq notmuch-tree-result-format
+  '((\"authors\" . \"%-40s\")
+(\"subject\" . \"%s\")))"
+  :type '(alist :key-type (choice string
+ (alist :key-type string
+:value-type string))
+   :value-type string)
   :group 'notmuch-tree)
 
 (defcustom notmuch-unthreaded-result-format
@@ -99,19 +106,24 @@ (defcustom notmuch-unthreaded-result-format
 ("authors" . "%-20s")
 ((("subject" . "%s")) ." %-54s ")
 ("tags" . "(%s)"))
-  "Result formatting for unthreaded tree view. Supported fields are: date,
-authors, subject, tree, tags.  Tree means the thread tree
-box graphics. The field may also be a list in which case
-the formatting rules are applied recursively and then the
-output of all the fields in the list is inserted
-according to format-string.
-
-Note the author string should not contain
-whitespace (put it in the neighbouring fields instead).
-For example:
-(setq notmuch-tree-result-format \(\(\"authors\" . \"%-40s\"\)
-  \(\"subject\" . \"%s\"\)\)\)"
-  :type '(alist :key-type (string) :value-type (string))
+  "Result formatting for unthreaded tree view.
+
+Supported fields are: date, authors, subject, tree, tags.
+
+Tree means the thread tree box graphics. The field may
+also be a list in which case the formatting rules are
+applied recursively and then the output of all the fields
+in the list is inserted according to format-string.
+
+Note that the author string should not contain whitespace
+\(put it in the neighbouring fields instead). For example:
+(setq notmuch-unthreaded-result-format
+  '((\"authors\" . \"%-40s\")
+(\"subject\" . \"%s\")))"
+  :type '(alist :key-type (choice string
+ (alist :key-type string
+:value-type string))
+   :value-type string)
   :group 'notmuch-tree)
 
 (defun notmuch-tree-result-format ()
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 351334aa..7f10c509 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -88,18 +88,21 @@ (defcustom notmuch-search-result-format
 ("authors" . "%-20s ")
 ("subject" . "%s ")
 ("tags" . "(%s)"))
-  "Search result formatting. Supported fields are:
-   date, count, authors, subject, tags
+  "Search result formatting.
+
+Supported fields are: date, count, authors, subject, tags.
 For example:
-   (setq notmuch-search-result-format \(\(\"authors\" . \"%-40s\"\)
-\(\"subject\" . \"%s\"\)\)\)
+(setq notmuch-search-result-format
+  '((\"authors\" . \"%-40s\")
+(\"subject\" . \"%s\")))
+
 Line breaks are permitted in format strings (though this is
 currently experimental).  Note that a line break at the end of an
 \"authors\" field will get elided if the authors list is long;
 place it instead at the beginning of the following field.  To
 enter a line break when setting this variable with setq, use \\n.
 To enter a line break in customize, press \\[quoted-insert] C-j."
-  :type '(alist :key-type (string) :value-type (string))
+  :type '(alist :key-type string :value-type string)
   :group 

[PATCH 2/5] emacs: add some function declarations

2021-07-19 Thread Jonas Bernoulli
---
 emacs/notmuch-jump.el | 4 
 1 file changed, 4 insertions(+)

diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
index c0760638..555ecd1f 100644
--- a/emacs/notmuch-jump.el
+++ b/emacs/notmuch-jump.el
@@ -25,6 +25,10 @@
 (require 'notmuch-lib)
 (require 'notmuch-hello)
 
+(declare-function notmuch-search "notmuch")
+(declare-function notmuch-tree "notmuch-tree")
+(declare-function notmuch-unthreaded "notmuch-tree")
+
 ;;;###autoload
 (defun notmuch-jump-search ()
   "Jump to a saved search by shortcut key.
-- 
2.31.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 1/5] emacs: use closures instead of backquoted lambdas

2021-07-19 Thread Jonas Bernoulli
---
 emacs/notmuch-hello.el | 16 
 emacs/notmuch-jump.el  | 26 ++
 emacs/notmuch-tag.el   |  2 +-
 3 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 1e66555b..c1b67e22 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -869,16 +869,16 @@ (defun notmuch-hello-insert-searches (title query-list 
 options)
(start (point)))
 (if is-hidden
(widget-create 'push-button
-  :notify `(lambda (widget  _ignore)
- (setq notmuch-hello-hidden-sections
-   (delete ,title 
notmuch-hello-hidden-sections))
- (notmuch-hello-update))
+  :notify (lambda ( _ignore)
+(setq notmuch-hello-hidden-sections
+  (delete title 
notmuch-hello-hidden-sections))
+(notmuch-hello-update))
   "show")
   (widget-create 'push-button
-:notify `(lambda (widget  _ignore)
-   (add-to-list 'notmuch-hello-hidden-sections
-,title)
-   (notmuch-hello-update))
+:notify (lambda ( _ignore)
+  (add-to-list 'notmuch-hello-hidden-sections
+   title)
+  (notmuch-hello-update))
 "hide"))
 (widget-insert "\n")
 (unless is-hidden
diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
index e228c8a2..c0760638 100644
--- a/emacs/notmuch-jump.el
+++ b/emacs/notmuch-jump.el
@@ -50,11 +50,11 @@ (defun notmuch-jump-search ()
(push (list key name
(cond
 ((eq (plist-get saved-search :search-type) 'tree)
- `(lambda () (notmuch-tree ',query)))
+ (lambda () (notmuch-tree query)))
 ((eq (plist-get saved-search :search-type) 'unthreaded)
- `(lambda () (notmuch-unthreaded ',query)))
+ (lambda () (notmuch-unthreaded query)))
 (t
- `(lambda () (notmuch-search ',query 
',oldest-first)
+ (lambda () (notmuch-search query oldest-first)
  action-map)
 (setq action-map (nreverse action-map))
 (if action-map
@@ -168,9 +168,10 @@ (defun notmuch-jump--make-keymap (action-map prompt)
 (pcase-dolist (`(,key ,_name ,fn) action-map)
   (when (= (length key) 1)
(define-key map key
- `(lambda () (interactive)
-(setq notmuch-jump--action ',fn)
-(exit-minibuffer)
+ (lambda ()
+   (interactive)
+   (setq notmuch-jump--action fn)
+   (exit-minibuffer)
 ;; By doing this in two passes (and checking if we already have a
 ;; binding) we avoid problems if the user specifies a binding which
 ;; is a prefix of another binding.
@@ -191,12 +192,13 @@ (defun notmuch-jump--make-keymap (action-map prompt)
  action-submap)
(setq action-submap (nreverse action-submap))
(define-key map keystr
- `(lambda () (interactive)
-(setq notmuch-jump--action
-  ',(apply-partially #'notmuch-jump
- action-submap
- new-prompt))
-(exit-minibuffer)))
+ (lambda ()
+   (interactive)
+   (setq notmuch-jump--action
+ (apply-partially #'notmuch-jump
+  action-submap
+  new-prompt))
+   (exit-minibuffer)))
 map))
 
 (provide 'notmuch-jump)
diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
index ebccb5a0..e3a60441 100644
--- a/emacs/notmuch-tag.el
+++ b/emacs/notmuch-tag.el
@@ -553,7 +553,7 @@ (defun notmuch-tag-jump (reverse)
name)
(mapconcat #'identity tag-change " "
(push (list key name-string
-   `(lambda () (,tag-function ',tag-change)))
+   (lambda () (funcall tag-function tag-change)))
  action-map)))
 (push (list notmuch-tag-jump-reverse-key
(if reverse
-- 
2.31.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 0/5] Use closures and other emacs cleanup

2021-07-19 Thread Jonas Bernoulli
Some assorted emacs cleanup and fixes.  The big one is the switch to
using closures instead of backquoted lambdas.  The other commits for
the most part just deal with things the compiler complained about.

Jonas Bernoulli (5):
  emacs: use closures instead of backquoted lambdas
  emacs: add some function declarations
  emacs: fix some option type declarations
  emacs: notmuch-show-pipe-message: cosmetics
  emacs: shorten lines in two doc-strings

 emacs/notmuch-draft.el |  2 +-
 emacs/notmuch-hello.el | 24 ---
 emacs/notmuch-jump.el  | 30 +++
 emacs/notmuch-show.el  | 26 -
 emacs/notmuch-tag.el   |  2 +-
 emacs/notmuch-tree.el  | 66 +-
 emacs/notmuch.el   | 13 +
 7 files changed, 93 insertions(+), 70 deletions(-)

-- 
2.31.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] emacs: notmuch-tree: mark the initial message at point as read

2021-07-19 Thread Jonas Bernoulli
David Bremner  writes:

> Jonas Bernoulli  writes:
>
>> Hm, when no tree buffer is involved, then `notmuch-show-command-hook'
>> probably is required.  Anyway, there seems to be some undead code and
>> rethinking all this would be a good idea.
>
> I'm not sure I followed the discussion, but I'm marking
> id:20210216000138.19625-1-jo...@bernoul.li as "notmuch::moreinfo",
> meaning we're expecting another version from Jonas. If that's wrong,
> please let me know.
>
> d

Please merge the proposed fix; IMO it is sound.  My follow-up, the reply
to Tomi, seems quite confused though.  But just because we are uncertain
whether there is further room for improvement, that shouldn't keep us
from fixing the bug.  Maybe in the future we can improve upon this fix
but I probably won't investigate any time soon.

 Jonas
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] emacs: remove useless lexically bound variable

2021-07-19 Thread Jonas Bernoulli
+1 (I was gonna suggest the same change.)

David Bremner  writes:

> A let binding without a value is just an obfuscated way of saying
> nil, especially if you are not going to mutate the variable.
> ---
>  emacs/notmuch-tree.el | 7 +++
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
> index b288c05d..eb7ea941 100644
> --- a/emacs/notmuch-tree.el
> +++ b/emacs/notmuch-tree.el
> @@ -1001,10 +1001,9 @@ message together with all its descendents."
>  
>  (defun notmuch-tree-insert-forest-thread (forest-thread)
>"Insert a single complete thread."
> -  (let (tree-status)
> -;; Reset at the start of each main thread.
> -(setq notmuch-tree-previous-subject nil)
> -(notmuch-tree-insert-thread forest-thread 0 tree-status)))
> +  ;; Reset at the start of each main thread.
> +  (setq notmuch-tree-previous-subject nil)
> +  (notmuch-tree-insert-thread forest-thread 0 nil))
>  
>  (defun notmuch-tree-insert-forest (forest)
>"Insert a forest of threads.
> -- 
> 2.30.2
> ___
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-le...@notmuchmail.org
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 2/2] NEWS: summarize changes to emacs interface.

2021-04-28 Thread Jonas Bernoulli
David Bremner  writes:

I couldn't wait until tonight. ;)

> This my attempt at a summary based on git log.

You have mostly covers the important bits that users need to
know about.  The only thing I would add is:

Some keymaps used to contain bindings for unnamed commands.  These
lambda expressions have been replaced by named commands (symbols),
to ease customization.

> +Removed or inlined functions and variables:
> + `notmuch-address-locate-command`, `notmuch-folder`,
> + `notmuch-remove-if-not`, `notmuch-search-disjunctive-regexp`,
> + `notmuch-sexp-eof`, `notmuch-split-content-type`,
> + `notmuch-tree-button-activate`,

You overlooked a few
  `notmuch-documentation-first-line`
  `notmuch-hello-trim'
and there's also a rename
  `notmuch-hello-versions` => `notmuch-version`

I would change this to:

Removed, inlined or renamed functions and variables:
  `notmuch-address-locate-command`,
  `notmuch-documentation-first-line`, `notmuch-folder`,
  `notmuch-hello-trim', `notmuch-hello-versions` => `notmuch-version`,
  `notmuch-remove-if-not`, `notmuch-search-disjunctive-regexp`,
  `notmuch-sexp-eof`, `notmuch-split-content-type`, and
  `notmuch-tree-button-activate`.
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: Release process for 0.32

2021-04-28 Thread Jonas Bernoulli
David Bremner  writes:
> Jonas, I know a lot of what you contributed is not user visible,
> but a patch for NEWS listing some of the user visible changes
> (particularly things like dropped variables and functions) would be
> appreciated.

I missed this request at the time, sorry.  I'll try to go over the
changes myself tonight to see if you overlooked anything important
in the entries you wrote yesterday.

 Jonas
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] emacs: notmuch-tree: mark the initial message at point as read

2021-02-26 Thread Jonas Bernoulli
Hm, when no tree buffer is involved, then `notmuch-show-command-hook'
probably is required.  Anyway, there seems to be some undead code and
rethinking all this would be a good idea.
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] emacs: notmuch-tree: mark the initial message at point as read

2021-02-26 Thread Jonas Bernoulli
> I try to understand whether adding notmuch-tree-command-hook to
> post-command-hook in notmuch-tree.el (not in this change) actually
> have any effect.

You're right, that's unnecessary, and it gets worse.

`notmuch-tree-command-hook' is unnecessary too and if it weren't,
then it would fail because its added to the buffer-local value of
`post-command-hook', but that buffer is not the current buffer
when the hook is run.

Using `post-command-hook' in any form for this is questionable in the
first place.  The idiomatic approach would be to use the `point-entered'
text property hook.  Or `notmuch-tree-{previous,next}-message' could
just do the marking explicitly.

It's also not okay that `notmuch-tree-show-message-in' keeps recreating
the window.

`notmuch-show-command-hook' forces redisplay to update values that pass
along, but don't and shouldn't use.  There is more than one function to
mark a message as read and they don't all end up doing the same thing.

What effectively does the marking is

(defun notmuch-tree-show-message-in ()
  ...
  (when notmuch-show-mark-read-tags
(notmuch-tree-tag-update-display notmuch-show-mark-read-tags))
  ...)

I am going to refactor this mess, but that will take a while.

 Jonas
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH] emacs: notmuch-tree: mark the initial message at point as read

2021-02-15 Thread Jonas Bernoulli
When moving between message in a tree or show buffer, the message at
point is marked as read.  Likewise when creating such a buffer, then
the message that is initially at point is supposed to be marked as
read as well.

The latter worked for `notmuch-show' but not for `notmuch-tree'.
Press "RET" or "M-RET" in a search buffer to observe these behaviors.

In both cases the marking is supposed to be done by the function
`notmuch-show-command-hook'.  In the case of `notmuch-show' that
function is added directly to `post-command-hook'.

`notmuch-tree' instead adds the function `notmuch-tree-command-hook'
to `post-command-hook' and that calls `notmuch-show-command-hook',
in the respective show buffer, but of course only if that exists.

Because the tree buffer is created asynchronously, the show buffer
doesn't exist yet by the time the `post-command-hook' is run, so
we have to explicitly run `notmuch-tree-command-hook' once the
show buffer exists.

The show buffer is created when `notmuch-tree-goto-and-insert-msg'
calls `notmuch-tree-show-message-in'.  `notmuch-tree-process-filter'
is what finally brings us here.
---
 emacs/notmuch-tree.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 13007a13..d9265fd5 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -949,7 +949,8 @@ (defun notmuch-tree-goto-and-insert-msg (msg)
   (goto-char (point-max))
   (forward-line -1)
   (when notmuch-tree-open-target
-   (notmuch-tree-show-message-in)
+   (notmuch-tree-show-message-in)
+   (notmuch-tree-command-hook)
 
 (defun notmuch-tree-insert-tree (tree depth tree-status first last)
   "Insert the message tree TREE at depth DEPTH in the current thread.
-- 
2.30.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH v2 00/36] [emacs] Add outline headings and switch to lexical scope

2021-01-13 Thread Jonas Bernoulli
David Bremner  writes:

> I pushed applied the first 22 patches to master.

Thanks!

> "[PATCH v2 23/36] emacs: various cosmetic improvements" leads to some
> test failures. FWIW, I'm using Emacs 27.1 on Debian testing.

Sorry about, it seems I did not rerun the tests after making the
responsible change.  It was a silly one character (well two) bug:

-  (pcase-lambda (`(,regexp ,folder))
+  (pcase-lambda (`(,regexp . ,folder))

I have send v3 of just that one commit (23).

 Jonas
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v3 23/36] emacs: various cosmetic improvements

2021-01-13 Thread Jonas Bernoulli
---
 emacs/notmuch-address.el | 22 --
 emacs/notmuch-hello.el   | 24 ---
 emacs/notmuch-jump.el|  4 +-
 emacs/notmuch-lib.el | 26 +--
 emacs/notmuch-maildir-fcc.el | 61 +++---
 emacs/notmuch-mua.el | 28 ++--
 emacs/notmuch-query.el   | 11 +++--
 emacs/notmuch-tag.el | 14 +++---
 emacs/notmuch.el | 83 ++--
 9 files changed, 125 insertions(+), 148 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 1017c3ce..2f0ec9b3 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -21,6 +21,8 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'cl-lib))
+
 (require 'message)
 (require 'notmuch-parser)
 (require 'notmuch-lib)
@@ -160,15 +162,12 @@ (defun notmuch-address-message-insinuate ()
   (message "calling notmuch-address-message-insinuate is no longer needed"))
 
 (defun notmuch-address-setup ()
-  (let* ((setup-company (and notmuch-address-use-company
-(require 'company nil t)))
-(pair (cons notmuch-address-completion-headers-regexp
-#'notmuch-address-expand-name)))
-(when setup-company
-  (notmuch-company-setup))
-(unless (member pair message-completion-alist)
-  (setq message-completion-alist
-   (push pair message-completion-alist)
+  (when (and notmuch-address-use-company
+(require 'company nil t))
+(notmuch-company-setup))
+  (cl-pushnew (cons notmuch-address-completion-headers-regexp
+   #'notmuch-address-expand-name)
+ message-completion-alist :test #'equal))
 
 (defun notmuch-address-toggle-internal-completion ()
   "Toggle use of internal completion for current buffer.
@@ -264,9 +263,6 @@ (defun notmuch-address-harvest-addr (result)
   (let ((name-addr (plist-get result :name-addr)))
 (puthash name-addr t notmuch-address-completions)))
 
-(defun notmuch-address-harvest-handle-result (obj)
-  (notmuch-address-harvest-addr obj))
-
 (defun notmuch-address-harvest-filter (proc string)
   (when (buffer-live-p (process-buffer proc))
 (with-current-buffer (process-buffer proc)
@@ -274,7 +270,7 @@ (defun notmuch-address-harvest-filter (proc string)
(goto-char (point-max))
(insert string))
   (notmuch-sexp-parse-partial-list
-   'notmuch-address-harvest-handle-result (process-buffer proc)
+   'notmuch-address-harvest-addr (process-buffer proc)
 
 (defvar notmuch-address-harvest-procs '(nil . nil)
   "The currently running harvests.
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index a134eb07..ffd3d799 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -432,8 +432,7 @@ (defun notmuch-hello-add-saved-search (widget  _event)
 ;; If an existing saved search with this name exists, remove it.
 (setq notmuch-saved-searches
  (cl-loop for elem in notmuch-saved-searches
-  if (not (equal name
- (notmuch-saved-search-get elem :name)))
+  unless (equal name (notmuch-saved-search-get elem :name))
   collect elem))
 ;; Add the new one.
 (customize-save-variable 'notmuch-saved-searches
@@ -481,18 +480,14 @@ (defun notmuch-hello-reflect (list ncols)
 append (notmuch-hello-reflect-generate-row ncols nrows row list
 
 (defun notmuch-hello-widget-search (widget  _ignore)
-  (cond
-   ((eq (widget-get widget :notmuch-search-type) 'tree)
-(notmuch-tree (widget-get widget
- :notmuch-search-terms)))
-   ((eq (widget-get widget :notmuch-search-type) 'unthreaded)
-(notmuch-unthreaded (widget-get widget
-   :notmuch-search-terms)))
+  (cl-case (widget-get widget :notmuch-search-type)
+   (tree
+(notmuch-tree (widget-get widget :notmuch-search-terms)))
+   (unthreaded
+(notmuch-unthreaded (widget-get widget :notmuch-search-terms)))
(t
-(notmuch-search (widget-get widget
-   :notmuch-search-terms)
-   (widget-get widget
-   :notmuch-search-oldest-first)
+(notmuch-search (widget-get widget :notmuch-search-terms)
+   (widget-get widget :notmuch-search-oldest-first)
 
 (defun notmuch-saved-search-count (search)
   (car (process-lines notmuch-command "count" search)))
@@ -823,8 +818,7 @@ (defun notmuch-hello-insert-search ()
   ;; instead of a space to make `show-trailing-whitespace'
   ;; happy, i.e. avoid it marking the whole line as trailing
   ;; spaces.
-  (widget-insert ".")
-  (put-text-property (1- (point)) (point) 'invisible t)
+  (widget-insert (propertize "." 'invisible t))
   (widget-insert "\n"))
 
 (defun notmuch-hello-insert-recent-searches ()
diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
index 51bc4e31..34d6c796 100644
--- 

Re: [PATCH 0/4] emacs: avoid type errors due to nil as content-type

2021-01-12 Thread Jonas Bernoulli
Tomi Ollila  writes:
> Note that messages 
>
> 20210110140112.25930-11-jo...@bernoul.li and
> 20210110140112.25930-12-jo...@bernoul.li
>
> have base64 -encoded content, with CRLF line endings
> so those don't apply as is, but CR's from the encoded
> content must be deleted.

Do you know why git would decide to send these commits that way?
Maybe we should try to keep it from doing that?  I didn't write
down the prompt but git actually asked something along the line
of "for these two messages you have to select the base64 encoding,
does utf-8 work for you?".

 Jonas
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 0/4] emacs: avoid type errors due to nil as content-type

2021-01-10 Thread Jonas Bernoulli
David Edmondson  writes:

> On Sunday, 2021-01-10 at 19:47:18 +01, Jonas Bernoulli wrote:
>
>> The fourth commit tries to address the issue raised in
>> id:87k0sxa6c3@fifthhorseman.net.
>>
>>   The output of "notmuch show --format=sexp --format-version=4"
>>   may contain `:content-type' entries with `nil' as the value,
>>   when it fails to detect the correct value.  Account for that
>>   in a few places where we would otherwise risk a type error.
>>
>> The other three commits cleanup the code I had to look at to do
>> the above, because I just can't help myself.
>>
>> This does not apply without first applying
>> id:20201214162401.19569-1-jo...@bernoul.li.
>
> I don't seem to have this one, but that could be a problem at my end.

I am sending you a copy of the original cover letter and
I have send v2 of the series earlier today, starting at
id:20210110140112.25930-1-jo...@bernoul.li.

> Anyway, for the series...
>
> Reviewed-by: David Edmondson 
>
>>
>>  Jonas
>>
>> Jonas Bernoulli (4):
>>   emacs: notmuch-mua-add-more-hidden-headers: use local binding
>>   emacs: notmuch-show--register-cids: fix names of bindings
>>   emacs: notmuch-show--get-cid-content: cosmetics
>>   emacs: avoid type errors due to nil as content-type
>>
>>  emacs/notmuch-lib.el  | 23 --
>>  emacs/notmuch-mua.el  |  7 +++
>>  emacs/notmuch-show.el | 46 +--
>>  3 files changed, 39 insertions(+), 37 deletions(-)
>>
>> -- 
>> 2.30.0
>> ___
>> notmuch mailing list -- notmuch@notmuchmail.org
>> To unsubscribe send an email to notmuch-le...@notmuchmail.org
>
> dme.
> -- 
> It was a perfectly good grand piano.
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 4/4] emacs: avoid type errors due to nil as content-type

2021-01-10 Thread Jonas Bernoulli
The output of "notmuch show --format=sexp --format-version=4"
may contain `:content-type' entries with `nil' as the value,
when it fails to detect the correct value.  Account for that
in a few places where we would otherwise risk a type error.

Note that `string=' does not choke on `nil' because it uses
the `symbol-name' when encountering a symbol.
---
 emacs/notmuch-lib.el  | 23 +--
 emacs/notmuch-show.el | 29 -
 2 files changed, 29 insertions(+), 23 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index bc550dc2..c7bb2091 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -552,16 +552,19 @@ (defun notmuch-plist-delete (plist property)
 ;;; MML Utilities
 
 (defun notmuch-match-content-type (t1 t2)
-  "Return t if t1 and t2 are matching content types, taking wildcards into 
account."
-  (let ((st1 (split-string t1 "/"))
-   (st2 (split-string t2 "/")))
-(if (or (string= (cadr st1) "*")
-   (string= (cadr st2) "*"))
-   ;; Comparison of content types should be case insensitive.
-   (string= (downcase (car st1))
-(downcase (car st2)))
-  (string= (downcase t1)
-  (downcase t2)
+  "Return t if t1 and t2 are matching content types.
+Take wildcards into account."
+  (and (stringp t1)
+   (stringp t2)
+   (let ((st1 (split-string t1 "/"))
+(st2 (split-string t2 "/")))
+(if (or (string= (cadr st1) "*")
+(string= (cadr st2) "*"))
+;; Comparison of content types should be case insensitive.
+(string= (downcase (car st1))
+ (downcase (car st2)))
+  (string= (downcase t1)
+   (downcase t2))
 
 (defvar notmuch-multipart/alternative-discouraged
   '(;; Avoid HTML parts.
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 8c846fb2..ba93febb 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -581,16 +581,17 @@ (defun notmuch-show--register-cids (msg part)
   ;; alternative (even if we can't render it).
   (push (list content-id msg part) notmuch-show--cids)))
   ;; Recurse on sub-parts
-  (pcase-let ((`(,type ,subtype)
-  (split-string (downcase (plist-get part :content-type)) "/")))
-(cond ((equal type "multipart")
-  (mapc (apply-partially #'notmuch-show--register-cids msg)
-(plist-get part :content)))
- ((and (equal type "message")
-   (equal subtype "rfc822"))
-  (notmuch-show--register-cids
-   msg
-   (car (plist-get (car (plist-get part :content)) :body)))
+  (when-let ((type (plist-get part :content-type)))
+(pcase-let ((`(,type ,subtype)
+(split-string (downcase type) "/")))
+  (cond ((equal type "multipart")
+(mapc (apply-partially #'notmuch-show--register-cids msg)
+  (plist-get part :content)))
+   ((and (equal type "message")
+ (equal subtype "rfc822"))
+(notmuch-show--register-cids
+ msg
+ (car (plist-get (car (plist-get part :content)) :body
 
 (defun notmuch-show--get-cid-content (cid)
   "Return a list (CID-content content-type) or nil.
@@ -948,7 +949,8 @@ (defun notmuch-show-lazy-part (part-args button)
 
 (defun notmuch-show-mime-type (part)
   "Return the correct mime-type to use for PART."
-  (let ((content-type (downcase (plist-get part :content-type
+  (when-let ((content-type (plist-get part :content-type)))
+(setq content-type (downcase content-type))
 (or (and (string= content-type "application/octet-stream")
 (notmuch-show-get-mime-type-of-application/octet-stream part))
(and (string= content-type "inline patch")
@@ -988,7 +990,7 @@ (defun notmuch-show-insert-bodypart (msg part depth 
 hide)
 HIDE determines whether to show or hide the part and the button
 as follows: If HIDE is nil, show the part and the button. If HIDE
 is t, hide the part initially and show the button."
-  (let* ((content-type (downcase (plist-get part :content-type)))
+  (let* ((content-type (plist-get part :content-type))
 (mime-type (notmuch-show-mime-type part))
 (nth (plist-get part :id))
 (long (and (notmuch-match-content-type mime-type "text/*")
@@ -1000,7 +1002,8 @@ (defun notmuch-show-insert-bodypart (msg part depth 
 hide)
 ;; the first (or only) part if this is text/plain.
 (button (and (funcall notmuch-show-insert-header-p-function part hide)
  (notmuch-show-insert-part-header
-  nth mime-type content-type
+  nth mime-type
+  (and content-type (downcase content-type))
   (plist-get part :filename
 ;; Hide the part initially if HIDE is t, or if it is too long
 ;; and we have a button to allow toggling.
-- 
2.30.0

[PATCH 3/4] emacs: notmuch-show--get-cid-content: cosmetics

2021-01-10 Thread Jonas Bernoulli
---
 emacs/notmuch-show.el | 17 +++--
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 21133611..8c846fb2 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -599,16 +599,13 @@ (defun notmuch-show--get-cid-content (cid)
 into the current buffer.  CID must be a raw content ID, without
 enclosing angle brackets, a cid: prefix, or URL encoding.  This
 will return nil if the CID is unknown or cannot be retrieved."
-  (let ((descriptor (cdr (assoc cid notmuch-show--cids
-(when descriptor
-  (let* ((msg (car descriptor))
-(part (cadr descriptor))
-;; Request caching for this content, as some messages
-;; reference the same cid: part many times (hundreds!).
-(content (notmuch-get-bodypart-binary
-  msg part notmuch-show-process-crypto 'cache))
-(content-type (plist-get part :content-type)))
-   (list content content-type)
+  (when-let ((descriptor (cdr (assoc cid notmuch-show--cids
+(pcase-let ((`(,msg ,part) descriptor))
+  ;; Request caching for this content, as some messages
+  ;; reference the same cid: part many times (hundreds!).
+  (list (notmuch-get-bodypart-binary
+msg part notmuch-show-process-crypto 'cache)
+   (plist-get part :content-type)
 
 (defun notmuch-show-setup-w3m ()
   "Instruct w3m how to retrieve content from a \"related\" part of a message."
-- 
2.30.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 2/4] emacs: notmuch-show--register-cids: fix names of bindings

2021-01-10 Thread Jonas Bernoulli
---
 emacs/notmuch-show.el | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index fdf4ab3c..21133611 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -581,13 +581,13 @@ (defun notmuch-show--register-cids (msg part)
   ;; alternative (even if we can't render it).
   (push (list content-id msg part) notmuch-show--cids)))
   ;; Recurse on sub-parts
-  (pcase-let ((`(,content ,type)
+  (pcase-let ((`(,type ,subtype)
   (split-string (downcase (plist-get part :content-type)) "/")))
-(cond ((equal content "multipart")
+(cond ((equal type "multipart")
   (mapc (apply-partially #'notmuch-show--register-cids msg)
 (plist-get part :content)))
- ((and (equal content "message")
-   (equal type "rfc822"))
+ ((and (equal type "message")
+   (equal subtype "rfc822"))
   (notmuch-show--register-cids
msg
(car (plist-get (car (plist-get part :content)) :body)))
-- 
2.30.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 1/4] emacs: notmuch-mua-add-more-hidden-headers: use local binding

2021-01-10 Thread Jonas Bernoulli
---
 emacs/notmuch-mua.el | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 08c73c16..bbf059a2 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -217,11 +217,10 @@ (defun notmuch-mua-add-more-hidden-headers ()
 (defun notmuch-mua-reply-crypto (parts)
   "Add mml sign-encrypt flag if any part of original message is encrypted."
   (cl-loop for part in parts
-  if (notmuch-match-content-type (plist-get part :content-type)
- "multipart/encrypted")
+  for type = (plist-get part :content-type)
+  if (notmuch-match-content-type type "multipart/encrypted")
   do (mml-secure-message-sign-encrypt)
-  else if (notmuch-match-content-type (plist-get part :content-type)
-  "multipart/*")
+  else if (notmuch-match-content-type type "multipart/*")
   do (notmuch-mua-reply-crypto (plist-get part :content
 
 ;; There is a bug in Emacs' message.el that results in a newline
-- 
2.30.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 0/4] emacs: avoid type errors due to nil as content-type

2021-01-10 Thread Jonas Bernoulli
The fourth commit tries to address the issue raised in
id:87k0sxa6c3@fifthhorseman.net.

  The output of "notmuch show --format=sexp --format-version=4"
  may contain `:content-type' entries with `nil' as the value,
  when it fails to detect the correct value.  Account for that
  in a few places where we would otherwise risk a type error.

The other three commits cleanup the code I had to look at to do
the above, because I just can't help myself.

This does not apply without first applying
id:20201214162401.19569-1-jo...@bernoul.li.

     Jonas

Jonas Bernoulli (4):
  emacs: notmuch-mua-add-more-hidden-headers: use local binding
  emacs: notmuch-show--register-cids: fix names of bindings
  emacs: notmuch-show--get-cid-content: cosmetics
  emacs: avoid type errors due to nil as content-type

 emacs/notmuch-lib.el  | 23 --
 emacs/notmuch-mua.el  |  7 +++
 emacs/notmuch-show.el | 46 +--
 3 files changed, 39 insertions(+), 37 deletions(-)

-- 
2.30.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] emacs/notmuch-show: Work around errors where a part lacks a content-type

2021-01-10 Thread Jonas Bernoulli
I accidentally responded off-list.  Here is (part of) Daniel's response
to that message:

On Wed 2021-01-06 18:48:09 +0100, Jonas Bernoulli wrote:
> Okay, I'll prepare a patch that does that.

Thanks!

> I wasn't so much worried having to deal with this in multiple places in
> elisp--that's quite manageable--but about all the other front-ends that
> will also have to discover and address this issue over time.

yep, makes sense.  This might well be a "both and" situation instead of
an "either or".
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 36/36] emacs: notmuch-address-expand-name: use the actual initial-input

2021-01-10 Thread Jonas Bernoulli
Users may type some text into the buffer on an address line, before
actually invoking address completion.  We now use that text as the
initial input when we begin address completion.

Previously we did knowingly replace the actual initial input with some
completion candidate that happens to match. Which candidate is used is
essentially random, at least when the actual initial input is short.
As a result users very often had to begin completion by deleting the
less than helpful "initial input".
---
 emacs/notmuch-address.el | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 6e136473..f0af6667 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -244,14 +244,8 @@ (defun notmuch-address-expand-name ()
(t
 (funcall notmuch-address-selection-function
  (format "Address (%s matches): " num-options)
- ;; We put the first match as the initial
- ;; input; we put all the matches as
- ;; possible completions, moving the
- ;; first match to the end of the list
- ;; makes cursor up/down in the list work
- ;; better.
- (append (cdr options) (list (car options)))
- (car options))
+ options
+ orig)
   (if chosen
  (progn
(push chosen notmuch-address-history)
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 35/36] emacs: allow opting out of notmuch's address completion

2021-01-10 Thread Jonas Bernoulli
IMO Notmuch should not override the default completion mechanism by
default, at least not globally. But since users are already used to
this behavior it is probably too late to change it. Do the next best
thing and at least allow users to opt out.
---
 emacs/notmuch-address.el | 48 +++-
 1 file changed, 28 insertions(+), 20 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index ca24c744..6e136473 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -54,21 +54,28 @@ (defun notmuch-address--harvest-ready ()
 (defcustom notmuch-address-command 'internal
   "Determines how address completion candidates are generated.
 
-If it is a string then that string should be an external program
-which must take a single argument (searched string) and output a
-list of completion candidates, one per line.
-
-Alternatively, it can be the symbol `internal', in which case
-internal completion is used; the variable
-`notmuch-address-internal-completion' can be used to customize
-this case.
-
-Finally, if this variable is nil then address completion is
-disabled."
+If this is a string, then that string should be an external
+program, which must take a single argument (searched string)
+and output a list of completion candidates, one per line.
+
+If this is the symbol `internal', then an implementation is used
+that relies on the \"notmuch address\" command, but does not use
+any third-party (i.e. \"external\") programs.
+
+If this is the symbol `as-is', then Notmuch does not modify the
+value of `message-completion-alist'. This option has to be set to
+this value before `notmuch' is loaded, otherwise the modification
+to `message-completion-alist' may already have taken place. This
+setting obviously does not prevent `message-completion-alist'
+from being modified at all; the user or some third-party package
+may still modify it.
+
+Finally, if this is nil, then address completion is disabled."
   :type '(radio
- (const :tag "Use internal address completion" internal)
- (const :tag "Disable address completion" nil)
- (string :tag "Use external completion command"))
+ (const  :tag "Use internal address completion" internal)
+ (string :tag "Use external completion command")
+ (const  :tag "Disable address completion" nil)
+ (const  :tag "Use default or third-party mechanism" as-is))
   :group 'notmuch-send
   :group 'notmuch-address
   :group 'notmuch-external)
@@ -160,12 +167,13 @@ (defun notmuch-address-message-insinuate ()
   (message "calling notmuch-address-message-insinuate is no longer needed"))
 
 (defun notmuch-address-setup ()
-  (when (and notmuch-address-use-company
-(require 'company nil t))
-(notmuch-company-setup))
-  (cl-pushnew (cons notmuch-address-completion-headers-regexp
-   #'notmuch-address-expand-name)
- message-completion-alist :test #'equal))
+  (unless (eq notmuch-address-command 'as-is)
+(when (and notmuch-address-use-company
+  (require 'company nil t))
+  (notmuch-company-setup))
+(cl-pushnew (cons notmuch-address-completion-headers-regexp
+ #'notmuch-address-expand-name)
+   message-completion-alist :test #'equal)))
 
 (defun notmuch-address-toggle-internal-completion ()
   "Toggle use of internal completion for current buffer.
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 34/36] emacs: notmuch-tree-get-match: No longer define as command

2021-01-10 Thread Jonas Bernoulli
When called from code, then this function returns non-nil when the
message at point is a matched message.  However it does nothing at all
to present that information to the user when it called interactively.
It is therefore safe to conclude that nobody is using this as a
command.
---
 emacs/notmuch-tree.el | 1 -
 1 file changed, 1 deletion(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 95d5f642..13007a13 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -421,7 +421,6 @@ (defun notmuch-tree-get-message-id ( bare)
 
 (defun notmuch-tree-get-match ()
   "Return whether the current message is a match."
-  (interactive)
   (notmuch-tree-get-prop :match))
 
 ;;; Update display
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 30/36] emacs: avoid unnecessary let-bindings

2021-01-10 Thread Jonas Bernoulli
To some extend this is a personal preference, but the preference is
strongly dependent on whether one is used to a language that makes it
necessary to use variables like this.

This makes it perfectly clear that we are first getting and then using
a "foo":

  (use-foo (get-foo))

Sure this has to be read "inside out", but that's something one better
gets used to quickly when dealing with lisp.  I don't understand why
one would want to write this instead:

  (let ((the-foo (get-foo)))
(use-foo the-foo))

Both `get-foo' and `use-foo' are named in a way that make it very
clear that we are dealing with a "foo".  Storing the value in an
additional variable `the-foo' does not make this any more clear.

On the contrary I makes the reader wonder why the author choose to
use a variable.  Is the value used more than once?  Is the value
being retrieved in one context and then used in another (e.g. when
the current buffer changes)?
---
 emacs/notmuch-address.el |  4 +--
 emacs/notmuch-lib.el |  6 ++---
 emacs/notmuch-maildir-fcc.el | 10 
 emacs/notmuch-show.el| 14 +-
 emacs/notmuch-tag.el | 10 
 emacs/notmuch-tree.el|  5 ++--
 emacs/notmuch.el | 50 +---
 7 files changed, 48 insertions(+), 51 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 1f22e377..f313c415 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -260,8 +260,8 @@ (defun notmuch-address-expand-name ()
 ;;; Harvest
 
 (defun notmuch-address-harvest-addr (result)
-  (let ((name-addr (plist-get result :name-addr)))
-(puthash name-addr t notmuch-address-completions)))
+  (puthash (plist-get result :name-addr)
+  t notmuch-address-completions))
 
 (defun notmuch-address-harvest-filter (proc string)
   (when (buffer-live-p (process-buffer proc))
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 2fd9a27d..cbac8859 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -416,9 +416,9 @@ (defun notmuch-help ()
 its prefixed behavior by setting the 'notmuch-prefix-doc property
 of its command symbol."
   (interactive)
-  (let* ((mode major-mode)
-(doc (substitute-command-keys
-  (notmuch-substitute-command-keys (documentation mode t)
+  (let ((doc (substitute-command-keys
+ (notmuch-substitute-command-keys
+  (documentation major-mode t)
 (with-current-buffer (generate-new-buffer "*notmuch-help*")
   (insert doc)
   (goto-char (point-min))
diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el
index efbb37f1..63e5514c 100644
--- a/emacs/notmuch-maildir-fcc.el
+++ b/emacs/notmuch-maildir-fcc.el
@@ -207,11 +207,11 @@ (defun notmuch-maildir-notmuch-insert-current-buffer 
(folder  create ta
 database in folder FOLDER. If CREATE is non-nil it will supply
 the --create-folder flag to create the folder if necessary. TAGS
 should be a list of tag changes to apply to the inserted message."
-  (let* ((args (append (and create (list "--create-folder"))
-  (list (concat "--folder=" folder))
-  tags)))
-(apply 'notmuch-call-notmuch-process
-  :stdin-string (buffer-string) "insert" args)))
+  (apply 'notmuch-call-notmuch-process
+:stdin-string (buffer-string) "insert"
+(append (and create (list "--create-folder"))
+(list (concat "--folder=" folder))
+tags)))
 
 (defun notmuch-maildir-fcc-with-notmuch-insert (fcc-header  create)
   "Store message with notmuch insert.
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 48374b38..27925669 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1666,13 +1666,13 @@ (defun notmuch-show-get-prop (prop  props)
 message in either tree or show. This means that several utility
 functions in notmuch-show can be used directly by notmuch-tree as
 they just need the correct message properties."
-  (let ((props (or props
-  (cond ((eq major-mode 'notmuch-show-mode)
- (notmuch-show-get-message-properties))
-((eq major-mode 'notmuch-tree-mode)
- (notmuch-tree-get-message-properties))
-(t nil)
-(plist-get props prop)))
+  (plist-get (or props
+(cond ((eq major-mode 'notmuch-show-mode)
+   (notmuch-show-get-message-properties))
+  ((eq major-mode 'notmuch-tree-mode)
+   (notmuch-tree-get-message-properties))
+  (t nil)))
+prop))
 
 (defun notmuch-show-get-message-id ( bare)
   "Return an id: query for the Message-Id of the current message.
diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
index c006026c..3c958dd4 100644
--- a/emacs/notmuch-tag.el
+++ b/emacs/notmuch-tag.el
@@ -406,8 +406,9 @@ (defun notmuch-tag-completions 

[PATCH v2 31/36] emacs: improve how cl-lib and pcase are required

2021-01-10 Thread Jonas Bernoulli
We need to load `cl-lib' at run-time because we use more from it than
just macros.  Never-the-less many, but not all libraries required it
only at compile-time, which we got away with because at least some
libraries already required it at run-time as well.

We use `cl-lib' and (currently to a lesser extend) `pcase' throughout
the code-base, which means that we should require these features in
most libraries.

In the past we tried to only require these features in just the
libraries that actually need them, without fully succeeding.  We did
not succeed in doing so because that means we would have to check
every time that we use a function from these features whether they
are already being required in the current library.

An alternative would be to add the `require' forms at the top of every
library but that is a bit annoying too.

In order to make sure that these features are loaded when needed but
also to keep the noise down we only require them in "notmuch-lib.el",
which most other libraries require, and in most of the few libraries
that do not do so, namely "notmuch-draft.el", "notmuch-message.el" and
"notmuch-parser.el".  ("coolj.el", "make-deps.el", various generated
libraries, and "notmuch-compat.el" are left touched.)
---
 emacs/notmuch-address.el | 2 --
 emacs/notmuch-company.el | 2 --
 emacs/notmuch-draft.el   | 3 +++
 emacs/notmuch-hello.el   | 1 -
 emacs/notmuch-jump.el| 4 
 emacs/notmuch-lib.el | 1 +
 emacs/notmuch-maildir-fcc.el | 2 --
 emacs/notmuch-message.el | 3 +++
 emacs/notmuch-mua.el | 2 --
 emacs/notmuch-parser.el  | 3 ++-
 emacs/notmuch-show.el| 4 
 emacs/notmuch-tag.el | 4 
 emacs/notmuch-tree.el| 2 --
 emacs/notmuch.el | 2 --
 14 files changed, 9 insertions(+), 26 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index f313c415..ca24c744 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -21,8 +21,6 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl-lib))
-
 (require 'message)
 (require 'notmuch-parser)
 (require 'notmuch-lib)
diff --git a/emacs/notmuch-company.el b/emacs/notmuch-company.el
index 4439cc15..c6a004ae 100644
--- a/emacs/notmuch-company.el
+++ b/emacs/notmuch-company.el
@@ -32,8 +32,6 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl-lib))
-
 (require 'notmuch-lib)
 
 (defvar-local notmuch-company-last-prefix nil)
diff --git a/emacs/notmuch-draft.el b/emacs/notmuch-draft.el
index bc688434..2939da55 100644
--- a/emacs/notmuch-draft.el
+++ b/emacs/notmuch-draft.el
@@ -25,6 +25,9 @@
 
 ;;; Code:
 
+(require 'cl-lib)
+(require 'pcase)
+
 (require 'notmuch-maildir-fcc)
 (require 'notmuch-tag)
 
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 186ac172..24d2d19e 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -21,7 +21,6 @@
 
 ;;; Code:
 
-(require 'cl-lib)
 (require 'widget)
 (require 'wid-edit) ; For `widget-forward'.
 
diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
index 34d6c796..6fab5a79 100644
--- a/emacs/notmuch-jump.el
+++ b/emacs/notmuch-jump.el
@@ -22,10 +22,6 @@
 
 ;;; Code:
 
-(eval-when-compile
-  (require 'cl-lib)
-  (require 'pcase))
-
 (require 'notmuch-lib)
 (require 'notmuch-hello)
 
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index cbac8859..6130309a 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -22,6 +22,7 @@
 ;;; Code:
 
 (require 'cl-lib)
+(require 'pcase)
 
 (require 'mm-util)
 (require 'mm-view)
diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el
index 63e5514c..374765b7 100644
--- a/emacs/notmuch-maildir-fcc.el
+++ b/emacs/notmuch-maildir-fcc.el
@@ -21,8 +21,6 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl-lib))
-
 (require 'message)
 
 (require 'notmuch-lib)
diff --git a/emacs/notmuch-message.el b/emacs/notmuch-message.el
index abeff53a..b90c934a 100644
--- a/emacs/notmuch-message.el
+++ b/emacs/notmuch-message.el
@@ -21,6 +21,9 @@
 
 ;;; Code:
 
+(require 'cl-lib)
+(require 'pcase)
+
 (require 'message)
 (require 'notmuch-tag)
 
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 2e4dc71a..c5b1b482 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -21,8 +21,6 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl-lib))
-
 (require 'message)
 (require 'mm-view)
 (require 'format-spec)
diff --git a/emacs/notmuch-parser.el b/emacs/notmuch-parser.el
index 294e0544..9749a6be 100644
--- a/emacs/notmuch-parser.el
+++ b/emacs/notmuch-parser.el
@@ -21,7 +21,8 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl-lib))
+(require 'cl-lib)
+(require 'pcase)
 
 (defun notmuch-sexp-create-parser ()
   "Return a new streaming S-expression parser.
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 27925669..eae5 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -23,10 +23,6 @@
 
 ;;; Code:
 
-(eval-when-compile
-  (require 'cl-lib)
-  (require 'pcase))
-
 (require 

[PATCH v2 33/36] emacs: use string-empty-p

2021-01-10 Thread Jonas Bernoulli
---
 emacs/notmuch-lib.el  | 2 +-
 emacs/notmuch-mua.el  | 2 +-
 emacs/notmuch-show.el | 4 ++--
 emacs/notmuch-tag.el  | 2 +-
 emacs/notmuch.el  | 4 ++--
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 05d3be10..bc550dc2 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -285,7 +285,7 @@ (defun notmuch-poll ()
   (interactive)
   (message "Polling mail...")
   (if (stringp notmuch-poll-script)
-  (unless (string= notmuch-poll-script "")
+  (unless (string-empty-p notmuch-poll-script)
(unless (equal (call-process notmuch-poll-script nil nil) 0)
  (error "Notmuch: poll script `%s' failed!" notmuch-poll-script)))
 (notmuch-call-notmuch-process "new"))
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index c5b1b482..08c73c16 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -388,7 +388,7 @@ (defun notmuch-mua-mail ( to subject other-headers 
_continue
   (interactive)
   (when notmuch-mua-user-agent-function
 (let ((user-agent (funcall notmuch-mua-user-agent-function)))
-  (unless (string= "" user-agent)
+  (unless (string-empty-p user-agent)
(push (cons 'User-Agent user-agent) other-headers
   (unless (assq 'From other-headers)
 (push (cons 'From (message-make-from
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index eae5..fdf4ab3c 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -333,7 +333,7 @@ (defun notmuch-show-with-message-as-text (fn)
 (header (concat
  "Subject: " subject "\n"
  "To: " to "\n"
- (if (not (string= cc ""))
+ (if (not (string-empty-p cc))
  (concat "Cc: " cc "\n")
"")
  "From: " from "\n"
@@ -1790,7 +1790,7 @@ (defun notmuch-show-filter-thread (query)
 Reshows the current thread with matches defined by the new query-string."
   (interactive (list (notmuch-read-query "Filter thread: ")))
   (let ((msg-id (notmuch-show-get-message-id)))
-(setq notmuch-show-query-context (if (string= query "") nil query))
+(setq notmuch-show-query-context (if (string-empty-p query) nil query))
 (notmuch-show-refresh-view t)
 (notmuch-show-goto-message msg-id)))
 
diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
index 982b372c..f348d4ae 100644
--- a/emacs/notmuch-tag.el
+++ b/emacs/notmuch-tag.el
@@ -452,7 +452,7 @@ (defun notmuch-update-tags (tags tag-changes)
 from TAGS if present."
   (let ((result-tags (copy-sequence tags)))
 (dolist (tag-change tag-changes)
-  (let ((tag (and (not (string= tag-change ""))
+  (let ((tag (and (not (string-empty-p tag-change))
  (substring tag-change 1
(cl-case (aref tag-change 0)
  (?+ (unless (member tag result-tags)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index d2e87b1b..26efcccd 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -814,13 +814,13 @@ (defun notmuch-search-insert-authors (format-string 
authors)
(setq invisible-string (notmuch-search-author-propertize 
invisible-string)))
   ;; If there is any invisible text, add it as a tooltip to the
   ;; visible text.
-  (unless (string= invisible-string "")
+  (unless (string-empty-p invisible-string)
(setq visible-string
  (propertize visible-string
  'help-echo (concat "..." invisible-string
   ;; Insert the visible and, if present, invisible author strings.
   (insert visible-string)
-  (unless (string= invisible-string "")
+  (unless (string-empty-p invisible-string)
(let ((start (point))
  overlay)
  (insert invisible-string)
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 29/36] emacs: reorder notmuch.el a bit

2021-01-10 Thread Jonas Bernoulli
---
 emacs/notmuch.el | 41 -
 1 file changed, 20 insertions(+), 21 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 481a0e0a..40b730df 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -70,6 +70,8 @@ (eval-when-compile (require 'cl-lib))
 (require 'mm-view)
 (require 'message)
 
+(require 'hl-line)
+
 (require 'notmuch-lib)
 (require 'notmuch-tag)
 (require 'notmuch-show)
@@ -114,8 +116,12 @@ (defcustom notmuch-init-file (locate-user-emacs-file 
"notmuch-config")
   :type 'file
   :group 'notmuch)
 
-(defvar notmuch-query-history nil
-  "Variable to store minibuffer history for notmuch queries.")
+(defcustom notmuch-search-hook '(notmuch-hl-line-mode)
+  "List of functions to call when notmuch displays the search results."
+  :type 'hook
+  :options '(notmuch-hl-line-mode)
+  :group 'notmuch-search
+  :group 'notmuch-hooks)
 
 ;;; Mime Utilities
 
@@ -155,24 +161,6 @@ (defun notmuch-save-attachments (mm-handle  
queryp)
(mm-save-part p
mm-handle))
 
-;;; Integrations
-
-(require 'hl-line)
-
-(defun notmuch-hl-line-mode ()
-  (prog1 (hl-line-mode)
-(when hl-line-overlay
-  (overlay-put hl-line-overlay 'priority 1
-
-;;; Options
-
-(defcustom notmuch-search-hook '(notmuch-hl-line-mode)
-  "List of functions to call when notmuch displays the search results."
-  :type 'hook
-  :options '(notmuch-hl-line-mode)
-  :group 'notmuch-search
-  :group 'notmuch-hooks)
-
 ;;; Keymap
 
 (defvar notmuch-search-mode-map
@@ -207,6 +195,9 @@ (defvar notmuch-search-mode-map
 
 ;;; Internal Variables
 
+(defvar notmuch-query-history nil
+  "Variable to store minibuffer history for notmuch queries.")
+
 (defvar-local notmuch-search-query-string nil)
 (defvar-local notmuch-search-target-thread nil)
 (defvar-local notmuch-search-target-line nil)
@@ -1150,7 +1141,15 @@ (defun notmuch-cycle-notmuch-buffers ()
  (pop-to-buffer-same-window first))
   (notmuch
 
-;;; Imenu Support
+;;; Integrations
+ Hl-line Support
+
+(defun notmuch-hl-line-mode ()
+  (prog1 (hl-line-mode)
+(when hl-line-overlay
+  (overlay-put hl-line-overlay 'priority 1
+
+ Imenu Support
 
 (defun notmuch-search-imenu-prev-index-position-function ()
   "Move point to previous message in notmuch-search buffer.
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 26/36] emacs: remove variable notmuch-search-disjunctive-regexp

2021-01-10 Thread Jonas Bernoulli
The value is the only possible value, it is only used in one
place, and using a global variable serves no purpose but to
make things more complicated.
---
 emacs/notmuch.el | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index f8c97c5d..ccece811 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -232,8 +232,6 @@ (defvar notmuch-search-query-string)
 (defvar notmuch-search-target-thread)
 (defvar notmuch-search-target-line)
 
-(defvar notmuch-search-disjunctive-regexp "\\<[oO][rR]\\>")
-
 ;;; Movement
 
 (defun notmuch-search-scroll-up ()
@@ -1079,10 +1077,8 @@ (defun notmuch-search-toggle-order ()
 
 (defun notmuch-group-disjunctive-query-string (query-string)
   "Group query if it contains a complex expression.
-
-Enclose QUERY-STRING in parentheses if it matches
-`notmuch-search-disjunctive-regexp'."
-  (if (string-match-p notmuch-search-disjunctive-regexp query-string)
+Enclose QUERY-STRING in parentheses if contains \"OR\" operators."
+  (if (string-match-p "\\<[oO][rR]\\>" query-string)
   (concat "( " query-string " )")
 query-string))
 
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 32/36] emacs: make subr-x available in all libraries

2021-01-10 Thread Jonas Bernoulli
Like `cl-lib' and `pcase', which are already available in all
libraries, `subr-x' also provided many useful functions that
we would like to use.

Making `subr-x' available in every library from the get-go means
that we can use the functions it defines without having to double
check every single time, whether the feature is already available
in the current library.
---
 emacs/notmuch-draft.el   | 1 +
 emacs/notmuch-lib.el | 1 +
 emacs/notmuch-message.el | 1 +
 emacs/notmuch-parser.el  | 1 +
 4 files changed, 4 insertions(+)

diff --git a/emacs/notmuch-draft.el b/emacs/notmuch-draft.el
index 2939da55..a68b7d8d 100644
--- a/emacs/notmuch-draft.el
+++ b/emacs/notmuch-draft.el
@@ -27,6 +27,7 @@
 
 (require 'cl-lib)
 (require 'pcase)
+(require 'subr-x)
 
 (require 'notmuch-maildir-fcc)
 (require 'notmuch-tag)
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 6130309a..05d3be10 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -23,6 +23,7 @@
 
 (require 'cl-lib)
 (require 'pcase)
+(require 'subr-x)
 
 (require 'mm-util)
 (require 'mm-view)
diff --git a/emacs/notmuch-message.el b/emacs/notmuch-message.el
index b90c934a..0856a2e9 100644
--- a/emacs/notmuch-message.el
+++ b/emacs/notmuch-message.el
@@ -23,6 +23,7 @@
 
 (require 'cl-lib)
 (require 'pcase)
+(require 'subr-x)
 
 (require 'message)
 (require 'notmuch-tag)
diff --git a/emacs/notmuch-parser.el b/emacs/notmuch-parser.el
index 9749a6be..f04b07c2 100644
--- a/emacs/notmuch-parser.el
+++ b/emacs/notmuch-parser.el
@@ -23,6 +23,7 @@
 
 (require 'cl-lib)
 (require 'pcase)
+(require 'subr-x)
 
 (defun notmuch-sexp-create-parser ()
   "Return a new streaming S-expression parser.
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 10/36] emacs: make headings outline-minor-mode compatible

2021-01-10 Thread Jonas Bernoulli
`outline-minor-mode' treats comments that begin with three or more
semicolons as headings.  That makes it very convenient to navigate
code and to show/hide parts of a file.

Elips libraries typically have four top-level sections, e.g.:

;;; notmuch.el --- run notmuch within emacs...
;;; Commentary:...
;;; Code:...
;;; notmuch.el ends here

In this package many libraries lack a "Commentary:" section, which is
not optimal but okay for most libraries, except major entry points.

Depending on how one chooses to look at it, the "... ends here" line
is not really a heading that begins a section, because it should never
have a "section" body (after all it marks eof).

If the file is rather short, then I left "Code:" as the only section
that contains code.  Otherwise I split the file into multiple sibling
sections.  The "Code:" section continues to contain `require' and
`declare-function' forms and other such "front matter".

If and only if I have split the code into multiple sections anyway,
then I also added an additional section named just "_" before the
`provide' form and shortly before the "...end here" line.  This
section could also be called "Back matter", but I feel it would be
distracting to be that explicit about it.  (The IMO unnecessary but
unfortunately still obligatory "... ends here" line is already
distracting enough as far as I am concerned.)

Before this commit some libraries already uses section headings, some
of them consistently.  When a library already had some headings, then
this commit often sticks to that style, even at the cost inconsistent
styling across all libraries.

A very limited number of variable and function definitions have to be
moved around because they would otherwise end up in sections they do
not belong into.

Sections, including but not limited to their heading, can and should
be further improved in the future.
---
 emacs/coolj.el   | 12 +++
 emacs/notmuch-address.el | 28 +++-
 emacs/notmuch-company.el |  1 -
 emacs/notmuch-compat.el  |  2 --
 emacs/notmuch-crypto.el  |  8 -
 emacs/notmuch-draft.el   |  9 -
 emacs/notmuch-hello.el   | 47 ++
 emacs/notmuch-jump.el|  2 --
 emacs/notmuch-lib.el | 41 ++-
 emacs/notmuch-maildir-fcc.el | 18 +-
 emacs/notmuch-mua.el | 18 +++---
 emacs/notmuch-print.el   |  8 +++--
 emacs/notmuch-query.el   |  8 ++---
 emacs/notmuch-show.el| 64 ++--
 emacs/notmuch-tag.el | 16 -
 emacs/notmuch-tree.el| 25 +++---
 emacs/notmuch-wash.el| 18 +-
 emacs/notmuch.el | 32 +-
 test/test-lib.el |  4 ++-
 19 files changed, 263 insertions(+), 98 deletions(-)

diff --git a/emacs/coolj.el b/emacs/coolj.el
index 0385872f..b3e314f0 100644
--- a/emacs/coolj.el
+++ b/emacs/coolj.el
@@ -25,13 +25,13 @@
 
 ;;; Commentary:
 
-;;; This is a simple derivative of some functionality from
-;;; `longlines.el'. The key difference is that this version will
-;;; insert a prefix at the head of each wrapped line. The prefix is
-;;; calculated from the originating long line.
+;; This is a simple derivative of some functionality from
+;; `longlines.el'. The key difference is that this version will
+;; insert a prefix at the head of each wrapped line. The prefix is
+;; calculated from the originating long line.
 
-;;; No minor-mode is provided, the caller is expected to call
-;;; `coolj-wrap-region' to wrap the region of interest.
+;; No minor-mode is provided, the caller is expected to call
+;; `coolj-wrap-region' to wrap the region of interest.
 
 ;;; Code:
 
diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 71985ed7..bf29c3a0 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -25,9 +25,11 @@ (require 'message)
 (require 'notmuch-parser)
 (require 'notmuch-lib)
 (require 'notmuch-company)
-;;
+
 (declare-function company-manual-begin "company")
 
+;;; Cache internals
+
 (defvar notmuch-address-last-harvest 0
   "Time of last address harvest.")
 
@@ -47,6 +49,8 @@ (defun notmuch-address--harvest-ready ()
   (or notmuch-address-full-harvest-finished
   (notmuch-address--load-address-hash)))
 
+;;; Options
+
 (defcustom notmuch-address-command 'internal
   "Determines how address completion candidates are generated.
 
@@ -133,6 +137,14 @@ (defcustom notmuch-address-post-completion-functions nil
   :group 'notmuch-address
   :group 'notmuch-hooks)
 
+(defcustom notmuch-address-use-company t
+  "If available, use company mode for address completion."
+  :type 'boolean
+  :group 'notmuch-send
+  :group 'notmuch-address)
+
+;;; Setup
+
 (defun notmuch-address-selection-function (prompt collection initial-input)
   "Call (`completing-read'
   PROMPT COLLECTION nil nil INITIAL-INPUT 'notmuch-address-history)"
@@ -147,12 +159,6 @@ (defvar notmuch-address-history nil)
 

[PATCH v2 25/36] emacs: various doc-string improvements

2021-01-10 Thread Jonas Bernoulli
---
 emacs/notmuch-draft.el   | 12 ++-
 emacs/notmuch-maildir-fcc.el | 21 +-
 emacs/notmuch-mua.el |  9 
 emacs/notmuch-tag.el | 41 ++--
 emacs/notmuch-tree.el| 10 -
 emacs/notmuch.el | 24 ++---
 6 files changed, 59 insertions(+), 58 deletions(-)

diff --git a/emacs/notmuch-draft.el b/emacs/notmuch-draft.el
index 8af04598..bc688434 100644
--- a/emacs/notmuch-draft.el
+++ b/emacs/notmuch-draft.el
@@ -77,9 +77,11 @@ (defcustom notmuch-draft-quoted-tags '()
   :group 'notmuch-send)
 
 (defcustom notmuch-draft-save-plaintext 'ask
-  "Should notmuch save/postpone in plaintext messages that seem
-like they are intended to be sent encrypted
-(i.e with an mml encryption tag in it)."
+  "Whether to allow saving plaintext when it seems encryption is intended.
+When a message contains mml tags, then that suggest it is
+intended to be encrypted.  If the user requests that such a
+message is saved locally, then this option controls whether
+that is allowed.  Beside a boolean, this can also be `ask'."
   :type '(radio
  (const :tag "Never" nil)
  (const :tag "Ask every time" ask)
@@ -146,13 +148,13 @@ (defun notmuch-draft-unquote-some-mml ()
(insert secure-tag "\n")
 
 (defun notmuch-draft--has-encryption-tag ()
-  "Returns t if there is an mml secure tag."
+  "Return non-nil if there is an mml secure tag."
   (save-excursion
 (message-goto-body)
 (re-search-forward notmuch-draft-encryption-tag-regex nil t)))
 
 (defun notmuch-draft--query-encryption ()
-  "Checks if we should save a message that should be encrypted.
+  "Return non-nil if we should save a message that should be encrypted.
 
 `notmuch-draft-save-plaintext' controls the behaviour."
   (cl-case notmuch-draft-save-plaintext
diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el
index b3c2570e..efbb37f1 100644
--- a/emacs/notmuch-maildir-fcc.el
+++ b/emacs/notmuch-maildir-fcc.el
@@ -90,10 +90,8 @@ (defcustom notmuch-maildir-use-notmuch-insert t
 (defun notmuch-fcc-header-setup ()
   "Add an Fcc header to the current message buffer.
 
-Sets the Fcc header based on the values of `notmuch-fcc-dirs'.
-
-Originally intended to be use a hook function, but now called directly
-by notmuch-mua-mail."
+If the Fcc header is already set, then keep it as-is.
+Otherwise set it according to `notmuch-fcc-dirs'."
   (let ((subdir
 (cond
  ((or (not notmuch-fcc-dirs)
@@ -153,8 +151,9 @@ (defmacro with-temporary-notmuch-message-buffer ( body)
,@body)))
 
 (defun notmuch-maildir-setup-message-for-saving ()
-  "Setup message for saving. Should be called on a temporary copy.
+  "Setup message for saving.
 
+This should be called on a temporary copy.
 This is taken from the function message-do-fcc."
   (message-encode-message-body)
   (save-restriction
@@ -308,8 +307,8 @@ (defun notmuch-maildir-fcc-move-tmp-to-cur (destdir msg-id 
 mark-seen)
 (defun notmuch-maildir-fcc-file-fcc (fcc-header)
   "Write the message to the file specified by FCC-HEADER.
 
-It offers the user a chance to correct the header, or filesystem,
-if needed."
+If that fails, then offer the user a chance to correct the header
+or filesystem."
   (if (notmuch-maildir-fcc-dir-is-maildir-p fcc-header)
   (notmuch-maildir-fcc-write-buffer-to-maildir fcc-header t)
 ;; The fcc-header is not a valid maildir see if the user wants to
@@ -329,9 +328,11 @@ (defun notmuch-maildir-fcc-file-fcc (fcc-header)
 (read-from-minibuffer "Fcc header: " fcc-header)))
 
 (defun notmuch-maildir-fcc-write-buffer-to-maildir (destdir  
mark-seen)
-  "Writes the current buffer to maildir destdir. If mark-seen is
-non-nil, it will write it to cur/, and mark it as read. It should
-return t if successful, and nil otherwise."
+  "Write the current buffer to maildir destdir.
+
+If mark-seen is non-nil, then write it to \"cur/\", and mark it
+as read, otherwise write it to \"new/\". Return t if successful,
+and nil otherwise."
   (let ((orig-buffer (buffer-name)))
 (with-temp-buffer
   (insert-buffer-substring orig-buffer)
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 4a08e8a7..2e4dc71a 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -99,7 +99,7 @@ (defcustom notmuch-always-prompt-for-sender nil
   :group 'notmuch-send)
 
 (defgroup notmuch-reply nil
-  "Replying to messages in notmuch"
+  "Replying to messages in notmuch."
   :group 'notmuch)
 
 (defcustom notmuch-mua-cite-function 'message-cite-original
@@ -144,9 +144,10 @@ (defcustom notmuch-mua-attachment-regexp
 ;;; Various functions
 
 (defun notmuch-mua-attachment-check ()
-  "Signal an error if the message text indicates that an
-attachment is expected but no MML referencing an attachment is
-found.
+  "Signal an error an attachement is expected but missing.
+
+Signal an error if the message text indicates that an 

[PATCH v2 24/36] emacs: various comment improvements

2021-01-10 Thread Jonas Bernoulli
---
 emacs/notmuch-address.el | 5 ++---
 emacs/notmuch-hello.el   | 4 +---
 emacs/notmuch-lib.el | 6 +++---
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 2f0ec9b3..1f22e377 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -381,7 +381,7 @@ (defun notmuch-address--load-address-hash ()
 (defun notmuch-address--save-address-hash ()
   (when notmuch-address-save-filename
 (if (or (not (file-exists-p notmuch-address-save-filename))
-   ;; The file exists, check it is a file we saved
+   ;; The file exists, check it is a file we saved.
(notmuch-address--get-address-hash))
(with-temp-file notmuch-address-save-filename
  (let ((save-plist
@@ -404,8 +404,7 @@ (defun notmuch-address-harvest-trigger ()
nil nil
(lambda (_proc event)
 ;; If harvest fails, we want to try
-;; again when the trigger is next
-;; called
+;; again when the trigger is next called.
 (if (string= event "finished\n")
 (progn
   (notmuch-address--save-address-hash)
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index ffd3d799..186ac172 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -731,9 +731,7 @@ (define-derived-mode notmuch-hello-mode fundamental-mode 
"notmuch-hello"
 Complete list of currently available key bindings:
 
 \\{notmuch-hello-mode-map}"
-  (setq notmuch-buffer-refresh-function #'notmuch-hello-update)
-  ;;(setq buffer-read-only t)
-  )
+  (setq notmuch-buffer-refresh-function #'notmuch-hello-update))
 
 ;;; Inserters
 
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 3add992b..72549a98 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -247,7 +247,7 @@ (defun notmuch-config-get (item)
   (let* ((val (notmuch-command-to-string "config" "get" item))
 (len (length val)))
 ;; Trim off the trailing newline (if the value is empty or not
-;; configured, there will be no newline)
+;; configured, there will be no newline).
 (if (and (> len 0)
 (= (aref val (- len 1)) ?\n))
(substring val 0 -1)
@@ -483,8 +483,8 @@ (defun notmuch-refresh-all-buffers ()
 ;;; String Utilities
 
 (defun notmuch-prettify-subject (subject)
-  ;; This function is used by `notmuch-search-process-filter' which
-  ;; requires that we not disrupt its' matching state.
+  ;; This function is used by `notmuch-search-process-filter',
+  ;; which requires that we not disrupt its matching state.
   (save-match-data
 (if (and subject
 (string-match "^[ \t]*$" subject))
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 27/36] emacs: define a few variables as automatically buffer-local

2021-01-10 Thread Jonas Bernoulli
Define these variables as automatically buffer-local, meaning that
they always become buffer-local when set unless explicitly told
otherwise using `setq-default' or when using the Custom interface.

Previously they were declared, which keeps the byte-compiler quiet but
is not actually the same as being defined.  `notmuch-search-mode' then
made them buffer-local in the current buffer and then set the local
values.  This works but is not kosher.

The definitions of the three non-option variables have to be moved up
a bit to enable the change in the next commit, which see.
---
 emacs/notmuch-lib.el |  1 +
 emacs/notmuch.el | 16 ++--
 2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 72549a98..2fd9a27d 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -101,6 +101,7 @@ (defcustom notmuch-search-oldest-first t
 search."
   :type 'boolean
   :group 'notmuch-search)
+(make-variable-buffer-local 'notmuch-search-oldest-first)
 
 (defcustom notmuch-poll-script nil
   "[Deprecated] Command to run to incorporate new mail into the notmuch 
database.
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index ccece811..027c5cfa 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -205,6 +205,12 @@ (defvar notmuch-search-mode-map
 map)
   "Keymap for \"notmuch search\" buffers.")
 
+;;; Internal Variables
+
+(defvar-local notmuch-search-query-string nil)
+(defvar-local notmuch-search-target-thread nil)
+(defvar-local notmuch-search-target-line nil)
+
 ;;; Stashing
 
 (defvar notmuch-search-stash-map
@@ -226,12 +232,6 @@ (defun notmuch-stash-query ()
   (interactive)
   (notmuch-common-do-stash (notmuch-search-get-query)))
 
-;;; Variables
-
-(defvar notmuch-search-query-string)
-(defvar notmuch-search-target-thread)
-(defvar notmuch-search-target-line)
-
 ;;; Movement
 
 (defun notmuch-search-scroll-up ()
@@ -404,10 +404,6 @@ (define-derived-mode notmuch-search-mode fundamental-mode 
"notmuch-search"
 Complete list of currently available key bindings:
 
 \\{notmuch-search-mode-map}"
-  (make-local-variable 'notmuch-search-query-string)
-  (make-local-variable 'notmuch-search-oldest-first)
-  (make-local-variable 'notmuch-search-target-thread)
-  (make-local-variable 'notmuch-search-target-line)
   (setq notmuch-buffer-refresh-function #'notmuch-search-refresh-view)
   (setq-local scroll-preserve-screen-position t)
   (add-to-invisibility-spec (cons 'ellipsis t))
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 28/36] emacs: notmuch-search-stash-thread-id: use notmuch-search-query-string

2021-01-10 Thread Jonas Bernoulli
No longer use the function `notmuch-search-get-query', which does
nothing but return the value of that variable.  That function was
added in [1: f47eeac0] for use in `notmuch-read-query' along-side
related `notmuch-show-get-query' and `notmuch-tree-get-query' but
using it here makes little sense.

1: f47eeac0b0186c3559eb559c4f0bee0e1fac1961
   emacs: set default in notmuch-read-query
---
 emacs/notmuch.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 027c5cfa..481a0e0a 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -230,7 +230,7 @@ (defun notmuch-search-stash-thread-id ()
 (defun notmuch-stash-query ()
   "Copy current query to kill-ring."
   (interactive)
-  (notmuch-common-do-stash (notmuch-search-get-query)))
+  (notmuch-common-do-stash notmuch-search-query-string))
 
 ;;; Movement
 
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 23/36] emacs: various cosmetic improvements

2021-01-10 Thread Jonas Bernoulli
---
 emacs/notmuch-address.el | 22 --
 emacs/notmuch-hello.el   | 24 ---
 emacs/notmuch-jump.el|  4 +-
 emacs/notmuch-lib.el | 26 +--
 emacs/notmuch-maildir-fcc.el | 61 +++---
 emacs/notmuch-mua.el | 28 ++--
 emacs/notmuch-query.el   | 11 +++--
 emacs/notmuch-tag.el | 14 +++---
 emacs/notmuch.el | 83 ++--
 9 files changed, 125 insertions(+), 148 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 1017c3ce..2f0ec9b3 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -21,6 +21,8 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'cl-lib))
+
 (require 'message)
 (require 'notmuch-parser)
 (require 'notmuch-lib)
@@ -160,15 +162,12 @@ (defun notmuch-address-message-insinuate ()
   (message "calling notmuch-address-message-insinuate is no longer needed"))
 
 (defun notmuch-address-setup ()
-  (let* ((setup-company (and notmuch-address-use-company
-(require 'company nil t)))
-(pair (cons notmuch-address-completion-headers-regexp
-#'notmuch-address-expand-name)))
-(when setup-company
-  (notmuch-company-setup))
-(unless (member pair message-completion-alist)
-  (setq message-completion-alist
-   (push pair message-completion-alist)
+  (when (and notmuch-address-use-company
+(require 'company nil t))
+(notmuch-company-setup))
+  (cl-pushnew (cons notmuch-address-completion-headers-regexp
+   #'notmuch-address-expand-name)
+ message-completion-alist :test #'equal))
 
 (defun notmuch-address-toggle-internal-completion ()
   "Toggle use of internal completion for current buffer.
@@ -264,9 +263,6 @@ (defun notmuch-address-harvest-addr (result)
   (let ((name-addr (plist-get result :name-addr)))
 (puthash name-addr t notmuch-address-completions)))
 
-(defun notmuch-address-harvest-handle-result (obj)
-  (notmuch-address-harvest-addr obj))
-
 (defun notmuch-address-harvest-filter (proc string)
   (when (buffer-live-p (process-buffer proc))
 (with-current-buffer (process-buffer proc)
@@ -274,7 +270,7 @@ (defun notmuch-address-harvest-filter (proc string)
(goto-char (point-max))
(insert string))
   (notmuch-sexp-parse-partial-list
-   'notmuch-address-harvest-handle-result (process-buffer proc)
+   'notmuch-address-harvest-addr (process-buffer proc)
 
 (defvar notmuch-address-harvest-procs '(nil . nil)
   "The currently running harvests.
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index a134eb07..ffd3d799 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -432,8 +432,7 @@ (defun notmuch-hello-add-saved-search (widget  _event)
 ;; If an existing saved search with this name exists, remove it.
 (setq notmuch-saved-searches
  (cl-loop for elem in notmuch-saved-searches
-  if (not (equal name
- (notmuch-saved-search-get elem :name)))
+  unless (equal name (notmuch-saved-search-get elem :name))
   collect elem))
 ;; Add the new one.
 (customize-save-variable 'notmuch-saved-searches
@@ -481,18 +480,14 @@ (defun notmuch-hello-reflect (list ncols)
 append (notmuch-hello-reflect-generate-row ncols nrows row list
 
 (defun notmuch-hello-widget-search (widget  _ignore)
-  (cond
-   ((eq (widget-get widget :notmuch-search-type) 'tree)
-(notmuch-tree (widget-get widget
- :notmuch-search-terms)))
-   ((eq (widget-get widget :notmuch-search-type) 'unthreaded)
-(notmuch-unthreaded (widget-get widget
-   :notmuch-search-terms)))
+  (cl-case (widget-get widget :notmuch-search-type)
+   (tree
+(notmuch-tree (widget-get widget :notmuch-search-terms)))
+   (unthreaded
+(notmuch-unthreaded (widget-get widget :notmuch-search-terms)))
(t
-(notmuch-search (widget-get widget
-   :notmuch-search-terms)
-   (widget-get widget
-   :notmuch-search-oldest-first)
+(notmuch-search (widget-get widget :notmuch-search-terms)
+   (widget-get widget :notmuch-search-oldest-first)
 
 (defun notmuch-saved-search-count (search)
   (car (process-lines notmuch-command "count" search)))
@@ -823,8 +818,7 @@ (defun notmuch-hello-insert-search ()
   ;; instead of a space to make `show-trailing-whitespace'
   ;; happy, i.e. avoid it marking the whole line as trailing
   ;; spaces.
-  (widget-insert ".")
-  (put-text-property (1- (point)) (point) 'invisible t)
+  (widget-insert (propertize "." 'invisible t))
   (widget-insert "\n"))
 
 (defun notmuch-hello-insert-recent-searches ()
diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
index 51bc4e31..34d6c796 100644
--- 

[PATCH v2 22/36] emacs: notmuch-crypto-status-button-type: fix potential bug

2021-01-10 Thread Jonas Bernoulli
The "help-echo" can potentially contain an unintended %-spec
so we have to make sure it would not be treated as such.
---
 emacs/notmuch-crypto.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index 50a3de46..db7cb75d 100644
--- a/emacs/notmuch-crypto.el
+++ b/emacs/notmuch-crypto.el
@@ -103,7 +103,7 @@ (defface notmuch-crypto-decryption
 ;;; Functions
 
 (define-button-type 'notmuch-crypto-status-button-type
-  'action (lambda (button) (message (button-get button 'help-echo)))
+  'action (lambda (button) (message "%s" (button-get button 'help-echo)))
   'follow-link t
   'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime 
parts."
   :supertype 'notmuch-button-type)
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 21/36] emacs: notmuch-mua.el: move all options into "Options" section

2021-01-10 Thread Jonas Bernoulli
This is how we do it in other libraries.
---
 emacs/notmuch-mua.el | 32 
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 2d0b7169..74ffd8f2 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -82,6 +82,22 @@ (defcustom notmuch-mua-hidden-headers nil
   :type '(repeat string)
   :group 'notmuch-send)
 
+(defcustom notmuch-identities nil
+  "Identities that can be used as the From: address when composing a new 
message.
+
+If this variable is left unset, then a list will be constructed from the
+name and addresses configured in the notmuch configuration file."
+  :type '(repeat string)
+  :group 'notmuch-send)
+
+(defcustom notmuch-always-prompt-for-sender nil
+  "Always prompt for the From: address when composing or forwarding a message.
+
+This is not taken into account when replying to a message, because in that case
+the From: header is already filled in by notmuch."
+  :type 'boolean
+  :group 'notmuch-send)
+
 (defgroup notmuch-reply nil
   "Replying to messages in notmuch"
   :group 'notmuch)
@@ -410,22 +426,6 @@ (defun notmuch-mua-mail ( to subject 
other-headers _continue
   (notmuch-mua-maybe-set-window-dedicated)
   (message-goto-to))
 
-(defcustom notmuch-identities nil
-  "Identities that can be used as the From: address when composing a new 
message.
-
-If this variable is left unset, then a list will be constructed from the
-name and addresses configured in the notmuch configuration file."
-  :type '(repeat string)
-  :group 'notmuch-send)
-
-(defcustom notmuch-always-prompt-for-sender nil
-  "Always prompt for the From: address when composing or forwarding a message.
-
-This is not taken into account when replying to a message, because in that case
-the From: header is already filled in by notmuch."
-  :type 'boolean
-  :group 'notmuch-send)
-
 (defvar notmuch-mua-sender-history nil)
 
 (defun notmuch-mua-prompt-for-sender ()
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 19/36] emacs: notmuch-wash.el: require diff-mode at beginning of code

2021-01-10 Thread Jonas Bernoulli
That's what we usually do.  Also do not declare variable
`diff-file-header-re' because it is defined in `diff-mode.el',
which we always require.
---
 emacs/notmuch-wash.el | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index d613e04c..653ecc2a 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -24,6 +24,7 @@
 ;;; Code:
 
 (require 'coolj)
+(require 'diff-mode)
 (require 'notmuch-lib)
 
 (declare-function notmuch-show-insert-bodypart "notmuch-show"
@@ -341,10 +342,6 @@ (defun notmuch-wash-wrap-long-lines (_msg depth)
 
  Convert Inline Patches
 
-(require 'diff-mode)
-
-(defvar diff-file-header-re) ; From `diff-mode.el'.
-
 (defun notmuch-wash-subject-to-filename (subject  maxlen)
   "Convert a mail SUBJECT into a filename.
 
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 18/36] emacs: notmuch-message-apply-queued-tag-changes: cosmetics

2021-01-10 Thread Jonas Bernoulli
---
 emacs/notmuch-message.el | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-message.el b/emacs/notmuch-message.el
index 9dc8d056..abeff53a 100644
--- a/emacs/notmuch-message.el
+++ b/emacs/notmuch-message.el
@@ -62,9 +62,8 @@ (defvar-local notmuch-message-queued-tag-changes nil
 (defun notmuch-message-apply-queued-tag-changes ()
   ;; Apply the tag changes queued in the buffer-local variable
   ;; notmuch-message-queued-tag-changes.
-  (dolist (query-and-tags notmuch-message-queued-tag-changes)
-(notmuch-tag (car query-and-tags)
-(cdr query-and-tags
+  (pcase-dolist (`(,query . ,tags) notmuch-message-queued-tag-changes)
+(notmuch-tag query tags)))
 
 (add-hook 'message-send-hook 'notmuch-message-apply-queued-tag-changes)
 
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 16/36] emacs: silence compiler wrt notmuch-show-insert-part-text/plain

2021-01-10 Thread Jonas Bernoulli
`notmuch-show-insert-part-text/plain' calls
`notmuch-show-insert-text/plain-hook' with two arguments
MSG and DEPTH. Currently all hook functions ignore MSG but
third-party functions may not.  One hook function uses DEPTH.
---
 emacs/notmuch-wash.el | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index 4fbb4e12..d613e04c 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -231,7 +231,7 @@ (defun notmuch-wash-region-to-button (beg end type 
 prefix)
 
 ;;; Hook functions
 
-(defun notmuch-wash-excerpt-citations (msg depth)
+(defun notmuch-wash-excerpt-citations (_msg _depth)
   "Excerpt citations and up to one signature."
   (goto-char (point-min))
   (beginning-of-line)
@@ -273,7 +273,7 @@ (defun notmuch-wash-excerpt-citations (msg depth)
   sig-start-marker sig-end-marker
   "signature"))
 
-(defun notmuch-wash-elide-blank-lines (msg depth)
+(defun notmuch-wash-elide-blank-lines (_msg _depth)
   "Elide leading, trailing and successive blank lines."
   ;; Algorithm derived from `article-strip-multiple-blank-lines' in
   ;; `gnus-art.el'.
@@ -294,7 +294,7 @@ (defun notmuch-wash-elide-blank-lines (msg depth)
   (when (looking-at "\n")
 (delete-region (match-beginning 0) (match-end 0
 
-(defun notmuch-wash-tidy-citations (msg depth)
+(defun notmuch-wash-tidy-citations (_msg _depth)
   "Improve the display of cited regions of a message.
 
 Perform several transformations on the message body:
@@ -318,7 +318,7 @@ (defun notmuch-wash-tidy-citations (msg depth)
   (while (re-search-forward "\\(^>[> ]*\n\\)\\(^$\\|^[^>].*\\)" nil t)
 (replace-match "\\2")))
 
-(defun notmuch-wash-wrap-long-lines (msg depth)
+(defun notmuch-wash-wrap-long-lines (_msg depth)
   "Wrap long lines in the message.
 
 If `notmuch-wash-wrap-lines-length' is a number, this will wrap
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 20/36] emacs: notmuch-mua-prompt-for-sender: don't force Ido on users

2021-01-10 Thread Jonas Bernoulli
We shouldn't force `ido-completion-read' on users who do not otherwise
use Ido.  Unfortunately simply turning on `ido-mode' does not change
every `completing-read' into a `ido-completing-read', instead it only
changes file and buffer completion.

I do realize that existing Ido users will initially dislike this
change, but I would like to encourage them to see this as an
opportunity to learn about Fido.

Unlike `ido-mode', build-in `fido-mode' confirms to the standard
completion API, so turning it on causes every `completing-read' to
use the Fido completion mechanism and which is similar to the Ido
mechanism:

> An enhanced `icomplete-mode' that emulates `ido-mode'.  This global
> minor mode makes minibuffer completion behave more like `ido-mode'
> than regular `icomplete-mode'."
---
 emacs/notmuch-mua.el | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 95d1965b..2d0b7169 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -431,16 +431,16 @@ (defvar notmuch-mua-sender-history nil)
 (defun notmuch-mua-prompt-for-sender ()
   "Prompt for a sender from the user's configured identities."
   (if notmuch-identities
-  (ido-completing-read "Send mail from: " notmuch-identities
-  nil nil nil 'notmuch-mua-sender-history
-  (car notmuch-identities))
+  (completing-read "Send mail from: " notmuch-identities
+  nil nil nil 'notmuch-mua-sender-history
+  (car notmuch-identities))
 (let* ((name (notmuch-user-name))
   (addrs (cons (notmuch-user-primary-email)
(notmuch-user-other-email)))
   (address
-   (ido-completing-read (concat "Sender address for " name ": ") addrs
-nil nil nil 'notmuch-mua-sender-history
-(car addrs
+   (completing-read (concat "Sender address for " name ": ") addrs
+nil nil nil 'notmuch-mua-sender-history
+(car addrs
   (message-make-from name address
 
 (put 'notmuch-mua-new-mail 'notmuch-prefix-doc "... and prompt for sender")
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 17/36] emacs: define notmuch-message-queued-tag-changes as buffer-local

2021-01-10 Thread Jonas Bernoulli
Also improve the doc-string.
---
 emacs/notmuch-message.el | 14 +++---
 emacs/notmuch-mua.el | 12 ++--
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/emacs/notmuch-message.el b/emacs/notmuch-message.el
index f0e9ffcc..9dc8d056 100644
--- a/emacs/notmuch-message.el
+++ b/emacs/notmuch-message.el
@@ -50,14 +50,14 @@ (defcustom notmuch-message-forwarded-tags '("+forwarded")
   :type '(repeat string)
   :group 'notmuch-send)
 
-(defconst notmuch-message-queued-tag-changes nil
-  "List of messages and corresponding tag-changes to be applied when sending a 
message.
+(defvar-local notmuch-message-queued-tag-changes nil
+  "List of tag changes to be applied when sending a message.
 
-This variable is overridden by buffer-local versions in message
-buffers where tag changes should be triggered when sending off
-the message.  Each item in this list is a list of strings, where
-the first is a notmuch query and the rest are the tag changes to
-be applied to the matching messages.")
+A list of queries and tag changes that are to be applied to them
+when the message that was composed in the current buffer is being
+send.  Each item in this list is a list of strings, where the
+first is a notmuch query and the rest are the tag changes to be
+applied to the matching messages.")
 
 (defun notmuch-message-apply-queued-tag-changes ()
   ;; Apply the tag changes queued in the buffer-local variable
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index b2930051..95d1965b 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -266,8 +266,8 @@ (defun notmuch-mua-reply (query-string  sender 
reply-all)
   ;; Create a buffer-local queue for tag changes triggered when
   ;; sending the reply.
   (when notmuch-message-replied-tags
-   (setq-local notmuch-message-queued-tag-changes
-   (list (cons query-string notmuch-message-replied-tags
+   (setq notmuch-message-queued-tag-changes
+ (list (cons query-string notmuch-message-replied-tags
   ;; Insert the message body - but put it in front of the signature
   ;; if one is present, and after any other content
   ;; message*setup-hooks may have added to the message body already.
@@ -507,10 +507,10 @@ (defun notmuch-mua-new-forward-messages (messages 
 prompt-for-sender)
   ;; Create a buffer-local queue for tag changes triggered when
   ;; sending the message.
   (when notmuch-message-forwarded-tags
-   (setq-local notmuch-message-queued-tag-changes
-   (cl-loop for id in forward-queries
-collect
-(cons id notmuch-message-forwarded-tags
+   (setq notmuch-message-queued-tag-changes
+ (cl-loop for id in forward-queries
+  collect
+  (cons id notmuch-message-forwarded-tags
   ;; `message-forward-make-body' shows the User-agent header.  Hide
   ;; it again.
   (message-hide-headers)
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 12/36] emacs: deal with unused lexical arguments and variables

2021-01-10 Thread Jonas Bernoulli
The previous commit switched to lexical-binding but without dealing
with the new warnings about unused lexical arguments and variables.

This commit deals with most of them, in most cases by either removing
leftover bindings that are actually unnecessary, or by marking certain
arguments as "known to be unused" by prefixing their names with "_".

In the case of the functions named `notmuch-show-insert-...' the
amount of silencing that is required is a bit extreme and we might
want to investigate if there is a better way.

In the case of `notmuch-mua-mail', ignoring CONTINUE means that we do
not fully follow the intended behavior described in `compose-mail's
doc-string.
---
 emacs/notmuch-address.el |  4 ++--
 emacs/notmuch-crypto.el  |  2 +-
 emacs/notmuch-hello.el   | 16 +++
 emacs/notmuch-jump.el|  6 +++---
 emacs/notmuch-lib.el |  2 +-
 emacs/notmuch-maildir-fcc.el |  4 ++--
 emacs/notmuch-mua.el |  2 +-
 emacs/notmuch-print.el   |  6 +++---
 emacs/notmuch-show.el| 38 ++--
 emacs/notmuch-tree.el| 14 +
 emacs/notmuch-wash.el| 16 +++
 emacs/notmuch.el |  5 ++---
 12 files changed, 54 insertions(+), 61 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 6b117458..1017c3ce 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -191,7 +191,7 @@ (defun notmuch-address-matching (substring)
 The candidates are taken from `notmuch-address-completions'."
   (let ((candidates)
(re (regexp-quote substring)))
-(maphash (lambda (key val)
+(maphash (lambda (key _val)
   (when (string-match re key)
 (push key candidates)))
 notmuch-address-completions)
@@ -406,7 +406,7 @@ (defun notmuch-address-harvest-trigger ()
   (setq notmuch-address-last-harvest now)
   (notmuch-address-harvest
nil nil
-   (lambda (proc event)
+   (lambda (_proc event)
 ;; If harvest fails, we want to try
 ;; again when the trigger is next
 ;; called
diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index ee5231e5..50a3de46 100644
--- a/emacs/notmuch-crypto.el
+++ b/emacs/notmuch-crypto.el
@@ -171,7 +171,7 @@ (defun notmuch-crypto-sigstatus-good-callback (button)
 (declare-function notmuch-show-refresh-view "notmuch-show" ( 
reset-state))
 (declare-function notmuch-show-get-message-id "notmuch-show" ( bare))
 
-(defun notmuch-crypto--async-key-sentinel (process event)
+(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.
 
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 586a2848..a134eb07 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -480,7 +480,7 @@ (defun notmuch-hello-reflect (list ncols)
 (cl-loop for row from 0 to (- nrows 1)
 append (notmuch-hello-reflect-generate-row ncols nrows row list
 
-(defun notmuch-hello-widget-search (widget  ignore)
+(defun notmuch-hello-widget-search (widget  _ignore)
   (cond
((eq (widget-get widget :notmuch-search-type) 'tree)
 (notmuch-tree (widget-get widget
@@ -775,14 +775,14 @@ (defun notmuch-hello-insert-header ()
   (let ((widget-link-prefix "")
(widget-link-suffix ""))
 (widget-create 'link
-  :notify (lambda ( ignore)
+  :notify (lambda ( _ignore)
 (browse-url notmuch-hello-url))
   :help-echo "Visit the notmuch website."
   "notmuch")
 (widget-insert ". ")
 (widget-insert "You have ")
 (widget-create 'link
-  :notify (lambda ( ignore)
+  :notify (lambda ( _ignore)
 (notmuch-hello-update))
   :help-echo "Refresh"
   (notmuch-hello-nice-number
@@ -801,7 +801,7 @@ (defun notmuch-hello-insert-saved-searches ()
 (when searches
   (widget-insert "Saved searches: ")
   (widget-create 'push-button
-:notify (lambda ( ignore)
+:notify (lambda ( _ignore)
   (customize-variable 'notmuch-saved-searches))
 "edit")
   (widget-insert "\n\n")
@@ -873,13 +873,13 @@ (defun notmuch-hello-insert-searches (title query-list 
 options)
(start (point)))
 (if is-hidden
(widget-create 'push-button
-  :notify `(lambda (widget  ignore)
+  :notify `(lambda (widget  _ignore)
  (setq notmuch-hello-hidden-sections
(delete ,title 
notmuch-hello-hidden-sections))
  (notmuch-hello-update))
   "show")
   (widget-create 'push-button
-:notify `(lambda 

[PATCH v2 11/36] emacs: use lexical-bindings in all libraries

2021-01-10 Thread Jonas Bernoulli
Doing so causes many new compile warnings.  Some of these warnings
concern genuine changes in behavior that have to be addressed right
away.

Many other warnings are due to unused variables.  Nothing has changed
here, except that the byte-compiler can now detect these pre-existing
and harmless issues.  We delay addressing these issues so that we can
focus on the important ones here.

A third group of warnings concern arguments that are not actually used
inside the function but which cannot be removed because the functions
signature is dictated by some outside convention.  Silencing these
warning is also delayed until subsequent commits.
---
 emacs/coolj.el   |  2 +-
 emacs/make-deps.el   |  2 +-
 emacs/notmuch-address.el |  2 +-
 emacs/notmuch-compat.el  |  2 +-
 emacs/notmuch-crypto.el  |  2 +-
 emacs/notmuch-draft.el   |  2 +-
 emacs/notmuch-hello.el   |  2 +-
 emacs/notmuch-jump.el|  2 +-
 emacs/notmuch-lib.el |  2 +-
 emacs/notmuch-maildir-fcc.el |  2 +-
 emacs/notmuch-message.el |  2 +-
 emacs/notmuch-mua.el |  7 ++-
 emacs/notmuch-parser.el  |  2 +-
 emacs/notmuch-print.el   |  2 +-
 emacs/notmuch-query.el   |  2 +-
 emacs/notmuch-show.el|  6 +-
 emacs/notmuch-tag.el | 18 ++
 emacs/notmuch-tree.el|  2 +-
 emacs/notmuch-wash.el|  2 +-
 emacs/notmuch.el |  2 +-
 emacs/rstdoc.el  |  2 +-
 21 files changed, 39 insertions(+), 28 deletions(-)

diff --git a/emacs/coolj.el b/emacs/coolj.el
index b3e314f0..d820525b 100644
--- a/emacs/coolj.el
+++ b/emacs/coolj.el
@@ -1,4 +1,4 @@
-;;; coolj.el --- automatically wrap long lines  -*- coding:utf-8 -*-
+;;; coolj.el --- automatically wrap long lines  -*- lexical-binding: t; 
coding: utf-8 -*-
 
 ;; Copyright (C) 2000, 2001, 2004-2009 Free Software Foundation, Inc.
 
diff --git a/emacs/make-deps.el b/emacs/make-deps.el
index a7699fb1..8c9e0a27 100644
--- a/emacs/make-deps.el
+++ b/emacs/make-deps.el
@@ -1,4 +1,4 @@
-;;; make-deps.el --- compute make dependencies for Elisp sources
+;;; make-deps.el --- compute make dependencies for Elisp sources  -*- 
lexical-binding: t -*-
 ;;
 ;; Copyright © Austin Clements
 ;;
diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index bf29c3a0..6b117458 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -1,4 +1,4 @@
-;;; notmuch-address.el --- address completion with notmuch
+;;; notmuch-address.el --- address completion with notmuch  -*- 
lexical-binding: t -*-
 ;;
 ;; Copyright © David Edmondson
 ;;
diff --git a/emacs/notmuch-compat.el b/emacs/notmuch-compat.el
index c4e07780..ad134dfe 100644
--- a/emacs/notmuch-compat.el
+++ b/emacs/notmuch-compat.el
@@ -1,4 +1,4 @@
-;;; notmuch-compat.el --- compatibility functions for earlier versions of emacs
+;;; notmuch-compat.el --- compatibility functions for earlier versions of 
emacs  -*- lexical-binding: t -*-
 ;;
 ;; The functions in this file are copied from more modern versions of
 ;; emacs and are Copyright (C) 1985-1986, 1992, 1994-1995, 1999-2017
diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index 6d2d35a5..ee5231e5 100644
--- a/emacs/notmuch-crypto.el
+++ b/emacs/notmuch-crypto.el
@@ -1,4 +1,4 @@
-;;; notmuch-crypto.el --- functions for handling display of cryptographic 
metadata
+;;; notmuch-crypto.el --- functions for handling display of cryptographic 
metadata  -*- lexical-binding: t -*-
 ;;
 ;; Copyright © Jameson Rollins
 ;;
diff --git a/emacs/notmuch-draft.el b/emacs/notmuch-draft.el
index 9ce9e736..8af04598 100644
--- a/emacs/notmuch-draft.el
+++ b/emacs/notmuch-draft.el
@@ -1,4 +1,4 @@
-;;; notmuch-draft.el --- functions for postponing and editing drafts
+;;; notmuch-draft.el --- functions for postponing and editing drafts  -*- 
lexical-binding: t -*-
 ;;
 ;; Copyright © Mark Walters
 ;; Copyright © David Bremner
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 28ffedd9..586a2848 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -1,4 +1,4 @@
-;;; notmuch-hello.el --- welcome to notmuch, a frontend
+;;; notmuch-hello.el --- welcome to notmuch, a frontend  -*- lexical-binding: 
t -*-
 ;;
 ;; Copyright © David Edmondson
 ;;
diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
index 7a27b6b3..5dcec970 100644
--- a/emacs/notmuch-jump.el
+++ b/emacs/notmuch-jump.el
@@ -1,4 +1,4 @@
-;;; notmuch-jump.el --- User-friendly shortcut keys
+;;; notmuch-jump.el --- User-friendly shortcut keys  -*- lexical-binding: t -*-
 ;;
 ;; Copyright © Austin Clements
 ;;
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 0b698d59..7595bbe1 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -1,4 +1,4 @@
-;;; notmuch-lib.el --- common variables, functions and function declarations
+;;; notmuch-lib.el --- common variables, functions and function declarations  
-*- lexical-binding: t -*-
 ;;
 ;; Copyright © Carl Worth
 ;;

[PATCH v2 15/36] emacs: notmuch-wash-region-to-button: remove unused MSG argument

2021-01-10 Thread Jonas Bernoulli
---
 emacs/notmuch-wash.el | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index 36041904..4fbb4e12 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -200,7 +200,7 @@ (defun notmuch-wash-button-label (overlay)
   (overlay-end overlay
 (format label-format lines-count)))
 
-(defun notmuch-wash-region-to-button (msg beg end type  prefix)
+(defun notmuch-wash-region-to-button (beg end type  prefix)
   "Auxiliary function to do the actual making of overlays and buttons.
 
 BEG and END are buffer locations. TYPE should a string, either
@@ -237,8 +237,7 @@ (defun notmuch-wash-excerpt-citations (msg depth)
   (beginning-of-line)
   (when (and (< (point) (point-max))
 (re-search-forward notmuch-wash-original-regexp nil t))
-(notmuch-wash-region-to-button msg
-  (match-beginning 0)
+(notmuch-wash-region-to-button (match-beginning 0)
   (point-max)
   "original"))
   (while (and (< (point) (point-max))
@@ -257,7 +256,7 @@ (defun notmuch-wash-excerpt-citations (msg depth)
  (goto-char cite-end)
  (forward-line (- notmuch-wash-citation-lines-suffix))
  (notmuch-wash-region-to-button
-  msg hidden-start (point-marker)
+  hidden-start (point-marker)
   "citation")
   (when (and (not (eobp))
 (re-search-forward notmuch-wash-signature-regexp nil t))
@@ -271,7 +270,7 @@ (defun notmuch-wash-excerpt-citations (msg depth)
  (overlay-put (make-overlay sig-start-marker sig-end-marker)
   'face 'message-cited-text)
  (notmuch-wash-region-to-button
-  msg sig-start-marker sig-end-marker
+  sig-start-marker sig-end-marker
   "signature"))
 
 (defun notmuch-wash-elide-blank-lines (msg depth)
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 08/36] emacs: avoid passing around some redundant information

2021-01-10 Thread Jonas Bernoulli
When running "notmuch" we use its full path but when displaying the
command to the user we show just its name for readability reasons.
Avoid passing around both representations because it is very easy
to get the name from the path.

Notmuch itself uses the involved functions just for "notmuch" but
there might be extensions that use them for other executable so we
forgo other potential simplifications.
---
 emacs/notmuch-lib.el | 43 ---
 1 file changed, 24 insertions(+), 19 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index be15af5e..e09912d3 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -800,20 +800,27 @@ (defun notmuch-check-exit-status (exit-status command 
 output err)
 Emacs requested a newer output format than supported by the notmuch CLI.
 You may need to restart Emacs or upgrade your notmuch package."))
(t
-(let* ((command-string
-   (mapconcat (lambda (arg)
-(shell-quote-argument
- (cond ((stringp arg) arg)
-   ((symbolp arg) (symbol-name arg))
-   (t "*UNKNOWN ARGUMENT*"
-  command " "))
-  (extra
-   (concat "command: " command-string "\n"
-   (if (integerp exit-status)
-   (format "exit status: %s\n" exit-status)
- (format "exit signal: %s\n" exit-status))
-   (and err(concat "stderr:\n" err))
-   (and output (concat "stdout:\n" output)
+(pcase-let*
+   ((`(,command . ,args) command)
+(command (if (equal (file-name-nondirectory command)
+notmuch-command)
+ notmuch-command
+   command))
+(command-string
+ (mapconcat (lambda (arg)
+  (shell-quote-argument
+   (cond ((stringp arg) arg)
+ ((symbolp arg) (symbol-name arg))
+ (t "*UNKNOWN ARGUMENT*"
+(cons command args)
+" "))
+(extra
+ (concat "command: " command-string "\n"
+ (if (integerp exit-status)
+ (format "exit status: %s\n" exit-status)
+   (format "exit signal: %s\n" exit-status))
+ (and err(concat "stderr:\n" err))
+ (and output (concat "stdout:\n" output)
   (if err
  ;; We have an error message straight from the CLI.
  (notmuch-logged-error
@@ -821,7 +828,7 @@ (defun notmuch-check-exit-status (exit-status command 
 output err)
;; We only have combined output from the CLI; don't inundate
;; the user with it.  Mimic `process-lines'.
(notmuch-logged-error (format "%s exited with status %s"
- (car command) exit-status)
+ command exit-status)
  extra))
   ;; `notmuch-logged-error' does not return.
   
@@ -908,7 +915,6 @@ (defun notmuch-start-notmuch (name buffer sentinel  
args)
 (err-proc (get-buffer-process err-buffer)))
 (process-put proc 'err-buffer err-buffer)
 (process-put proc 'sub-sentinel sentinel)
-(process-put proc 'real-command (cons notmuch-command args))
 (set-process-sentinel proc #'notmuch-start-notmuch-sentinel)
 (set-process-sentinel err-proc #'notmuch-start-notmuch-error-sentinel)
 proc))
@@ -919,8 +925,7 @@ (defun notmuch-start-notmuch-sentinel (proc event)
 (err (and (buffer-live-p err-buffer)
   (not (zerop (buffer-size err-buffer)))
   (with-current-buffer err-buffer (buffer-string
-(sub-sentinel (process-get proc 'sub-sentinel))
-(real-command (process-get proc 'real-command)))
+(sub-sentinel (process-get proc 'sub-sentinel)))
 (condition-case err
(progn
  ;; Invoke the sub-sentinel, if any
@@ -932,7 +937,7 @@ (defun notmuch-start-notmuch-sentinel (proc event)
  ;; and there's no point in telling the user that (but we
  ;; still check for and report stderr output below).
  (when (buffer-live-p (process-buffer proc))
-   (notmuch-check-async-exit-status proc event real-command err))
+   (notmuch-check-async-exit-status proc event nil err))
  ;; If that didn't signal an error, then any error output was
  ;; really warning output.  Show warnings, if any.
  (let ((warnings
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 09/36] emacs: avoid killing process buffer when process is still alive

2021-01-10 Thread Jonas Bernoulli
In practice this probably does not make a difference or we would
have heard about it many times, but better be safe than sorry.

Process sentinels are called not only when the process has finished
but also on other state changes.
---
 emacs/notmuch-lib.el | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index e09912d3..0e235fa3 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -960,9 +960,10 @@ (defun notmuch-start-notmuch-sentinel (proc event)
(message "%s" (error-message-string err))
 
 (defun notmuch-start-notmuch-error-sentinel (proc event)
-  (let ((buffer (process-buffer proc)))
-(when (buffer-live-p buffer)
-  (kill-buffer buffer
+  (unless (process-live-p proc)
+(let ((buffer (process-buffer proc)))
+  (when (buffer-live-p buffer)
+   (kill-buffer buffer)
 
 (defvar-local notmuch-show-process-crypto nil)
 
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 14/36] emacs: inline notmuch-sexp-eof into only caller

2021-01-10 Thread Jonas Bernoulli
This function had a few issues.
- Neither its name nor the old comment before it is called made it
  clear what it does.
- It took one argument but didn't do anything with it.
- It's doc-string made a few claims, which are untrue and generally
  focused on details instead of that its purpose is.
---
 emacs/notmuch-parser.el | 16 +---
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/emacs/notmuch-parser.el b/emacs/notmuch-parser.el
index b8c3fd2c..294e0544 100644
--- a/emacs/notmuch-parser.el
+++ b/emacs/notmuch-parser.el
@@ -140,15 +140,6 @@ (defun notmuch-sexp-begin-list (sp)
 (forward-char)
 (signal 'invalid-read-syntax (list (string (char-before)))
 
-(defun notmuch-sexp-eof (sp)
-  "Signal an error if there is more data in SP's buffer.
-
-Moves point to the beginning of any trailing data or to the end
-of the buffer if there is only trailing whitespace."
-  (skip-chars-forward " \n\r\t")
-  (unless (eobp)
-(error "Trailing garbage following expression")))
-
 (defvar notmuch-sexp--parser nil
   "The buffer-local notmuch-sexp-parser instance.
 
@@ -187,8 +178,11 @@ (defun notmuch-sexp-parse-partial-list (result-function 
result-buffer)
 (t (with-current-buffer result-buffer
  (funcall result-function result))
(end
-;; Any trailing data is unexpected
-(notmuch-sexp-eof notmuch-sexp--parser)
+;; Skip over trailing whitespace.
+(skip-chars-forward " \n\r\t")
+;; Any trailing data is unexpected.
+(unless (eobp)
+  (error "Trailing garbage following expression"))
 (setq done t)
   ;; Clear out what we've parsed
   (delete-region (point-min) (point)))
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 13/36] emacs: notmuch-tag--get-formats: silence byte-compiler

2021-01-10 Thread Jonas Bernoulli
`format-alist' is a global variable and the byte-compiler is unhappy
when a lexical function argument shadows a global (dynamic) binding.
---
 emacs/notmuch-tag.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
index fa376b02..a553dfd9 100644
--- a/emacs/notmuch-tag.el
+++ b/emacs/notmuch-tag.el
@@ -285,12 +285,12 @@ (defun notmuch-tag-clear-cache ()
   "Clear the internal cache of tag formats."
   (clrhash notmuch-tag--format-cache))
 
-(defun notmuch-tag--get-formats (tag format-alist)
+(defun notmuch-tag--get-formats (tag alist)
   "Find the first item whose car regexp-matches TAG."
   (save-match-data
 ;; Don't use assoc-default since there's no way to distinguish a
 ;; missing key from a present key with a null cdr.
-(cl-assoc tag format-alist
+(cl-assoc tag alist
  :test (lambda (tag key)
  (and (eq (string-match key tag) 0)
   (= (match-end 0) (length tag)))
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 06/36] emacs: notmuch-start-notmuch-sentinel: assert buffer is alive

2021-01-10 Thread Jonas Bernoulli
---
 emacs/notmuch-lib.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 21fa2582..06ca8cdc 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -917,7 +917,8 @@ (defun notmuch-start-notmuch (name buffer sentinel  
args)
 (defun notmuch-start-notmuch-sentinel (proc event)
   "Process sentinel function used by `notmuch-start-notmuch'."
   (let* ((err-buffer (process-get proc 'err-buffer))
-(err (and (not (zerop (buffer-size err-buffer)))
+(err (and (buffer-live-p err-buffer)
+  (not (zerop (buffer-size err-buffer)))
   (with-current-buffer err-buffer (buffer-string
 (sub-sentinel (process-get proc 'sub-sentinel))
 (real-command (process-get proc 'real-command)))
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 07/36] emacs: notmuch-start-notmuch: avoid storing process buffer twice

2021-01-10 Thread Jonas Bernoulli
The buffer of the error process is accessible using `process-buffer'.
We still have to store the error-buffer in the non-error process
because for that process `process-buffer' obviously returns its own
buffer.
---
 emacs/notmuch-lib.el | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 06ca8cdc..be15af5e 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -906,12 +906,11 @@ (defun notmuch-start-notmuch (name buffer sentinel  
args)
:connection-type 'pipe
:stderr err-buffer))
 (err-proc (get-buffer-process err-buffer)))
-(process-put err-proc 'err-buffer err-buffer)
-(set-process-sentinel err-proc #'notmuch-start-notmuch-error-sentinel)
 (process-put proc 'err-buffer err-buffer)
 (process-put proc 'sub-sentinel sentinel)
 (process-put proc 'real-command (cons notmuch-command args))
 (set-process-sentinel proc #'notmuch-start-notmuch-sentinel)
+(set-process-sentinel err-proc #'notmuch-start-notmuch-error-sentinel)
 proc))
 
 (defun notmuch-start-notmuch-sentinel (proc event)
@@ -956,7 +955,7 @@ (defun notmuch-start-notmuch-sentinel (proc event)
(message "%s" (error-message-string err))
 
 (defun notmuch-start-notmuch-error-sentinel (proc event)
-  (let ((buffer (process-get proc 'err-buffer)))
+  (let ((buffer (process-buffer proc)))
 (when (buffer-live-p buffer)
   (kill-buffer buffer
 
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 05/36] emacs: notmuch-start-notmuch-error-sentinel: assert buffer is alive

2021-01-10 Thread Jonas Bernoulli
---
 emacs/notmuch-lib.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 76387779..21fa2582 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -956,7 +956,8 @@ (defun notmuch-start-notmuch-sentinel (proc event)
 
 (defun notmuch-start-notmuch-error-sentinel (proc event)
   (let ((buffer (process-get proc 'err-buffer)))
-(kill-buffer buffer)))
+(when (buffer-live-p buffer)
+  (kill-buffer buffer
 
 (defvar-local notmuch-show-process-crypto nil)
 
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 03/36] emacs: define new notmuch-search-item widget type

2021-01-10 Thread Jonas Bernoulli
This is complex enough to warrant a dedicated widget type,
which will make future improvements less messy to implement.
---
 emacs/notmuch-hello.el | 92 +-
 1 file changed, 45 insertions(+), 47 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 767c6874..7bc713f3 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -385,6 +385,40 @@ (defun notmuch-hello-nice-number (n)
 (format "%s%03d" notmuch-hello-thousands-separator elem))
   (cdr result)
 
+(define-widget 'notmuch-search-item 'item
+  "A recent search."
+  :format "%v\n"
+  :value-create 'notmuch-search-item-value-create)
+
+(defun notmuch-search-item-value-create (widget)
+  (let ((value (widget-get widget :value)))
+(widget-insert (make-string notmuch-hello-indent ?\s))
+(widget-create 'editable-field
+  :size (widget-get widget :size)
+  :parent widget
+  :action #'notmuch-hello-search
+  value)
+(widget-insert " ")
+(widget-create 'push-button
+  :parent widget
+  :notify #'notmuch-hello-add-saved-search
+  "save")
+(widget-insert " ")
+(widget-create 'push-button
+  :parent widget
+  :notify #'notmuch-hello-delete-search-from-history
+  "del")))
+
+(defun notmuch-search-item-field-width ()
+  (max 8 ; Don't let the search boxes be less than 8 characters wide.
+   (- (window-width)
+ notmuch-hello-indent ; space at bol
+ notmuch-hello-indent ; space at eol
+ 1; for the space before the [save] button
+ 6; for the [save] button
+ 1; for the space before the [del] button
+ 5))) ; for the [del] button
+
 (defun notmuch-hello-search (widget  _event)
   (let ((search (widget-value widget)))
 (when search
@@ -778,54 +812,18 @@ (defun notmuch-hello-insert-recent-searches ()
   "Insert recent searches."
   (when notmuch-search-history
 (widget-insert "Recent searches: ")
-(widget-create 'push-button
-  :notify (lambda ( ignore)
-(when (y-or-n-p "Are you sure you want to clear 
the searches? ")
-  (setq notmuch-search-history nil)
-  (notmuch-hello-update)))
-  "clear")
+(widget-create
+ 'push-button
+ :notify (lambda ( _ignore)
+  (when (y-or-n-p "Are you sure you want to clear the searches? ")
+(setq notmuch-search-history nil)
+(notmuch-hello-update)))
+ "clear")
 (widget-insert "\n\n")
-(let ((start (point)))
-  (cl-loop for i from 1 to notmuch-hello-recent-searches-max
-  for search in notmuch-search-history do
-  (let ((widget-symbol (intern (format "notmuch-hello-search-%d" 
i
-(set widget-symbol
- (widget-create 'editable-field
-;; Don't let the search boxes be
-;; less than 8 characters wide.
-:size (max 8
-   (- (window-width)
-  ;; Leave some space
-  ;; at the start and
-  ;; end of the
-  ;; boxes.
-  (* 2 notmuch-hello-indent)
-  ;; 1 for the space
-  ;; before the
-  ;; `[save]' button. 6
-  ;; for the `[save]'
-  ;; button.
-  1 6
-  ;; 1 for the space
-  ;; before the `[del]'
-  ;; button. 5 for the
-  ;; `[del]' button.
-  1 5))
-:action #'notmuch-hello-search
-search))
-(widget-insert " ")
-(widget-create 'push-button
-   :notify #'notmuch-hello-add-saved-search
-   :notmuch-saved-search-widget widget-symbol
-   "save")
-(widget-insert " ")
-(widget-create 'push-button
-   :notify 
#'notmuch-hello-delete-search-from-history
-   

[PATCH v2 02/36] emacs: sanitize dedicated widget action/notify functions

2021-01-10 Thread Jonas Bernoulli
These functions are used as action/notify functions.  That dictates
the appropriate function signatures but even though these functions
are not used for anything else they use incompatible signatures,
forcing the callers to use lambda expressions to deal with these
incompatibilities.

Fix that by adjusting the function signatures to the needs of the
only intended callers.

Two of these functions were defined as commands but because the
interactive form did not return the mandatory arguments, we know
that nobody (successfully) used these as commands.

In one case we move the location of a y-or-n-p prompt.
---
 emacs/notmuch-hello.el | 47 +-
 1 file changed, 19 insertions(+), 28 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index fa31694f..767c6874 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -385,18 +385,16 @@ (defun notmuch-hello-nice-number (n)
 (format "%s%03d" notmuch-hello-thousands-separator elem))
   (cdr result)
 
-(defun notmuch-hello-search ( search)
-  (unless (null search)
-(setq search (string-trim search))
-(let ((history-delete-duplicates t))
-  (add-to-history 'notmuch-search-history search)))
-  (notmuch-search search notmuch-search-oldest-first))
-
-(defun notmuch-hello-add-saved-search (widget)
-  (interactive)
-  (let ((search (widget-value
-(symbol-value
- (widget-get widget :notmuch-saved-search-widget
+(defun notmuch-hello-search (widget  _event)
+  (let ((search (widget-value widget)))
+(when search
+  (setq search (string-trim search))
+  (let ((history-delete-duplicates t))
+   (add-to-history 'notmuch-search-history search)))
+(notmuch-search search notmuch-search-oldest-first)))
+
+(defun notmuch-hello-add-saved-search (widget  _event)
+  (let ((search (widget-value (widget-get widget :parent)))
(name (completing-read "Name for saved search: "
   notmuch-saved-searches)))
 ;; If an existing saved search with this name exists, remove it.
@@ -412,13 +410,11 @@ (defun notmuch-hello-add-saved-search (widget)
 (message "Saved '%s' as '%s'." search name)
 (notmuch-hello-update)))
 
-(defun notmuch-hello-delete-search-from-history (widget)
-  (interactive)
-  (let ((search (widget-value
-(symbol-value
- (widget-get widget :notmuch-saved-search-widget)
-(setq notmuch-search-history (delete search
-notmuch-search-history))
+(defun notmuch-hello-delete-search-from-history (widget  _event)
+  (when (y-or-n-p "Are you sure you want to delete this search? ")
+(let ((search (widget-value (widget-get widget :parent
+  (setq notmuch-search-history
+   (delete search notmuch-search-history)))
 (notmuch-hello-update)))
 
 (defun notmuch-hello-longest-label (searches-alist)
@@ -768,8 +764,7 @@ (defun notmuch-hello-insert-search ()
 ;; search boxes.
 :size (max 8 (- (window-width) notmuch-hello-indent
 (length "Search: ")))
-:action (lambda (widget  ignore)
-  (notmuch-hello-search (widget-value widget
+:action #'notmuch-hello-search)
   ;; Add an invisible dot to make `widget-end-of-line' ignore
   ;; trailing spaces in the search widget field.  A dot is used
   ;; instead of a space to make `show-trailing-whitespace'
@@ -816,20 +811,16 @@ (defun notmuch-hello-insert-recent-searches ()
   ;; button. 5 for the
   ;; `[del]' button.
   1 5))
-:action (lambda (widget  ignore)
-  (notmuch-hello-search 
(widget-value widget)))
+:action #'notmuch-hello-search
 search))
 (widget-insert " ")
 (widget-create 'push-button
-   :notify (lambda (widget  ignore)
- (notmuch-hello-add-saved-search 
widget))
+   :notify #'notmuch-hello-add-saved-search
:notmuch-saved-search-widget widget-symbol
"save")
 (widget-insert " ")
 (widget-create 'push-button
-   :notify (lambda (widget  ignore)
- (when (y-or-n-p "Are you sure you 
want to delete this search? ")
-   
(notmuch-hello-delete-search-from-history widget)))
+   :notify 
#'notmuch-hello-delete-search-from-history

[PATCH v2 00/36] [emacs] Add outline headings and switch to lexical scope

2021-01-10 Thread Jonas Bernoulli
This fixes a minor whitespace bug that Tomi notices in (1).

This also adds for commits, two of them in response to a concern
raised by Tomi, who didn't "see enough point for requiring subr-x
just [for string-empty-p]", which I agree with:

2) Changes how `cl-lib' and `pcase' are required.  I did that first
   because I want to do it the same way as for `subr-x'.

3) Require `subr-x', so that we can use it without having to worry
   whether we have now reached the threshold where it becomes
   justified to require an additional library.

   Personally I consider this library to be part of core elisp
   libraries, and wish it were autoloaded like, say `subr'.  I am
   not the only one with that opinion and some other package is
   bound to load this very small library anyways, so we might as
   well benefit from the goodies that it provides too.

The remaining two new commits (4,5) I have already submitted earlier
in a separate thread.  Unfortunately they did not get merged or even
just discussed so far, so I am including them here again.

 Cheers,
     Jonas

Jonas Bernoulli (36):
  emacs: use setq instead of set
  emacs: sanitize dedicated widget action/notify functions
  emacs: define new notmuch-search-item widget type
  emacs: notmuch-start-notmuch: remove backward compatibility code
  emacs: notmuch-start-notmuch-error-sentinel: assert buffer is alive
  emacs: notmuch-start-notmuch-sentinel: assert buffer is alive
  emacs: notmuch-start-notmuch: avoid storing process buffer twice
  emacs: avoid passing around some redundant information
  emacs: avoid killing process buffer when process is still alive
  emacs: make headings outline-minor-mode compatible
  emacs: use lexical-bindings in all libraries
  emacs: deal with unused lexical arguments and variables
  emacs: notmuch-tag--get-formats: silence byte-compiler
  emacs: inline notmuch-sexp-eof into only caller
  emacs: notmuch-wash-region-to-button: remove unused MSG argument
  emacs: silence compiler wrt notmuch-show-insert-part-text/plain
  emacs: define notmuch-message-queued-tag-changes as buffer-local
  emacs: notmuch-message-apply-queued-tag-changes: cosmetics
  emacs: notmuch-wash.el: require diff-mode at beginning of code
  emacs: notmuch-mua-prompt-for-sender: don't force Ido on users
  emacs: notmuch-mua.el: move all options into "Options" section
  emacs: notmuch-crypto-status-button-type: fix potential bug
1 emacs: various cosmetic improvements
  emacs: various comment improvements
  emacs: various doc-string improvements
  emacs: remove variable notmuch-search-disjunctive-regexp
  emacs: define a few variables as automatically buffer-local
  emacs: notmuch-search-stash-thread-id: use notmuch-search-query-string
  emacs: reorder notmuch.el a bit
  emacs: avoid unnecessary let-bindings
2 emacs: improve how cl-lib and pcase are required
3 emacs: make subr-x available in all libraries
  emacs: use string-empty-p
  emacs: notmuch-tree-get-match: No longer define as command
4 emacs: allow opting out of notmuch's address completion
5 emacs: notmuch-address-expand-name: use the actual initial-input

 emacs/coolj.el   |  14 +-
 emacs/make-deps.el   |   2 +-
 emacs/notmuch-address.el | 103 +++---
 emacs/notmuch-company.el |   3 -
 emacs/notmuch-compat.el  |   4 +-
 emacs/notmuch-crypto.el  |  14 +-
 emacs/notmuch-draft.el   |  27 +++-
 emacs/notmuch-hello.el   | 229 +++---
 emacs/notmuch-jump.el|  18 +--
 emacs/notmuch-lib.el | 199 +-
 emacs/notmuch-maildir-fcc.el | 114 +++
 emacs/notmuch-message.el |  25 ++--
 emacs/notmuch-mua.el | 124 +
 emacs/notmuch-parser.el  |  22 ++-
 emacs/notmuch-print.el   |  16 ++-
 emacs/notmuch-query.el   |  21 ++-
 emacs/notmuch-show.el| 130 ++---
 emacs/notmuch-tag.el | 103 --
 emacs/notmuch-tree.el|  61 
 emacs/notmuch-wash.el|  54 
 emacs/notmuch.el | 261 ++-
 emacs/rstdoc.el  |   2 +-
 test/test-lib.el |   4 +-
 23 files changed, 813 insertions(+), 737 deletions(-)

-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 04/36] emacs: notmuch-start-notmuch: remove backward compatibility code

2021-01-10 Thread Jonas Bernoulli
We no longer support Emacs releases before version 25.1.

Also adjust the sentinels which only had to deal with
an error file when using an older Emacs release was used.
---
 emacs/notmuch-lib.el | 64 
 1 file changed, 17 insertions(+), 47 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index e23999ad..76387779 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -896,42 +896,19 @@ (defun notmuch-start-notmuch (name buffer sentinel  
args)
 invoke `set-process-sentinel' directly on the returned process,
 as that will interfere with the handling of stderr and the exit
 status."
-  (let (err-file err-buffer proc err-proc
-;; Find notmuch using Emacs' `exec-path'
-(command (or (executable-find notmuch-command)
- (error "Command not found: %s" notmuch-command
-(if (fboundp 'make-process)
-   (progn
- (setq err-buffer (generate-new-buffer " *notmuch-stderr*"))
- ;; Emacs 25 and newer has `make-process', which allows
- ;; redirecting stderr independently from stdout to a
- ;; separate buffer. As this allows us to avoid using a
- ;; temporary file and shell invocation, use it when
- ;; available.
- (setq proc (make-process
- :name name
- :buffer buffer
- :command (cons command args)
- :connection-type 'pipe
- :stderr err-buffer))
- (setq err-proc (get-buffer-process err-buffer))
- (process-put proc 'err-buffer err-buffer)
-
- (process-put err-proc 'err-file err-file)
- (process-put err-proc 'err-buffer err-buffer)
- (set-process-sentinel err-proc 
#'notmuch-start-notmuch-error-sentinel))
-  ;; On Emacs versions before 25, there is no way to capture
-  ;; stdout and stderr separately for asynchronous processes, or
-  ;; even to redirect stderr to a file, so we use a trivial shell
-  ;; wrapper to send stderr to a temporary file and clean things
-  ;; up in the sentinel.
-  (setq err-file (make-temp-file "nmerr"))
-  (let ((process-connection-type nil)) ;; Use a pipe
-   (setq proc (apply #'start-process name buffer
- "/bin/sh" "-c"
- "exec 2>\"$1\"; shift; exec \"$0\" \"$@\""
- command err-file args)))
-  (process-put proc 'err-file err-file))
+  (let* ((command (or (executable-find notmuch-command)
+ (error "Command not found: %s" notmuch-command)))
+(err-buffer (generate-new-buffer " *notmuch-stderr*"))
+(proc (make-process
+   :name name
+   :buffer buffer
+   :command (cons command args)
+   :connection-type 'pipe
+   :stderr err-buffer))
+(err-proc (get-buffer-process err-buffer)))
+(process-put err-proc 'err-buffer err-buffer)
+(set-process-sentinel err-proc #'notmuch-start-notmuch-error-sentinel)
+(process-put proc 'err-buffer err-buffer)
 (process-put proc 'sub-sentinel sentinel)
 (process-put proc 'real-command (cons notmuch-command args))
 (set-process-sentinel proc #'notmuch-start-notmuch-sentinel)
@@ -939,9 +916,7 @@ (defun notmuch-start-notmuch (name buffer sentinel  
args)
 
 (defun notmuch-start-notmuch-sentinel (proc event)
   "Process sentinel function used by `notmuch-start-notmuch'."
-  (let* ((err-file (process-get proc 'err-file))
-(err-buffer (or (process-get proc 'err-buffer)
-(find-file-noselect err-file)))
+  (let* ((err-buffer (process-get proc 'err-buffer))
 (err (and (not (zerop (buffer-size err-buffer)))
   (with-current-buffer err-buffer (buffer-string
 (sub-sentinel (process-get proc 'sub-sentinel))
@@ -977,16 +952,11 @@ (defun notmuch-start-notmuch-sentinel (proc event)
   (error
;; Emacs behaves strangely if an error escapes from a sentinel,
;; so turn errors into messages.
-   (message "%s" (error-message-string err
-(when err-file (ignore-errors (delete-file err-file)
+   (message "%s" (error-message-string err))
 
 (defun notmuch-start-notmuch-error-sentinel (proc event)
-  (let* ((err-file (process-get proc 'err-file))
-;; When `make-process' is available, use the error buffer
-;; associated with the process, otherwise the error file.
-(err-buffer (or (process-get proc 'err-buffer)
-(find-file-noselect err-file
-(when err-buffer (kill-buffer err-buffer
+  (let ((buffer (process-get proc 'err-buffer)))
+(kill-buffer buffer)))
 
 (defvar-local notmuch-show-process-crypto nil)
 
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to 

[PATCH v2 01/36] emacs: use setq instead of set

2021-01-10 Thread Jonas Bernoulli
Commonly `set' is only used if there is no way around it;
i.e. when the variable cannot be known until runtime.
---
 emacs/notmuch-tree.el |  2 +-
 emacs/notmuch.el  | 14 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 57843e25..17863f6a 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -1133,7 +1133,7 @@ (defun notmuch-tree ( query query-context target 
buffer-name open-targe
(inhibit-read-only t))
 (pop-to-buffer-same-window buffer))
   ;; Don't track undo information for this buffer
-  (set 'buffer-undo-list t)
+  (setq buffer-undo-list t)
   (notmuch-tree-worker query query-context target open-target unthreaded)
   (setq notmuch-tree-parent-buffer parent-buffer)
   (setq truncate-lines t))
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 132e7724..bba4ca03 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -693,7 +693,7 @@ (defun notmuch-search-process-sentinel (proc msg)
(throw 'return nil))
  (when (and atbob
 (not (string= notmuch-search-target-thread 
"found")))
-   (set 'never-found-target-thread t)
+   (setq never-found-target-thread t)
(when (and never-found-target-thread
   notmuch-search-target-line)
  (goto-char (point-min))
@@ -996,11 +996,11 @@ (defun notmuch-search ( query oldest-first 
target-thread target-line no
   (pop-to-buffer-same-window buffer))
 (notmuch-search-mode)
 ;; Don't track undo information for this buffer
-(set 'buffer-undo-list t)
-(set 'notmuch-search-query-string query)
-(set 'notmuch-search-oldest-first oldest-first)
-(set 'notmuch-search-target-thread target-thread)
-(set 'notmuch-search-target-line target-line)
+(setq buffer-undo-list t)
+(setq notmuch-search-query-string query)
+(setq notmuch-search-oldest-first oldest-first)
+(setq notmuch-search-target-thread target-thread)
+(setq notmuch-search-target-line target-line)
 (notmuch-tag-clear-cache)
 (let ((proc (get-buffer-process (current-buffer)))
  (inhibit-read-only t))
@@ -1048,7 +1048,7 @@ (defun notmuch-search-toggle-order ()
 This command toggles the sort order for the current search. The
 default sort order is defined by `notmuch-search-oldest-first'."
   (interactive)
-  (set 'notmuch-search-oldest-first (not notmuch-search-oldest-first))
+  (setq notmuch-search-oldest-first (not notmuch-search-oldest-first))
   (notmuch-search-refresh-view))
 
 (defun notmuch-group-disjunctive-query-string (query-string)
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: failure in emacs notmuch-show: notmuch-show--register-cids: Wrong type argument: char-or-string-p, nil

2021-01-02 Thread Jonas Bernoulli
Daniel Kahn Gillmor  writes:

> My elisp is too weak to know how to debug this well.  suggestions
> welcome!

"M-x toggle-debug-on-error" and then trying to show the message should
give you a backtrace.  But before doing that also "M-x eval-buffer" in
"notmuch-show.el" to make it more meaningful.

> notmuch-show--register-cids: Wrong type argument:
> char-or-string-p, nil

With only that information my guess is that
  (plist-get part :content-type)
returns nil, which "downcase" understandably isn't happy with.

The "part" plist comes from "notmuch show ..." in
"notmuch-query-get-threads", so one problem seems to be that that
can return nil as the type (as opposed to e.g. "unknown/unknown")
while this elisp function (and maybe others) expect a string.

> 0 dkg@alice:~$ notmuch show --decrypt=false --format=raw id:$messageid  | 
> email-print-mime-structure --use-gpg-agent
> └┬╴multipart/encrypted 27703 bytes
>  ├─╴application/pgp-encrypted 11 bytes
>  └─╴application/octet-stream inline [encrypted.asc] 23828 bytes
>   ↧ (decrypts to)
>   └┬╴multipart/mixed 26085 bytes
>├─╴text/plain 1028 bytes
>└┬╴message/rfc822 attachment [attachment.eml] 24707 bytes
> └─╴text/plain 24510 bytes

And another problem seems to be that notmuch cannot determine the type
of some part even though "email-print-mime-structure" can.  You should
be able to figure out which part by adding a debug statement such as:

  (message "> %S" part)

 Cheers,
 Jonas
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 00/32] [emacs] Add outline headings and switch to lexical scope

2020-12-30 Thread Jonas Bernoulli
Tomi Ollila  writes:

> The patch series did not apply for me (fully) anymore.

Since you got it applied now I am not sending a second iteration just
yet, or should I?

By the way, a regularly rebased version can be found in the "pending"
branch at https://github.com/tarsiiformes/notmuch.git.  Currently it
ends with two additional commits that are not from this patch series but
which I have submitted separately (their commit messages are prefixed
with "[copy]").

> I like the series (on paper), 2 comments

:D

> In patch 23/32, line

Fixed

> Then, I personally don't see enough point for requiring subr-x
> just just for changing (string= foo "") to (string-empty-p). If
> there were more features picked from subr-x then that would be
> different...

I was on the fence about that too.  I left it in for now but have
no problems removing it before merge.

 Thanks for taking a look,
 Jonas
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 31/32] emacs: use string-empty-p

2020-12-14 Thread Jonas Bernoulli
Unfortunately that means we have to explicitly require subr-x, which
arguably should always be loaded without packages having to require
it, but the Emacs developers decided otherwise.  Loading it explicitly
most likely comes without any additional cost because almost certainly
some other packages would load it anyway--the functions it defines are
that popular.  And we are likely to use other functions from subr-x in
the future.
---
 emacs/notmuch-lib.el  | 3 ++-
 emacs/notmuch-mua.el  | 3 ++-
 emacs/notmuch-show.el | 5 +++--
 emacs/notmuch-tag.el  | 3 ++-
 emacs/notmuch.el  | 5 +++--
 5 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index cbac8859..7a64e728 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -22,6 +22,7 @@
 ;;; Code:
 
 (require 'cl-lib)
+(require 'subr-x)
 
 (require 'mm-util)
 (require 'mm-view)
@@ -283,7 +284,7 @@ (defun notmuch-poll ()
   (interactive)
   (message "Polling mail...")
   (if (stringp notmuch-poll-script)
-  (unless (string= notmuch-poll-script "")
+  (unless (string-empty-p notmuch-poll-script)
(unless (equal (call-process notmuch-poll-script nil nil) 0)
  (error "Notmuch: poll script `%s' failed!" notmuch-poll-script)))
 (notmuch-call-notmuch-process "new"))
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 2e4dc71a..a8643522 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -22,6 +22,7 @@
 ;;; Code:
 
 (eval-when-compile (require 'cl-lib))
+(require 'subr-x)
 
 (require 'message)
 (require 'mm-view)
@@ -390,7 +391,7 @@ (defun notmuch-mua-mail ( to subject other-headers 
_continue
   (interactive)
   (when notmuch-mua-user-agent-function
 (let ((user-agent (funcall notmuch-mua-user-agent-function)))
-  (unless (string= "" user-agent)
+  (unless (string-empty-p user-agent)
(push (cons 'User-Agent user-agent) other-headers
   (unless (assq 'From other-headers)
 (push (cons 'From (message-make-from
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 27925669..13d08b62 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -26,6 +26,7 @@
 (eval-when-compile
   (require 'cl-lib)
   (require 'pcase))
+(require 'subr-x)
 
 (require 'mm-view)
 (require 'message)
@@ -337,7 +338,7 @@ (defun notmuch-show-with-message-as-text (fn)
 (header (concat
  "Subject: " subject "\n"
  "To: " to "\n"
- (if (not (string= cc ""))
+ (if (not (string-empty-p cc))
  (concat "Cc: " cc "\n")
"")
  "From: " from "\n"
@@ -1794,7 +1795,7 @@ (defun notmuch-show-filter-thread (query)
 Reshows the current thread with matches defined by the new query-string."
   (interactive (list (notmuch-read-query "Filter thread: ")))
   (let ((msg-id (notmuch-show-get-message-id)))
-(setq notmuch-show-query-context (if (string= query "") nil query))
+(setq notmuch-show-query-context (if (string-empty-p query) nil query))
 (notmuch-show-refresh-view t)
 (notmuch-show-goto-message msg-id)))
 
diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
index 3c958dd4..1e8f7d4d 100644
--- a/emacs/notmuch-tag.el
+++ b/emacs/notmuch-tag.el
@@ -26,6 +26,7 @@
 (require 'cl-lib)
 (eval-when-compile
   (require 'pcase))
+(require 'subr-x)
 
 (require 'crm)
 
@@ -456,7 +457,7 @@ (defun notmuch-update-tags (tags tag-changes)
 from TAGS if present."
   (let ((result-tags (copy-sequence tags)))
 (dolist (tag-change tag-changes)
-  (let ((tag (and (not (string= tag-change ""))
+  (let ((tag (and (not (string-empty-p tag-change))
  (substring tag-change 1
(cl-case (aref tag-change 0)
  (?+ (unless (member tag result-tags)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 6553893b..860b3d6a 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -66,6 +66,7 @@
 ;;; Code:
 
 (eval-when-compile (require 'cl-lib))
+(require 'subr-x)
 
 (require 'mm-view)
 (require 'message)
@@ -816,13 +817,13 @@ (defun notmuch-search-insert-authors (format-string 
authors)
(setq invisible-string (notmuch-search-author-propertize 
invisible-string)))
   ;; If there is any invisible text, add it as a tooltip to the
   ;; visible text.
-  (unless (string= invisible-string "")
+  (unless (string-empty-p invisible-string)
(setq visible-string
  (propertize visible-string
  'help-echo (concat "..." invisible-string
   ;; Insert the visible and, if present, invisible author strings.
   (insert visible-string)
-  (unless (string= invisible-string "")
+  (unless (string-empty-p invisible-string)
(let ((start (point))
  overlay)
  (insert invisible-string)
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe 

[PATCH 32/32] emacs: notmuch-tree-get-match: No longer define as command

2020-12-14 Thread Jonas Bernoulli
When called from code, then this function returns non-nil when the
message at point is a matched message.  However it does nothing at all
to present that information to the user when it called interactively.
It is therefore safe to conclude that nobody is using this as a
command.
---
 emacs/notmuch-tree.el | 1 -
 1 file changed, 1 deletion(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 51a43edd..bd0e0945 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -423,7 +423,6 @@ (defun notmuch-tree-get-message-id ( bare)
 
 (defun notmuch-tree-get-match ()
   "Return whether the current message is a match."
-  (interactive)
   (notmuch-tree-get-prop :match))
 
 ;;; Update display
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 25/32] emacs: various doc-string improvements

2020-12-14 Thread Jonas Bernoulli
---
 emacs/notmuch-draft.el   | 12 ++-
 emacs/notmuch-maildir-fcc.el | 21 +-
 emacs/notmuch-mua.el |  9 
 emacs/notmuch-tag.el | 41 ++--
 emacs/notmuch-tree.el| 10 -
 emacs/notmuch.el | 24 ++---
 6 files changed, 59 insertions(+), 58 deletions(-)

diff --git a/emacs/notmuch-draft.el b/emacs/notmuch-draft.el
index 8af04598..bc688434 100644
--- a/emacs/notmuch-draft.el
+++ b/emacs/notmuch-draft.el
@@ -77,9 +77,11 @@ (defcustom notmuch-draft-quoted-tags '()
   :group 'notmuch-send)
 
 (defcustom notmuch-draft-save-plaintext 'ask
-  "Should notmuch save/postpone in plaintext messages that seem
-like they are intended to be sent encrypted
-(i.e with an mml encryption tag in it)."
+  "Whether to allow saving plaintext when it seems encryption is intended.
+When a message contains mml tags, then that suggest it is
+intended to be encrypted.  If the user requests that such a
+message is saved locally, then this option controls whether
+that is allowed.  Beside a boolean, this can also be `ask'."
   :type '(radio
  (const :tag "Never" nil)
  (const :tag "Ask every time" ask)
@@ -146,13 +148,13 @@ (defun notmuch-draft-unquote-some-mml ()
(insert secure-tag "\n")
 
 (defun notmuch-draft--has-encryption-tag ()
-  "Returns t if there is an mml secure tag."
+  "Return non-nil if there is an mml secure tag."
   (save-excursion
 (message-goto-body)
 (re-search-forward notmuch-draft-encryption-tag-regex nil t)))
 
 (defun notmuch-draft--query-encryption ()
-  "Checks if we should save a message that should be encrypted.
+  "Return non-nil if we should save a message that should be encrypted.
 
 `notmuch-draft-save-plaintext' controls the behaviour."
   (cl-case notmuch-draft-save-plaintext
diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el
index 945a66fc..863d 100644
--- a/emacs/notmuch-maildir-fcc.el
+++ b/emacs/notmuch-maildir-fcc.el
@@ -90,10 +90,8 @@ (defcustom notmuch-maildir-use-notmuch-insert t
 (defun notmuch-fcc-header-setup ()
   "Add an Fcc header to the current message buffer.
 
-Sets the Fcc header based on the values of `notmuch-fcc-dirs'.
-
-Originally intended to be use a hook function, but now called directly
-by notmuch-mua-mail."
+If the Fcc header is already set, then keep it as-is.
+Otherwise set it according to `notmuch-fcc-dirs'."
   (let ((subdir
 (cond
  ((or (not notmuch-fcc-dirs)
@@ -153,8 +151,9 @@ (defmacro with-temporary-notmuch-message-buffer ( body)
,@body)))
 
 (defun notmuch-maildir-setup-message-for-saving ()
-  "Setup message for saving. Should be called on a temporary copy.
+  "Setup message for saving.
 
+This should be called on a temporary copy.
 This is taken from the function message-do-fcc."
   (message-encode-message-body)
   (save-restriction
@@ -308,8 +307,8 @@ (defun notmuch-maildir-fcc-move-tmp-to-cur (destdir msg-id 
 mark-seen)
 (defun notmuch-maildir-fcc-file-fcc (fcc-header)
   "Write the message to the file specified by FCC-HEADER.
 
-It offers the user a chance to correct the header, or filesystem,
-if needed."
+If that fails, then offer the user a chance to correct the header
+or filesystem."
   (if (notmuch-maildir-fcc-dir-is-maildir-p fcc-header)
   (notmuch-maildir-fcc-write-buffer-to-maildir fcc-header t)
 ;; The fcc-header is not a valid maildir see if the user wants to
@@ -329,9 +328,11 @@ (defun notmuch-maildir-fcc-file-fcc (fcc-header)
 (read-from-minibuffer "Fcc header: " fcc-header)))
 
 (defun notmuch-maildir-fcc-write-buffer-to-maildir (destdir  
mark-seen)
-  "Writes the current buffer to maildir destdir. If mark-seen is
-non-nil, it will write it to cur/, and mark it as read. It should
-return t if successful, and nil otherwise."
+  "Write the current buffer to maildir destdir.
+
+If mark-seen is non-nil, then write it to \"cur/\", and mark it
+as read, otherwise write it to \"new/\". Return t if successful,
+and nil otherwise."
   (let ((orig-buffer (buffer-name)))
 (with-temp-buffer
   (insert-buffer-substring orig-buffer)
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 4a08e8a7..2e4dc71a 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -99,7 +99,7 @@ (defcustom notmuch-always-prompt-for-sender nil
   :group 'notmuch-send)
 
 (defgroup notmuch-reply nil
-  "Replying to messages in notmuch"
+  "Replying to messages in notmuch."
   :group 'notmuch)
 
 (defcustom notmuch-mua-cite-function 'message-cite-original
@@ -144,9 +144,10 @@ (defcustom notmuch-mua-attachment-regexp
 ;;; Various functions
 
 (defun notmuch-mua-attachment-check ()
-  "Signal an error if the message text indicates that an
-attachment is expected but no MML referencing an attachment is
-found.
+  "Signal an error an attachement is expected but missing.
+
+Signal an error if the message text indicates that an 

[PATCH 23/32] emacs: various cosmetic improvements

2020-12-14 Thread Jonas Bernoulli
---
 emacs/notmuch-address.el | 22 --
 emacs/notmuch-hello.el   | 24 ---
 emacs/notmuch-jump.el|  4 +-
 emacs/notmuch-lib.el | 26 +--
 emacs/notmuch-maildir-fcc.el | 61 +++---
 emacs/notmuch-mua.el | 28 ++--
 emacs/notmuch-query.el   | 11 +++--
 emacs/notmuch-tag.el | 14 +++---
 emacs/notmuch.el | 83 ++--
 9 files changed, 125 insertions(+), 148 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 1017c3ce..2f0ec9b3 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -21,6 +21,8 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'cl-lib))
+
 (require 'message)
 (require 'notmuch-parser)
 (require 'notmuch-lib)
@@ -160,15 +162,12 @@ (defun notmuch-address-message-insinuate ()
   (message "calling notmuch-address-message-insinuate is no longer needed"))
 
 (defun notmuch-address-setup ()
-  (let* ((setup-company (and notmuch-address-use-company
-(require 'company nil t)))
-(pair (cons notmuch-address-completion-headers-regexp
-#'notmuch-address-expand-name)))
-(when setup-company
-  (notmuch-company-setup))
-(unless (member pair message-completion-alist)
-  (setq message-completion-alist
-   (push pair message-completion-alist)
+  (when (and notmuch-address-use-company
+(require 'company nil t))
+(notmuch-company-setup))
+  (cl-pushnew (cons notmuch-address-completion-headers-regexp
+   #'notmuch-address-expand-name)
+ message-completion-alist :test #'equal))
 
 (defun notmuch-address-toggle-internal-completion ()
   "Toggle use of internal completion for current buffer.
@@ -264,9 +263,6 @@ (defun notmuch-address-harvest-addr (result)
   (let ((name-addr (plist-get result :name-addr)))
 (puthash name-addr t notmuch-address-completions)))
 
-(defun notmuch-address-harvest-handle-result (obj)
-  (notmuch-address-harvest-addr obj))
-
 (defun notmuch-address-harvest-filter (proc string)
   (when (buffer-live-p (process-buffer proc))
 (with-current-buffer (process-buffer proc)
@@ -274,7 +270,7 @@ (defun notmuch-address-harvest-filter (proc string)
(goto-char (point-max))
(insert string))
   (notmuch-sexp-parse-partial-list
-   'notmuch-address-harvest-handle-result (process-buffer proc)
+   'notmuch-address-harvest-addr (process-buffer proc)
 
 (defvar notmuch-address-harvest-procs '(nil . nil)
   "The currently running harvests.
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index a134eb07..ffd3d799 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -432,8 +432,7 @@ (defun notmuch-hello-add-saved-search (widget  _event)
 ;; If an existing saved search with this name exists, remove it.
 (setq notmuch-saved-searches
  (cl-loop for elem in notmuch-saved-searches
-  if (not (equal name
- (notmuch-saved-search-get elem :name)))
+  unless (equal name (notmuch-saved-search-get elem :name))
   collect elem))
 ;; Add the new one.
 (customize-save-variable 'notmuch-saved-searches
@@ -481,18 +480,14 @@ (defun notmuch-hello-reflect (list ncols)
 append (notmuch-hello-reflect-generate-row ncols nrows row list
 
 (defun notmuch-hello-widget-search (widget  _ignore)
-  (cond
-   ((eq (widget-get widget :notmuch-search-type) 'tree)
-(notmuch-tree (widget-get widget
- :notmuch-search-terms)))
-   ((eq (widget-get widget :notmuch-search-type) 'unthreaded)
-(notmuch-unthreaded (widget-get widget
-   :notmuch-search-terms)))
+  (cl-case (widget-get widget :notmuch-search-type)
+   (tree
+(notmuch-tree (widget-get widget :notmuch-search-terms)))
+   (unthreaded
+(notmuch-unthreaded (widget-get widget :notmuch-search-terms)))
(t
-(notmuch-search (widget-get widget
-   :notmuch-search-terms)
-   (widget-get widget
-   :notmuch-search-oldest-first)
+(notmuch-search (widget-get widget :notmuch-search-terms)
+   (widget-get widget :notmuch-search-oldest-first)
 
 (defun notmuch-saved-search-count (search)
   (car (process-lines notmuch-command "count" search)))
@@ -823,8 +818,7 @@ (defun notmuch-hello-insert-search ()
   ;; instead of a space to make `show-trailing-whitespace'
   ;; happy, i.e. avoid it marking the whole line as trailing
   ;; spaces.
-  (widget-insert ".")
-  (put-text-property (1- (point)) (point) 'invisible t)
+  (widget-insert (propertize "." 'invisible t))
   (widget-insert "\n"))
 
 (defun notmuch-hello-insert-recent-searches ()
diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
index 51bc4e31..34d6c796 100644
--- 

[PATCH 30/32] emacs: avoid unnecessary let-bindings

2020-12-14 Thread Jonas Bernoulli
To some extend this is a personal preference, but the preference is
strongly dependent on whether one is used to a language that makes it
necessary to use variables like this.

This makes it perfectly clear that we are first getting and then using
a "foo":

  (use-foo (get-foo))

Sure this has to be read "inside out", but that's something one better
gets used to quickly when dealing with lisp.  I don't understand why
one would want to write this instead:

  (let ((the-foo (get-foo)))
(use-foo the-foo))

Both `get-foo' and `use-foo' are named in a way that make it very
clear that we are dealing with a "foo".  Storing the value in an
additional variable `the-foo' does not make this any more clear.

On the contrary I makes the reader wonder why the author choose to
use a variable.  Is the value used more than once?  Is the value
being retrieved in one context and then used in another (e.g. when
the current buffer changes)?
---
 emacs/notmuch-address.el |  4 +--
 emacs/notmuch-lib.el |  6 ++---
 emacs/notmuch-maildir-fcc.el | 10 
 emacs/notmuch-show.el| 14 +-
 emacs/notmuch-tag.el | 10 
 emacs/notmuch-tree.el|  5 ++--
 emacs/notmuch.el | 50 +---
 7 files changed, 48 insertions(+), 51 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 1f22e377..f313c415 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -260,8 +260,8 @@ (defun notmuch-address-expand-name ()
 ;;; Harvest
 
 (defun notmuch-address-harvest-addr (result)
-  (let ((name-addr (plist-get result :name-addr)))
-(puthash name-addr t notmuch-address-completions)))
+  (puthash (plist-get result :name-addr)
+  t notmuch-address-completions))
 
 (defun notmuch-address-harvest-filter (proc string)
   (when (buffer-live-p (process-buffer proc))
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 2fd9a27d..cbac8859 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -416,9 +416,9 @@ (defun notmuch-help ()
 its prefixed behavior by setting the 'notmuch-prefix-doc property
 of its command symbol."
   (interactive)
-  (let* ((mode major-mode)
-(doc (substitute-command-keys
-  (notmuch-substitute-command-keys (documentation mode t)
+  (let ((doc (substitute-command-keys
+ (notmuch-substitute-command-keys
+  (documentation major-mode t)
 (with-current-buffer (generate-new-buffer "*notmuch-help*")
   (insert doc)
   (goto-char (point-min))
diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el
index 863d..8a5c5640 100644
--- a/emacs/notmuch-maildir-fcc.el
+++ b/emacs/notmuch-maildir-fcc.el
@@ -207,11 +207,11 @@ (defun notmuch-maildir-notmuch-insert-current-buffer 
(folder  create ta
 database in folder FOLDER. If CREATE is non-nil it will supply
 the --create-folder flag to create the folder if necessary. TAGS
 should be a list of tag changes to apply to the inserted message."
-  (let* ((args (append (and create (list "--create-folder"))
-  (list (concat "--folder=" folder))
-  tags)))
-(apply 'notmuch-call-notmuch-process
-  :stdin-string (buffer-string) "insert" args)))
+  (apply 'notmuch-call-notmuch-process
+:stdin-string (buffer-string) "insert"
+(append (and create (list "--create-folder"))
+(list (concat "--folder=" folder))
+tags)))
 
 (defun notmuch-maildir-fcc-with-notmuch-insert (fcc-header  create)
   "Store message with notmuch insert.
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 48374b38..27925669 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1666,13 +1666,13 @@ (defun notmuch-show-get-prop (prop  props)
 message in either tree or show. This means that several utility
 functions in notmuch-show can be used directly by notmuch-tree as
 they just need the correct message properties."
-  (let ((props (or props
-  (cond ((eq major-mode 'notmuch-show-mode)
- (notmuch-show-get-message-properties))
-((eq major-mode 'notmuch-tree-mode)
- (notmuch-tree-get-message-properties))
-(t nil)
-(plist-get props prop)))
+  (plist-get (or props
+(cond ((eq major-mode 'notmuch-show-mode)
+   (notmuch-show-get-message-properties))
+  ((eq major-mode 'notmuch-tree-mode)
+   (notmuch-tree-get-message-properties))
+  (t nil)))
+prop))
 
 (defun notmuch-show-get-message-id ( bare)
   "Return an id: query for the Message-Id of the current message.
diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
index c006026c..3c958dd4 100644
--- a/emacs/notmuch-tag.el
+++ b/emacs/notmuch-tag.el
@@ -406,8 +406,9 @@ (defun notmuch-tag-completions 

[PATCH 29/32] emacs: reorder notmuch.el a bit

2020-12-14 Thread Jonas Bernoulli
---
 emacs/notmuch.el | 41 -
 1 file changed, 20 insertions(+), 21 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 0fb9874b..24b930bf 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -70,6 +70,8 @@ (eval-when-compile (require 'cl-lib))
 (require 'mm-view)
 (require 'message)
 
+(require 'hl-line)
+
 (require 'notmuch-lib)
 (require 'notmuch-tag)
 (require 'notmuch-show)
@@ -114,8 +116,12 @@ (defcustom notmuch-init-file (locate-user-emacs-file 
"notmuch-config")
   :type 'file
   :group 'notmuch)
 
-(defvar notmuch-query-history nil
-  "Variable to store minibuffer history for notmuch queries.")
+(defcustom notmuch-search-hook '(notmuch-hl-line-mode)
+  "List of functions to call when notmuch displays the search results."
+  :type 'hook
+  :options '(notmuch-hl-line-mode)
+  :group 'notmuch-search
+  :group 'notmuch-hooks)
 
 ;;; Mime Utilities
 
@@ -155,24 +161,6 @@ (defun notmuch-save-attachments (mm-handle  
queryp)
(mm-save-part p
mm-handle))
 
-;;; Integrations
-
-(require 'hl-line)
-
-(defun notmuch-hl-line-mode ()
-  (prog1 (hl-line-mode)
-(when hl-line-overlay
-  (overlay-put hl-line-overlay 'priority 1
-
-;;; Options
-
-(defcustom notmuch-search-hook '(notmuch-hl-line-mode)
-  "List of functions to call when notmuch displays the search results."
-  :type 'hook
-  :options '(notmuch-hl-line-mode)
-  :group 'notmuch-search
-  :group 'notmuch-hooks)
-
 ;;; Keymap
 
 (defvar notmuch-search-mode-map
@@ -207,6 +195,9 @@ (defvar notmuch-search-mode-map
 
 ;;; Internal Variables
 
+(defvar notmuch-query-history nil
+  "Variable to store minibuffer history for notmuch queries.")
+
 (defvar-local notmuch-search-query-string nil)
 (defvar-local notmuch-search-target-thread nil)
 (defvar-local notmuch-search-target-line nil)
@@ -1154,7 +1145,15 @@ (defun notmuch-cycle-notmuch-buffers ()
  (pop-to-buffer-same-window first))
   (notmuch
 
-;;; Imenu Support
+;;; Integrations
+ Hl-line Support
+
+(defun notmuch-hl-line-mode ()
+  (prog1 (hl-line-mode)
+(when hl-line-overlay
+  (overlay-put hl-line-overlay 'priority 1
+
+ Imenu Support
 
 (defun notmuch-search-imenu-prev-index-position-function ()
   "Move point to previous message in notmuch-search buffer.
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 10/32] emacs: make headings outline-minor-mode compatible

2020-12-14 Thread Jonas Bernoulli
`outline-minor-mode' treats comments that begin with three or more
semicolons as headings.  That makes it very convenient to navigate
code and to show/hide parts of a file.

Elips libraries typically have four top-level sections, e.g.:

;;; notmuch.el --- run notmuch within emacs...
;;; Commentary:...
;;; Code:...
;;; notmuch.el ends here

In this package many libraries lack a "Commentary:" section, which is
not optimal but okay for most libraries, except major entry points.

Depending on how one chooses to look at it, the "... ends here" line
is not really a heading that begins a section, because it should never
have a "section" body (after all it marks eof).

If the file is rather short, then I left "Code:" as the only section
that contains code.  Otherwise I split the file into multiple sibling
sections.  The "Code:" section continues to contain `require' and
`declare-function' forms and other such "front matter".

If and only if I have split the code into multiple sections anyway,
then I also added an additional section named just "_" before the
`provide' form and shortly before the "...end here" line.  This
section could also be called "Back matter", but I feel it would be
distracting to be that explicit about it.  (The IMO unnecessary but
unfortunately still obligatory "... ends here" line is already
distracting enough as far as I am concerned.)

Before this commit some libraries already uses section headings, some
of them consistently.  When a library already had some headings, then
this commit often sticks to that style, even at the cost inconsistent
styling across all libraries.

A very limited number of variable and function definitions have to be
moved around because they would otherwise end up in sections they do
not belong into.

Sections, including but not limited to their heading, can and should
be further improved in the future.
---
 emacs/coolj.el   | 12 +++
 emacs/notmuch-address.el | 28 +++-
 emacs/notmuch-company.el |  1 -
 emacs/notmuch-compat.el  |  2 --
 emacs/notmuch-crypto.el  |  8 -
 emacs/notmuch-draft.el   |  9 -
 emacs/notmuch-hello.el   | 47 ++
 emacs/notmuch-jump.el|  2 --
 emacs/notmuch-lib.el | 41 ++-
 emacs/notmuch-maildir-fcc.el | 18 +-
 emacs/notmuch-mua.el | 18 +++---
 emacs/notmuch-print.el   |  8 +++--
 emacs/notmuch-query.el   |  8 ++---
 emacs/notmuch-show.el| 64 ++--
 emacs/notmuch-tag.el | 16 -
 emacs/notmuch-tree.el| 25 +++---
 emacs/notmuch-wash.el| 18 +-
 emacs/notmuch.el | 32 +-
 test/test-lib.el |  4 ++-
 19 files changed, 263 insertions(+), 98 deletions(-)

diff --git a/emacs/coolj.el b/emacs/coolj.el
index 0385872f..b3e314f0 100644
--- a/emacs/coolj.el
+++ b/emacs/coolj.el
@@ -25,13 +25,13 @@
 
 ;;; Commentary:
 
-;;; This is a simple derivative of some functionality from
-;;; `longlines.el'. The key difference is that this version will
-;;; insert a prefix at the head of each wrapped line. The prefix is
-;;; calculated from the originating long line.
+;; This is a simple derivative of some functionality from
+;; `longlines.el'. The key difference is that this version will
+;; insert a prefix at the head of each wrapped line. The prefix is
+;; calculated from the originating long line.
 
-;;; No minor-mode is provided, the caller is expected to call
-;;; `coolj-wrap-region' to wrap the region of interest.
+;; No minor-mode is provided, the caller is expected to call
+;; `coolj-wrap-region' to wrap the region of interest.
 
 ;;; Code:
 
diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 71985ed7..bf29c3a0 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -25,9 +25,11 @@ (require 'message)
 (require 'notmuch-parser)
 (require 'notmuch-lib)
 (require 'notmuch-company)
-;;
+
 (declare-function company-manual-begin "company")
 
+;;; Cache internals
+
 (defvar notmuch-address-last-harvest 0
   "Time of last address harvest.")
 
@@ -47,6 +49,8 @@ (defun notmuch-address--harvest-ready ()
   (or notmuch-address-full-harvest-finished
   (notmuch-address--load-address-hash)))
 
+;;; Options
+
 (defcustom notmuch-address-command 'internal
   "Determines how address completion candidates are generated.
 
@@ -133,6 +137,14 @@ (defcustom notmuch-address-post-completion-functions nil
   :group 'notmuch-address
   :group 'notmuch-hooks)
 
+(defcustom notmuch-address-use-company t
+  "If available, use company mode for address completion."
+  :type 'boolean
+  :group 'notmuch-send
+  :group 'notmuch-address)
+
+;;; Setup
+
 (defun notmuch-address-selection-function (prompt collection initial-input)
   "Call (`completing-read'
   PROMPT COLLECTION nil nil INITIAL-INPUT 'notmuch-address-history)"
@@ -147,12 +159,6 @@ (defvar notmuch-address-history nil)
 

[PATCH 27/32] emacs: define a few variables as automatically buffer-local

2020-12-14 Thread Jonas Bernoulli
Define these variables as automatically buffer-local, meaning that
they always become buffer-local when set unless explicitly told
otherwise using `setq-default' or when using the Custom interface.

Previously they were declared, which keeps the byte-compiler quiet but
is not actually the same as being defined.  `notmuch-search-mode' then
made them buffer-local in the current buffer and then set the local
values.  This works but is not kosher.

The definitions of the three non-option variables have to be moved up
a bit to enable the change in the next commit, which see.
---
 emacs/notmuch-lib.el |  1 +
 emacs/notmuch.el | 16 ++--
 2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 72549a98..2fd9a27d 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -101,6 +101,7 @@ (defcustom notmuch-search-oldest-first t
 search."
   :type 'boolean
   :group 'notmuch-search)
+(make-variable-buffer-local 'notmuch-search-oldest-first)
 
 (defcustom notmuch-poll-script nil
   "[Deprecated] Command to run to incorporate new mail into the notmuch 
database.
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 35f825b9..464960e4 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -205,6 +205,12 @@ (defvar notmuch-search-mode-map
 map)
   "Keymap for \"notmuch search\" buffers.")
 
+;;; Internal Variables
+
+(defvar-local notmuch-search-query-string nil)
+(defvar-local notmuch-search-target-thread nil)
+(defvar-local notmuch-search-target-line nil)
+
 ;;; Stashing
 
 (defvar notmuch-search-stash-map
@@ -226,12 +232,6 @@ (defun notmuch-stash-query ()
   (interactive)
   (notmuch-common-do-stash (notmuch-search-get-query)))
 
-;;; Variables
-
-(defvar notmuch-search-query-string)
-(defvar notmuch-search-target-thread)
-(defvar notmuch-search-target-line)
-
 ;;; Movement
 
 (defun notmuch-search-scroll-up ()
@@ -404,10 +404,6 @@ (define-derived-mode notmuch-search-mode fundamental-mode 
"notmuch-search"
 Complete list of currently available key bindings:
 
 \\{notmuch-search-mode-map}"
-  (make-local-variable 'notmuch-search-query-string)
-  (make-local-variable 'notmuch-search-oldest-first)
-  (make-local-variable 'notmuch-search-target-thread)
-  (make-local-variable 'notmuch-search-target-line)
   (setq notmuch-buffer-refresh-function #'notmuch-search-refresh-view)
   (setq-local scroll-preserve-screen-position t)
   (add-to-invisibility-spec (cons 'ellipsis t))
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 26/32] emacs: remove variable notmuch-search-disjunctive-regexp

2020-12-14 Thread Jonas Bernoulli
The value is the only possible value, it is only used in one
place, and using a global variable serves no purpose but to
make things more complicated.
---
 emacs/notmuch.el | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 20d2f095..35f825b9 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -232,8 +232,6 @@ (defvar notmuch-search-query-string)
 (defvar notmuch-search-target-thread)
 (defvar notmuch-search-target-line)
 
-(defvar notmuch-search-disjunctive-regexp "\\<[oO][rR]\\>")
-
 ;;; Movement
 
 (defun notmuch-search-scroll-up ()
@@ -1083,10 +1081,8 @@ (defun notmuch-search-toggle-order ()
 
 (defun notmuch-group-disjunctive-query-string (query-string)
   "Group query if it contains a complex expression.
-
-Enclose QUERY-STRING in parentheses if it matches
-`notmuch-search-disjunctive-regexp'."
-  (if (string-match-p notmuch-search-disjunctive-regexp query-string)
+Enclose QUERY-STRING in parentheses if contains \"OR\" operators."
+  (if (string-match-p "\\<[oO][rR]\\>" query-string)
   (concat "( " query-string " )")
 query-string))
 
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 28/32] emacs: notmuch-search-stash-thread-id: use notmuch-search-query-string

2020-12-14 Thread Jonas Bernoulli
No longer use the function `notmuch-search-get-query', which does
nothing but return the value of that variable.  That function was
added in [1: f47eeac0] for use in `notmuch-read-query' along-side
related `notmuch-show-get-query' and `notmuch-tree-get-query' but
using it here makes little sense.

1: f47eeac0b0186c3559eb559c4f0bee0e1fac1961
   emacs: set default in notmuch-read-query
---
 emacs/notmuch.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 464960e4..0fb9874b 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -230,7 +230,7 @@ (defun notmuch-search-stash-thread-id ()
 (defun notmuch-stash-query ()
   "Copy current query to kill-ring."
   (interactive)
-  (notmuch-common-do-stash (notmuch-search-get-query)))
+  (notmuch-common-do-stash notmuch-search-query-string))
 
 ;;; Movement
 
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 22/32] emacs: notmuch-crypto-status-button-type: fix potential bug

2020-12-14 Thread Jonas Bernoulli
The "help-echo" can potentially contain an unintended %-spec
so we have to make sure it would not be treated as such.
---
 emacs/notmuch-crypto.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index 50a3de46..db7cb75d 100644
--- a/emacs/notmuch-crypto.el
+++ b/emacs/notmuch-crypto.el
@@ -103,7 +103,7 @@ (defface notmuch-crypto-decryption
 ;;; Functions
 
 (define-button-type 'notmuch-crypto-status-button-type
-  'action (lambda (button) (message (button-get button 'help-echo)))
+  'action (lambda (button) (message "%s" (button-get button 'help-echo)))
   'follow-link t
   'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime 
parts."
   :supertype 'notmuch-button-type)
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 20/32] emacs: notmuch-mua-prompt-for-sender: don't force Ido on users

2020-12-14 Thread Jonas Bernoulli
We shouldn't force `ido-completion-read' on users who do not otherwise
use Ido.  Unfortunately simply turning on `ido-mode' does not change
every `completing-read' into a `ido-completing-read', instead it only
changes file and buffer completion.

I do realize that existing Ido users will initially dislike this
change, but I would like to encourage them to see this as an
opportunity to learn about Fido.

Unlike `ido-mode', build-in `fido-mode' confirms to the standard
completion API, so turning it on causes every `completing-read' to
use the Fido completion mechanism and which is similar to the Ido
mechanism:

> An enhanced `icomplete-mode' that emulates `ido-mode'.  This global
> minor mode makes minibuffer completion behave more like `ido-mode'
> than regular `icomplete-mode'."
---
 emacs/notmuch-mua.el | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 95d1965b..2d0b7169 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -431,16 +431,16 @@ (defvar notmuch-mua-sender-history nil)
 (defun notmuch-mua-prompt-for-sender ()
   "Prompt for a sender from the user's configured identities."
   (if notmuch-identities
-  (ido-completing-read "Send mail from: " notmuch-identities
-  nil nil nil 'notmuch-mua-sender-history
-  (car notmuch-identities))
+  (completing-read "Send mail from: " notmuch-identities
+  nil nil nil 'notmuch-mua-sender-history
+  (car notmuch-identities))
 (let* ((name (notmuch-user-name))
   (addrs (cons (notmuch-user-primary-email)
(notmuch-user-other-email)))
   (address
-   (ido-completing-read (concat "Sender address for " name ": ") addrs
-nil nil nil 'notmuch-mua-sender-history
-(car addrs
+   (completing-read (concat "Sender address for " name ": ") addrs
+nil nil nil 'notmuch-mua-sender-history
+(car addrs
   (message-make-from name address
 
 (put 'notmuch-mua-new-mail 'notmuch-prefix-doc "... and prompt for sender")
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 24/32] emacs: various comment improvements

2020-12-14 Thread Jonas Bernoulli
---
 emacs/notmuch-address.el | 5 ++---
 emacs/notmuch-hello.el   | 4 +---
 emacs/notmuch-lib.el | 6 +++---
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 2f0ec9b3..1f22e377 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -381,7 +381,7 @@ (defun notmuch-address--load-address-hash ()
 (defun notmuch-address--save-address-hash ()
   (when notmuch-address-save-filename
 (if (or (not (file-exists-p notmuch-address-save-filename))
-   ;; The file exists, check it is a file we saved
+   ;; The file exists, check it is a file we saved.
(notmuch-address--get-address-hash))
(with-temp-file notmuch-address-save-filename
  (let ((save-plist
@@ -404,8 +404,7 @@ (defun notmuch-address-harvest-trigger ()
nil nil
(lambda (_proc event)
 ;; If harvest fails, we want to try
-;; again when the trigger is next
-;; called
+;; again when the trigger is next called.
 (if (string= event "finished\n")
 (progn
   (notmuch-address--save-address-hash)
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index ffd3d799..186ac172 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -731,9 +731,7 @@ (define-derived-mode notmuch-hello-mode fundamental-mode 
"notmuch-hello"
 Complete list of currently available key bindings:
 
 \\{notmuch-hello-mode-map}"
-  (setq notmuch-buffer-refresh-function #'notmuch-hello-update)
-  ;;(setq buffer-read-only t)
-  )
+  (setq notmuch-buffer-refresh-function #'notmuch-hello-update))
 
 ;;; Inserters
 
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 3add992b..72549a98 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -247,7 +247,7 @@ (defun notmuch-config-get (item)
   (let* ((val (notmuch-command-to-string "config" "get" item))
 (len (length val)))
 ;; Trim off the trailing newline (if the value is empty or not
-;; configured, there will be no newline)
+;; configured, there will be no newline).
 (if (and (> len 0)
 (= (aref val (- len 1)) ?\n))
(substring val 0 -1)
@@ -483,8 +483,8 @@ (defun notmuch-refresh-all-buffers ()
 ;;; String Utilities
 
 (defun notmuch-prettify-subject (subject)
-  ;; This function is used by `notmuch-search-process-filter' which
-  ;; requires that we not disrupt its' matching state.
+  ;; This function is used by `notmuch-search-process-filter',
+  ;; which requires that we not disrupt its matching state.
   (save-match-data
 (if (and subject
 (string-match "^[ \t]*$" subject))
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 18/32] emacs: notmuch-message-apply-queued-tag-changes: cosmetics

2020-12-14 Thread Jonas Bernoulli
---
 emacs/notmuch-message.el | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-message.el b/emacs/notmuch-message.el
index 9dc8d056..abeff53a 100644
--- a/emacs/notmuch-message.el
+++ b/emacs/notmuch-message.el
@@ -62,9 +62,8 @@ (defvar-local notmuch-message-queued-tag-changes nil
 (defun notmuch-message-apply-queued-tag-changes ()
   ;; Apply the tag changes queued in the buffer-local variable
   ;; notmuch-message-queued-tag-changes.
-  (dolist (query-and-tags notmuch-message-queued-tag-changes)
-(notmuch-tag (car query-and-tags)
-(cdr query-and-tags
+  (pcase-dolist (`(,query . ,tags) notmuch-message-queued-tag-changes)
+(notmuch-tag query tags)))
 
 (add-hook 'message-send-hook 'notmuch-message-apply-queued-tag-changes)
 
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 15/32] emacs: notmuch-wash-region-to-button: remove unused MSG argument

2020-12-14 Thread Jonas Bernoulli
---
 emacs/notmuch-wash.el | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index 36041904..4fbb4e12 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -200,7 +200,7 @@ (defun notmuch-wash-button-label (overlay)
   (overlay-end overlay
 (format label-format lines-count)))
 
-(defun notmuch-wash-region-to-button (msg beg end type  prefix)
+(defun notmuch-wash-region-to-button (beg end type  prefix)
   "Auxiliary function to do the actual making of overlays and buttons.
 
 BEG and END are buffer locations. TYPE should a string, either
@@ -237,8 +237,7 @@ (defun notmuch-wash-excerpt-citations (msg depth)
   (beginning-of-line)
   (when (and (< (point) (point-max))
 (re-search-forward notmuch-wash-original-regexp nil t))
-(notmuch-wash-region-to-button msg
-  (match-beginning 0)
+(notmuch-wash-region-to-button (match-beginning 0)
   (point-max)
   "original"))
   (while (and (< (point) (point-max))
@@ -257,7 +256,7 @@ (defun notmuch-wash-excerpt-citations (msg depth)
  (goto-char cite-end)
  (forward-line (- notmuch-wash-citation-lines-suffix))
  (notmuch-wash-region-to-button
-  msg hidden-start (point-marker)
+  hidden-start (point-marker)
   "citation")
   (when (and (not (eobp))
 (re-search-forward notmuch-wash-signature-regexp nil t))
@@ -271,7 +270,7 @@ (defun notmuch-wash-excerpt-citations (msg depth)
  (overlay-put (make-overlay sig-start-marker sig-end-marker)
   'face 'message-cited-text)
  (notmuch-wash-region-to-button
-  msg sig-start-marker sig-end-marker
+  sig-start-marker sig-end-marker
   "signature"))
 
 (defun notmuch-wash-elide-blank-lines (msg depth)
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 17/32] emacs: define notmuch-message-queued-tag-changes as buffer-local

2020-12-14 Thread Jonas Bernoulli
Also improve the doc-string.
---
 emacs/notmuch-message.el | 14 +++---
 emacs/notmuch-mua.el | 12 ++--
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/emacs/notmuch-message.el b/emacs/notmuch-message.el
index f0e9ffcc..9dc8d056 100644
--- a/emacs/notmuch-message.el
+++ b/emacs/notmuch-message.el
@@ -50,14 +50,14 @@ (defcustom notmuch-message-forwarded-tags '("+forwarded")
   :type '(repeat string)
   :group 'notmuch-send)
 
-(defconst notmuch-message-queued-tag-changes nil
-  "List of messages and corresponding tag-changes to be applied when sending a 
message.
+(defvar-local notmuch-message-queued-tag-changes nil
+  "List of tag changes to be applied when sending a message.
 
-This variable is overridden by buffer-local versions in message
-buffers where tag changes should be triggered when sending off
-the message.  Each item in this list is a list of strings, where
-the first is a notmuch query and the rest are the tag changes to
-be applied to the matching messages.")
+A list of queries and tag changes that are to be applied to them
+when the message that was composed in the current buffer is being
+send.  Each item in this list is a list of strings, where the
+first is a notmuch query and the rest are the tag changes to be
+applied to the matching messages.")
 
 (defun notmuch-message-apply-queued-tag-changes ()
   ;; Apply the tag changes queued in the buffer-local variable
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index b2930051..95d1965b 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -266,8 +266,8 @@ (defun notmuch-mua-reply (query-string  sender 
reply-all)
   ;; Create a buffer-local queue for tag changes triggered when
   ;; sending the reply.
   (when notmuch-message-replied-tags
-   (setq-local notmuch-message-queued-tag-changes
-   (list (cons query-string notmuch-message-replied-tags
+   (setq notmuch-message-queued-tag-changes
+ (list (cons query-string notmuch-message-replied-tags
   ;; Insert the message body - but put it in front of the signature
   ;; if one is present, and after any other content
   ;; message*setup-hooks may have added to the message body already.
@@ -507,10 +507,10 @@ (defun notmuch-mua-new-forward-messages (messages 
 prompt-for-sender)
   ;; Create a buffer-local queue for tag changes triggered when
   ;; sending the message.
   (when notmuch-message-forwarded-tags
-   (setq-local notmuch-message-queued-tag-changes
-   (cl-loop for id in forward-queries
-collect
-(cons id notmuch-message-forwarded-tags
+   (setq notmuch-message-queued-tag-changes
+ (cl-loop for id in forward-queries
+  collect
+  (cons id notmuch-message-forwarded-tags
   ;; `message-forward-make-body' shows the User-agent header.  Hide
   ;; it again.
   (message-hide-headers)
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 21/32] emacs: notmuch-mua.el: move all options into "Options" section

2020-12-14 Thread Jonas Bernoulli
This is how we do it in other libraries.
---
 emacs/notmuch-mua.el | 32 
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 2d0b7169..74ffd8f2 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -82,6 +82,22 @@ (defcustom notmuch-mua-hidden-headers nil
   :type '(repeat string)
   :group 'notmuch-send)
 
+(defcustom notmuch-identities nil
+  "Identities that can be used as the From: address when composing a new 
message.
+
+If this variable is left unset, then a list will be constructed from the
+name and addresses configured in the notmuch configuration file."
+  :type '(repeat string)
+  :group 'notmuch-send)
+
+(defcustom notmuch-always-prompt-for-sender nil
+  "Always prompt for the From: address when composing or forwarding a message.
+
+This is not taken into account when replying to a message, because in that case
+the From: header is already filled in by notmuch."
+  :type 'boolean
+  :group 'notmuch-send)
+
 (defgroup notmuch-reply nil
   "Replying to messages in notmuch"
   :group 'notmuch)
@@ -410,22 +426,6 @@ (defun notmuch-mua-mail ( to subject 
other-headers _continue
   (notmuch-mua-maybe-set-window-dedicated)
   (message-goto-to))
 
-(defcustom notmuch-identities nil
-  "Identities that can be used as the From: address when composing a new 
message.
-
-If this variable is left unset, then a list will be constructed from the
-name and addresses configured in the notmuch configuration file."
-  :type '(repeat string)
-  :group 'notmuch-send)
-
-(defcustom notmuch-always-prompt-for-sender nil
-  "Always prompt for the From: address when composing or forwarding a message.
-
-This is not taken into account when replying to a message, because in that case
-the From: header is already filled in by notmuch."
-  :type 'boolean
-  :group 'notmuch-send)
-
 (defvar notmuch-mua-sender-history nil)
 
 (defun notmuch-mua-prompt-for-sender ()
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 19/32] emacs: notmuch-wash.el: require diff-mode at beginning of code

2020-12-14 Thread Jonas Bernoulli
That's what we usually do.  Also do not declare variable
`diff-file-header-re' because it is defined in `diff-mode.el',
which we always require.
---
 emacs/notmuch-wash.el | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index d613e04c..653ecc2a 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -24,6 +24,7 @@
 ;;; Code:
 
 (require 'coolj)
+(require 'diff-mode)
 (require 'notmuch-lib)
 
 (declare-function notmuch-show-insert-bodypart "notmuch-show"
@@ -341,10 +342,6 @@ (defun notmuch-wash-wrap-long-lines (_msg depth)
 
  Convert Inline Patches
 
-(require 'diff-mode)
-
-(defvar diff-file-header-re) ; From `diff-mode.el'.
-
 (defun notmuch-wash-subject-to-filename (subject  maxlen)
   "Convert a mail SUBJECT into a filename.
 
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 12/32] emacs: deal with unused lexical arguments and variables

2020-12-14 Thread Jonas Bernoulli
The previous commit switched to lexical-binding but without dealing
with the new warnings about unused lexical arguments and variables.

This commit deals with most of them, in most cases by either removing
leftover bindings that are actually unnecessary, or by marking certain
arguments as "known to be unused" by prefixing their names with "_".

In the case of the functions named `notmuch-show-insert-...' the
amount of silencing that is required is a bit extreme and we might
want to investigate if there is a better way.

In the case of `notmuch-mua-mail', ignoring CONTINUE means that we do
not fully follow the intended behavior described in `compose-mail's
doc-string.
---
 emacs/notmuch-address.el |  4 ++--
 emacs/notmuch-crypto.el  |  2 +-
 emacs/notmuch-hello.el   | 16 +++
 emacs/notmuch-jump.el|  6 +++---
 emacs/notmuch-lib.el |  2 +-
 emacs/notmuch-maildir-fcc.el |  4 ++--
 emacs/notmuch-mua.el |  2 +-
 emacs/notmuch-print.el   |  6 +++---
 emacs/notmuch-show.el| 38 ++--
 emacs/notmuch-tree.el| 14 +
 emacs/notmuch-wash.el| 16 +++
 emacs/notmuch.el |  5 ++---
 12 files changed, 54 insertions(+), 61 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 6b117458..1017c3ce 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -191,7 +191,7 @@ (defun notmuch-address-matching (substring)
 The candidates are taken from `notmuch-address-completions'."
   (let ((candidates)
(re (regexp-quote substring)))
-(maphash (lambda (key val)
+(maphash (lambda (key _val)
   (when (string-match re key)
 (push key candidates)))
 notmuch-address-completions)
@@ -406,7 +406,7 @@ (defun notmuch-address-harvest-trigger ()
   (setq notmuch-address-last-harvest now)
   (notmuch-address-harvest
nil nil
-   (lambda (proc event)
+   (lambda (_proc event)
 ;; If harvest fails, we want to try
 ;; again when the trigger is next
 ;; called
diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index ee5231e5..50a3de46 100644
--- a/emacs/notmuch-crypto.el
+++ b/emacs/notmuch-crypto.el
@@ -171,7 +171,7 @@ (defun notmuch-crypto-sigstatus-good-callback (button)
 (declare-function notmuch-show-refresh-view "notmuch-show" ( 
reset-state))
 (declare-function notmuch-show-get-message-id "notmuch-show" ( bare))
 
-(defun notmuch-crypto--async-key-sentinel (process event)
+(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.
 
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 586a2848..a134eb07 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -480,7 +480,7 @@ (defun notmuch-hello-reflect (list ncols)
 (cl-loop for row from 0 to (- nrows 1)
 append (notmuch-hello-reflect-generate-row ncols nrows row list
 
-(defun notmuch-hello-widget-search (widget  ignore)
+(defun notmuch-hello-widget-search (widget  _ignore)
   (cond
((eq (widget-get widget :notmuch-search-type) 'tree)
 (notmuch-tree (widget-get widget
@@ -775,14 +775,14 @@ (defun notmuch-hello-insert-header ()
   (let ((widget-link-prefix "")
(widget-link-suffix ""))
 (widget-create 'link
-  :notify (lambda ( ignore)
+  :notify (lambda ( _ignore)
 (browse-url notmuch-hello-url))
   :help-echo "Visit the notmuch website."
   "notmuch")
 (widget-insert ". ")
 (widget-insert "You have ")
 (widget-create 'link
-  :notify (lambda ( ignore)
+  :notify (lambda ( _ignore)
 (notmuch-hello-update))
   :help-echo "Refresh"
   (notmuch-hello-nice-number
@@ -801,7 +801,7 @@ (defun notmuch-hello-insert-saved-searches ()
 (when searches
   (widget-insert "Saved searches: ")
   (widget-create 'push-button
-:notify (lambda ( ignore)
+:notify (lambda ( _ignore)
   (customize-variable 'notmuch-saved-searches))
 "edit")
   (widget-insert "\n\n")
@@ -873,13 +873,13 @@ (defun notmuch-hello-insert-searches (title query-list 
 options)
(start (point)))
 (if is-hidden
(widget-create 'push-button
-  :notify `(lambda (widget  ignore)
+  :notify `(lambda (widget  _ignore)
  (setq notmuch-hello-hidden-sections
(delete ,title 
notmuch-hello-hidden-sections))
  (notmuch-hello-update))
   "show")
   (widget-create 'push-button
-:notify `(lambda 

[PATCH 16/32] emacs: silence compiler wrt notmuch-show-insert-part-text/plain

2020-12-14 Thread Jonas Bernoulli
`notmuch-show-insert-part-text/plain' calls
`notmuch-show-insert-text/plain-hook' with two arguments
MSG and DEPTH. Currently all hook functions ignore MSG but
third-party functions may not.  One hook function uses DEPTH.
---
 emacs/notmuch-wash.el | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index 4fbb4e12..d613e04c 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -231,7 +231,7 @@ (defun notmuch-wash-region-to-button (beg end type 
 prefix)
 
 ;;; Hook functions
 
-(defun notmuch-wash-excerpt-citations (msg depth)
+(defun notmuch-wash-excerpt-citations (_msg _depth)
   "Excerpt citations and up to one signature."
   (goto-char (point-min))
   (beginning-of-line)
@@ -273,7 +273,7 @@ (defun notmuch-wash-excerpt-citations (msg depth)
   sig-start-marker sig-end-marker
   "signature"))
 
-(defun notmuch-wash-elide-blank-lines (msg depth)
+(defun notmuch-wash-elide-blank-lines (_msg _depth)
   "Elide leading, trailing and successive blank lines."
   ;; Algorithm derived from `article-strip-multiple-blank-lines' in
   ;; `gnus-art.el'.
@@ -294,7 +294,7 @@ (defun notmuch-wash-elide-blank-lines (msg depth)
   (when (looking-at "\n")
 (delete-region (match-beginning 0) (match-end 0
 
-(defun notmuch-wash-tidy-citations (msg depth)
+(defun notmuch-wash-tidy-citations (_msg _depth)
   "Improve the display of cited regions of a message.
 
 Perform several transformations on the message body:
@@ -318,7 +318,7 @@ (defun notmuch-wash-tidy-citations (msg depth)
   (while (re-search-forward "\\(^>[> ]*\n\\)\\(^$\\|^[^>].*\\)" nil t)
 (replace-match "\\2")))
 
-(defun notmuch-wash-wrap-long-lines (msg depth)
+(defun notmuch-wash-wrap-long-lines (_msg depth)
   "Wrap long lines in the message.
 
 If `notmuch-wash-wrap-lines-length' is a number, this will wrap
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 14/32] emacs: inline notmuch-sexp-eof into only caller

2020-12-14 Thread Jonas Bernoulli
This function had a few issues.
- Neither its name nor the old comment before it is called made it
  clear what it does.
- It took one argument but didn't do anything with it.
- It's doc-string made a few claims, which are untrue and generally
  focused on details instead of that its purpose is.
---
 emacs/notmuch-parser.el | 16 +---
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/emacs/notmuch-parser.el b/emacs/notmuch-parser.el
index b8c3fd2c..294e0544 100644
--- a/emacs/notmuch-parser.el
+++ b/emacs/notmuch-parser.el
@@ -140,15 +140,6 @@ (defun notmuch-sexp-begin-list (sp)
 (forward-char)
 (signal 'invalid-read-syntax (list (string (char-before)))
 
-(defun notmuch-sexp-eof (sp)
-  "Signal an error if there is more data in SP's buffer.
-
-Moves point to the beginning of any trailing data or to the end
-of the buffer if there is only trailing whitespace."
-  (skip-chars-forward " \n\r\t")
-  (unless (eobp)
-(error "Trailing garbage following expression")))
-
 (defvar notmuch-sexp--parser nil
   "The buffer-local notmuch-sexp-parser instance.
 
@@ -187,8 +178,11 @@ (defun notmuch-sexp-parse-partial-list (result-function 
result-buffer)
 (t (with-current-buffer result-buffer
  (funcall result-function result))
(end
-;; Any trailing data is unexpected
-(notmuch-sexp-eof notmuch-sexp--parser)
+;; Skip over trailing whitespace.
+(skip-chars-forward " \n\r\t")
+;; Any trailing data is unexpected.
+(unless (eobp)
+  (error "Trailing garbage following expression"))
 (setq done t)
   ;; Clear out what we've parsed
   (delete-region (point-min) (point)))
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 13/32] emacs: notmuch-tag--get-formats: silence byte-compiler

2020-12-14 Thread Jonas Bernoulli
`format-alist' is a global variable and the byte-compiler is unhappy
when a lexical function argument shadows a global (dynamic) binding.
---
 emacs/notmuch-tag.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
index fa376b02..a553dfd9 100644
--- a/emacs/notmuch-tag.el
+++ b/emacs/notmuch-tag.el
@@ -285,12 +285,12 @@ (defun notmuch-tag-clear-cache ()
   "Clear the internal cache of tag formats."
   (clrhash notmuch-tag--format-cache))
 
-(defun notmuch-tag--get-formats (tag format-alist)
+(defun notmuch-tag--get-formats (tag alist)
   "Find the first item whose car regexp-matches TAG."
   (save-match-data
 ;; Don't use assoc-default since there's no way to distinguish a
 ;; missing key from a present key with a null cdr.
-(cl-assoc tag format-alist
+(cl-assoc tag alist
  :test (lambda (tag key)
  (and (eq (string-match key tag) 0)
   (= (match-end 0) (length tag)))
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 11/32] emacs: use lexical-bindings in all libraries

2020-12-14 Thread Jonas Bernoulli
Doing so causes many new compile warnings.  Some of these warnings
concern genuine changes in behavior that have to be addressed right
away.

Many other warnings are due to unused variables.  Nothing has changed
here, except that the byte-compiler can now detect these pre-existing
and harmless issues.  We delay addressing these issues so that we can
focus on the important ones here.

A third group of warnings concern arguments that are not actually used
inside the function but which cannot be removed because the functions
signature is dictated by some outside convention.  Silencing these
warning is also delayed until subsequent commits.
---
 emacs/coolj.el   |  2 +-
 emacs/make-deps.el   |  2 +-
 emacs/notmuch-address.el |  2 +-
 emacs/notmuch-compat.el  |  2 +-
 emacs/notmuch-crypto.el  |  2 +-
 emacs/notmuch-draft.el   |  2 +-
 emacs/notmuch-hello.el   |  2 +-
 emacs/notmuch-jump.el|  2 +-
 emacs/notmuch-lib.el |  2 +-
 emacs/notmuch-maildir-fcc.el |  2 +-
 emacs/notmuch-message.el |  2 +-
 emacs/notmuch-mua.el |  7 ++-
 emacs/notmuch-parser.el  |  2 +-
 emacs/notmuch-print.el   |  2 +-
 emacs/notmuch-query.el   |  2 +-
 emacs/notmuch-show.el|  6 +-
 emacs/notmuch-tag.el | 18 ++
 emacs/notmuch-tree.el|  2 +-
 emacs/notmuch-wash.el|  2 +-
 emacs/notmuch.el |  2 +-
 emacs/rstdoc.el  |  2 +-
 21 files changed, 39 insertions(+), 28 deletions(-)

diff --git a/emacs/coolj.el b/emacs/coolj.el
index b3e314f0..d820525b 100644
--- a/emacs/coolj.el
+++ b/emacs/coolj.el
@@ -1,4 +1,4 @@
-;;; coolj.el --- automatically wrap long lines  -*- coding:utf-8 -*-
+;;; coolj.el --- automatically wrap long lines  -*- lexical-binding: t; 
coding: utf-8 -*-
 
 ;; Copyright (C) 2000, 2001, 2004-2009 Free Software Foundation, Inc.
 
diff --git a/emacs/make-deps.el b/emacs/make-deps.el
index a7699fb1..8c9e0a27 100644
--- a/emacs/make-deps.el
+++ b/emacs/make-deps.el
@@ -1,4 +1,4 @@
-;;; make-deps.el --- compute make dependencies for Elisp sources
+;;; make-deps.el --- compute make dependencies for Elisp sources  -*- 
lexical-binding: t -*-
 ;;
 ;; Copyright © Austin Clements
 ;;
diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index bf29c3a0..6b117458 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -1,4 +1,4 @@
-;;; notmuch-address.el --- address completion with notmuch
+;;; notmuch-address.el --- address completion with notmuch  -*- 
lexical-binding: t -*-
 ;;
 ;; Copyright © David Edmondson
 ;;
diff --git a/emacs/notmuch-compat.el b/emacs/notmuch-compat.el
index c4e07780..ad134dfe 100644
--- a/emacs/notmuch-compat.el
+++ b/emacs/notmuch-compat.el
@@ -1,4 +1,4 @@
-;;; notmuch-compat.el --- compatibility functions for earlier versions of emacs
+;;; notmuch-compat.el --- compatibility functions for earlier versions of 
emacs  -*- lexical-binding: t -*-
 ;;
 ;; The functions in this file are copied from more modern versions of
 ;; emacs and are Copyright (C) 1985-1986, 1992, 1994-1995, 1999-2017
diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index 6d2d35a5..ee5231e5 100644
--- a/emacs/notmuch-crypto.el
+++ b/emacs/notmuch-crypto.el
@@ -1,4 +1,4 @@
-;;; notmuch-crypto.el --- functions for handling display of cryptographic 
metadata
+;;; notmuch-crypto.el --- functions for handling display of cryptographic 
metadata  -*- lexical-binding: t -*-
 ;;
 ;; Copyright © Jameson Rollins
 ;;
diff --git a/emacs/notmuch-draft.el b/emacs/notmuch-draft.el
index 9ce9e736..8af04598 100644
--- a/emacs/notmuch-draft.el
+++ b/emacs/notmuch-draft.el
@@ -1,4 +1,4 @@
-;;; notmuch-draft.el --- functions for postponing and editing drafts
+;;; notmuch-draft.el --- functions for postponing and editing drafts  -*- 
lexical-binding: t -*-
 ;;
 ;; Copyright © Mark Walters
 ;; Copyright © David Bremner
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 28ffedd9..586a2848 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -1,4 +1,4 @@
-;;; notmuch-hello.el --- welcome to notmuch, a frontend
+;;; notmuch-hello.el --- welcome to notmuch, a frontend  -*- lexical-binding: 
t -*-
 ;;
 ;; Copyright © David Edmondson
 ;;
diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
index 7a27b6b3..5dcec970 100644
--- a/emacs/notmuch-jump.el
+++ b/emacs/notmuch-jump.el
@@ -1,4 +1,4 @@
-;;; notmuch-jump.el --- User-friendly shortcut keys
+;;; notmuch-jump.el --- User-friendly shortcut keys  -*- lexical-binding: t -*-
 ;;
 ;; Copyright © Austin Clements
 ;;
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 0b698d59..7595bbe1 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -1,4 +1,4 @@
-;;; notmuch-lib.el --- common variables, functions and function declarations
+;;; notmuch-lib.el --- common variables, functions and function declarations  
-*- lexical-binding: t -*-
 ;;
 ;; Copyright © Carl Worth
 ;;

[PATCH 08/32] emacs: avoid passing around some redundant information

2020-12-14 Thread Jonas Bernoulli
When running "notmuch" we use its full path but when displaying the
command to the user we show just its name for readability reasons.
Avoid passing around both representations because it is very easy
to get the name from the path.

Notmuch itself uses the involved functions just for "notmuch" but
there might be extensions that use them for other executable so we
forgo other potential simplifications.
---
 emacs/notmuch-lib.el | 43 ---
 1 file changed, 24 insertions(+), 19 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index be15af5e..e09912d3 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -800,20 +800,27 @@ (defun notmuch-check-exit-status (exit-status command 
 output err)
 Emacs requested a newer output format than supported by the notmuch CLI.
 You may need to restart Emacs or upgrade your notmuch package."))
(t
-(let* ((command-string
-   (mapconcat (lambda (arg)
-(shell-quote-argument
- (cond ((stringp arg) arg)
-   ((symbolp arg) (symbol-name arg))
-   (t "*UNKNOWN ARGUMENT*"
-  command " "))
-  (extra
-   (concat "command: " command-string "\n"
-   (if (integerp exit-status)
-   (format "exit status: %s\n" exit-status)
- (format "exit signal: %s\n" exit-status))
-   (and err(concat "stderr:\n" err))
-   (and output (concat "stdout:\n" output)
+(pcase-let*
+   ((`(,command . ,args) command)
+(command (if (equal (file-name-nondirectory command)
+notmuch-command)
+ notmuch-command
+   command))
+(command-string
+ (mapconcat (lambda (arg)
+  (shell-quote-argument
+   (cond ((stringp arg) arg)
+ ((symbolp arg) (symbol-name arg))
+ (t "*UNKNOWN ARGUMENT*"
+(cons command args)
+" "))
+(extra
+ (concat "command: " command-string "\n"
+ (if (integerp exit-status)
+ (format "exit status: %s\n" exit-status)
+   (format "exit signal: %s\n" exit-status))
+ (and err(concat "stderr:\n" err))
+ (and output (concat "stdout:\n" output)
   (if err
  ;; We have an error message straight from the CLI.
  (notmuch-logged-error
@@ -821,7 +828,7 @@ (defun notmuch-check-exit-status (exit-status command 
 output err)
;; We only have combined output from the CLI; don't inundate
;; the user with it.  Mimic `process-lines'.
(notmuch-logged-error (format "%s exited with status %s"
- (car command) exit-status)
+ command exit-status)
  extra))
   ;; `notmuch-logged-error' does not return.
   
@@ -908,7 +915,6 @@ (defun notmuch-start-notmuch (name buffer sentinel  
args)
 (err-proc (get-buffer-process err-buffer)))
 (process-put proc 'err-buffer err-buffer)
 (process-put proc 'sub-sentinel sentinel)
-(process-put proc 'real-command (cons notmuch-command args))
 (set-process-sentinel proc #'notmuch-start-notmuch-sentinel)
 (set-process-sentinel err-proc #'notmuch-start-notmuch-error-sentinel)
 proc))
@@ -919,8 +925,7 @@ (defun notmuch-start-notmuch-sentinel (proc event)
 (err (and (buffer-live-p err-buffer)
   (not (zerop (buffer-size err-buffer)))
   (with-current-buffer err-buffer (buffer-string
-(sub-sentinel (process-get proc 'sub-sentinel))
-(real-command (process-get proc 'real-command)))
+(sub-sentinel (process-get proc 'sub-sentinel)))
 (condition-case err
(progn
  ;; Invoke the sub-sentinel, if any
@@ -932,7 +937,7 @@ (defun notmuch-start-notmuch-sentinel (proc event)
  ;; and there's no point in telling the user that (but we
  ;; still check for and report stderr output below).
  (when (buffer-live-p (process-buffer proc))
-   (notmuch-check-async-exit-status proc event real-command err))
+   (notmuch-check-async-exit-status proc event nil err))
  ;; If that didn't signal an error, then any error output was
  ;; really warning output.  Show warnings, if any.
  (let ((warnings
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 06/32] emacs: notmuch-start-notmuch-sentinel: assert buffer is alive

2020-12-14 Thread Jonas Bernoulli
---
 emacs/notmuch-lib.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 21fa2582..06ca8cdc 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -917,7 +917,8 @@ (defun notmuch-start-notmuch (name buffer sentinel  
args)
 (defun notmuch-start-notmuch-sentinel (proc event)
   "Process sentinel function used by `notmuch-start-notmuch'."
   (let* ((err-buffer (process-get proc 'err-buffer))
-(err (and (not (zerop (buffer-size err-buffer)))
+(err (and (buffer-live-p err-buffer)
+  (not (zerop (buffer-size err-buffer)))
   (with-current-buffer err-buffer (buffer-string
 (sub-sentinel (process-get proc 'sub-sentinel))
 (real-command (process-get proc 'real-command)))
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 05/32] emacs: notmuch-start-notmuch-error-sentinel: assert buffer is alive

2020-12-14 Thread Jonas Bernoulli
---
 emacs/notmuch-lib.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 76387779..21fa2582 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -956,7 +956,8 @@ (defun notmuch-start-notmuch-sentinel (proc event)
 
 (defun notmuch-start-notmuch-error-sentinel (proc event)
   (let ((buffer (process-get proc 'err-buffer)))
-(kill-buffer buffer)))
+(when (buffer-live-p buffer)
+  (kill-buffer buffer
 
 (defvar-local notmuch-show-process-crypto nil)
 
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 07/32] emacs: notmuch-start-notmuch: avoid storing process buffer twice

2020-12-14 Thread Jonas Bernoulli
The buffer of the error process is accessible using `process-buffer'.
We still have to store the error-buffer in the non-error process
because for that process `process-buffer' obviously returns its own
buffer.
---
 emacs/notmuch-lib.el | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 06ca8cdc..be15af5e 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -906,12 +906,11 @@ (defun notmuch-start-notmuch (name buffer sentinel  
args)
:connection-type 'pipe
:stderr err-buffer))
 (err-proc (get-buffer-process err-buffer)))
-(process-put err-proc 'err-buffer err-buffer)
-(set-process-sentinel err-proc #'notmuch-start-notmuch-error-sentinel)
 (process-put proc 'err-buffer err-buffer)
 (process-put proc 'sub-sentinel sentinel)
 (process-put proc 'real-command (cons notmuch-command args))
 (set-process-sentinel proc #'notmuch-start-notmuch-sentinel)
+(set-process-sentinel err-proc #'notmuch-start-notmuch-error-sentinel)
 proc))
 
 (defun notmuch-start-notmuch-sentinel (proc event)
@@ -956,7 +955,7 @@ (defun notmuch-start-notmuch-sentinel (proc event)
(message "%s" (error-message-string err))
 
 (defun notmuch-start-notmuch-error-sentinel (proc event)
-  (let ((buffer (process-get proc 'err-buffer)))
+  (let ((buffer (process-buffer proc)))
 (when (buffer-live-p buffer)
   (kill-buffer buffer
 
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 09/32] emacs: avoid killing process buffer when process is still alive

2020-12-14 Thread Jonas Bernoulli
In practice this probably does not make a difference or we would
have heard about it many times, but better be safe than sorry.

Process sentinels are called not only when the process has finished
but also on other state changes.
---
 emacs/notmuch-lib.el | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index e09912d3..0e235fa3 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -960,9 +960,10 @@ (defun notmuch-start-notmuch-sentinel (proc event)
(message "%s" (error-message-string err))
 
 (defun notmuch-start-notmuch-error-sentinel (proc event)
-  (let ((buffer (process-buffer proc)))
-(when (buffer-live-p buffer)
-  (kill-buffer buffer
+  (unless (process-live-p proc)
+(let ((buffer (process-buffer proc)))
+  (when (buffer-live-p buffer)
+   (kill-buffer buffer)
 
 (defvar-local notmuch-show-process-crypto nil)
 
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 03/32] emacs: define new notmuch-search-item widget type

2020-12-14 Thread Jonas Bernoulli
This is complex enough to warrant a dedicated widget type,
which will make future improvements less messy to implement.
---
 emacs/notmuch-hello.el | 92 +-
 1 file changed, 45 insertions(+), 47 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 767c6874..7bc713f3 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -385,6 +385,40 @@ (defun notmuch-hello-nice-number (n)
 (format "%s%03d" notmuch-hello-thousands-separator elem))
   (cdr result)
 
+(define-widget 'notmuch-search-item 'item
+  "A recent search."
+  :format "%v\n"
+  :value-create 'notmuch-search-item-value-create)
+
+(defun notmuch-search-item-value-create (widget)
+  (let ((value (widget-get widget :value)))
+(widget-insert (make-string notmuch-hello-indent ?\s))
+(widget-create 'editable-field
+  :size (widget-get widget :size)
+  :parent widget
+  :action #'notmuch-hello-search
+  value)
+(widget-insert " ")
+(widget-create 'push-button
+  :parent widget
+  :notify #'notmuch-hello-add-saved-search
+  "save")
+(widget-insert " ")
+(widget-create 'push-button
+  :parent widget
+  :notify #'notmuch-hello-delete-search-from-history
+  "del")))
+
+(defun notmuch-search-item-field-width ()
+  (max 8 ; Don't let the search boxes be less than 8 characters wide.
+   (- (window-width)
+ notmuch-hello-indent ; space at bol
+ notmuch-hello-indent ; space at eol
+ 1; for the space before the [save] button
+ 6; for the [save] button
+ 1; for the space before the [del] button
+ 5))) ; for the [del] button
+
 (defun notmuch-hello-search (widget  _event)
   (let ((search (widget-value widget)))
 (when search
@@ -778,54 +812,18 @@ (defun notmuch-hello-insert-recent-searches ()
   "Insert recent searches."
   (when notmuch-search-history
 (widget-insert "Recent searches: ")
-(widget-create 'push-button
-  :notify (lambda ( ignore)
-(when (y-or-n-p "Are you sure you want to clear 
the searches? ")
-  (setq notmuch-search-history nil)
-  (notmuch-hello-update)))
-  "clear")
+(widget-create
+ 'push-button
+ :notify (lambda ( _ignore)
+  (when (y-or-n-p "Are you sure you want to clear the searches? ")
+(setq notmuch-search-history nil)
+(notmuch-hello-update)))
+ "clear")
 (widget-insert "\n\n")
-(let ((start (point)))
-  (cl-loop for i from 1 to notmuch-hello-recent-searches-max
-  for search in notmuch-search-history do
-  (let ((widget-symbol (intern (format "notmuch-hello-search-%d" 
i
-(set widget-symbol
- (widget-create 'editable-field
-;; Don't let the search boxes be
-;; less than 8 characters wide.
-:size (max 8
-   (- (window-width)
-  ;; Leave some space
-  ;; at the start and
-  ;; end of the
-  ;; boxes.
-  (* 2 notmuch-hello-indent)
-  ;; 1 for the space
-  ;; before the
-  ;; `[save]' button. 6
-  ;; for the `[save]'
-  ;; button.
-  1 6
-  ;; 1 for the space
-  ;; before the `[del]'
-  ;; button. 5 for the
-  ;; `[del]' button.
-  1 5))
-:action #'notmuch-hello-search
-search))
-(widget-insert " ")
-(widget-create 'push-button
-   :notify #'notmuch-hello-add-saved-search
-   :notmuch-saved-search-widget widget-symbol
-   "save")
-(widget-insert " ")
-(widget-create 'push-button
-   :notify 
#'notmuch-hello-delete-search-from-history
-   

[PATCH 02/32] emacs: sanitize dedicated widget action/notify functions

2020-12-14 Thread Jonas Bernoulli
These functions are used as action/notify functions.  That dictates
the appropriate function signatures but even though these functions
are not used for anything else they use incompatible signatures,
forcing the callers to use lambda expressions to deal with these
incompatibilities.

Fix that by adjusting the function signatures to the needs of the
only intended callers.

Two of these functions were defined as commands but because the
interactive form did not return the mandatory arguments, we know
that nobody (successfully) used these as commands.

In one case we move the location of a y-or-n-p prompt.
---
 emacs/notmuch-hello.el | 47 +-
 1 file changed, 19 insertions(+), 28 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index fa31694f..767c6874 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -385,18 +385,16 @@ (defun notmuch-hello-nice-number (n)
 (format "%s%03d" notmuch-hello-thousands-separator elem))
   (cdr result)
 
-(defun notmuch-hello-search ( search)
-  (unless (null search)
-(setq search (string-trim search))
-(let ((history-delete-duplicates t))
-  (add-to-history 'notmuch-search-history search)))
-  (notmuch-search search notmuch-search-oldest-first))
-
-(defun notmuch-hello-add-saved-search (widget)
-  (interactive)
-  (let ((search (widget-value
-(symbol-value
- (widget-get widget :notmuch-saved-search-widget
+(defun notmuch-hello-search (widget  _event)
+  (let ((search (widget-value widget)))
+(when search
+  (setq search (string-trim search))
+  (let ((history-delete-duplicates t))
+   (add-to-history 'notmuch-search-history search)))
+(notmuch-search search notmuch-search-oldest-first)))
+
+(defun notmuch-hello-add-saved-search (widget  _event)
+  (let ((search (widget-value (widget-get widget :parent)))
(name (completing-read "Name for saved search: "
   notmuch-saved-searches)))
 ;; If an existing saved search with this name exists, remove it.
@@ -412,13 +410,11 @@ (defun notmuch-hello-add-saved-search (widget)
 (message "Saved '%s' as '%s'." search name)
 (notmuch-hello-update)))
 
-(defun notmuch-hello-delete-search-from-history (widget)
-  (interactive)
-  (let ((search (widget-value
-(symbol-value
- (widget-get widget :notmuch-saved-search-widget)
-(setq notmuch-search-history (delete search
-notmuch-search-history))
+(defun notmuch-hello-delete-search-from-history (widget  _event)
+  (when (y-or-n-p "Are you sure you want to delete this search? ")
+(let ((search (widget-value (widget-get widget :parent
+  (setq notmuch-search-history
+   (delete search notmuch-search-history)))
 (notmuch-hello-update)))
 
 (defun notmuch-hello-longest-label (searches-alist)
@@ -768,8 +764,7 @@ (defun notmuch-hello-insert-search ()
 ;; search boxes.
 :size (max 8 (- (window-width) notmuch-hello-indent
 (length "Search: ")))
-:action (lambda (widget  ignore)
-  (notmuch-hello-search (widget-value widget
+:action #'notmuch-hello-search)
   ;; Add an invisible dot to make `widget-end-of-line' ignore
   ;; trailing spaces in the search widget field.  A dot is used
   ;; instead of a space to make `show-trailing-whitespace'
@@ -816,20 +811,16 @@ (defun notmuch-hello-insert-recent-searches ()
   ;; button. 5 for the
   ;; `[del]' button.
   1 5))
-:action (lambda (widget  ignore)
-  (notmuch-hello-search 
(widget-value widget)))
+:action #'notmuch-hello-search
 search))
 (widget-insert " ")
 (widget-create 'push-button
-   :notify (lambda (widget  ignore)
- (notmuch-hello-add-saved-search 
widget))
+   :notify #'notmuch-hello-add-saved-search
:notmuch-saved-search-widget widget-symbol
"save")
 (widget-insert " ")
 (widget-create 'push-button
-   :notify (lambda (widget  ignore)
- (when (y-or-n-p "Are you sure you 
want to delete this search? ")
-   
(notmuch-hello-delete-search-from-history widget)))
+   :notify 
#'notmuch-hello-delete-search-from-history

[PATCH 04/32] emacs: notmuch-start-notmuch: remove backward compatibility code

2020-12-14 Thread Jonas Bernoulli
We no longer support Emacs releases before version 25.1.

Also adjust the sentinels which only had to deal with
an error file when using an older Emacs release was used.
---
 emacs/notmuch-lib.el | 64 
 1 file changed, 17 insertions(+), 47 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index e23999ad..76387779 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -896,42 +896,19 @@ (defun notmuch-start-notmuch (name buffer sentinel  
args)
 invoke `set-process-sentinel' directly on the returned process,
 as that will interfere with the handling of stderr and the exit
 status."
-  (let (err-file err-buffer proc err-proc
-;; Find notmuch using Emacs' `exec-path'
-(command (or (executable-find notmuch-command)
- (error "Command not found: %s" notmuch-command
-(if (fboundp 'make-process)
-   (progn
- (setq err-buffer (generate-new-buffer " *notmuch-stderr*"))
- ;; Emacs 25 and newer has `make-process', which allows
- ;; redirecting stderr independently from stdout to a
- ;; separate buffer. As this allows us to avoid using a
- ;; temporary file and shell invocation, use it when
- ;; available.
- (setq proc (make-process
- :name name
- :buffer buffer
- :command (cons command args)
- :connection-type 'pipe
- :stderr err-buffer))
- (setq err-proc (get-buffer-process err-buffer))
- (process-put proc 'err-buffer err-buffer)
-
- (process-put err-proc 'err-file err-file)
- (process-put err-proc 'err-buffer err-buffer)
- (set-process-sentinel err-proc 
#'notmuch-start-notmuch-error-sentinel))
-  ;; On Emacs versions before 25, there is no way to capture
-  ;; stdout and stderr separately for asynchronous processes, or
-  ;; even to redirect stderr to a file, so we use a trivial shell
-  ;; wrapper to send stderr to a temporary file and clean things
-  ;; up in the sentinel.
-  (setq err-file (make-temp-file "nmerr"))
-  (let ((process-connection-type nil)) ;; Use a pipe
-   (setq proc (apply #'start-process name buffer
- "/bin/sh" "-c"
- "exec 2>\"$1\"; shift; exec \"$0\" \"$@\""
- command err-file args)))
-  (process-put proc 'err-file err-file))
+  (let* ((command (or (executable-find notmuch-command)
+ (error "Command not found: %s" notmuch-command)))
+(err-buffer (generate-new-buffer " *notmuch-stderr*"))
+(proc (make-process
+   :name name
+   :buffer buffer
+   :command (cons command args)
+   :connection-type 'pipe
+   :stderr err-buffer))
+(err-proc (get-buffer-process err-buffer)))
+(process-put err-proc 'err-buffer err-buffer)
+(set-process-sentinel err-proc #'notmuch-start-notmuch-error-sentinel)
+(process-put proc 'err-buffer err-buffer)
 (process-put proc 'sub-sentinel sentinel)
 (process-put proc 'real-command (cons notmuch-command args))
 (set-process-sentinel proc #'notmuch-start-notmuch-sentinel)
@@ -939,9 +916,7 @@ (defun notmuch-start-notmuch (name buffer sentinel  
args)
 
 (defun notmuch-start-notmuch-sentinel (proc event)
   "Process sentinel function used by `notmuch-start-notmuch'."
-  (let* ((err-file (process-get proc 'err-file))
-(err-buffer (or (process-get proc 'err-buffer)
-(find-file-noselect err-file)))
+  (let* ((err-buffer (process-get proc 'err-buffer))
 (err (and (not (zerop (buffer-size err-buffer)))
   (with-current-buffer err-buffer (buffer-string
 (sub-sentinel (process-get proc 'sub-sentinel))
@@ -977,16 +952,11 @@ (defun notmuch-start-notmuch-sentinel (proc event)
   (error
;; Emacs behaves strangely if an error escapes from a sentinel,
;; so turn errors into messages.
-   (message "%s" (error-message-string err
-(when err-file (ignore-errors (delete-file err-file)
+   (message "%s" (error-message-string err))
 
 (defun notmuch-start-notmuch-error-sentinel (proc event)
-  (let* ((err-file (process-get proc 'err-file))
-;; When `make-process' is available, use the error buffer
-;; associated with the process, otherwise the error file.
-(err-buffer (or (process-get proc 'err-buffer)
-(find-file-noselect err-file
-(when err-buffer (kill-buffer err-buffer
+  (let ((buffer (process-get proc 'err-buffer)))
+(kill-buffer buffer)))
 
 (defvar-local notmuch-show-process-crypto nil)
 
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to 

[PATCH 01/32] emacs: use setq instead of set

2020-12-14 Thread Jonas Bernoulli
Commonly `set' is only used if there is no way around it;
i.e. when the variable cannot be known until runtime.
---
 emacs/notmuch-tree.el |  2 +-
 emacs/notmuch.el  | 14 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 57843e25..17863f6a 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -1133,7 +1133,7 @@ (defun notmuch-tree ( query query-context target 
buffer-name open-targe
(inhibit-read-only t))
 (pop-to-buffer-same-window buffer))
   ;; Don't track undo information for this buffer
-  (set 'buffer-undo-list t)
+  (setq buffer-undo-list t)
   (notmuch-tree-worker query query-context target open-target unthreaded)
   (setq notmuch-tree-parent-buffer parent-buffer)
   (setq truncate-lines t))
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 95770fc3..b221be05 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -693,7 +693,7 @@ (defun notmuch-search-process-sentinel (proc msg)
(throw 'return nil))
  (when (and atbob
 (not (string= notmuch-search-target-thread 
"found")))
-   (set 'never-found-target-thread t)
+   (setq never-found-target-thread t)
(when (and never-found-target-thread
   notmuch-search-target-line)
  (goto-char (point-min))
@@ -1000,11 +1000,11 @@ (defun notmuch-search ( query oldest-first 
target-thread target-line no
 (unless (eq major-mode 'notmuch-search-mode)
   (notmuch-search-mode))
 ;; Don't track undo information for this buffer
-(set 'buffer-undo-list t)
-(set 'notmuch-search-query-string query)
-(set 'notmuch-search-oldest-first oldest-first)
-(set 'notmuch-search-target-thread target-thread)
-(set 'notmuch-search-target-line target-line)
+(setq buffer-undo-list t)
+(setq notmuch-search-query-string query)
+(setq notmuch-search-oldest-first oldest-first)
+(setq notmuch-search-target-thread target-thread)
+(setq notmuch-search-target-line target-line)
 (notmuch-tag-clear-cache)
 (let ((proc (get-buffer-process (current-buffer)))
  (inhibit-read-only t))
@@ -1052,7 +1052,7 @@ (defun notmuch-search-toggle-order ()
 This command toggles the sort order for the current search. The
 default sort order is defined by `notmuch-search-oldest-first'."
   (interactive)
-  (set 'notmuch-search-oldest-first (not notmuch-search-oldest-first))
+  (setq notmuch-search-oldest-first (not notmuch-search-oldest-first))
   (notmuch-search-refresh-view))
 
 (defun notmuch-group-disjunctive-query-string (query-string)
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 00/32] [emacs] Add outline headings and switch to lexical scope

2020-12-14 Thread Jonas Bernoulli
Hello,

This patch serious changes a number of things, including boring
cleanup, but the big changes are the following.  The respective
commits are also marked in the list below.  See these commits
for longer descriptions.

1. Split all libraries into sections by adding new headings or
   formatting existing headings properly to be compatible with
   outline-minor-mode.

2. Use lexical-scope in all libraries.  This is potentially faster
   and is recommended for all new code (and old code someone cares
   about enough).  It also has the advantage that it can reveal
   subtle bugs.

Among the many more commits that do not concern these two big
changes, there are a few that might need special attention.
(Again see the commits for details.)

3. No longer use Ido in notmuch-mua-prompt-for-sender.  Might be
   controversial.

4. Stop using unnecessary let-bindings, though how "unnecessary"
   these bindings are is somewhat subjective.

 Cheers,
 Jonas

PS: Don't worry.  I do NOT have another large patch series waiting
after this.  Future changes should be more focused or even come
in the form of independent extensions.

Jonas Bernoulli (32):
  emacs: use setq instead of set
  emacs: sanitize dedicated widget action/notify functions
  emacs: define new notmuch-search-item widget type
  emacs: notmuch-start-notmuch: remove backward compatibility code
  emacs: notmuch-start-notmuch-error-sentinel: assert buffer is alive
  emacs: notmuch-start-notmuch-sentinel: assert buffer is alive
  emacs: notmuch-start-notmuch: avoid storing process buffer twice
  emacs: avoid passing around some redundant information
  emacs: avoid killing process buffer when process is still alive
1 emacs: make headings outline-minor-mode compatible
2 emacs: use lexical-bindings in all libraries
" emacs: deal with unused lexical arguments and variables
" emacs: notmuch-tag--get-formats: silence byte-compiler
  emacs: inline notmuch-sexp-eof into only caller
  emacs: notmuch-wash-region-to-button: remove unused MSG argument
  emacs: silence compiler wrt notmuch-show-insert-part-text/plain
  emacs: define notmuch-message-queued-tag-changes as buffer-local
  emacs: notmuch-message-apply-queued-tag-changes: cosmetics
  emacs: notmuch-wash.el: require diff-mode at beginning of code
3 emacs: notmuch-mua-prompt-for-sender: don't force Ido on users
  emacs: notmuch-mua.el: move all options into "Options" section
  emacs: notmuch-crypto-status-button-type: fix potential bug
  emacs: various cosmetic improvements
  emacs: various comment improvements
  emacs: various doc-string improvements
  emacs: remove variable notmuch-search-disjunctive-regexp
  emacs: define a few variables as automatically buffer-local
  emacs: notmuch-search-stash-thread-id: use notmuch-search-query-string
  emacs: reorder notmuch.el a bit
4 emacs: avoid unnecessary let-bindings
  emacs: use string-empty-p
  emacs: notmuch-tree-get-match: No longer define as command

 emacs/coolj.el   |  14 +-
 emacs/make-deps.el   |   2 +-
 emacs/notmuch-address.el |  65 +
 emacs/notmuch-company.el |   1 -
 emacs/notmuch-compat.el  |   4 +-
 emacs/notmuch-crypto.el  |  14 +-
 emacs/notmuch-draft.el   |  23 +++-
 emacs/notmuch-hello.el   | 228 +++---
 emacs/notmuch-jump.el|  14 +-
 emacs/notmuch-lib.el | 198 +-
 emacs/notmuch-maildir-fcc.el | 112 +++
 emacs/notmuch-message.el |  21 ++-
 emacs/notmuch-mua.el | 123 +
 emacs/notmuch-parser.el  |  18 +--
 emacs/notmuch-print.el   |  16 ++-
 emacs/notmuch-query.el   |  21 ++-
 emacs/notmuch-show.el| 127 ++---
 emacs/notmuch-tag.el | 100 --
 emacs/notmuch-tree.el|  59 
 emacs/notmuch-wash.el|  54 
 emacs/notmuch.el | 260 +++
 emacs/rstdoc.el  |   2 +-
 test/test-lib.el |   4 +-
 23 files changed, 786 insertions(+), 694 deletions(-)

-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH v2 23/23] emacs: various cosmetic improvements

2020-12-14 Thread Jonas Bernoulli
David Bremner  writes:
> Apologies for the delay, I missed the second review.

No problem, I probably should just have pinged after a week or so.
Will do that next time.  Sorry for being slow to respond myself!

By the way, you seem to have missed some more patch series of mine:

- id:20201108231150.5419-1-jo...@bernoul.li
  Improves notmuch-address.el a bit.

- id:20201108174929.1227-1-jo...@bernoul.li
  Fixes a regression that also came up in id:877dqtkqs9@uwaterloo.ca
  I had the same issue as mentioned there.  Since applying this patch, I
  haven't seen it.

> I've applied the first 22, but this last one is not applying to
> (current) master for me.

You seem to have accidentally dropped another commits, which is why
this commit did not apply.  I have another series with a "few" commits
waiting for submissions and will just lead that with these two commits
from the last series.

 Jonas
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 23/23] emacs: various cosmetic improvements

2020-11-16 Thread Jonas Bernoulli
---
 emacs/notmuch-address.el | 31 ++
 emacs/notmuch-hello.el   | 28 +
 emacs/notmuch-lib.el | 38 +
 emacs/notmuch-mua.el | 10 ++---
 emacs/notmuch-tag.el |  2 +-
 emacs/notmuch.el | 88 
 6 files changed, 91 insertions(+), 106 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 71985ed7..a00ca8d7 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -21,6 +21,8 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'cl-lib))
+
 (require 'message)
 (require 'notmuch-parser)
 (require 'notmuch-lib)
@@ -154,15 +156,12 @@ (defcustom notmuch-address-use-company t
   :group 'notmuch-address)
 
 (defun notmuch-address-setup ()
-  (let* ((setup-company (and notmuch-address-use-company
-(require 'company nil t)))
-(pair (cons notmuch-address-completion-headers-regexp
-#'notmuch-address-expand-name)))
-(when setup-company
-  (notmuch-company-setup))
-(unless (member pair message-completion-alist)
-  (setq message-completion-alist
-   (push pair message-completion-alist)
+  (when (and notmuch-address-use-company
+(require 'company nil t))
+(notmuch-company-setup))
+  (cl-pushnew (cons notmuch-address-completion-headers-regexp
+   #'notmuch-address-expand-name)
+ message-completion-alist :test #'equal))
 
 (defun notmuch-address-toggle-internal-completion ()
   "Toggle use of internal completion for current buffer.
@@ -251,11 +250,8 @@ (defun notmuch-address-expand-name ()
(t nil)))
 
 (defun notmuch-address-harvest-addr (result)
-  (let ((name-addr (plist-get result :name-addr)))
-(puthash name-addr t notmuch-address-completions)))
-
-(defun notmuch-address-harvest-handle-result (obj)
-  (notmuch-address-harvest-addr obj))
+  (puthash (plist-get result :name-addr)
+  t notmuch-address-completions))
 
 (defun notmuch-address-harvest-filter (proc string)
   (when (buffer-live-p (process-buffer proc))
@@ -264,7 +260,7 @@ (defun notmuch-address-harvest-filter (proc string)
(goto-char (point-max))
(insert string))
   (notmuch-sexp-parse-partial-list
-   'notmuch-address-harvest-handle-result (process-buffer proc)
+   'notmuch-address-harvest-addr (process-buffer proc)
 
 (defvar notmuch-address-harvest-procs '(nil . nil)
   "The currently running harvests.
@@ -375,7 +371,7 @@ (defun notmuch-address--load-address-hash ()
 (defun notmuch-address--save-address-hash ()
   (when notmuch-address-save-filename
 (if (or (not (file-exists-p notmuch-address-save-filename))
-   ;; The file exists, check it is a file we saved
+   ;; The file exists, check it is a file we saved.
(notmuch-address--get-address-hash))
(with-temp-file notmuch-address-save-filename
  (let ((save-plist
@@ -398,8 +394,7 @@ (defun notmuch-address-harvest-trigger ()
nil nil
(lambda (proc event)
 ;; If harvest fails, we want to try
-;; again when the trigger is next
-;; called
+;; again when the trigger is next called.
 (if (string= event "finished\n")
 (progn
   (notmuch-address--save-address-hash)
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index fa31694f..80af7544 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -402,8 +402,7 @@ (defun notmuch-hello-add-saved-search (widget)
 ;; If an existing saved search with this name exists, remove it.
 (setq notmuch-saved-searches
  (cl-loop for elem in notmuch-saved-searches
-  if (not (equal name
- (notmuch-saved-search-get elem :name)))
+  unless (equal name (notmuch-saved-search-get elem :name))
   collect elem))
 ;; Add the new one.
 (customize-save-variable 'notmuch-saved-searches
@@ -446,18 +445,14 @@ (defun notmuch-hello-reflect (list ncols)
 append (notmuch-hello-reflect-generate-row ncols nrows row list
 
 (defun notmuch-hello-widget-search (widget  ignore)
-  (cond
-   ((eq (widget-get widget :notmuch-search-type) 'tree)
-(notmuch-tree (widget-get widget
- :notmuch-search-terms)))
-   ((eq (widget-get widget :notmuch-search-type) 'unthreaded)
-(notmuch-unthreaded (widget-get widget
-   :notmuch-search-terms)))
+  (cl-case (widget-get widget :notmuch-search-type)
+   (tree
+(notmuch-tree (widget-get widget :notmuch-search-terms)))
+   (unthreaded
+(notmuch-unthreaded (widget-get widget :notmuch-search-terms)))
(t
-(notmuch-search (widget-get widget
-   :notmuch-search-terms)
-   (widget-get widget
-   :notmuch-search-oldest-first)
+(notmuch-search 

  1   2   3   >