Re: emacs: error decrypting s/mime

2020-12-14 Thread Alexander Adolf
Alexander Adolf  writes:

> [...]
> (defalias notmuch-show-insert-part-application/x-pkcs7-mime
>   notmuch-show-insert-part-application/pkcs7-mime)
> [...]

Err, this should be:

(fset 'notmuch-show-insert-part-application/x-pkcs7-mime
  'notmuch-show-insert-part-application/pkcs7-mime)
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: emacs: error decrypting s/mime

2020-12-14 Thread Alexander Adolf
Hello David,

David Bremner  writes:

> David Bremner  writes:
>
>>
>> It's not perfect (the encryption status for S/MIME needs some new UI
>> code on the emacs end), but it's better than the status quo, as far as I
>> can tell.
>
> I think this might be a deeper issue. Looking at the structure of
>
>   test/corpora/protected-headers/smime-sign+enc.eml
>
> it looks like there is an application/pkcs-7 part for the outer
> container with an encstatus, and one inside that (with the same mime
> type) with a sigstatus. So maybe the right thing is to just ignore
> missing encstatus?

This cures most of the issues for me:

(defun notmuch-show-insert-part-application/pkcs7-mime (msg part content-type 
nth depth button)
  (let* ((encstatus-plist (car (plist-get part :encstatus)))
 (encstatus (plist-get encstatus-plist :status)))
  (notmuch-crypto-insert-encstatus-button encstatus-plist)
  (if (not (string= encstatus "bad"))
  (notmuch-show-insert-part-multipart/signed msg
 (car (plist-get part 
:content))
 content-type
 nth
 depth
 button

(defalias notmuch-show-insert-part-application/x-pkcs7-mime
  notmuch-show-insert-part-application/pkcs7-mime)


It shows the contents of the S/MIME message, and could e.g. end up in
notmuch-show.el, I think.

What is left to be desired (IMHO) are some improvements in the gpgsm
integration. User-id and key-id matching is a bit rough sometimes. Not
sure though whether that is a notmuch issue even (probably an EPA one)?


Cheers, and looking forward to your thoughts,

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


Re: consistent database corruption with notmuch new

2020-12-14 Thread Gregor Zattler
Hi notmuch developers,
* Gregor Zattler  [13. Dez. 2020]:
> * Gregor Zattler  [13. Dez. 2020]:
>> I now do a notmuch new with libxapian30 version 1.4.17-1
>> and will report back in a few hours.
>
> The result is only slightly different from version 1.4.11:

actually now I realized, that notmuch was not linked against
libxapian v1.4.17-1.

Now I build notmuch from master and linked it with
libxapian 1.4.17-1.  The result is almost the same, though:
0 (master *) grfz@no:~/Mail/.notmuch$ nice ionice -c3 notmuch new --full-scan ; 
nice ionice -c3 notmuch new --full-scan ; nice ionice -c3 notmuch new 
--full-scan
Welcome to a new version of notmuch! Your database will now be upgraded.
This process is safe to interrupt.
Backing up tags to /home/grfz/Mail/.notmuch/dump-20201214T124836.gz...
Your notmuch database has now been upgraded.
Note: Ignoring non-mail file: 
/home/grfz/Mail/spam-old/cur/1607940473.9509_1.no:2,S
Note: Ignoring non-mail file: 
/home/grfz/Mail/spam-old/cur/1607943993.24776_1.no:2,
Note: Ignoring non-mail file: 
/home/grfz/Mail/spam-old/cur/1607947606.8134_1.no:2,
Note: Ignoring non-mail file: /home/grfz/Mail/drafts.mbox
Note: Ignoring non-mail file: /home/grfz/Mail/postponed.mbox
Processed 1176599 total files in 3h 31m 23s (92 files/sec.).
Added 1102787 new messages to the database.
Note: Ignoring non-mail file: 
/home/grfz/Mail/spam-old/cur/1607940473.9509_1.no:2,S
Note: Ignoring non-mail file: 
/home/grfz/Mail/spam-old/cur/1607943993.24776_1.no:2,
Note: Ignoring non-mail file: 
/home/grfz/Mail/spam-old/cur/1607947606.8134_1.no:2,
Note: Ignoring non-mail file: /home/grfz/Mail/drafts.mbox
Note: Ignoring non-mail file: /home/grfz/Mail/postponed.mbox
Processed 125008 total files in 44m 59s (46 files/sec.).
Added 83898 new messages to the database.
Note: Ignoring non-mail file: 
/home/grfz/Mail/spam-old/cur/1607940473.9509_1.no:2,S
Note: Ignoring non-mail file: 
/home/grfz/Mail/spam-old/cur/1607943993.24776_1.no:2,
Note: Ignoring non-mail file: 
/home/grfz/Mail/spam-old/cur/1607947606.8134_1.no:2,
add_file: A Xapian exception occurred).
A Xapian exception occurred at lib/message.cc:1182: Too few chunks of 
compressed data
Processed 122480 total files in 42m 1s (48 files/sec.).
Added 83907 new messages to the database.
Note: A fatal error was encountered: A Xapian exception occurred
1 (master *) grfz@no:~/Mail/.notmuch$

notmuch new still corrupts the database, the second notmuch new
invocation finds emails the first did not find.


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


Re: consistent database corruption with notmuch new

2020-12-14 Thread David Bremner
David Bremner  writes:

> David Bremner  writes:
>
>> Gregor Zattler  writes:
>>>
>>> I now do a notmuch new with libxapian30 version 1.4.17-1
>>> and will report back in a few hours.
>>>
>>
>> I have just uploaded 0.31.3 to buster-backports
>
> Sorry, I meant 0.31.2-3.

version 0.31.2-3~bpo10+2 is now available in Debian backports, at least
for amd64. Other architectures should follow.  I'd be a bit surprised if
this fixed your issues, but it seems worth testing.

d
___
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 David Bremner
Jonas Bernoulli  writes:

> David Bremner  writes:
>
> 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.

Sounds good. Sorry for the extra work.

d
___
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


Re: consistent database corruption with notmuch new

2020-12-14 Thread Gregor Zattler
Hi David, notmuch developers,
* David Edmondson  [14. Dez. 2020]:
> Which filesystem are you using for the mail store?
>
> I had similar looking problems when using ZFS and never got to the
> bottom of it.

this is a ext4 file system, which gets checked
every time I boot my laptop.

I also run memtest 8.4 (but since it's the gratis
version only for 4 passes) without errors.


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


Re: consistent database corruption with notmuch new

2020-12-14 Thread David Edmondson
Which filesystem are you using for the mail store?

I had similar looking problems when using ZFS and never got to the
bottom of it.

dme.
-- 
Why does it have to be like this? I can never tell.
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org