[PATCH v3 01/34] emacs: Shorten long lines

2020-08-08 Thread Jonas Bernoulli
---
 emacs/coolj.el   |   2 +-
 emacs/notmuch-address.el |  38 +++--
 emacs/notmuch-company.el |  17 --
 emacs/notmuch-crypto.el  |  16 +++---
 emacs/notmuch-draft.el   |  12 ++--
 emacs/notmuch-hello.el   |  43 ++-
 emacs/notmuch-jump.el|   7 ++-
 emacs/notmuch-lib.el |  62 +
 emacs/notmuch-maildir-fcc.el |  14 ++---
 emacs/notmuch-message.el |   3 +-
 emacs/notmuch-mua.el |  78 +++---
 emacs/notmuch-show.el| 103 +++
 emacs/notmuch-tag.el |  14 +++--
 emacs/notmuch-tree.el|  55 +--
 emacs/notmuch-wash.el|  19 +--
 emacs/notmuch.el |  27 ++---
 emacs/rstdoc.el  |   3 +-
 17 files changed, 326 insertions(+), 187 deletions(-)

diff --git a/emacs/coolj.el b/emacs/coolj.el
index 350d537f..5d311170 100644
--- a/emacs/coolj.el
+++ b/emacs/coolj.el
@@ -1,6 +1,6 @@
 ;;; coolj.el --- automatically wrap long lines  -*- coding:utf-8 -*-
 
-;; Copyright (C) 2000, 2001, 2004, 2005, 2006, 2007, 2008, 2009 Free Software 
Foundation, Inc.
+;; Copyright (C) 2000, 2001, 2004-2009 Free Software Foundation, Inc.
 
 ;; Authors:Kai Grossjohann 
 ;; Alex Schroeder 
diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 0d56fba7..2a9c411a 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -195,10 +195,11 @@ (defun notmuch-address-options (original)
((eq notmuch-address-command 'internal)
 (unless (notmuch-address--harvest-ready)
   ;; First, run quick synchronous harvest based on what the user
-  ;; entered so far
+  ;; entered so far.
   (notmuch-address-harvest original t))
 (prog1 (notmuch-address-matching original)
-  ;; Then start the (potentially long-running) full asynchronous harvest 
if necessary
+  ;; Then start the (potentially long-running) full asynchronous
+  ;; harvest if necessary.
   (notmuch-address-harvest-trigger)))
(t
 (process-lines notmuch-address-command original
@@ -241,7 +242,8 @@ (defun notmuch-address-expand-name ()
(push chosen notmuch-address-history)
(delete-region beg end)
(insert chosen)
-   (run-hook-with-args 'notmuch-address-post-completion-functions 
chosen))
+   (run-hook-with-args 'notmuch-address-post-completion-functions
+   chosen))
(message "No matches.")
(ding
(t nil)))
@@ -393,10 +395,11 @@ (defun notmuch-address--save-address-hash ()
  ;; 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 (list :version notmuch-address--save-hash-version
- :completion-settings 
notmuch-address-internal-completion
- :last-harvest notmuch-address-last-harvest
- :completions notmuch-address-completions)))
+ (let ((save-plist
+(list :version notmuch-address--save-hash-version
+  :completion-settings notmuch-address-internal-completion
+  :last-harvest notmuch-address-last-harvest
+  :completions notmuch-address-completions)))
(print "notmuch-address-hash" (current-buffer))
(print save-plist (current-buffer
   (message "\
@@ -408,16 +411,17 @@ (defun notmuch-address-harvest-trigger ()
   (let ((now (float-time)))
 (when (> (- now notmuch-address-last-harvest) 86400)
   (setq notmuch-address-last-harvest now)
-  (notmuch-address-harvest nil nil
-  (lambda (proc event)
-;; If harvest fails, we want to try
-;; again when the trigger is next
-;; called
-(if (string= event "finished\n")
-(progn
-  (notmuch-address--save-address-hash)
-  (setq 
notmuch-address-full-harvest-finished t))
-  (setq notmuch-address-last-harvest 0)))
+  (notmuch-address-harvest
+   nil nil
+   (lambda (proc event)
+;; If harvest fails, we want to try
+;; again when the trigger is next
+;; called
+(if (string= event "finished\n")
+(progn
+  (notmuch-address--save-address-hash)
+  (setq notmuch-address-full-harvest-finished t))
+  (setq notmuch-address-last-harvest 0)))
 
 ;;
 
diff --git a/emacs/notmuch-company.el b/emacs/notmuch-company.el
index ac998f9b..c1f3594e 100644
--- a/emacs/notmuch-company.el
+++ b/emacs/notmuch-company.el
@@ -69,9 +69,11 @@ (defu

[PATCH v3 08/34] emacs: Use 'when' instead of 'if' when there is no ELSE part

2020-08-08 Thread Jonas Bernoulli
---
 emacs/notmuch-address.el |   8 ++--
 emacs/notmuch-compat.el  |   6 +--
 emacs/notmuch-hello.el   |   8 ++--
 emacs/notmuch-jump.el|  54 ++---
 emacs/notmuch-lib.el |  10 ++--
 emacs/notmuch-mua.el |  24 +-
 emacs/notmuch-query.el   |   4 +-
 emacs/notmuch-show.el|  93 ++--
 emacs/notmuch-tree.el|  30 ++--
 emacs/notmuch-wash.el|  68 +-
 emacs/notmuch.el | 100 +++
 test/test-lib.el |   4 +-
 12 files changed, 206 insertions(+), 203 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 2dd08661..85531489 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -171,10 +171,10 @@ (defun notmuch-address-toggle-internal-completion ()
   (if (local-variable-p 'notmuch-address-command)
   (kill-local-variable 'notmuch-address-command)
 (notmuch-setq-local notmuch-address-command 'internal))
-  (if (boundp 'company-idle-delay)
-  (if (local-variable-p 'company-idle-delay)
- (kill-local-variable 'company-idle-delay)
-   (notmuch-setq-local company-idle-delay nil
+  (when (boundp 'company-idle-delay)
+(if (local-variable-p 'company-idle-delay)
+   (kill-local-variable 'company-idle-delay)
+  (notmuch-setq-local company-idle-delay nil
 
 (defun notmuch-address-matching (substring)
   "Returns a list of completion candidates matching SUBSTRING.
diff --git a/emacs/notmuch-compat.el b/emacs/notmuch-compat.el
index 388ef70f..3340918f 100644
--- a/emacs/notmuch-compat.el
+++ b/emacs/notmuch-compat.el
@@ -68,9 +68,9 @@ (if (fboundp 'read-char-choice)
   ;; This is an inlined copy of help-form-show as that
   ;; was introduced in emacs 24 too.
   (let ((msg (eval help-form)))
-(if (stringp msg)
-(with-output-to-temp-buffer " *Char Help*"
-  (princ msg))
+(when (stringp msg)
+  (with-output-to-temp-buffer " *Char Help*"
+(princ msg))
 ((memq char chars)
  (setq done t))
 ((and executing-kbd-macro (= char -1))
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 1c0b1848..c17b46bc 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -589,8 +589,8 @@ (defun notmuch-hello-insert-buttons (searches)
 (mapc (lambda (elem)
;; (not elem) indicates an empty slot in the matrix.
(when elem
- (if (> column-indent 0)
- (widget-insert (make-string column-indent ? )))
+ (when (> column-indent 0)
+   (widget-insert (make-string column-indent ? )))
  (let* ((name (plist-get elem :name))
 (query (plist-get elem :query))
 (oldest-first (cl-case (plist-get elem :sort-order)
@@ -890,8 +890,8 @@ (defun notmuch-hello-insert-searches (title query-list 
&rest options)
the same values as :filter. If :filter and :filter-count are specified, this
will be used instead of :filter, not in conjunction with it."
   (widget-insert title ": ")
-  (if (and notmuch-hello-first-run (plist-get options :initially-hidden))
-  (add-to-list 'notmuch-hello-hidden-sections title))
+  (when (and notmuch-hello-first-run (plist-get options :initially-hidden))
+(add-to-list 'notmuch-hello-hidden-sections title))
   (let ((is-hidden (member title notmuch-hello-hidden-sections))
(start (point)))
 (if is-hidden
diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
index adf79650..e302fe00 100644
--- a/emacs/notmuch-jump.el
+++ b/emacs/notmuch-jump.el
@@ -169,37 +169,37 @@ (defun notmuch-jump--make-keymap (action-map prompt)
   (let ((map (make-sparse-keymap)))
 (set-keymap-parent map notmuch-jump-minibuffer-map)
 (pcase-dolist (`(,key ,name ,fn) action-map)
-  (if (= (length key) 1)
- (define-key map key
-   `(lambda () (interactive)
-  (setq notmuch-jump--action ',fn)
-  (exit-minibuffer)
+  (when (= (length key) 1)
+   (define-key map key
+ `(lambda () (interactive)
+(setq notmuch-jump--action ',fn)
+(exit-minibuffer)
 ;; By doing this in two passes (and checking if we already have a
 ;; binding) we avoid problems if the user specifies a binding which
 ;; is a prefix of another binding.
 (pcase-dolist (`(,key ,name ,fn) action-map)
-  (if (> (length key) 1)
- (let* ((key (elt key 0))
-(keystr (string key))
-(new-prompt (concat prompt (format-kbd-macro keystr) " "))
-(action-submap nil))
-   (unless (lookup-key map keystr)
- (pcase-dolist (`(,k ,n ,f) action-map)
-   (when (= key (elt k 0))
-  

[PATCH v3 12/34] emacs: No longer define notmuch-hello-mode-map as a function

2020-08-08 Thread Jonas Bernoulli
It was defined as such for a decade; ever since
a56010ac8b89a2489eee5c78469f05cee85ec858 but there
wasn't a reason to do that then nor is there now.
---
 emacs/notmuch-hello.el | 1 -
 1 file changed, 1 deletion(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index c17b46bc..876d8ef1 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -687,7 +687,6 @@ (defvar notmuch-hello-mode-map
 (define-key map (kbd "") 'widget-backward)
 map)
   "Keymap for \"notmuch hello\" buffers.")
-(fset 'notmuch-hello-mode-map notmuch-hello-mode-map)
 
 (define-derived-mode notmuch-hello-mode fundamental-mode "notmuch-hello"
   "Major mode for convenient notmuch navigation. This is your entry portal 
into notmuch.
-- 
2.28.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v3 23/34] .gitignore: Sort using sort-lines

2020-08-08 Thread Jonas Bernoulli
---
 .gitignore | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/.gitignore b/.gitignore
index 8f3ebec0..3edd1768 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,20 +1,20 @@
-/.first-build-message
-/Makefile.config
-/sh.config
-/version.stamp
-TAGS
-tags
-*cscope*
-/.deps
-/notmuch
-/notmuch-shared
-/lib/libnotmuch.so*
-/lib/libnotmuch*.dylib
 *.[ao]
+*.stamp
+*cscope*
 *~
 .*.swp
-/releases
+/.deps
+/.first-build-message
 /.stamps
-*.stamp
+/Makefile.config
 /bindings/python-cffi/build/
+/lib/libnotmuch*.dylib
+/lib/libnotmuch.so*
+/notmuch
+/notmuch-shared
+/releases
+/sh.config
 /sphinx.config
+/version.stamp
+TAGS
+tags
-- 
2.28.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v3 14/34] emacs: Use makefile-gmake-mode in Makefile*s

2020-08-08 Thread Jonas Bernoulli
Use `makefile-gmake-mode' instead of `makefile-mode' because the
former also highlights ifdef et al. while the latter does not.

"./Makefile.global" and one "Makefile.local" failed to specify any
major mode at all but doing so is necessary because Emacs does not
automatically figure out that these are Makefiles (of any flavor).
---
 Makefile.global  | 1 +
 Makefile.local   | 2 +-
 bindings/Makefile.local  | 2 +-
 compat/Makefile.local| 2 +-
 completion/Makefile.local| 2 +-
 doc/Makefile.local   | 2 +-
 emacs/Makefile.local | 2 +-
 lib/Makefile.local   | 2 +-
 parse-time-string/Makefile.local | 2 ++
 performance-test/Makefile.local  | 2 +-
 test/Makefile.local  | 2 +-
 util/Makefile.local  | 2 +-
 12 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/Makefile.global b/Makefile.global
index 4fd796e3..cd489ef2 100644
--- a/Makefile.global
+++ b/Makefile.global
@@ -1,3 +1,4 @@
+# -*- makefile-gmake -*-
 # Here's the (hopefully simple) versioning scheme.
 #
 # Releases of notmuch have a two-digit version (0.1, 0.2, etc.). We
diff --git a/Makefile.local b/Makefile.local
index 39f36d50..156c8ce1 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -1,4 +1,4 @@
-# -*- makefile -*-
+# -*- makefile-gmake -*-
 
 .PHONY: all
 all: notmuch notmuch-shared build-man build-info ruby-bindings 
python-cffi-bindings
diff --git a/bindings/Makefile.local b/bindings/Makefile.local
index 19ddd6ea..bc960bbc 100644
--- a/bindings/Makefile.local
+++ b/bindings/Makefile.local
@@ -1,4 +1,4 @@
-# -*- makefile -*-
+# -*- makefile-gmake -*-
 
 dir := bindings
 
diff --git a/compat/Makefile.local b/compat/Makefile.local
index bcb9f0ec..2ee1b399 100644
--- a/compat/Makefile.local
+++ b/compat/Makefile.local
@@ -1,4 +1,4 @@
-# -*- makefile -*-
+# -*- makefile-gmake -*-
 
 dir := compat
 extra_cflags += -I$(srcdir)/$(dir)
diff --git a/completion/Makefile.local b/completion/Makefile.local
index 8e86c9d2..54df463c 100644
--- a/completion/Makefile.local
+++ b/completion/Makefile.local
@@ -1,4 +1,4 @@
-# -*- makefile -*-
+# -*- makefile-gmake -*-
 
 dir := completion
 
diff --git a/doc/Makefile.local b/doc/Makefile.local
index 30411341..60bd7184 100644
--- a/doc/Makefile.local
+++ b/doc/Makefile.local
@@ -1,4 +1,4 @@
-# -*- makefile -*-
+# -*- makefile-gmake -*-
 
 dir := doc
 
diff --git a/emacs/Makefile.local b/emacs/Makefile.local
index 141f5868..d1b320c3 100644
--- a/emacs/Makefile.local
+++ b/emacs/Makefile.local
@@ -1,4 +1,4 @@
-# -*- makefile -*-
+# -*- makefile-gmake -*-
 
 dir := emacs
 emacs_sources := \
diff --git a/lib/Makefile.local b/lib/Makefile.local
index 5dc057c0..a6400126 100644
--- a/lib/Makefile.local
+++ b/lib/Makefile.local
@@ -1,4 +1,4 @@
-# -*- makefile -*-
+# -*- makefile-gmake -*-
 
 dir := lib
 
diff --git a/parse-time-string/Makefile.local b/parse-time-string/Makefile.local
index 53534f3e..ee8030cc 100644
--- a/parse-time-string/Makefile.local
+++ b/parse-time-string/Makefile.local
@@ -1,3 +1,5 @@
+# -*- makefile-gmake -*-
+
 dir := parse-time-string
 extra_cflags += -I$(srcdir)/$(dir)
 
diff --git a/performance-test/Makefile.local b/performance-test/Makefile.local
index 9dc260e3..b9f580c7 100644
--- a/performance-test/Makefile.local
+++ b/performance-test/Makefile.local
@@ -1,4 +1,4 @@
-# -*- makefile -*-
+# -*- makefile-gmake -*-
 
 dir := performance-test
 
diff --git a/test/Makefile.local b/test/Makefile.local
index 47244e8f..40574739 100644
--- a/test/Makefile.local
+++ b/test/Makefile.local
@@ -1,4 +1,4 @@
-# -*- makefile -*-
+# -*- makefile-gmake -*-
 
 dir := test
 
diff --git a/util/Makefile.local b/util/Makefile.local
index f5d72f79..7ef029a5 100644
--- a/util/Makefile.local
+++ b/util/Makefile.local
@@ -1,4 +1,4 @@
-# -*- makefile -*-
+# -*- makefile-gmake -*-
 
 dir := util
 extra_cflags += -I$(srcdir)/$(dir)
-- 
2.28.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v3 18/34] emacs: Various cosmetic changes

2020-08-08 Thread Jonas Bernoulli
---
 emacs/make-deps.el  |  3 ++-
 emacs/notmuch-lib.el|  8 +++-
 emacs/notmuch-parser.el |  9 +++--
 emacs/notmuch-show.el   | 18 +++---
 emacs/rstdoc.el |  9 -
 test/test-lib.el| 31 +++
 6 files changed, 34 insertions(+), 44 deletions(-)

diff --git a/emacs/make-deps.el b/emacs/make-deps.el
index dcac319c..91f4ef3d 100644
--- a/emacs/make-deps.el
+++ b/emacs/make-deps.el
@@ -36,7 +36,8 @@ (defun make-deps (&optional dir)
 This prints make dependencies to `standard-output' based on the
 top-level `require' expressions in the current buffer.  Paths in
 rules will be given relative to DIR, or `default-directory'."
-  (setq dir (or dir default-directory))
+  (unless dir
+(setq dir default-directory))
   (save-excursion
 (goto-char (point-min))
 (condition-case nil
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index b86c44ed..05d86ea1 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -53,9 +53,8 @@ (defgroup notmuch-show nil
 
 (defgroup notmuch-send nil
   "Sending messages from Notmuch."
-  :group 'notmuch)
-
-(custom-add-to-group 'notmuch-send 'message 'custom-group)
+  :group 'notmuch
+  :group 'message)
 
 (defgroup notmuch-tag nil
   "Tags and tagging in Notmuch."
@@ -782,8 +781,7 @@ (defun notmuch-logged-error (msg &optional extra)
(insert extra)
(unless (bolp)
  (newline)
-  (error "%s"
-(concat msg (and extra " (see *Notmuch errors* for more details)"
+  (error "%s%s" msg (if extra " (see *Notmuch errors* for more details)" "")))
 
 (defun notmuch-check-async-exit-status (proc msg &optional command err)
   "If PROC exited abnormally, pop up an error buffer and signal an error.
diff --git a/emacs/notmuch-parser.el b/emacs/notmuch-parser.el
index fbcfc2ef..3aa5bd8f 100644
--- a/emacs/notmuch-parser.el
+++ b/emacs/notmuch-parser.el
@@ -39,12 +39,9 @@ (defun notmuch-sexp-create-parser ()
 buffer.  Hence, the caller is allowed to delete any data before
 point and may resynchronize after an error by moving point."
   (vector 'notmuch-sexp-parser
- ;; List depth
- 0
- ;; Partial parse position marker
- nil
- ;; Partial parse state
- nil))
+ 0 ; List depth
+ nil   ; Partial parse position marker
+ nil)) ; Partial parse state
 
 (defmacro notmuch-sexp--depth (sp) `(aref ,sp 1))
 (defmacro notmuch-sexp--partial-pos (sp)   `(aref ,sp 2))
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 015edb0c..5640346f 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -499,21 +499,17 @@ (define-button-type 'notmuch-show-part-button-type
 
 (defun notmuch-show-insert-part-header (nth content-type declared-type
&optional name comment)
-  (let ((button)
-   (base-label (concat (and name (concat name ": "))
+  (let ((base-label (concat (and name (concat name ": "))
declared-type
(and (not (string-equal declared-type content-type))
 (concat " (as " content-type ")"))
comment)))
-(setq button
- (insert-button
-  (concat "[ " base-label " ]")
-  :base-label base-label
-  :type 'notmuch-show-part-button-type
-  :notmuch-part-hidden nil))
-(insert "\n")
-;; return button
-button))
+(prog1 (insert-button
+   (concat "[ " base-label " ]")
+   :base-label base-label
+   :type 'notmuch-show-part-button-type
+   :notmuch-part-hidden nil)
+  (insert "\n"
 
 (defun notmuch-show-toggle-part-invisibility (&optional button)
   (interactive)
diff --git a/emacs/rstdoc.el b/emacs/rstdoc.el
index 92a337c8..41390bbe 100644
--- a/emacs/rstdoc.el
+++ b/emacs/rstdoc.el
@@ -24,7 +24,6 @@
 ;;
 
 ;;; Commentary:
-;;
 
 ;; Rstdoc provides a facility to extract all of the docstrings defined in
 ;; an elisp source file. Usage:
@@ -68,10 +67,10 @@ (defun rstdoc--insert-docstring (symbol docstring)
   (insert "\n"))
 
 (defvar rst--escape-alist
-  '( ("='" . "'")
- ("\\([^\\]\\)'" . "\\1`")
- ("^[[:space:]\t]*$" . "|br|")
- ("^[[:space:]\t]" . "|indent| "))
+  '(("='" . "'")
+("\\([^\\]\\)'" . "\\1`")
+("^[[:space:]\t]*$" . "|br|")
+("^[[:space:]\t]" . "|indent| "))
   "List of (regex . replacement) pairs.")
 
 (defun rstdoc--rst-quote-string (str)
diff --git a/test/test-lib.el b/test/test-lib.el
index 6a39bbe2..e9e7c379 100644
--- a/test/test-lib.el
+++ b/test/test-lib.el
@@ -154,22 +154,21 @@ (defun notmuch-test-report-unexpected (output expected)
 
 (defun notmuch-test-expect-equal (output expected)
   "Compare OUTPUT with EXPECTED. Report any discrepencies."
-  (if (equal output expected)
-  t
-(cond
- ((and (listp output)
-  (listp expected))
-  ;; Reporting the dif

[PATCH v3 22/34] test: Fix indentation

2020-08-08 Thread Jonas Bernoulli
Fix it to consistently match the style we have configured in
".dir-locals.el".
---
 test/test-lib.sh | 36 ++--
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/test/test-lib.sh b/test/test-lib.sh
index 527c9e8b..c23a0d20 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -136,16 +136,16 @@ add_gpgsm_home ()
 at_exit_function _gnupg_exit
 mkdir -p -m 0700 "$GNUPGHOME"
 openssl pkcs12 -export -passout pass: -inkey 
"$NOTMUCH_SRCDIR/test/smime/key+cert.pem" \
-< "$NOTMUCH_SRCDIR/test/smime/test.crt" | \
-gpgsm --batch --no-tty --no-common-certs-import 
--pinentry-mode=loopback --passphrase-fd 3 \
-  --disable-dirmngr --import  >"$GNUPGHOME"/import.log 2>&1 3<<<''
+   < "$NOTMUCH_SRCDIR/test/smime/test.crt" | \
+   gpgsm --batch --no-tty --no-common-certs-import 
--pinentry-mode=loopback --passphrase-fd 3 \
+ --disable-dirmngr --import  >"$GNUPGHOME"/import.log 2>&1 3<<<''
 fpr=$(gpgsm --batch --list-key test_su...@notmuchmail.org | sed -n 
's/.*fingerprint: //p')
 echo "$fpr S relax" >> "$GNUPGHOME/trustlist.txt"
 gpgsm --quiet --batch --no-tty --no-common-certs-import --disable-dirmngr 
--import < $NOTMUCH_SRCDIR/test/smime/ca.crt
 echo "4D:E0:FF:63:C0:E9:EC:01:29:11:C8:7A:EE:DA:3A:9A:7F:6E:C1:0D S" >> 
"$GNUPGHOME/trustlist.txt"
 printf '%s::1\n' include-certs disable-crl-checks | gpgconf --output 
/dev/null --change-options gpgsm
 gpgsm --batch --no-tty --no-common-certs-import --pinentry-mode=loopback 
--passphrase-fd 3 \
-  --disable-dirmngr --import "$NOTMUCH_SRCDIR/test/smime/bob.p12" 
>>"$GNUPGHOME"/import.log 2>&1 3<<<''
+ --disable-dirmngr --import "$NOTMUCH_SRCDIR/test/smime/bob.p12" 
>>"$GNUPGHOME"/import.log 2>&1 3<<<''
 test_debug "cat $GNUPGHOME/import.log"
 }
 
@@ -394,8 +394,8 @@ emacs_fcc_message ()
 local nmn_args subject body
 nmn_args=''
 while [[ "$1" =~ ^-- ]]; do
-nmn_args="$nmn_args $1"
-shift
+   nmn_args="$nmn_args $1"
+   shift
 done
 subject="$1"
 body="$2"
@@ -405,7 +405,7 @@ emacs_fcc_message ()
 
 test_emacs \
"(let ((message-send-mail-function (lambda () t))
-   (mail-host-address \"example.com\"))
+  (mail-host-address \"example.com\"))
   (notmuch-mua-mail)
   (message-goto-to)
   (insert \"test_su...@notmuchmail.org\nDate: 01 Jan 2000 12:00:00 
-\")
@@ -524,9 +524,9 @@ test_expect_equal_json () {
 # override Python's stdio encoding defaults.
 script='import json, sys; json.dump(json.load(sys.stdin), sys.stdout, 
sort_keys=True, indent=4)'
 output=$(echo "$1" | PYTHONIOENCODING=utf-8 $NOTMUCH_PYTHON -c "$script" \
-|| echo "$1")
+   || echo "$1")
 expected=$(echo "$2" | PYTHONIOENCODING=utf-8 $NOTMUCH_PYTHON -c "$script" 
\
-|| echo "$2")
+   || echo "$2")
 shift 2
 test_expect_equal "$output" "$expected" "$@"
 }
@@ -540,15 +540,15 @@ test_valid_json () {
 # Sort the top-level list of JSON data from stdin.
 test_sort_json () {
 PYTHONIOENCODING=utf-8 $NOTMUCH_PYTHON -c \
-"import sys, json; json.dump(sorted(json.load(sys.stdin)),sys.stdout)"
+   "import sys, json; json.dump(sorted(json.load(sys.stdin)),sys.stdout)"
 }
 
 # test for json objects:
 # read the source of test/json_check_nodes.py (or the output when
 # invoking it without arguments) for an explanation of the syntax.
 test_json_nodes () {
-local output
-exec 1>&6 2>&7 # Restore stdout and stderr
+   local output
+   exec 1>&6 2>&7  # Restore stdout and stderr
if [ -z "$inside_subtest" ]; then
error "bug in the test script: test_json_eval without 
test_begin_subtest"
fi
@@ -662,7 +662,7 @@ notmuch_json_show_sanitize ()
-e 's|"filename": "signature.asc",||g' \
-e 's|"filename": \["/[^"]*"\],|"filename": \["Y"\],|g' \
-e 's|"timestamp": 97...|"timestamp": 42|g' \
--e 's|"content-length": [1-9][0-9]*|"content-length": "NONZERO"|g'
+   -e 's|"content-length": [1-9][0-9]*|"content-length": "NONZERO"|g'
 }
 
 notmuch_emacs_error_sanitize ()
@@ -673,7 +673,7 @@ notmuch_emacs_error_sanitize ()
 for file in "$@"; do
echo "=== $file ==="
cat "$file"
-done | sed  \
+done | sed \
-e 's/^\[.*\]$/[XXX]/' \
-e "s|^\(command: \)\{0,1\}/.*/$command|\1YYY/$command|"
 }
@@ -929,8 +929,8 @@ test_expect_code () {
 # but is a prefix that can be used in the test script, like:
 #
 #  test_expect_success 'complain and die' '
-#   do something &&
-#   do something else &&
+#  do something &&
+#  do something else &&
 #  test_must_fail git checkout ../outerspace
 #  '
 #
@@ -1020,8 +1020,8 @@ export NOTMUCH_CONFIG=$NOTMUCH_CONFIG
 
 # Here's what we are using here:
 #
-# --quick  Use minimal

[PATCH v3 19/34] emacs: Increase consistency of library headers

2020-08-08 Thread Jonas Bernoulli
---
 emacs/make-deps.el|  2 +-
 emacs/notmuch-company.el  | 37 +++--
 emacs/notmuch-compat.el   | 22 +---
 emacs/notmuch-crypto.el   |  2 +-
 emacs/notmuch-lib.el  |  2 --
 emacs/notmuch-maildir-fcc.el  | 39 +--
 emacs/notmuch-print.el|  2 +-
 emacs/notmuch-show.el |  2 +-
 emacs/notmuch-tag.el  |  3 +--
 emacs/notmuch-tree.el |  2 +-
 emacs/notmuch-version.el.tmpl |  3 +--
 emacs/notmuch.el  |  4 ++--
 12 files changed, 68 insertions(+), 52 deletions(-)

diff --git a/emacs/make-deps.el b/emacs/make-deps.el
index 91f4ef3d..a7699fb1 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
 ;;
 ;; Copyright © Austin Clements
 ;;
diff --git a/emacs/notmuch-company.el b/emacs/notmuch-company.el
index c1f3594e..24e7446c 100644
--- a/emacs/notmuch-company.el
+++ b/emacs/notmuch-company.el
@@ -1,29 +1,34 @@
 ;;; notmuch-company.el --- Mail address completion for notmuch via 
company-mode  -*- lexical-binding: t -*-
-
-;; Authors: Trevor Jim 
-;; Michal Sojka 
 ;;
-;; Keywords: mail, completion
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
+;; Copyright © Trevor Jim
+;; Copyright © Michal Sojka
+;;
+;; This file is part of Notmuch.
+;;
+;; Notmuch is free software: you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
 ;; the Free Software Foundation, either version 3 of the License, or
 ;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
+;;
+;; Notmuch is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+;;
 ;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see .
+;; along with Notmuch.  If not, see .
+;;
+;; Authors: Trevor Jim 
+;; Michal Sojka 
+;; Keywords: mail, completion
 
 ;;; Commentary:
 
-;; To enable this, install company mode (https://company-mode.github.io/)
+;; Mail address completion for notmuch via company-mode.  To enable
+;; this, install company mode from .
 ;;
 ;; NB company-minimum-prefix-length defaults to 3 so you don't get
-;; completion unless you type 3 characters
+;; completion unless you type 3 characters.
 
 ;;; Code:
 
diff --git a/emacs/notmuch-compat.el b/emacs/notmuch-compat.el
index 3340918f..9d82a729 100644
--- a/emacs/notmuch-compat.el
+++ b/emacs/notmuch-compat.el
@@ -1,10 +1,26 @@
-;; Compatibility functions for earlier versions of emacs
-
+;;; notmuch-compat.el --- compatibility functions for earlier versions of emacs
+;;
 ;; The functions in this file are copied from more modern versions of
 ;; emacs and are Copyright (C) 1985-1986, 1992, 1994-1995, 1999-2017
 ;; Free Software Foundation, Inc.
+;;
+;; This file is part of Notmuch.
+;;
+;; Notmuch is free software: you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; Notmuch is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with Notmuch.  If not, see .
+
+;;; Code:
 
-
 ;; emacs master has a bugfix for folding long headers when sending
 ;; messages. Include the fix for earlier versions of emacs. To avoid
 ;; interfering with gnus we only run the hook when called from
diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index e6bf8339..6df1dd64 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
 ;;
 ;; Copyright © Jameson Rollins
 ;;
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 05d86ea1..fded2d7b 100644
--- a/emacs/notmuch-lib.el
+++ 

[PATCH v3 24/34] emacs: Provide 'rstdoc' feature at end of file

2020-08-08 Thread Jonas Bernoulli
Features should nearly always be provided at the very end of their
libraries.  This feature isn't one of the rare exceptions.
---
 emacs/rstdoc.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/emacs/rstdoc.el b/emacs/rstdoc.el
index 41390bbe..63fa2794 100644
--- a/emacs/rstdoc.el
+++ b/emacs/rstdoc.el
@@ -32,8 +32,6 @@
 
 ;;; Code:
 
-(provide 'rstdoc)
-
 (defun rstdoc-batch-extract ()
   "Extract docstrings to and from the files on the command line."
   (apply #'rstdoc-extract command-line-args-left))
@@ -82,4 +80,6 @@ (defun rstdoc--rst-quote-string (str)
(replace-match (cdr pair
 (buffer-substring (point-min) (point-max
 
+(provide 'rstdoc)
+
 ;;; rstdoc.el ends here
-- 
2.28.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v3 25/34] emacs: Add end-of-file line to libraries that lack it

2020-08-08 Thread Jonas Bernoulli
---
 emacs/notmuch-compat.el | 2 ++
 emacs/notmuch-tag.el| 2 ++
 2 files changed, 4 insertions(+)

diff --git a/emacs/notmuch-compat.el b/emacs/notmuch-compat.el
index 9d82a729..370cafa1 100644
--- a/emacs/notmuch-compat.el
+++ b/emacs/notmuch-compat.el
@@ -107,3 +107,5 @@ (if (fboundp 'read-char-choice)
 ;; End of compatibility functions
 
 (provide 'notmuch-compat)
+
+;;; notmuch-compat.el ends here
diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
index c7a1e322..5d4a6865 100644
--- a/emacs/notmuch-tag.el
+++ b/emacs/notmuch-tag.el
@@ -550,3 +550,5 @@ (defun notmuch-tag-jump (reverse)
 ;;
 
 (provide 'notmuch-tag)
+
+;;; notmuch-tag.el ends here
-- 
2.28.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v3 20/34] Fix typos

2020-08-08 Thread Jonas Bernoulli
---
 NEWS   |  2 +-
 bindings/python-cffi/notmuch2/__init__.py  |  2 +-
 bindings/python-cffi/notmuch2/_base.py |  6 +++---
 bindings/python-cffi/notmuch2/_database.py |  8 
 bindings/python-cffi/notmuch2/_message.py  |  4 ++--
 bindings/python-cffi/notmuch2/_tags.py |  8 
 bindings/python-cffi/tests/conftest.py |  2 +-
 bindings/python/notmuch/database.py| 12 ++--
 bindings/python/notmuch/query.py   |  2 +-
 emacs/notmuch-crypto.el|  2 +-
 emacs/notmuch-lib.el   |  2 +-
 emacs/notmuch-mua.el   |  2 +-
 lib/notmuch.h  |  4 ++--
 tag-util.c |  2 +-
 tag-util.h |  2 +-
 test/T610-message-property.sh  |  2 +-
 test/T710-message-id.sh|  2 +-
 test/random-corpus.c   |  2 +-
 test/test-lib.el   |  2 +-
 19 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/NEWS b/NEWS
index 0d8b930f..9f0db031 100644
--- a/NEWS
+++ b/NEWS
@@ -116,7 +116,7 @@ information about cryptographic protections for the Subject 
header.
 Emacs
 -
 
-Optionally check for missing attachements in outgoing messages (see
+Optionally check for missing attachments in outgoing messages (see
 function `notmuch-mua-attachment-check`).
 
 Bind `B` to browse URLs in current message.
diff --git a/bindings/python-cffi/notmuch2/__init__.py 
b/bindings/python-cffi/notmuch2/__init__.py
index 613317e0..f281edc1 100644
--- a/bindings/python-cffi/notmuch2/__init__.py
+++ b/bindings/python-cffi/notmuch2/__init__.py
@@ -10,7 +10,7 @@ should consider their signatures implementation details.
 Errors
 ==
 
-All errors occuring due to errors from the underlying notmuch database
+All errors occurring due to errors from the underlying notmuch database
 are subclasses of the :exc:`NotmuchError`.  Due to memory management
 it is possible to try and use an object after it has been freed.  In
 this case a :exc:`ObjectDestroyedError` will be raised.
diff --git a/bindings/python-cffi/notmuch2/_base.py 
b/bindings/python-cffi/notmuch2/_base.py
index 31258149..1cf03c88 100644
--- a/bindings/python-cffi/notmuch2/_base.py
+++ b/bindings/python-cffi/notmuch2/_base.py
@@ -29,7 +29,7 @@ class NotmuchObject(metaclass=abc.ABCMeta):
 However during some peculiar situations, e.g. interpreter
 shutdown, it is possible for the :meth:`__del__` method to have
 been called, whele there are still references to an object.  This
-could result in child objects asking their memeory to be freed
+could result in child objects asking their memory to be freed
 after the parent has already freed the memory, making things
 rather unhappy as double frees are not taken lightly in C.  To
 handle this case all objects need to follow the same protocol to
@@ -73,7 +73,7 @@ class NotmuchObject(metaclass=abc.ABCMeta):
 def _destroy(self):
 """Destroy the object, freeing all memory.
 
-This method needs to destory the object on the
+This method needs to destroy the object on the
 libnotmuch-level.  It must ensure it's not been destroyed by
 it's parent object yet before doing so.  It also must be
 idempotent.
@@ -134,7 +134,7 @@ class BinString(str):
 
 Most data in libnotmuch should be valid ASCII or valid UTF-8.
 However since it is a C library these are represented as
-bytestrings intead which means on an API level we can not
+bytestrings instead which means on an API level we can not
 guarantee that decoding this to UTF-8 will both succeed and be
 lossless.  This string type converts bytes to unicode in a lossy
 way, but also makes the raw bytes available.
diff --git a/bindings/python-cffi/notmuch2/_database.py 
b/bindings/python-cffi/notmuch2/_database.py
index 7db5a7f8..5ab0f20a 100644
--- a/bindings/python-cffi/notmuch2/_database.py
+++ b/bindings/python-cffi/notmuch2/_database.py
@@ -422,7 +422,7 @@ class Database(base.NotmuchObject):
of it as ``dup = db.remove_message(name); if dup: ...``.
 :rtype: bool
 
-:raises XapianError: A Xapian exception ocurred.
+:raises XapianError: A Xapian exception occurred.
 :raises ReadOnlyDatabaseError: The database is opened in
READ_ONLY mode.
 :raises UpgradeRequiredError: The database must be upgraded
@@ -458,7 +458,7 @@ class Database(base.NotmuchObject):
 :raises LookupError: If no message was found.
 :raises OutOfMemoryError: When there is no memory to allocate
the message instance.
-:raises XapianError: A Xapian exception ocurred.
+:raises XapianError: A Xapian exception occurred.
 :raises ObjectDestroyedError: if used after destroyed.
 """
 msg_pp = capi.ffi.new('notmuch_message_t **')
@@ -4

[PATCH v3 26/34] NEWS: Add stub for 0.31

2020-08-08 Thread Jonas Bernoulli
---
 NEWS | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/NEWS b/NEWS
index 9f0db031..3790204b 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,6 @@
+Notmuch 0.31 (UNRELEASED)
+=
+
 Notmuch 0.30 (2020-07-10)
 =
 
-- 
2.28.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v3 27/34] NEWS: At least Emacs 25.1 is required now

2020-08-08 Thread Jonas Bernoulli
Some backward incompatible changes follow in the next few commits
and going forward contributors don't have to worry about Emacs 24
at all anymore.
---
 NEWS  | 5 +
 emacs/notmuch-pkg.el.tmpl | 3 +--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 3790204b..4160e39c 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,11 @@
 Notmuch 0.31 (UNRELEASED)
 =
 
+Emacs
+-
+
+The minimum supported major version of GNU Emacs is now 25.1.
+
 Notmuch 0.30 (2020-07-10)
 =
 
diff --git a/emacs/notmuch-pkg.el.tmpl b/emacs/notmuch-pkg.el.tmpl
index 9d0999c1..85c631de 100644
--- a/emacs/notmuch-pkg.el.tmpl
+++ b/emacs/notmuch-pkg.el.tmpl
@@ -3,5 +3,4 @@
   "notmuch"
   %VERSION%
   "Emacs based front-end (MUA) for notmuch"
-  '((emacs "24")
-(cl-lib "0.6.1")))
+  '((emacs "25.1")))
-- 
2.28.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v3 29/34] emacs: Remove notmuch-setq-local

2020-08-08 Thread Jonas Bernoulli
Just use setq-local, which existed since Emacs 24.3.
---
 emacs/notmuch-address.el | 4 ++--
 emacs/notmuch-company.el | 2 +-
 emacs/notmuch-compat.el  | 8 
 3 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index cd0ffb67..8a6d299c 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -172,11 +172,11 @@ (defun notmuch-address-toggle-internal-completion ()
   (interactive)
   (if (local-variable-p 'notmuch-address-command)
   (kill-local-variable 'notmuch-address-command)
-(notmuch-setq-local notmuch-address-command 'internal))
+(setq-local notmuch-address-command 'internal))
   (when (boundp 'company-idle-delay)
 (if (local-variable-p 'company-idle-delay)
(kill-local-variable 'company-idle-delay)
-  (notmuch-setq-local company-idle-delay nil
+  (setq-local company-idle-delay nil
 
 (defun notmuch-address-matching (substring)
   "Returns a list of completion candidates matching SUBSTRING.
diff --git a/emacs/notmuch-company.el b/emacs/notmuch-company.el
index 24e7446c..9ee8ceca 100644
--- a/emacs/notmuch-company.el
+++ b/emacs/notmuch-company.el
@@ -62,7 +62,7 @@ (defun notmuch-company-setup ()
   ;; internal completion) can still be accessed via standard company
   ;; functions, e.g., company-complete.
   (unless (eq notmuch-address-command 'internal)
-(notmuch-setq-local company-idle-delay nil)))
+(setq-local company-idle-delay nil)))
 
 ;;;###autoload
 (defun notmuch-company (command &optional arg &rest _ignore)
diff --git a/emacs/notmuch-compat.el b/emacs/notmuch-compat.el
index 370cafa1..fafc64f3 100644
--- a/emacs/notmuch-compat.el
+++ b/emacs/notmuch-compat.el
@@ -40,14 +40,6 @@ (defun notmuch-message--fold-long-headers ()
 (unless (fboundp 'message--fold-long-headers)
   (add-hook 'message-header-hook 'notmuch-message--fold-long-headers))
 
-(if (fboundp 'setq-local)
-(defalias 'notmuch-setq-local 'setq-local)
-  (defmacro notmuch-setq-local (var val)
-"Set variable VAR to value VAL in current buffer.
-
-Backport of setq-local for emacs without setq-local (pre 24.3)."
-`(set (make-local-variable ',var) ,val)))
-
 (if (fboundp 'read-char-choice)
 (defalias 'notmuch-read-char-choice 'read-char-choice)
   (defun notmuch-read-char-choice (prompt chars &optional 
inhibit-keyboard-quit)
-- 
2.28.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v3 32/34] emacs: Do not abuse advice to monkey patch while testing

2020-08-08 Thread Jonas Bernoulli
Use `cl-letf*' instead.
---
 test/T310-emacs.sh | 14 --
 test/test-lib.el   |  8 
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/test/T310-emacs.sh b/test/T310-emacs.sh
index 5f74305d..78ac19a8 100755
--- a/test/T310-emacs.sh
+++ b/test/T310-emacs.sh
@@ -40,12 +40,14 @@ test_emacs '(notmuch-search "tag:inbox")
 test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox OUTPUT
 
 test_begin_subtest "Incremental parsing of search results"
-test_emacs "(ad-enable-advice 'notmuch-search-process-filter 'around 'pessimal)
-   (ad-activate 'notmuch-search-process-filter)
-   (notmuch-search \"tag:inbox\")
-   (notmuch-test-wait)
-   (ad-disable-advice 'notmuch-search-process-filter 'around 'pessimal)
-   (ad-activate 'notmuch-search-process-filter)
+test_emacs "(cl-letf* (((symbol-function 'orig)
+   (symbol-function 'notmuch-search-process-filter))
+  ((symbol-function 'notmuch-search-process-filter)
+   (lambda (proc string)
+ (cl-loop for char across string
+  do (orig proc (char-to-string char))
+ (notmuch-search \"tag:inbox\")
+ (notmuch-test-wait))
(test-output)"
 test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox OUTPUT
 
diff --git a/test/test-lib.el b/test/test-lib.el
index 044c2da4..ec16c59c 100644
--- a/test/test-lib.el
+++ b/test/test-lib.el
@@ -97,14 +97,6 @@ (defvar notmuch-hello-refresh-hook-counter -100
 (add-hook 'notmuch-hello-refresh-hook
  (lambda () (cl-incf notmuch-hello-refresh-hook-counter)))
 
-(defadvice notmuch-search-process-filter (around pessimal activate disable)
-  "Feed notmuch-search-process-filter one character at a time."
-  (let ((string (ad-get-arg 1)))
-(cl-loop for char across string
-do (progn
- (ad-set-arg 1 (char-to-string char))
- ad-do-it
-
 (defun notmuch-test-mark-links ()
   "Enclose links in the current buffer with << and >>."
   ;; Links are often created by jit-lock functions
-- 
2.28.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v3 34/34] try-emacs-mua: Trim `require' advice for Emacs 25

2020-08-08 Thread Jonas Bernoulli
- Since Emacs 25 comes with `load-prefer-newer' we can remove the
  complicated variant of the advice, which implemented a poorman's
  version of that.

- Since Emacs 25 comes with the new advice mechanism, we can use
  that now for the simple variant of the advice, which just informs
  about the library that is being required.
---
 devel/try-emacs-mua | 26 --
 1 file changed, 4 insertions(+), 22 deletions(-)

diff --git a/devel/try-emacs-mua b/devel/try-emacs-mua
index 041f6216..585d6242 100755
--- a/devel/try-emacs-mua
+++ b/devel/try-emacs-mua
@@ -44,28 +44,10 @@ while looking at: " pdir "emacs\n\nexit emacs (y or n)? ")
try-notmuch-emacs-directory (concat pdir "emacs/")
load-path (cons try-notmuch-emacs-directory load-path)))
 
-;; they say advice doesn't work for primitives (functions from c source)
-;; well, these 'before' advice works for emacs 23.1 - 24.5 (at least)
-;; ...and for our purposes 24.3 is enough (there is no load-prefer-newer there)
-;; note also that the old, "obsolete" defadvice mechanism was used, but that
-;; is the only one available for emacs 23 and 24 up to 24.3.
-
-(if (boundp 'load-prefer-newer)
-(defadvice require (before before-require activate)
-  (unless (featurep feature)
-   (message "require: %s" feature)))
-  ;; else: special require "short-circuit"; after load feature is provided...
-  ;; ... in notmuch sources we always use require and there are no loops
-  (defadvice require (before before-require activate)
-(unless (featurep feature)
-  (message "require: %s" feature)
-  (let ((name (symbol-name feature)))
-   (if (and (string-match "^notmuch" name)
-(file-newer-than-file-p
- (concat try-notmuch-emacs-directory name ".el")
- (concat try-notmuch-emacs-directory name ".elc")))
-   (load (concat try-notmuch-emacs-directory name ".el") nil nil t t)
- )
+(define-advice require
+(:before (feature &optional _filename _noerror) notmuch)
+  (unless (featurep feature)
+(message "require: %s" feature)))
 
 (insert "Found notmuch emacs client in " try-notmuch-emacs-directory "\n")
 
-- 
2.28.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v3 33/34] emacs: Use new advice mechanism do advice mm-shr

2020-08-08 Thread Jonas Bernoulli
Also because we now only support Emacs >= 25,
we can remove the check for Emacs >= 24.
---
 emacs/notmuch-lib.el | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 91c94781..118faf1e 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -661,11 +661,9 @@ (defun notmuch-get-bodypart-text (msg part process-crypto 
&optional cache)
 ;; first loading gnus-art, which defines it, resulting in a
 ;; void-variable error.  Hence, we advise `mm-shr' to ensure gnus-art
 ;; is loaded.
-(when (>= emacs-major-version 24)
-  (defadvice mm-shr (before load-gnus-arts activate)
-(require 'gnus-art nil t)
-(ad-disable-advice 'mm-shr 'before 'load-gnus-arts)
-(ad-activate 'mm-shr)))
+(define-advice mm-shr (:before (_handle) notmuch--load-gnus-args)
+  "Require `gnus-art' since we use its variables."
+  (require 'gnus-art nil t))
 
 (defun notmuch-mm-display-part-inline (msg part content-type process-crypto)
   "Use the mm-decode/mm-view functions to display a part in the
-- 
2.28.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v3 31/34] emacs: Drop old advices that were only need for Emacs 23

2020-08-08 Thread Jonas Bernoulli
---
 emacs/notmuch-mua.el | 14 --
 test/test-lib.el | 17 -
 2 files changed, 31 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index f321e0c6..dcddca76 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -425,20 +425,6 @@ (defcustom notmuch-always-prompt-for-sender nil
 
 (defvar notmuch-mua-sender-history nil)
 
-;; Workaround: Running `ido-completing-read' in emacs 23.1, 23.2 and 23.3
-;; without some explicit initialization fill freeze the operation.
-;; Hence, we advice `ido-completing-read' to ensure required initialization
-;; is done.
-(when (and (= emacs-major-version 23)
-  (< emacs-minor-version 4))
-  (defadvice ido-completing-read (before notmuch-ido-mode-init activate)
-(ido-init-completion-maps)
-(add-hook 'minibuffer-setup-hook 'ido-minibuffer-setup)
-(add-hook 'choose-completion-string-functions
- 'ido-choose-completion-string)
-(ad-disable-advice 'ido-completing-read 'before 'notmuch-ido-mode-init)
-(ad-activate 'ido-completing-read)))
-
 (defun notmuch-mua-prompt-for-sender ()
   "Prompt for a sender from the user's configured identities."
   (if notmuch-identities
diff --git a/test/test-lib.el b/test/test-lib.el
index 2def7ffe..044c2da4 100644
--- a/test/test-lib.el
+++ b/test/test-lib.el
@@ -34,23 +34,6 @@ (require 'smtpmail)
 ;; `read' call.
 (setq read-file-name-function (lambda (&rest _) (read)))
 
-;; Work around a bug in emacs 23.1 and emacs 23.2 which prevents
-;; noninteractive (kill-emacs) from emacsclient.
-(when (and (= emacs-major-version 23) (< emacs-minor-version 3))
-  (defadvice kill-emacs (before disable-yes-or-no-p activate)
-"Disable yes-or-no-p before executing kill-emacs"
-(defun yes-or-no-p (prompt) t)))
-
-;; Emacs bug #2930:
-;; 23.0.92; `accept-process-output' and `sleep-for' do not run sentinels
-;; seems to be present in Emacs 23.1.
-;; Running `list-processes' after `accept-process-output' seems to work
-;; around this problem.
-(when (and (= emacs-major-version 23) (= emacs-minor-version 1))
-  (defadvice accept-process-output (after run-list-processes activate)
-"run list-processes after executing accept-process-output"
-(list-processes)))
-
 (defun notmuch-test-wait ()
   "Wait for process completion."
   (while (get-buffer-process (current-buffer))
-- 
2.28.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v3 28/34] emacs: Use cl-incf where appropriate

2020-08-08 Thread Jonas Bernoulli
It's shorter.  That's it pretty much.
---
 emacs/notmuch-hello.el | 2 +-
 emacs/notmuch-lib.el   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 876d8ef1..c127bba9 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -609,7 +609,7 @@ (defun notmuch-hello-insert-buttons (searches)
   name)
(setq column-indent
  (1+ (max 0 (- column-width (length name)))
-   (setq count (1+ count))
+   (cl-incf count)
(when (eq (% count tags-per-line) 0)
  (setq column-indent 0)
  (widget-insert "\n")))
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 11f6858e..91c94781 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -413,7 +413,7 @@ (defun notmuch-subkeymap-help ()
 (i 0))
 (while (< i (length prefix))
   (aset prefix i (aref key i))
-  (setq i (1+ i)))
+  (cl-incf i))
 (let* ((subkeymap (key-binding prefix))
   (ua-keys (where-is-internal 'universal-argument nil t))
   (prefix-string (notmuch-prefix-key-description prefix))
-- 
2.28.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v3 30/34] emacs: Remove notmuch-read-char-choice

2020-08-08 Thread Jonas Bernoulli
Just use `read-char-choice', which existed since Emacs 24.1.
---
 emacs/notmuch-compat.el  | 56 
 emacs/notmuch-maildir-fcc.el |  4 +--
 2 files changed, 2 insertions(+), 58 deletions(-)

diff --git a/emacs/notmuch-compat.el b/emacs/notmuch-compat.el
index fafc64f3..3ede6b36 100644
--- a/emacs/notmuch-compat.el
+++ b/emacs/notmuch-compat.el
@@ -40,62 +40,6 @@ (defun notmuch-message--fold-long-headers ()
 (unless (fboundp 'message--fold-long-headers)
   (add-hook 'message-header-hook 'notmuch-message--fold-long-headers))
 
-(if (fboundp 'read-char-choice)
-(defalias 'notmuch-read-char-choice 'read-char-choice)
-  (defun notmuch-read-char-choice (prompt chars &optional 
inhibit-keyboard-quit)
-"Read and return one of CHARS, prompting for PROMPT.
-Any input that is not one of CHARS is ignored.
-
-If optional argument INHIBIT-KEYBOARD-QUIT is non-nil, ignore
-keyboard-quit events while waiting for a valid input.
-
-This is an exact copy of this function from emacs 24 for use on
-emacs 23, except with the one emacs 24 only function it calls
-inlined."
-(unless (consp chars)
-  (error "Called `read-char-choice' without valid char choices"))
-(let (char done show-help (helpbuf " *Char Help*"))
-  (let ((cursor-in-echo-area t)
-   (executing-kbd-macro executing-kbd-macro)
-   (esc-flag nil))
-   (save-window-excursion; in case we call help-form-show
- (while (not done)
-   (unless (get-text-property 0 'face prompt)
- (setq prompt (propertize prompt 'face 'minibuffer-prompt)))
-   (setq char (let ((inhibit-quit inhibit-keyboard-quit))
-(read-key prompt)))
-   (and show-help (buffer-live-p (get-buffer helpbuf))
-(kill-buffer helpbuf))
-   (cond
-((not (numberp char)))
-;; If caller has set help-form, that's enough.
-;; They don't explicitly have to add help-char to chars.
-((and help-form
-  (eq char help-char)
-  (setq show-help t)
-  ;; This is an inlined copy of help-form-show as that
-  ;; was introduced in emacs 24 too.
-  (let ((msg (eval help-form)))
-(when (stringp msg)
-  (with-output-to-temp-buffer " *Char Help*"
-(princ msg))
-((memq char chars)
- (setq done t))
-((and executing-kbd-macro (= char -1))
- ;; read-event returns -1 if we are in a kbd macro and
- ;; there are no more events in the macro.  Attempt to
- ;; get an event interactively.
- (setq executing-kbd-macro nil))
-((not inhibit-keyboard-quit)
- (cond
-  ((and (null esc-flag) (eq char ?\e))
-   (setq esc-flag t))
-  ((memq char '(?\C-g ?\e))
-   (keyboard-quit
-  ;; Display the question with the answer.  But without 
cursor-in-echo-area.
-  (message "%s%s" prompt (char-to-string char))
-  char)))
-
 ;; End of compatibility functions
 
 (provide 'notmuch-compat)
diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el
index aa07b26a..a9103a20 100644
--- a/emacs/notmuch-maildir-fcc.el
+++ b/emacs/notmuch-maildir-fcc.el
@@ -242,7 +242,7 @@ (defun notmuch-maildir-fcc-with-notmuch-insert (fcc-header 
&optional create)
   ;; typo, or just the user want a new folder, let the user decide
   ;; how to deal with it.
   (error
-   (let ((response (notmuch-read-char-choice "Insert failed: \
+   (let ((response (read-char-choice "Insert failed: \
 \(r)etry, (c)reate folder, (i)gnore, or (e)dit the header? " '(?r ?c ?i ?e
 (cl-case response
   (?r (notmuch-maildir-fcc-with-notmuch-insert fcc-header))
@@ -327,7 +327,7 @@ (defun notmuch-maildir-fcc-file-fcc (fcc-header)
 ;; fix it in some way.
 (let* ((prompt (format "Fcc %s is not a maildir: \
 \(r)etry, (c)reate folder, (i)gnore, or (e)dit the header? " fcc-header))
-  (response (notmuch-read-char-choice prompt '(?r ?c ?i ?e
+  (response (read-char-choice prompt '(?r ?c ?i ?e
   (cl-case response
(?r (notmuch-maildir-fcc-file-fcc fcc-header))
(?c (if (file-writable-p fcc-header)
-- 
2.28.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH v3 00/34] A great number of cosmetic changes

2020-08-09 Thread Jonas Bernoulli
Tomi Ollila  writes:

> I made a quick check of release dates of emacs 25.1, gmime 3 and xapian 1.4
> -- gmime 3 released early 2017, xapian 1.4 middle of 2016 and emacs 25.1
> sept 2016 -- so requiring emacs 25.1 is pretty much aligned to those
> releases and therefore dropping emacs 24 support looks good to me.

Great!

>> That resulted in a few new commits of course, marked with * below.
>> And since I had to add some commit anyway, I also added three other
>> minor commits, marked with ^ below.
>
> I checked the new commits, looks good to me. I also was preparing dropping
> emacs 23 support code and the changes aligned what I tried. Interestinglyy
> this change in notmuch-mua.el:
>   ;; There is a bug in emacs 23's message.el that results in a newline
>   ;; not being inserted after the References header, so the next header
>   ;; is concatenated to the end of it. 
> Is still effective in emacs 26.3 -- I wonder whether there is something
> wrong notmuch-emacs handles the case `notmuch-mua-insert-references` is
> needed.

I'll have a look.

> I trust the earlier changes are the same as in v2 and v1

Almost. In "emacs: Increase consistency of library headers" I did bring
the headers of "notmuch-compat.el" and "emacs/notmuch-version.el.tmpl"
more in line.  But that's it.

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


Re: [PATCH v3 00/34] A great number of cosmetic changes

2020-08-09 Thread Jonas Bernoulli
Đoàn Trần Công Danh  writes:

> On 2020-08-09 09:09:39-0300, David Bremner  wrote:
>> Jonas Bernoulli  writes:
>> >
>> > Jonas Bernoulli (34):
>> >   emacs: Shorten long lines
>> >   emacs: Remove excess empty lines
>> 
>> 
>> These patches (and Đoàn Trần Công Danh's that I just applied by hand)
>> both seem to have problem with base64 encoded patches documented at.
>> 
>>  https://lore.kernel.org/git/20191218194144.gl17...@pobox.com/
>> 
>> It seems that the patches have CRLF line endings inside the base64
>> encoding, and git fails to strip the CRs.
>> 
>> I'm not sure why this happens for some patches and not for others;
>> I hope there is not re-encoding happening on the mailing list. If there
>> is we should fix that.
>
> It seems like the mailing list base64-encodes utf-8 email.
> My email will be sent in utf-8 for obvious reason.
>
> I don't know about Jonas's, some of them are in utf-8 and some other
> is in plain ascii.

That seems to be it.  I don't remember the exact question but when
sending I was asked about what encoding to use and I confirmed the
default, which was utf-8.  Usually I am not asked this question.

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


Re: [PATCH v3 00/34] A great number of cosmetic changes

2020-08-09 Thread Jonas Bernoulli
David Bremner  writes:
> A short term fix would be to fetch a ref from somewhere.

You can fetch it with:

git fetch https://github.com/tarsiiformes/notmuch.git cleanup

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


Re: [PATCH] Emacs: Fix notmuch-message-summary-face definition

2020-08-16 Thread Jonas Bernoulli
Teemu Likonen  writes:

> Emacs face definition forms are either
>
> ((DISPLAY . PLIST)
>  (DISPLAY . PLIST))
>
> or
>
> ((DISPLAY PLIST)   ;For backward compatibility.
>  (DISPLAY PLIST))
>
> Commit a2388bc56e55da5d5695816818274f8a84b0ed92 (2020-08-08) follows
> neither of the correct formats. It defines:
>
> `class color) (background light))
>,@(and (>= emacs-major-version 27) '(:extend t))
>(:background "#f0f0f0"))
>   (((class color) (background dark))
>,@(and (>= emacs-major-version 27) '(:extend t))
>(:background "#303030")))
>
> which produces:
>
> ((DISPLAY
>   :extend t (:background "#f0f0f0"))
>  (DISPLAY
>   :extend t (:background "#303030")))
>
> And that is wrong format.

You are right.

Sorry about this.  It happened because in every other package I patched
so far the new format was used and I didn't notice that this wasn't the
case here.

> This change fixes the face definition form to produce:
>
> ((DISPLAY
>   (:background "#f0f0f0" :extend t))
>  (DISPLAY
>   (:background "#303030" :extend t)))
>
> which follows the (DISPLAY PLIST) format (see above).
> ---
>  emacs/notmuch.el | 6 ++
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index babddbb6..16227b5c 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -274,11 +274,9 @@ there will be called at other points of notmuch 
> execution."
>  
>  (defface notmuch-message-summary-face
>`class color) (background light))
> - ,@(and (>= emacs-major-version 27) '(:extend t))
> - (:background "#f0f0f0"))
> + (:background "#f0f0f0" ,@(if (>= emacs-major-version 27) '(:extend t
>  (((class color) (background dark))
> - ,@(and (>= emacs-major-version 27) '(:extend t))
> - (:background "#303030")))
> + (:background "#303030" ,@(if (>= emacs-major-version 27) '(:extend 
> t)
>"Face for the single-line message summary in notmuch-show-mode."
>:group 'notmuch-show
>:group 'notmuch-faces)
> -- 
> 2.20.1

I would recommend that you
- switch to using the new format
- keep the `:extend' setting on its own line
- keep the `:extend' at the beginning of the list
- use `and' instead of `if' because
  - it is better to use `when' instead of `if' when
there is no ELSE part
  - it is better to use `and' instead of `when` when
the form is about the returned value, not some
side-effect


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


[PATCH] Revert "emacs: notmuch-search: avoid wiping out buffer-local variables"

2020-11-08 Thread Jonas Bernoulli
This reverts commit f9fbd1ee3bfd679175d88af403752d87a730349f.

Emacs provides a mechanism for avoiding wiping out buffer-local
variables: marking them as "permanent local", which essentially
means "don't wip out the local value when enabling major-mode".

  (put 'the-variable 'permanent-local t)

See (info "(elisp)Creating Buffer-Local").

Whether refreshing the buffer contents should involve re-enable the
mode is a different question, which should not be decided based on
the fact that we want keep the value of some random variable, not
least because some other (e.g. cache) variables are likely expected
to be wiped.
---
 emacs/notmuch.el | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 83bcee57..c4078bd3 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -995,11 +995,7 @@ (defun notmuch-search (&optional query oldest-first 
target-thread target-line no
 (if no-display
(set-buffer buffer)
   (pop-to-buffer-same-window buffer))
-;; avoid wiping out third party buffer-local variables in the case
-;; where we're just refreshing or changing the sort order of an
-;; existing search results buffer
-(unless (eq major-mode 'notmuch-search-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)
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 06/27] emacs: fix old bug in notmuch-mua-mail

2020-11-08 Thread Jonas Bernoulli
This fixes a regression introduced in [1: 7e20d264].  If the argument
RETURN-ACTION was non-nil then we should pass along the value of that
argument.  Instead we passed along the constant symbol `return-action'.

1: 7e20d26480553f57d53bd9ec28cae163c1ac91e3
   emacs: Fix mail composition under Emacs 23
---
 emacs/notmuch-mua.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 616b625c..1204fb6a 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -402,7 +402,7 @@ (defun notmuch-mua-mail (&optional to subject other-headers 
continue
 ;; argument. Pass it only if it is supplied by the caller. This
 ;; will never be the case when we're called by `compose-mail' in
 ;; Emacs 23.
-(when return-action (nconc args '(return-action)))
+(when return-action (nconc args (list return-action)))
 (apply 'message-setup-1 headers args))
   (notmuch-fcc-header-setup)
   (message-sort-headers)
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 01/27] emacs: silence byte-compiler

2020-11-08 Thread Jonas Bernoulli
---
 emacs/notmuch-tree.el | 5 +
 1 file changed, 5 insertions(+)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index f342f85a..7b1e34ca 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -42,6 +42,11 @@ (declare-function notmuch-read-query "notmuch" (prompt))
 (declare-function notmuch-search-find-thread-id "notmuch" (&optional bare))
 (declare-function notmuch-search-find-subject "notmuch" ())
 
+;; For `notmuch-tree-next-thread-from-search'.
+(declare-function notmuch-search-next-thread "notmuch" ())
+(declare-function notmuch-search-previous-thread "notmuch" ())
+(declare-function notmuch-tree-from-search-thread "notmuch" ())
+
 ;; the following variable is defined in notmuch.el
 (defvar notmuch-search-query-string)
 
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 00/27] Another set up Emacs cleanup

2020-11-08 Thread Jonas Bernoulli
I did it again; looked at some code and cleaned it up along the way.

 Cheers,
 Jonas

Jonas Bernoulli (27):
  emacs: silence byte-compiler
  emacs: define notmuch-message-mode-map explicitly
  emacs: add doc-string to notmuch-tree-mode-map
  emacs: don't fset keymaps
  emacs: remove redundant notmuch-hello-trim
  emacs: fix old bug in notmuch-mua-mail
  emacs: remove kludge for Emacs 23 from notmuch-mua-mail
  emacs: more cleanup since dropping support for Emacs 24
  emacs: sanitize function that displays version
  emacs: define notmuch-hello-url as a constant
  emacs: shorten/replace first sentence of a few doc-strings
  emacs: place only first sentence on first doc-string line
  emacs: place complete first sentence on first doc-string line
  emacs: always use elisp quoting style in doc-strings
  emacs: misc doc-string improvements
  emacs: remove deprecated notmuch-folder command
  emacs: remove unnecessary notmuch-remove-if-not
  emacs: remove unused notmuch-address-locate-command
  emacs: remove unnecessary notmuch-tree-button-activate
  emacs: inline notmuch-documentation-first-line
  emacs: inline notmuch-split-content-type
  emacs: use defvar-local
  emacs: use setq-local
  emacs: use setq instead set
  emacs: do not quote self-quoting t
  emacs: avoid binding unnamed commands in keymaps
  emacs: various cosmetic improvements

 emacs/coolj.el   |   4 +-
 emacs/notmuch-address.el |  58 
 emacs/notmuch-company.el |   7 +-
 emacs/notmuch-compat.el  |   9 +-
 emacs/notmuch-crypto.el  |   7 +-
 emacs/notmuch-draft.el   |  17 ++--
 emacs/notmuch-hello.el   | 123 
 emacs/notmuch-jump.el|   5 -
 emacs/notmuch-lib.el | 108 +
 emacs/notmuch-maildir-fcc.el |  12 +--
 emacs/notmuch-mua.el |  77 +++
 emacs/notmuch-parser.el  |   5 +-
 emacs/notmuch-show.el|  57 +--
 emacs/notmuch-tag.el |  24 ++---
 emacs/notmuch-tree.el| 179 ++-
 emacs/notmuch.el | 109 +++--
 16 files changed, 346 insertions(+), 455 deletions(-)

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


[PATCH 02/27] emacs: define notmuch-message-mode-map explicitly

2020-11-08 Thread Jonas Bernoulli
Key bindings should not be defined at the top-level but inside
a `defvar' form.  Doing it at the top-level makes it harder to
reliably customize key bindings.
---
 emacs/notmuch-mua.el | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 03c7cc97..616b625c 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -324,17 +324,21 @@ (defun notmuch-mua-reply (query-string &optional sender 
reply-all)
   (message-goto-body)
   (set-buffer-modified-p nil))
 
+(defvar notmuch-message-mode-map
+  (let ((map (make-sparse-keymap)))
+(define-key map (kbd "C-c C-c") #'notmuch-mua-send-and-exit)
+(define-key map (kbd "C-c C-s") #'notmuch-mua-send)
+(define-key map (kbd "C-c C-p") #'notmuch-draft-postpone)
+(define-key map (kbd "C-x C-s") #'notmuch-draft-save)
+map)
+  "Keymap for `notmuch-message-mode'.")
+
 (define-derived-mode notmuch-message-mode message-mode "Message[Notmuch]"
   "Notmuch message composition mode. Mostly like `message-mode'."
   (notmuch-address-setup))
 
 (put 'notmuch-message-mode 'flyspell-mode-predicate 'mail-mode-flyspell-verify)
 
-(define-key notmuch-message-mode-map (kbd "C-c C-c") 
#'notmuch-mua-send-and-exit)
-(define-key notmuch-message-mode-map (kbd "C-c C-s") #'notmuch-mua-send)
-(define-key notmuch-message-mode-map (kbd "C-c C-p") #'notmuch-draft-postpone)
-(define-key notmuch-message-mode-map (kbd "C-x C-s") #'notmuch-draft-save)
-
 (defun notmuch-mua-pop-to-buffer (name switch-function)
   "Pop to buffer NAME, and warn if it already exists and is
 modified. This function is notmuch adaptation of
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 07/27] emacs: remove kludge for Emacs 23 from notmuch-mua-mail

2020-11-08 Thread Jonas Bernoulli
Notmuch requires at least Emacs version 25.

The `return-action' argument was added prior to Emacs 24.1
in 25ca2e61403f97b5a023164f2924d5f8aca2492a.
---
 emacs/notmuch-mua.el | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 1204fb6a..869ec51a 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -394,16 +394,10 @@ (defun notmuch-mua-mail (&optional to subject 
other-headers continue
  (dolist (h other-headers other-headers)
(when (stringp (car h))
  (setcar h (intern (capitalize (car h
-   (args (list yank-action send-actions))
;; Cause `message-setup-1' to do things relevant for mail,
;; such as observe `message-default-mail-headers'.
(message-this-is-mail t))
-;; message-setup-1 in Emacs 23 does not accept return-action
-;; argument. Pass it only if it is supplied by the caller. This
-;; will never be the case when we're called by `compose-mail' in
-;; Emacs 23.
-(when return-action (nconc args (list return-action)))
-(apply 'message-setup-1 headers args))
+(message-setup-1 headers yank-action send-actions return-action))
   (notmuch-fcc-header-setup)
   (message-sort-headers)
   (message-hide-headers)
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 09/27] emacs: sanitize function that displays version

2020-11-08 Thread Jonas Bernoulli
Previously it was defined in "notmuch-hello.el" and its name contained
"hello" solely because it replaced an anonymous function that was
mistakenly only bound in `notmuch-hello-mode-map'.  But it makes more
sense to bind it in all notmuch modes and even if we did not change
that aspect it still would make no sense to have "hello" in its name.
---
 emacs/notmuch-hello.el | 14 --
 emacs/notmuch-lib.el   | 16 
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index af170dd4..69d0ad64 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -652,26 +652,12 @@ (defun notmuch-hello-window-configuration-change ()
   (remove-hook 'window-configuration-change-hook
   #'notmuch-hello-window-configuration-change
 
-;; the following variable is defined as being defconst in notmuch-version.el
-(defvar notmuch-emacs-version)
-
-(defun notmuch-hello-versions ()
-  "Display the notmuch version(s)."
-  (interactive)
-  (let ((notmuch-cli-version (notmuch-cli-version)))
-(message "notmuch version %s"
-(if (string= notmuch-emacs-version notmuch-cli-version)
-notmuch-cli-version
-  (concat notmuch-cli-version
-  " (emacs mua version " notmuch-emacs-version ")")
-
 (defvar notmuch-hello-mode-map
   ;; Inherit both widget-keymap and notmuch-common-keymap.  We have
   ;; to use make-sparse-keymap to force this to be a new keymap (so
   ;; that when we modify map it does not modify widget-keymap).
   (let ((map (make-composed-keymap (list (make-sparse-keymap) widget-keymap
 (set-keymap-parent map notmuch-common-keymap)
-(define-key map "v" 'notmuch-hello-versions)
 (define-key map (kbd "") 'widget-backward)
 map)
   "Keymap for \"notmuch hello\" buffers.")
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index edb40533..8ee3f17f 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -147,6 +147,7 @@ (defcustom notmuch-archive-tags '("-inbox")
 (defvar notmuch-common-keymap
   (let ((map (make-sparse-keymap)))
 (define-key map "?" 'notmuch-help)
+(define-key map "v" 'notmuch-version)
 (define-key map "q" 'notmuch-bury-or-kill-this-buffer)
 (define-key map "s" 'notmuch-search)
 (define-key map "t" 'notmuch-search-by-tag)
@@ -218,6 +219,21 @@ (defun notmuch-cli-version ()
(match-string 2 long-string)
   "unknown")))
 
+(defvar notmuch-emacs-version)
+
+(defun notmuch-version ()
+  "Display the notmuch version.
+The versions of the Emacs package and the `notmuch' executable
+should match, but if and only if they don't, then this command
+displays both values separately."
+  (interactive)
+  (let ((cli-version (notmuch-cli-version)))
+(message "notmuch version %s"
+(if (string= notmuch-emacs-version cli-version)
+cli-version
+  (concat cli-version
+  " (emacs mua version " notmuch-emacs-version ")")
+
 (defun notmuch-config-get (item)
   "Return a value from the notmuch configuration."
   (let* ((val (notmuch-command-to-string "config" "get" item))
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 15/27] emacs: misc doc-string improvements

2020-11-08 Thread Jonas Bernoulli
---
 emacs/notmuch-address.el | 6 +++---
 emacs/notmuch-crypto.el  | 4 ++--
 emacs/notmuch-mua.el | 7 ---
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 561cc140..04353522 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -36,9 +36,9 @@ (defvar notmuch-address-completions (make-hash-table :test 
'equal)
 This variable is set by calling `notmuch-address-harvest'.")
 
 (defvar notmuch-address-full-harvest-finished nil
-  "t indicates that full completion address harvesting has been finished.
-Use notmuch-address--harvest-ready to access as that will load a
-saved hash if necessary (and available).")
+  "Whether full completion address harvesting has finished.
+Use notmuch-address--harvest-ready to access as that will load
+a saved hash if necessary (and available).")
 
 (defun notmuch-address--harvest-ready ()
   "Return t if there is a full address hash available.
diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index 4fab215a..9e6f3a9d 100644
--- a/emacs/notmuch-crypto.el
+++ b/emacs/notmuch-crypto.el
@@ -27,7 +27,7 @@ (require 'notmuch-lib)
 (declare-function notmuch-show-get-message-id "notmuch-show" (&optional bare))
 
 (defcustom notmuch-crypto-process-mime t
-  "Should cryptographic MIME parts be processed?
+  "Whether to process cryptographic MIME parts.
 
 If this variable is non-nil signatures in multipart/signed
 messages will be verified and multipart/encrypted parts will be
@@ -46,7 +46,7 @@ (defcustom notmuch-crypto-process-mime t
   :group 'notmuch-crypto)
 
 (defcustom notmuch-crypto-get-keys-asynchronously t
-  "Retrieve gpg keys asynchronously."
+  "Whether to retrieve openpgp keys asynchronously."
   :type 'boolean
   :group 'notmuch-crypto)
 
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 62d615d1..821bb324 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -82,10 +82,11 @@ (defgroup notmuch-reply nil
   :group 'notmuch)
 
 (defcustom notmuch-mua-cite-function 'message-cite-original
-  "*Function for citing an original message.
+  "Function for citing an original message.
+
 Predefined functions include `message-cite-original' and
-`message-cite-original-without-signature'.
-Note that these functions use `mail-citation-hook' if that is non-nil."
+`message-cite-original-without-signature'.  Note that these
+functions use `mail-citation-hook' if that is non-nil."
   :type '(radio (function-item message-cite-original)
(function-item message-cite-original-without-signature)
(function-item sc-cite-original)
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 08/27] emacs: more cleanup since dropping support for Emacs 24

2020-11-08 Thread Jonas Bernoulli
Notmuch requires at least version 25 of Emacs now.

Adjust comments that previously referenced version 24 specifically,
even though they also apply to later releases. Remove documentation
and code that no longer applies.

- `mm-shr' no longer references `gnus-inhibit-images'.
---
 emacs/notmuch-compat.el |  9 +
 emacs/notmuch-hello.el  | 16 +---
 emacs/notmuch-jump.el   |  5 -
 emacs/notmuch-lib.el| 12 
 emacs/notmuch-mua.el| 17 ++---
 emacs/notmuch-show.el   | 10 --
 emacs/notmuch-tree.el   |  7 ---
 7 files changed, 24 insertions(+), 52 deletions(-)

diff --git a/emacs/notmuch-compat.el b/emacs/notmuch-compat.el
index 3ede6b36..2975f4c2 100644
--- a/emacs/notmuch-compat.el
+++ b/emacs/notmuch-compat.el
@@ -21,10 +21,11 @@
 
 ;;; Code:
 
-;; emacs master has a bugfix for folding long headers when sending
-;; messages. Include the fix for earlier versions of emacs. To avoid
-;; interfering with gnus we only run the hook when called from
-;; notmuch-message-mode.
+;; Before Emacs 26.1 lines that are longer than 998 octets were not.
+;; folded. Commit 77bbca8c82f6e553c42abbfafca28f55fc995d00 fixed
+;; that. Until we drop support for Emacs 25 we have to backport that
+;; fix. To avoid interfering with Gnus we only run the hook when
+;; called from notmuch-message-mode.
 
 (declare-function mail-header-fold-field "mail-parse" nil)
 
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index b67a5e19..af170dd4 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -645,6 +645,7 @@ (defun notmuch-hello-window-configuration-change ()
   ;; Refresh hello as soon as we get back to redisplay.  On Emacs
   ;; 24, we can't do it right here because something in this
   ;; hook's call stack overrides hello's point placement.
+  ;; FIXME And on Emacs releases that we still support?
   (run-at-time nil nil #'notmuch-hello t))
 (unless hello-buf
   ;; Clean up hook
@@ -665,17 +666,10 @@ (defun notmuch-hello-versions ()
   " (emacs mua version " notmuch-emacs-version ")")
 
 (defvar notmuch-hello-mode-map
-  (let ((map (if (fboundp 'make-composed-keymap)
-;; Inherit both widget-keymap and
-;; notmuch-common-keymap. We have to use
-;; make-sparse-keymap to force this to be a new
-;; keymap (so that when we modify map it does not
-;; modify widget-keymap).
-(make-composed-keymap (list (make-sparse-keymap) 
widget-keymap))
-  ;; Before Emacs 24, keymaps didn't support multiple
-  ;; inheritance,, so just copy the widget keymap since
-  ;; it's unlikely to change.
-  (copy-keymap widget-keymap
+  ;; Inherit both widget-keymap and notmuch-common-keymap.  We have
+  ;; to use make-sparse-keymap to force this to be a new keymap (so
+  ;; that when we modify map it does not modify widget-keymap).
+  (let ((map (make-composed-keymap (list (make-sparse-keymap) widget-keymap
 (set-keymap-parent map notmuch-common-keymap)
 (define-key map "v" 'notmuch-hello-versions)
 (define-key map (kbd "") 'widget-backward)
diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
index 1e2d0497..ff622055 100644
--- a/emacs/notmuch-jump.el
+++ b/emacs/notmuch-jump.el
@@ -29,11 +29,6 @@ (eval-when-compile
 (require 'notmuch-lib)
 (require 'notmuch-hello)
 
-(eval-and-compile
-  (unless (fboundp 'window-body-width)
-;; Compatibility for Emacs pre-24
-(defalias 'window-body-width 'window-width)))
-
 ;;;###autoload
 (defun notmuch-jump-search ()
   "Jump to a saved search by shortcut key.
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 118faf1e..edb40533 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -653,18 +653,6 @@ (defun notmuch-get-bodypart-text (msg part process-crypto 
&optional cache)
 MSG (if it isn't already)."
   (notmuch--get-bodypart-raw msg part process-crypto nil cache))
 
-;; Workaround: The call to `mm-display-part' below triggers a bug in
-;; Emacs 24 if it attempts to use the shr renderer to display an HTML
-;; part with images in it (demonstrated in 24.1 and 24.2 on Debian and
-;; Fedora 17, though unreproducible in other configurations).
-;; `mm-shr' references the variable `gnus-inhibit-images' without
-;; first loading gnus-art, which defines it, resulting in a
-;; void-variable error.  Hence, we advise `mm-shr' to ensure gnus-art
-;; is loaded.
-(define-advice mm-shr (:before (_handle) notmuch--load-gnus-args)
-  "Require `gnus-art' since we use its variables."
-  (require 'gnus-art nil t))
-
 (defun notmuch-mm-display-part-inline (msg part content-type process-crypto)
   "Use the mm-decode/mm-view functions to display a part in the
 current buffer, if possible."
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 869ec51a..49bad00d 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/n

[PATCH 19/27] emacs: remove unnecessary notmuch-tree-button-activate

2020-11-08 Thread Jonas Bernoulli
Since [1: f8bdba37] no key is bound to this command and it is
redundant because the behavior of `push-command' is identical
when called as a command.

1: f8bdba37d3f4c877e05e17b5b1c7d2d512106538
   emacs: tree: remove binding for pressing button in message pane
---
 emacs/notmuch-tree.el | 8 
 1 file changed, 8 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 28c9372e..71b6387a 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -267,14 +267,6 @@ (defun notmuch-tree-inherit-from-message-pane (sym)
(symbol-value sym))
 (symbol-value sym)))
 
-(defun notmuch-tree-button-activate (&optional button)
-  "Activate BUTTON or button at point.
-
-This function does not give an error if there is no button."
-  (interactive)
-  (let ((button (or button (button-at (point)
-(when button (button-activate button
-
 (defun notmuch-tree-close-message-pane-and (func)
   "Close message pane and execute FUNC.
 
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 20/27] emacs: inline notmuch-documentation-first-line

2020-11-08 Thread Jonas Bernoulli
Inline a simplified version of `notmuch-documentation-first-line'
into its only caller.  The new code snippet differs from the
removed function in that it returns nil instead of the empty string
for symbols that have no function documentation.  That value is
ultimately used as an argument to `concat', which treats nil like
the empty string.  So we can do the logical thing without changing
the behavior.
---
 emacs/notmuch-lib.el | 17 -
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index d7c6b737..61107e38 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -287,18 +287,6 @@ (defun notmuch-bury-or-kill-this-buffer ()
   (bury-buffer)
 (kill-buffer)))
 
-(defun notmuch-documentation-first-line (symbol)
-  "Return the first line of the documentation string for SYMBOL."
-  (let ((doc (documentation symbol)))
-(if doc
-   (with-temp-buffer
- (insert (documentation symbol t))
- (goto-char (point-min))
- (let ((beg (point)))
-   (end-of-line)
-   (buffer-substring beg (point
-  "")))
-
 (defun notmuch-prefix-key-description (key)
   "Given a prefix key code, return a human-readable string representation.
 
@@ -331,7 +319,10 @@ (defun notmuch-describe-key (actual-key binding prefix 
ua-keys tail)
  (or (and (symbolp binding)
   (get binding 'notmuch-doc))
  (and (functionp binding)
-  (notmuch-documentation-first-line binding
+  (let ((doc (documentation binding)))
+(and doc
+ (string-match "\\`.+" doc)
+ (match-string 0 doc))
tail)))
   tail)
 
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 16/27] emacs: remove deprecated notmuch-folder command

2020-11-08 Thread Jonas Bernoulli
It has been deprecated for a decade and it's time to let go.
---
 emacs/notmuch-hello.el | 5 -
 1 file changed, 5 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index bc07c29c..f5d9e0ec 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -987,11 +987,6 @@ (defun notmuch-hello (&optional no-display)
   (run-hooks 'notmuch-hello-refresh-hook)
   (setq notmuch-hello-first-run nil))
 
-(defun notmuch-folder ()
-  "Deprecated function for invoking notmuch---calling `notmuch' is preferred 
now."
-  (interactive)
-  (notmuch-hello))
-
 ;;
 
 (provide 'notmuch-hello)
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 04/27] emacs: don't fset keymaps

2020-11-08 Thread Jonas Bernoulli
These keymaps are never invoked as commands
so the function definitions serve no purpose.
---
 emacs/notmuch-show.el | 1 -
 emacs/notmuch-tree.el | 1 -
 emacs/notmuch.el  | 1 -
 3 files changed, 3 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index b08ceb97..ec22fd94 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1485,7 +1485,6 @@ (defvar notmuch-show-mode-map
 (define-key map "B" 'notmuch-show-browse-urls)
 map)
   "Keymap for \"notmuch show\" buffers.")
-(fset 'notmuch-show-mode-map notmuch-show-mode-map)
 
 (define-derived-mode notmuch-show-mode fundamental-mode "notmuch-show"
   "Major mode for viewing a thread with notmuch.
diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index ea6a5cf3..ad08f7c6 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -361,7 +361,6 @@ (defvar notmuch-tree-mode-map
 (define-key map "e" 'notmuch-tree-resume-message)
 map)
   "Keymap for \"notmuch tree\" buffers.")
-(fset 'notmuch-tree-mode-map notmuch-tree-mode-map)
 
 (defun notmuch-tree-get-message-properties ()
   "Return the properties of the current message as a plist.
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 83bcee57..165aaa43 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -194,7 +194,6 @@ (defvar notmuch-search-mode-map
 (define-key map "U" 'notmuch-unthreaded-from-search-current-query)
 map)
   "Keymap for \"notmuch search\" buffers.")
-(fset 'notmuch-search-mode-map notmuch-search-mode-map)
 
 (defvar notmuch-search-stash-map
   (let ((map (make-sparse-keymap)))
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 13/27] emacs: place complete first sentence on first doc-string line

2020-11-08 Thread Jonas Bernoulli
---
 emacs/notmuch-crypto.el |  3 +--
 emacs/notmuch-hello.el  |  3 +--
 emacs/notmuch-mua.el| 11 ---
 3 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index 276c9859..4fab215a 100644
--- a/emacs/notmuch-crypto.el
+++ b/emacs/notmuch-crypto.el
@@ -103,8 +103,7 @@ (define-button-type 'notmuch-crypto-status-button-type
   :supertype 'notmuch-button-type)
 
 (defun notmuch-crypto-insert-sigstatus-button (sigstatus from)
-  "Insert a button describing the signature status SIGSTATUS sent
-by user FROM."
+  "Insert a button describing the signature status SIGSTATUS sent by user 
FROM."
   (let* ((status (plist-get sigstatus :status))
 (show-button t)
 (face 'notmuch-crypto-signature-unknown)
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 003bec33..28784345 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -372,8 +372,7 @@ (defvar notmuch-hello-hidden-sections nil
   "List of sections titles whose contents are hidden.")
 
 (defvar notmuch-hello-first-run t
-  "True if `notmuch-hello' is run for the first time, set to nil
-afterwards.")
+  "True if `notmuch-hello' is run for the first time, set to nil afterwards.")
 
 (defun notmuch-hello-nice-number (n)
   (let (result)
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 9d08c2c9..62d615d1 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -73,8 +73,7 @@ (defcustom notmuch-mua-user-agent-function nil
   :group 'notmuch-send)
 
 (defcustom notmuch-mua-hidden-headers nil
-  "Headers that are added to the `message-mode' hidden headers
-list."
+  "Headers that are added to the `message-mode' hidden headers list."
   :type '(repeat string)
   :group 'notmuch-send)
 
@@ -167,8 +166,7 @@ (defun notmuch-mua-get-switch-function ()
(t (error "Invalid value for `notmuch-mua-compose-in'"
 
 (defun notmuch-mua-maybe-set-window-dedicated ()
-  "Set the selected window as dedicated according to
-`notmuch-mua-compose-in'."
+  "Set the selected window as dedicated according to `notmuch-mua-compose-in'."
   (when (or (eq notmuch-mua-compose-in 'new-frame)
(eq notmuch-mua-compose-in 'new-window))
 (set-window-dedicated-p (selected-window) t)))
@@ -335,9 +333,8 @@ (define-derived-mode notmuch-message-mode message-mode 
"Message[Notmuch]"
 (put 'notmuch-message-mode 'flyspell-mode-predicate 'mail-mode-flyspell-verify)
 
 (defun notmuch-mua-pop-to-buffer (name switch-function)
-  "Pop to buffer NAME, and warn if it already exists and is
-modified. This function is notmuch adaptation of
-`message-pop-to-buffer'."
+  "Pop to buffer NAME, and warn if it already exists and is modified.
+This function is notmuch adaptation of `message-pop-to-buffer'."
   (let ((buffer (get-buffer name)))
 (if (and buffer
 (buffer-name buffer))
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 11/27] emacs: shorten/replace first sentence of a few doc-strings

2020-11-08 Thread Jonas Bernoulli
The first sentence should fit on the first line.  It is okay if
the first sentence/line does not contain all the information that
the rest of the doc-string covers.
---
 emacs/notmuch-show.el | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 6a757687..14250d34 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -2347,7 +2347,9 @@ (defun notmuch-show-stash-mlarchive-link-and-go 
(&optional mla)
   (browse-url (current-kill 0 t)))
 
 (defun notmuch-show-stash-git-helper (addresses prefix)
-  "Escape, trim, quote, and add PREFIX to each address in list of ADDRESSES, 
and return the result as a single string."
+  "Normalize all ADDRESSES while adding PREFIX.
+Escape, trim, quote and add PREFIX to each address in list
+of ADDRESSES, and return the result as a single string."
   (mapconcat (lambda (x)
   (concat prefix "\""
   ;; escape double-quotes
@@ -2360,10 +2362,12 @@ (defun notmuch-show-stash-git-helper (addresses prefix)
 addresses " "))
 
 (put 'notmuch-show-stash-git-send-email 'notmuch-prefix-doc
- "Copy From/To/Cc of current message to kill-ring in a form suitable for 
pasting to git send-email command line.")
+ "Copy From/To/Cc of current message to kill-ring.
+Use a form suitable for pasting to git send-email command line.")
 
 (defun notmuch-show-stash-git-send-email (&optional no-in-reply-to)
-  "Copy From/To/Cc/Message-Id of current message to kill-ring in a form 
suitable for pasting to git send-email command line.
+  "Copy From/To/Cc/Message-Id of current message to kill-ring.
+Use a form suitable for pasting to git send-email command line.
 
 If invoked with a prefix argument (or NO-IN-REPLY-TO is non-nil),
 omit --in-reply-to=."
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 03/27] emacs: add doc-string to notmuch-tree-mode-map

2020-11-08 Thread Jonas Bernoulli
---
 emacs/notmuch-tree.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 7b1e34ca..ea6a5cf3 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -359,7 +359,8 @@ (defvar notmuch-tree-mode-map
 (define-key map " " 'notmuch-tree-scroll-or-next)
 (define-key map (kbd "DEL") 'notmuch-tree-scroll-message-window-back)
 (define-key map "e" 'notmuch-tree-resume-message)
-map))
+map)
+  "Keymap for \"notmuch tree\" buffers.")
 (fset 'notmuch-tree-mode-map notmuch-tree-mode-map)
 
 (defun notmuch-tree-get-message-properties ()
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 05/27] emacs: remove redundant notmuch-hello-trim

2020-11-08 Thread Jonas Bernoulli
Use `string-trim', which exists since Emacs 24.4.
---
 emacs/notmuch-hello.el | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index bb60a890..b67a5e19 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -387,15 +387,9 @@ (defun notmuch-hello-nice-number (n)
 (format "%s%03d" notmuch-hello-thousands-separator elem))
   (cdr result)
 
-(defun notmuch-hello-trim (search)
-  "Trim whitespace."
-  (if (string-match "^[[:space:]]*\\(.*[^[:space:]]\\)[[:space:]]*$" search)
-  (match-string 1 search)
-search))
-
 (defun notmuch-hello-search (&optional search)
   (unless (null search)
-(setq search (notmuch-hello-trim 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))
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 23/27] emacs: use setq-local

2020-11-08 Thread Jonas Bernoulli
It is available since Emacs 24.3 and we require at least Emacs 25.
It makes the variable buffer-local if it isn't always buffer-local
anyway.
---
 emacs/notmuch-company.el | 3 +--
 emacs/notmuch-parser.el  | 5 ++---
 emacs/notmuch.el | 2 +-
 3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-company.el b/emacs/notmuch-company.el
index 9e743029..b50e73c8 100644
--- a/emacs/notmuch-company.el
+++ b/emacs/notmuch-company.el
@@ -55,8 +55,7 @@ (defvar notmuch-address-command)
 ;;;###autoload
 (defun notmuch-company-setup ()
   (company-mode)
-  (make-local-variable 'company-backends)
-  (setq company-backends '(notmuch-company))
+  (setq-local company-backends '(notmuch-company))
   ;; Disable automatic company completion unless an internal
   ;; completion method is configured. Company completion (using
   ;; internal completion) can still be accessed via standard company
diff --git a/emacs/notmuch-parser.el b/emacs/notmuch-parser.el
index 3aa5bd8f..4a437016 100644
--- a/emacs/notmuch-parser.el
+++ b/emacs/notmuch-parser.el
@@ -168,9 +168,8 @@ (defun notmuch-sexp-parse-partial-list (result-function 
result-buffer)
 move point in the input buffer."
   ;; Set up the initial state
   (unless (local-variable-p 'notmuch-sexp--parser)
-(set (make-local-variable 'notmuch-sexp--parser)
-(notmuch-sexp-create-parser))
-(set (make-local-variable 'notmuch-sexp--state) 'begin))
+(setq-local notmuch-sexp--parser (notmuch-sexp-create-parser))
+(setq-local notmuch-sexp--state 'begin))
   (let (done)
 (while (not done)
   (cl-case notmuch-sexp--state
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 3ca27b26..95770fc3 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -391,7 +391,7 @@ (define-derived-mode notmuch-search-mode fundamental-mode 
"notmuch-search"
   (make-local-variable 'notmuch-search-target-thread)
   (make-local-variable 'notmuch-search-target-line)
   (setq notmuch-buffer-refresh-function #'notmuch-search-refresh-view)
-  (set (make-local-variable 'scroll-preserve-screen-position) t)
+  (setq-local scroll-preserve-screen-position t)
   (add-to-invisibility-spec (cons 'ellipsis t))
   (setq truncate-lines t)
   (setq buffer-read-only t)
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 21/27] emacs: inline notmuch-split-content-type

2020-11-08 Thread Jonas Bernoulli
This trivial helper function actually made things slightly
*less* readable by adding an unnecessary indirection.
---
 emacs/notmuch-lib.el  |  8 ++--
 emacs/notmuch-show.el | 16 
 2 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 61107e38..2c8de328 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -534,14 +534,10 @@ (defun notmuch-plist-delete (plist property)
   (setq pred (cddr pred)))
 (cdr xplist)))
 
-(defun notmuch-split-content-type (content-type)
-  "Split content/type into 'content' and 'type'."
-  (split-string content-type "/"))
-
 (defun notmuch-match-content-type (t1 t2)
   "Return t if t1 and t2 are matching content types, taking wildcards into 
account."
-  (let ((st1 (notmuch-split-content-type t1))
-   (st2 (notmuch-split-content-type t2)))
+  (let ((st1 (split-string t1 "/"))
+   (st2 (split-string t2 "/")))
 (if (or (string= (cadr st1) "*")
(string= (cadr st2) "*"))
;; Comparison of content types should be case insensitive.
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 14250d34..09cdeaaa 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -573,12 +573,13 @@ (defun notmuch-show--register-cids (msg part)
   ;; alternative (even if we can't render it).
   (push (list content-id msg part) notmuch-show--cids)))
   ;; Recurse on sub-parts
-  (let ((ctype (notmuch-split-content-type
-   (downcase (plist-get part :content-type)
-(cond ((equal (car ctype) "multipart")
+  (pcase-let ((`(,content ,type)
+  (split-string (downcase (plist-get part :content-type)) "/")))
+(cond ((equal content "multipart")
   (mapc (apply-partially #'notmuch-show--register-cids msg)
 (plist-get part :content)))
- ((equal ctype '("message" "rfc822"))
+ ((and (equal content "message")
+   (equal type "rfc822"))
   (notmuch-show--register-cids
msg
(car (plist-get (car (plist-get part :content)) :body)))
@@ -851,10 +852,9 @@ (defun notmuch-show-handlers-for (content-type)
  (push func result)))
  ;; Reverse order of prefrence.
  (list (intern (concat "notmuch-show-insert-part-*/*"))
-   (intern (concat
-"notmuch-show-insert-part-"
-(car (notmuch-split-content-type content-type))
-"/*"))
+   (intern (concat "notmuch-show-insert-part-"
+   (car (split-string content-type "/"))
+   "/*"))
(intern (concat "notmuch-show-insert-part-" content-type
 result))
 
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 24/27] emacs: use setq instead set

2020-11-08 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 3b5dab3e..7cc28b62 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -1115,7 +1115,7 @@ (defun notmuch-tree (&optional 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 (&optional 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 18/27] emacs: remove unused notmuch-address-locate-command

2020-11-08 Thread Jonas Bernoulli
We stopped using it in [1: 0e671478].

1: 0e671478c6f37018973392f049979da5e1a8ff99
   emacs: replace use of notmuch-address-message-insinuate
---
 emacs/notmuch-address.el | 19 ---
 1 file changed, 19 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 04353522..21d1d82f 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -250,25 +250,6 @@ (defun notmuch-address-expand-name ()
(ding
(t nil)))
 
-;; Copied from `w3m-which-command'.
-(defun notmuch-address-locate-command (command)
-  "Return non-nil if `command' is an executable either on
-`exec-path' or an absolute pathname."
-  (and (stringp command)
-   (if (and (file-name-absolute-p command)
-   (file-executable-p command))
-  command
-(setq command (file-name-nondirectory command))
-(catch 'found-command
-  (let (bin)
-(dolist (dir exec-path)
-  (setq bin (expand-file-name command dir))
-  (when (or (and (file-executable-p bin)
- (not (file-directory-p bin)))
-(and (file-executable-p (setq bin (concat bin ".exe")))
- (not (file-directory-p bin
-(throw 'found-command bin
-
 (defun notmuch-address-harvest-addr (result)
   (let ((name-addr (plist-get result :name-addr)))
 (puthash name-addr t notmuch-address-completions)))
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 14/27] emacs: always use elisp quoting style in doc-strings

2020-11-08 Thread Jonas Bernoulli
Emacs doc-strings use neither markdown nor lisp symbol quoting.
---
 emacs/notmuch-address.el |  2 +-
 emacs/notmuch-draft.el   |  8 
 emacs/notmuch-hello.el   |  4 ++--
 emacs/notmuch-maildir-fcc.el |  2 +-
 emacs/notmuch-tag.el | 20 ++--
 emacs/notmuch.el |  4 ++--
 6 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 8a6d299c..561cc140 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -294,7 +294,7 @@ (defun notmuch-address-harvest (&optional addr-prefix 
synchronous callback)
   "Collect addresses completion candidates.
 
 It queries the notmuch database for messages sent/received (as
-configured with `notmuch-address-command`) by the user, collects
+configured with `notmuch-address-command') by the user, collects
 destination/source addresses from those messages and stores them
 in `notmuch-address-completions'.
 
diff --git a/emacs/notmuch-draft.el b/emacs/notmuch-draft.el
index 283830ad..b13eb51c 100644
--- a/emacs/notmuch-draft.el
+++ b/emacs/notmuch-draft.el
@@ -101,7 +101,7 @@ (defun notmuch-draft--mark-deleted ()
 (notmuch-tag notmuch-draft-id '("+deleted"
 
 (defun notmuch-draft-quote-some-mml ()
-  "Quote the mml tags in `notmuch-draft-quoted-tags`."
+  "Quote the mml tags in `notmuch-draft-quoted-tags'."
   (save-excursion
 ;; First we deal with any secure tag separately.
 (message-goto-body)
@@ -122,7 +122,7 @@ (defun notmuch-draft-quote-some-mml ()
  (insert "!"))
 
 (defun notmuch-draft-unquote-some-mml ()
-  "Unquote the mml tags in `notmuch-draft-quoted-tags`."
+  "Unquote the mml tags in `notmuch-draft-quoted-tags'."
   (save-excursion
 (when notmuch-draft-quoted-tags
   (let ((re (concat "<#!+/?\\("
@@ -174,7 +174,7 @@ (defun notmuch-draft-save ()
   "Save the current draft message in the notmuch database.
 
 This saves the current message in the database with tags
-`notmuch-draft-tags` (in addition to any default tags
+`notmuch-draft-tags' (in addition to any default tags
 applied to newly inserted messages)."
   (interactive)
   (when (notmuch-draft--has-encryption-tag)
@@ -185,7 +185,7 @@ (defun notmuch-draft-save ()
  ;; so that it is easier to search for the message, and the
  ;; latter so we have a way of accessing the saved message (for
  ;; example to delete it at a later time). We check that the
- ;; user has these in `message-deletable-headers` (the default)
+ ;; user has these in `message-deletable-headers' (the default)
  ;; as otherwise they are doing something strange and we
  ;; shouldn't interfere. Note, since we are doing this in a new
  ;; buffer we don't change the version in the compose buffer.
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 28784345..bc07c29c 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -138,8 +138,8 @@ (defcustom notmuch-saved-searches
shown. If not present then the :query property
is used.
   :sort-order  Specify the sort order to be used for the search.
-   Possible values are 'oldest-first 'newest-first or
-   nil. Nil means use the default sort order.
+   Possible values are `oldest-first', `newest-first'
+   or nil. Nil means use the default sort order.
   :search-type Specify whether to run the search in search-mode,
tree mode or unthreaded mode. Set to 'tree to specify tree
mode, 'unthreaded to specify unthreaded mode, and set to nil
diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el
index a9103a20..b1da93e6 100644
--- a/emacs/notmuch-maildir-fcc.el
+++ b/emacs/notmuch-maildir-fcc.el
@@ -196,7 +196,7 @@ (defun notmuch-maildir-message-do-fcc ()
 (defun notmuch-fcc-handler (fcc-header)
   "Store message with notmuch insert or normal (file) fcc.
 
-If `notmuch-maildir-use-notmuch-insert` is set then store the
+If `notmuch-maildir-use-notmuch-insert' is set then store the
 message using notmuch insert. Otherwise store the message using
 normal fcc."
   (message "Doing Fcc...")
diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
index 5d4a6865..dc9a2186 100644
--- a/emacs/notmuch-tag.el
+++ b/emacs/notmuch-tag.el
@@ -68,15 +68,15 @@ (defcustom notmuch-tagging-keys
 be used (either as a key, or as the start of a key sequence) as
 it is already bound: it switches the menu to a menu of the
 reverse tagging operations. The reverse of a tagging operation is
-the same list of individual tag-ops but with `+tag` replaced by
-`-tag` and vice versa.
+the same list of individual tag-ops but with `+tag' replaced by
+`-tag' and vice versa.
 
 If setting this variable outside of customize then it should be a
 list of triples (lists of three elements). Each triple should be
 of the form (key-binding tagging-operations name). KEY-BI

[PATCH 10/27] emacs: define notmuch-hello-url as a constant

2020-11-08 Thread Jonas Bernoulli
---
 emacs/notmuch-hello.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 69d0ad64..003bec33 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -282,7 +282,7 @@ (defcustom notmuch-hello-refresh-hook nil
   :group 'notmuch-hello
   :group 'notmuch-hooks)
 
-(defvar notmuch-hello-url "https://notmuchmail.org";
+(defconst notmuch-hello-url "https://notmuchmail.org";
   "The `notmuch' web site.")
 
 (defvar notmuch-hello-custom-section-options
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 17/27] emacs: remove unnecessary notmuch-remove-if-not

2020-11-08 Thread Jonas Bernoulli
We could just have switched to using `cl-remove-if-not' instead,
but the two uses of the *remove-if-not function are pretty strange
to begin with so we refactor to not use any such function at all.
---
 emacs/notmuch-hello.el | 43 --
 emacs/notmuch-lib.el   |  9 -
 2 files changed, 20 insertions(+), 32 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index f5d9e0ec..fa31694f 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -21,8 +21,7 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl-lib))
-
+(require 'cl-lib)
 (require 'widget)
 (require 'wid-edit) ; For `widget-forward'.
 
@@ -542,21 +541,19 @@ (defun notmuch-hello-query-counts (query-list &rest 
options)
 --batch'. In general we recommend running matching versions of
 the CLI and emacs interface."))
 (goto-char (point-min))
-(notmuch-remove-if-not
- #'identity
- (mapcar
-  (lambda (elem)
-   (let* ((elem-plist (notmuch-hello-saved-search-to-plist elem))
-  (search-query (plist-get elem-plist :query))
-  (filtered-query (notmuch-hello-filtered-query
-   search-query (plist-get options :filter)))
-  (message-count (prog1 (read (current-buffer))
-   (forward-line 1
- (when (and filtered-query (or (plist-get options :show-empty-searches)
-   (> message-count 0)))
-   (setq elem-plist (plist-put elem-plist :query filtered-query))
-   (plist-put elem-plist :count message-count
-  query-list
+(cl-mapcan
+ (lambda (elem)
+   (let* ((elem-plist (notmuch-hello-saved-search-to-plist elem))
+ (search-query (plist-get elem-plist :query))
+ (filtered-query (notmuch-hello-filtered-query
+  search-query (plist-get options :filter)))
+ (message-count (prog1 (read (current-buffer))
+  (forward-line 1
+(when (and filtered-query (or (plist-get options :show-empty-searches)
+  (> message-count 0)))
+  (setq elem-plist (plist-put elem-plist :query filtered-query))
+  (list (plist-put elem-plist :count message-count)
+ query-list)))
 
 (defun notmuch-hello-insert-buttons (searches)
   "Insert buttons for SEARCHES.
@@ -698,12 +695,12 @@ (define-derived-mode notmuch-hello-mode fundamental-mode 
"notmuch-hello"
 
 (defun notmuch-hello-generate-tag-alist (&optional hide-tags)
   "Return an alist from tags to queries to display in the all-tags section."
-  (mapcar (lambda (tag)
-   (cons tag (concat "tag:" (notmuch-escape-boolean-term tag
- (notmuch-remove-if-not
-  (lambda (tag)
-(not (member tag hide-tags)))
-  (process-lines notmuch-command "search" "--output=tags" "*"
+  (cl-mapcan (lambda (tag)
+  (and (not (member tag hide-tags))
+   (list (cons tag
+   (concat "tag:"
+   (notmuch-escape-boolean-term tag))
+(process-lines notmuch-command "search" "--output=tags" "*")))
 
 (defun notmuch-hello-insert-header ()
   "Insert the default notmuch-hello header."
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 8ee3f17f..d7c6b737 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -534,15 +534,6 @@ (defun notmuch-common-do-stash (text)
 
 ;;
 
-(defun notmuch-remove-if-not (predicate list)
-  "Return a copy of LIST with all items not satisfying PREDICATE removed."
-  (let (out)
-(while list
-  (when (funcall predicate (car list))
-   (push (car list) out))
-  (setq list (cdr list)))
-(nreverse out)))
-
 (defun notmuch-plist-delete (plist property)
   (let* ((xplist (cons nil plist))
 (pred xplist))
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 26/27] emacs: avoid binding unnamed commands in keymaps

2020-11-08 Thread Jonas Bernoulli
One should never bind unnamed commands in keymaps because doing that
makes it needlessly hard for users to change these bindings.

Replace such anonymous bindings with named commands that are generated
using macros and some boilerplate. Using macros is better than using a
simple loop because that makes it possible for `find-function' to find
the definitions. Eat your boilerplate--it forms character.

Admittedly this approach is quite ugly and it might be better to teach
the original commands to support different buffers directly instead of
requiring wrapper commands to do just that.

Never-the-less as a short-term solution this is better than what we
had before.
---
 emacs/notmuch-tree.el | 126 --
 1 file changed, 72 insertions(+), 54 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 7cc28b62..17863f6a 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -238,57 +238,83 @@ (defvar-local notmuch-tree-message-buffer nil
 if the user has loaded a different buffer in that window.")
 (put 'notmuch-tree-message-buffer 'permanent-local t)
 
-(defun notmuch-tree-to-message-pane (func)
-  "Execute FUNC in message pane.
-
-This function returns a function (so can be used as a keybinding)
-which executes function FUNC in the message pane if it is
-open (if the message pane is closed it does nothing)."
-  `(lambda ()
- ,(concat "(In message pane) " (documentation func t))
+(defmacro notmuch-tree--define-do-in-message-window (name cmd)
+  "Define NAME as a command that calls CMD interactively in the message window.
+If the message pane is closed then this command does nothing.
+Avoid using this macro in new code; it will be removed."
+  `(defun ,name ()
+ ,(concat "(In message window) " (documentation cmd t))
  (interactive)
  (when (window-live-p notmuch-tree-message-window)
(with-selected-window notmuch-tree-message-window
-(call-interactively #',func)
-
-(defun notmuch-tree-inherit-from-message-pane (sym)
-  "Return value of SYM in message-pane if open, or tree-pane if not."
+(call-interactively #',cmd)
+
+(notmuch-tree--define-do-in-message-window
+ notmuch-tree-previous-message-button
+ notmuch-show-previous-button)
+(notmuch-tree--define-do-in-message-window
+ notmuch-tree-next-message-button
+ notmuch-show-next-button)
+(notmuch-tree--define-do-in-message-window
+ notmuch-tree-toggle-message-process-crypto
+ notmuch-show-toggle-process-crypto)
+
+(defun notmuch-tree--message-process-crypto ()
+  "Return value of `notmuch-show-process-crypto' in the message window.
+If that window isn't alive, then return the current value.
+Avoid using this function in new code; it will be removed."
   (if (window-live-p notmuch-tree-message-window)
   (with-selected-window notmuch-tree-message-window
-   (symbol-value sym))
-(symbol-value sym)))
-
-(defun notmuch-tree-close-message-pane-and (func)
-  "Close message pane and execute FUNC.
-
-This function returns a function (so can be used as a keybinding)
-which closes the message pane if open and then executes function
-FUNC."
-  `(lambda ()
- ,(concat "(Close message pane and) " (documentation func t))
+   notmuch-show-process-crypto)
+notmuch-show-process-crypto))
+
+(defmacro notmuch-tree--define-close-message-window-and (name cmd)
+  "Define NAME as a variant of CMD.
+
+NAME determines the value of `notmuch-show-process-crypto' in the
+message window, closes the window, and then call CMD interactively
+with that value let-bound.  If the message window does not exist,
+then NAME behaves like CMD."
+  `(defun ,name ()
+ ,(concat "(Close message pane and) " (documentation cmd t))
  (interactive)
  (let ((notmuch-show-process-crypto
-   (notmuch-tree-inherit-from-message-pane 
'notmuch-show-process-crypto)))
+   (notmuch-tree--message-process-crypto)))
(notmuch-tree-close-message-window)
-   (call-interactively #',func
+   (call-interactively #',cmd
+
+(notmuch-tree--define-close-message-window-and
+ notmuch-tree-help
+ notmuch-help)
+(notmuch-tree--define-close-message-window-and
+ notmuch-tree-new-mail
+ notmuch-mua-new-mail)
+(notmuch-tree--define-close-message-window-and
+ notmuch-tree-jump-search
+ notmuch-jump-search)
+(notmuch-tree--define-close-message-window-and
+ notmuch-tree-forward-message
+ notmuch-show-forward-message)
+(notmuch-tree--define-close-message-window-and
+ notmuch-tree-reply-sender
+ notmuch-show-reply-sender)
+(notmuch-tree--define-close-message-window-and
+ notmuch-tree-reply
+ notmuch-show-reply)
+(notmuch-tree--define-close-message-window-and
+ notmuch-tree-view-raw-message
+ notmuch-show-view-raw-message)
 
 (defvar notmuch-tree-mode-map
   (let ((map (make-sparse-keymap)))
 (set-keymap-parent map notmuch-common-keymap)
-;; The following override the global keymap.
-;; Override because we want to close message pane first.
-(defi

[PATCH 25/27] emacs: do not quote self-quoting t

2020-11-08 Thread Jonas Bernoulli
---
 emacs/notmuch-draft.el   |  6 +++---
 emacs/notmuch-maildir-fcc.el | 10 +-
 emacs/notmuch-mua.el |  6 +++---
 emacs/notmuch-show.el|  2 +-
 emacs/notmuch-tag.el |  2 +-
 5 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/emacs/notmuch-draft.el b/emacs/notmuch-draft.el
index ca720384..f928be87 100644
--- a/emacs/notmuch-draft.el
+++ b/emacs/notmuch-draft.el
@@ -135,7 +135,7 @@ (defun notmuch-draft-unquote-some-mml ()
 (let (secure-tag)
   (save-restriction
(message-narrow-to-headers)
-   (setq secure-tag (message-fetch-field "X-Notmuch-Emacs-Secure" 't))
+   (setq secure-tag (message-fetch-field "X-Notmuch-Emacs-Secure" t))
(message-remove-header "X-Notmuch-Emacs-Secure"))
   (message-goto-body)
   (when secure-tag
@@ -145,7 +145,7 @@ (defun notmuch-draft--has-encryption-tag ()
   "Returns t if there is an mml secure tag."
   (save-excursion
 (message-goto-body)
-(re-search-forward notmuch-draft-encryption-tag-regex nil 't)))
+(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.
@@ -207,7 +207,7 @@ (defun notmuch-draft-save ()
  (notmuch-draft-quote-some-mml)
  (notmuch-maildir-setup-message-for-saving)
  (notmuch-maildir-notmuch-insert-current-buffer
-  notmuch-draft-folder 't notmuch-draft-tags))
+  notmuch-draft-folder t notmuch-draft-tags))
 ;; We are now back in the original compose buffer. Note the
 ;; function notmuch-call-notmuch-process (called by
 ;; notmuch-maildir-notmuch-insert-current-buffer) signals an error
diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el
index b1da93e6..32b8100e 100644
--- a/emacs/notmuch-maildir-fcc.el
+++ b/emacs/notmuch-maildir-fcc.el
@@ -76,7 +76,7 @@ (defcustom notmuch-fcc-dirs "sent"
   :require 'notmuch-fcc-initialization
   :group 'notmuch-send)
 
-(defcustom notmuch-maildir-use-notmuch-insert 't
+(defcustom notmuch-maildir-use-notmuch-insert t
   "Should fcc use notmuch insert instead of simple fcc."
   :type '(choice :tag "Fcc Method"
 (const :tag "Use notmuch insert" t)
@@ -246,8 +246,8 @@ (defun notmuch-maildir-fcc-with-notmuch-insert (fcc-header 
&optional create)
 \(r)etry, (c)reate folder, (i)gnore, or (e)dit the header? " '(?r ?c ?i ?e
 (cl-case response
   (?r (notmuch-maildir-fcc-with-notmuch-insert fcc-header))
-  (?c (notmuch-maildir-fcc-with-notmuch-insert fcc-header 't))
-  (?i 't)
+  (?c (notmuch-maildir-fcc-with-notmuch-insert fcc-header t))
+  (?i t)
   (?e (notmuch-maildir-fcc-with-notmuch-insert
(read-from-minibuffer "Fcc header: " fcc-header)
 
@@ -322,7 +322,7 @@ (defun notmuch-maildir-fcc-file-fcc (fcc-header)
 It offers the user a chance to correct the header, or filesystem,
 if needed."
   (if (notmuch-maildir-fcc-dir-is-maildir-p fcc-header)
-  (notmuch-maildir-fcc-write-buffer-to-maildir fcc-header 't)
+  (notmuch-maildir-fcc-write-buffer-to-maildir fcc-header t)
 ;; The fcc-header is not a valid maildir see if the user wants to
 ;; fix it in some way.
 (let* ((prompt (format "Fcc %s is not a maildir: \
@@ -335,7 +335,7 @@ (defun notmuch-maildir-fcc-file-fcc (fcc-header)
  (message "No permission to create %s." fcc-header)
  (sit-for 2))
(notmuch-maildir-fcc-file-fcc fcc-header))
-   (?i 't)
+   (?i t)
(?e (notmuch-maildir-fcc-file-fcc
 (read-from-minibuffer "Fcc header: " fcc-header)))
 
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 821bb324..f9843546 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -538,11 +538,11 @@ (defun notmuch-mua-check-no-misplaced-secure-tag ()
   (goto-char (point-max))
   (or
;; We are always fine if there is no secure tag.
-   (not (search-backward "<#secure" nil 't))
+   (not (search-backward "<#secure" nil t))
;; There is a secure tag, so it must be at the start of the
;; body, with no secure tag earlier (i.e., in the headers).
(and (= (point) body-start)
-   (not (search-backward "<#secure" nil 't)))
+   (not (search-backward "<#secure" nil t)))
;; The user confirms they means it.
(yes-or-no-p "\
 There is a <#secure> tag not at the start of the body. It is
@@ -582,7 +582,7 @@ (defun notmuch-mua-send-common (arg &optional exit)
 
 (defun notmuch-mua-send-and-exit (&optional arg)
   (interactive "P")
-  (notmuch-mua-send-common arg 't))
+  (notmuch-mua-send-common arg t))
 
 (defun notmuch-mua-send (&optional arg)
   (interactive "P")
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index c9b1e966..056c4e30 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1751,7 +1751,7 @@ (defun notmuch-show-command-hook ()
  

[PATCH 27/27] emacs: various cosmetic improvements

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

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

[PATCH 22/27] emacs: use defvar-local

2020-11-08 Thread Jonas Bernoulli
It is available since Emacs 24.3 and we require at least Emacs 25.
---
 emacs/coolj.el   |  4 +---
 emacs/notmuch-company.el |  4 ++--
 emacs/notmuch-draft.el   |  3 +--
 emacs/notmuch-lib.el |  8 ++--
 emacs/notmuch-show.el| 18 ++
 emacs/notmuch-tree.el| 27 +--
 6 files changed, 21 insertions(+), 43 deletions(-)

diff --git a/emacs/coolj.el b/emacs/coolj.el
index 39a8de2b..0385872f 100644
--- a/emacs/coolj.el
+++ b/emacs/coolj.el
@@ -50,9 +50,7 @@ (defcustom coolj-line-prefix-regexp "^\\(>+ \\)*"
   :group 'coolj
   :type 'regexp)
 
-(defvar coolj-wrap-point nil)
-
-(make-variable-buffer-local 'coolj-wrap-point)
+(defvar-local coolj-wrap-point nil)
 
 (defun coolj-determine-prefix ()
   "Determine the prefix for the current line."
diff --git a/emacs/notmuch-company.el b/emacs/notmuch-company.el
index 9ee8ceca..9e743029 100644
--- a/emacs/notmuch-company.el
+++ b/emacs/notmuch-company.el
@@ -36,8 +36,8 @@ (eval-when-compile (require 'cl-lib))
 
 (require 'notmuch-lib)
 
-(defvar notmuch-company-last-prefix nil)
-(make-variable-buffer-local 'notmuch-company-last-prefix)
+(defvar-local notmuch-company-last-prefix nil)
+
 (declare-function company-begin-backend "company")
 (declare-function company-grab "company")
 (declare-function company-mode "company")
diff --git a/emacs/notmuch-draft.el b/emacs/notmuch-draft.el
index b13eb51c..ca720384 100644
--- a/emacs/notmuch-draft.el
+++ b/emacs/notmuch-draft.el
@@ -89,9 +89,8 @@ (defvar notmuch-draft-encryption-tag-regex
   "<#\\(part encrypt\\|secure.*mode=.*encrypt>\\)"
   "Regular expression matching mml tags indicating encryption of part or 
message.")
 
-(defvar notmuch-draft-id nil
+(defvar-local notmuch-draft-id nil
   "Message-id of the most recent saved draft of this message.")
-(make-variable-buffer-local 'notmuch-draft-id)
 
 (defun notmuch-draft--mark-deleted ()
   "Tag the last saved draft deleted.
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 2c8de328..e23999ad 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -435,9 +435,8 @@ (defun notmuch-subkeymap-help ()
  (insert desc)))
   (pop-to-buffer (help-buffer)
 
-(defvar notmuch-buffer-refresh-function nil
+(defvar-local notmuch-buffer-refresh-function nil
   "Function to call to refresh the current buffer.")
-(make-variable-buffer-local 'notmuch-buffer-refresh-function)
 
 (defun notmuch-refresh-this-buffer ()
   "Refresh the current buffer."
@@ -989,10 +988,7 @@ (defun notmuch-start-notmuch-error-sentinel (proc event)
 (find-file-noselect err-file
 (when err-buffer (kill-buffer err-buffer
 
-;; This variable is used only buffer local, but it needs to be
-;; declared globally first to avoid compiler warnings.
-(defvar notmuch-show-process-crypto nil)
-(make-variable-buffer-local 'notmuch-show-process-crypto)
+(defvar-local notmuch-show-process-crypto nil)
 
 (defun notmuch-interactive-region ()
   "Return the bounds of the current interactive region.
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 09cdeaaa..c9b1e966 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -162,23 +162,17 @@ (defcustom notmuch-show-text/html-blocked-images "."
   :type '(choice (const nil) regexp)
   :group 'notmuch-show)
 
-(defvar notmuch-show-thread-id nil)
-(make-variable-buffer-local 'notmuch-show-thread-id)
+(defvar-local notmuch-show-thread-id nil)
 
-(defvar notmuch-show-parent-buffer nil)
-(make-variable-buffer-local 'notmuch-show-parent-buffer)
+(defvar-local notmuch-show-parent-buffer nil)
 
-(defvar notmuch-show-query-context nil)
-(make-variable-buffer-local 'notmuch-show-query-context)
+(defvar-local notmuch-show-query-context nil)
 
-(defvar notmuch-show-process-crypto nil)
-(make-variable-buffer-local 'notmuch-show-process-crypto)
+(defvar-local notmuch-show-process-crypto nil)
 
-(defvar notmuch-show-elide-non-matching-messages nil)
-(make-variable-buffer-local 'notmuch-show-elide-non-matching-messages)
+(defvar-local notmuch-show-elide-non-matching-messages nil)
 
-(defvar notmuch-show-indent-content t)
-(make-variable-buffer-local 'notmuch-show-indent-content)
+(defvar-local notmuch-show-indent-content t)
 
 (defvar notmuch-show-attachment-debug nil
   "If t log stdout and stderr from attachment handlers.
diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 71b6387a..3b5dab3e 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -51,9 +51,8 @@ (declare-function notmuch-tree-from-search-thread "notmuch" 
())
 (defvar notmuch-search-query-string)
 
 ;; this variable distinguishes the unthreaded display from the normal tree 
display
-(defvar notmuch-tree-unthreaded nil
+(defvar-local notmuch-tree-unthreaded nil
   "A buffer local copy of argument unthreaded to the function notmuch-tree.")
-(make-variable-buffer-local 'notmuch-tree-unthreaded)
 
 (defgroup notmuch-tree nil
   "Showing message and thread structure

[PATCH 12/27] emacs: place only first sentence on first doc-string line

2020-11-08 Thread Jonas Bernoulli
---
 emacs/notmuch-mua.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 49bad00d..9d08c2c9 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -62,8 +62,8 @@ (defcustom notmuch-mua-compose-in 'current-window
 (const :tag "Compose mail in a new frame"   new-frame)))
 
 (defcustom notmuch-mua-user-agent-function nil
-  "Function used to generate a `User-Agent:' string. If this is
-`nil' then no `User-Agent:' will be generated."
+  "Function used to generate a `User-Agent:' string.
+If this is `nil' then no `User-Agent:' will be generated."
   :type '(choice (const :tag "No user agent string" nil)
 (const :tag "Full" notmuch-mua-user-agent-full)
 (const :tag "Notmuch" notmuch-mua-user-agent-notmuch)
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


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

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

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

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


[PATCH 2/3] emacs: allow opting out of notmuch's address completion

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

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


[PATCH 0/3] emacs: allow opting out of notmuch's address completion

2020-11-08 Thread Jonas Bernoulli
Hello

Notmuch's address completion didn't work well for me.  I read the
respective code and found some issues, some of which are difficult
to address.

I wrote my own implementation, which might eventually be suitable as
a replacement for the current implementation, but it is not ready yet.

In a first step I would like to make it possible to use notmuch and
some other address completion mechanism without having to advice a
notmuch-address.el function to prevent it making destructive changes.
The second commit in this series does that.  Here is the hack I am
currently using instead:

,
| ;;; Counteract notmuch-address.el
| 
| (defun notmuch-address-setup--noop (_fn)
|   "Prevent modification of `message-completion-alist'.")
| (advice-add 'notmuch-address-setup :around
| 'notmuch-address-setup--noop)
`

You can find my implementation (named notmuch-addr.el because it is
like notmuch-address.el, but "smaller") here:

,
| https://git.sr.ht/~tarsius/notmuch-addr
`

The main reason I am not trying to improve that until it can serve as
a replacement for notmuch-address.el is that it depends on Emacs 27.1,
which was just released. (Aside from that it also omits features that
*I* don't need.)

The main reason I am listing defects of notmuch-address.el below is
that by the time we can fix all of them (when we drop support for
Emacs releases before 27.1) I will have forgotten about them, so it
seem like a good idea to document them.

* Emacs' address completion API used to be rather wacky and that was
  not fixed until version 27.1. "Callers" didn't merely have to
  provide a list of completion candidate, instead they actually had to
  perform completion themselves.  Starting with 27.1 the completion-
  at-point API is respected but there are kludges to support the old
  style as well, see https://git.savannah.gnu.org/cgit/emacs.git/com
  mit/?id=47a767c24e9cc4323432e29103b0a2cc46f8f3e4.

  Using capf API has the advantage that many things don't have to be
  re-implemented.  For example `company-mode' just works.  Notmuch
  currently has to implement support explicitly in notmuch-company.el.

* Some essentially random completion candidate is used as the "initial
  input".  The last commit in this series (which see) fixes that.

* The special cases when there is not matching candidate or just a
  single match are handled specifically, which IMO is an optimization
  that makes things worse.  That should also be an easy fix, but since
  it might also be a controversial change, I did not implement it.

* Completion candidates are pre-filered based on the text that was
  already at-point before at-point completion was invoked, which makes
  it possible to choose candidates that that initial text does not
  match.  IMO that's another optimization that badly back fires.

  I was surprised to learn that notmuch shared this feature/defect
  with the current default address implementation in Emacs 27.1.

  The initial commit of my implementation also shares this defect;
  but only so that I can use the second commit to demonstrate how
  that can be fixed.

 Cheers,
 Jonas

Jonas Bernoulli (3):
  emacs: notmuch-address-setup: cosmetics
  emacs: allow opting out of notmuch's address completion
  emacs: notmuch-address-expand-name: use the actual initial-input

 emacs/notmuch-address.el | 57 
 1 file changed, 29 insertions(+), 28 deletions(-)

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


[PATCH 1/3] emacs: notmuch-address-setup: cosmetics

2020-11-08 Thread Jonas Bernoulli
---
 emacs/notmuch-address.el | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 8a6d299c..3518beef 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -21,6 +21,8 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'cl-lib))
+
 (require 'message)
 (require 'notmuch-parser)
 (require 'notmuch-lib)
@@ -154,15 +156,12 @@ (defcustom notmuch-address-use-company t
   :group 'notmuch-address)
 
 (defun notmuch-address-setup ()
-  (let* ((setup-company (and notmuch-address-use-company
-(require 'company nil t)))
-(pair (cons notmuch-address-completion-headers-regexp
-#'notmuch-address-expand-name)))
-(when setup-company
-  (notmuch-company-setup))
-(unless (member pair message-completion-alist)
-  (setq message-completion-alist
-   (push pair message-completion-alist)
+  (when (and notmuch-address-use-company
+(require 'company nil t))
+(notmuch-company-setup))
+  (cl-pushnew (cons notmuch-address-completion-headers-regexp
+   #'notmuch-address-expand-name)
+ message-completion-alist :test #'equal))
 
 (defun notmuch-address-toggle-internal-completion ()
   "Toggle use of internal completion for current buffer.
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: Debugging slow down over time

2020-11-11 Thread Jonas Bernoulli
Sebastian Fischmeister  writes:
> For some time already I experience a slowdown of the emacs notmuch
> interface over time.

Please check if my recent patch in
id:20201108174929.1227-1-jo...@bernoul.li fixes that.

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


Re: [PATCH 01/27] emacs: silence byte-compiler

2020-11-11 Thread Jonas Bernoulli
William Casarin  writes:
> LGTM, I have a similar patch here: id:20200908171536.20679-1-j...@jb55.com

So if I understood correctly the problem with that was that you were
unable to run the tests and therefore couldn't confirm that you fixed
the issue or even that there was an issue in the first place.

Well I was able to build and test and I can confirm that there is an
issue and that your commit fixes it.  So it should be merged (though
I would merge my own variant because of the extra comment ;-).

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


Re: [PATCH 27/27] emacs: various cosmetic improvements

2020-11-16 Thread Jonas Bernoulli
David Edmondson  writes:

> On Sunday, 2020-11-08 at 20:03:11 +01, Jonas Bernoulli wrote:
>
> There were some places here where you capitalised comments (more
> generally, turned them into English prose) when they were moving for
> $reasons, and others where you left them alone. Was there a rationale
> for the different treatment?

I kept amending to this commit over time.  I suppose this difference
came about because apparently on some days such fuzzy comments bother
me more than others.

By the way, I am fairly strict about not sneaking unrelated changes
into and such comment cosmetic are about the only exception I make.

Anyway, I've amended this commit to improve two more comments.

jrb

>
> Reviewed-by: David Edmondson 
>
>> ---
>>  emacs/notmuch-address.el | 31 ++
>>  emacs/notmuch-hello.el   | 28 +
>>  emacs/notmuch-lib.el | 38 +
>>  emacs/notmuch-mua.el | 10 ++---
>>  emacs/notmuch-tag.el |  2 +-
>>  emacs/notmuch.el | 88 
>>  6 files changed, 91 insertions(+), 106 deletions(-)
>>
>> diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
>> index 21d1d82f..0dedd5d5 100644
>> --- a/emacs/notmuch-address.el
>> +++ b/emacs/notmuch-address.el
>> @@ -21,6 +21,8 @@
>>  
>>  ;;; Code:
>>  
>> +(eval-when-compile (require 'cl-lib))
>> +
>>  (require 'message)
>>  (require 'notmuch-parser)
>>  (require 'notmuch-lib)
>> @@ -154,15 +156,12 @@ (defcustom notmuch-address-use-company t
>>:group 'notmuch-address)
>>  
>>  (defun notmuch-address-setup ()
>> -  (let* ((setup-company (and notmuch-address-use-company
>> - (require 'company nil t)))
>> - (pair (cons notmuch-address-completion-headers-regexp
>> - #'notmuch-address-expand-name)))
>> -(when setup-company
>> -  (notmuch-company-setup))
>> -(unless (member pair message-completion-alist)
>> -  (setq message-completion-alist
>> -(push pair message-completion-alist)
>> +  (when (and notmuch-address-use-company
>> + (require 'company nil t))
>> +(notmuch-company-setup))
>> +  (cl-pushnew (cons notmuch-address-completion-headers-regexp
>> +#'notmuch-address-expand-name)
>> +  message-completion-alist :test #'equal))
>>  
>>  (defun notmuch-address-toggle-internal-completion ()
>>"Toggle use of internal completion for current buffer.
>> @@ -251,11 +250,8 @@ (defun notmuch-address-expand-name ()
>> (t nil)))
>>  
>>  (defun notmuch-address-harvest-addr (result)
>> -  (let ((name-addr (plist-get result :name-addr)))
>> -(puthash name-addr t notmuch-address-completions)))
>> -
>> -(defun notmuch-address-harvest-handle-result (obj)
>> -  (notmuch-address-harvest-addr obj))
>> +  (puthash (plist-get result :name-addr)
>> +   t notmuch-address-completions))
>>  
>>  (defun notmuch-address-harvest-filter (proc string)
>>(when (buffer-live-p (process-buffer proc))
>> @@ -264,7 +260,7 @@ (defun notmuch-address-harvest-filter (proc string)
>>  (goto-char (point-max))
>>  (insert string))
>>(notmuch-sexp-parse-partial-list
>> -   'notmuch-address-harvest-handle-result (process-buffer proc)
>> +   'notmuch-address-harvest-addr (process-buffer proc)
>>  
>>  (defvar notmuch-address-harvest-procs '(nil . nil)
>>"The currently running harvests.
>> @@ -375,7 +371,7 @@ (defun notmuch-address--load-address-hash ()
>>  (defun notmuch-address--save-address-hash ()
>>(when notmuch-address-save-filename
>>  (if (or (not (file-exists-p notmuch-address-save-filename))
>> -;; The file exists, check it is a file we saved
>> +;; The file exists, check it is a file we saved.
>>  (notmuch-address--get-address-hash))
>>  (with-temp-file notmuch-address-save-filename
>>(let ((save-plist
>> @@ -398,8 +394,7 @@ (defun notmuch-address-harvest-trigger ()
>> nil nil
>> (lambda (proc event)
>>   ;; If harvest fails, we want to try
>> - ;; again when the trigger is next
>> - ;; called
>> + ;; again when the trigger is next called.
>>   (if (string= event "finished\n")
>>   (progn
>> (notmuch-address--save-address-hash)
>> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
>> index f

Re: [PATCH 13/27] emacs: place complete first sentence on first doc-string line

2020-11-16 Thread Jonas Bernoulli
David Edmondson  writes:

> On Sunday, 2020-11-08 at 20:02:57 +01, Jonas Bernoulli wrote:
>
> With a suggested rewording below...
>
> Reviewed-by: David Edmondson 
>
>> ---
>>  emacs/notmuch-crypto.el |  3 +--
>>  emacs/notmuch-hello.el  |  3 +--
>>  emacs/notmuch-mua.el| 11 ---
>>  3 files changed, 6 insertions(+), 11 deletions(-)
>>
>> diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
>> index 276c9859..4fab215a 100644
>> --- a/emacs/notmuch-crypto.el
>> +++ b/emacs/notmuch-crypto.el
>> @@ -103,8 +103,7 @@ (define-button-type 'notmuch-crypto-status-button-type
>>:supertype 'notmuch-button-type)
>>  
>>  (defun notmuch-crypto-insert-sigstatus-button (sigstatus from)
>> -  "Insert a button describing the signature status SIGSTATUS sent
>> -by user FROM."
>> +  "Insert a button describing the signature status SIGSTATUS sent by user 
>> FROM."
>>(let* ((status (plist-get sigstatus :status))
>>   (show-button t)
>>   (face 'notmuch-crypto-signature-unknown)
>> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
>> index 003bec33..28784345 100644
>> --- a/emacs/notmuch-hello.el
>> +++ b/emacs/notmuch-hello.el
>> @@ -372,8 +372,7 @@ (defvar notmuch-hello-hidden-sections nil
>>"List of sections titles whose contents are hidden.")
>>  
>>  (defvar notmuch-hello-first-run t
>> -  "True if `notmuch-hello' is run for the first time, set to nil
>> -afterwards.")
>> +  "True if `notmuch-hello' is run for the first time, set to nil 
>> afterwards.")
>>  
>>  (defun notmuch-hello-nice-number (n)
>>(let (result)
>> diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
>> index 9d08c2c9..62d615d1 100644
>> --- a/emacs/notmuch-mua.el
>> +++ b/emacs/notmuch-mua.el
>> @@ -73,8 +73,7 @@ (defcustom notmuch-mua-user-agent-function nil
>>:group 'notmuch-send)
>>  
>>  (defcustom notmuch-mua-hidden-headers nil
>> -  "Headers that are added to the `message-mode' hidden headers
>> -list."
>> +  "Headers that are added to the `message-mode' hidden headers list."
>>:type '(repeat string)
>>:group 'notmuch-send)
>>  
>> @@ -167,8 +166,7 @@ (defun notmuch-mua-get-switch-function ()
>>  (t (error "Invalid value for `notmuch-mua-compose-in'"
>>  
>>  (defun notmuch-mua-maybe-set-window-dedicated ()
>> -  "Set the selected window as dedicated according to
>> -`notmuch-mua-compose-in'."
>> +  "Set the selected window as dedicated according to 
>> `notmuch-mua-compose-in'."
>>(when (or (eq notmuch-mua-compose-in 'new-frame)
>>  (eq notmuch-mua-compose-in 'new-window))
>>  (set-window-dedicated-p (selected-window) t)))
>> @@ -335,9 +333,8 @@ (define-derived-mode notmuch-message-mode message-mode 
>> "Message[Notmuch]"
>>  (put 'notmuch-message-mode 'flyspell-mode-predicate 
>> 'mail-mode-flyspell-verify)
>>  
>>  (defun notmuch-mua-pop-to-buffer (name switch-function)
>> -  "Pop to buffer NAME, and warn if it already exists and is
>> -modified. This function is notmuch adaptation of
>> -`message-pop-to-buffer'."
>> +  "Pop to buffer NAME, and warn if it already exists and is modified.
>> +This function is notmuch adaptation of `message-pop-to-buffer'."
>
> "notmuch's adaptation" or "a notmuch adaptation", or just "an adaptation".
>

I switched it to Emacsspeak, which here is:

Like `message-pop-to-buffer' but enable `notmuch-message-mode'
instead of `message-mode' and SWITCH-FUNCTION is mandatory.


>>(let ((buffer (get-buffer name)))
>>  (if (and buffer
>>   (buffer-name buffer))
>> -- 
>> 2.29.1
>> ___
>> notmuch mailing list -- notmuch@notmuchmail.org
>> To unsubscribe send an email to notmuch-le...@notmuchmail.org
>
> dme.
> -- 
> You bring light in.
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH v2] emacs: add notmuch-expr, sexp-style queries

2020-11-16 Thread Jonas Bernoulli
Tom Fitzhenry  writes:

> From: Tom Fitzhenry 
>
> notmuch-expr allows you to write notmuch search queries in sexp style like:
>
> (notmuch-expr
>   '(and
> (to "emacs-devel")
> "info manual"
> (or
>   (not (is "spam"))
>   (is "important"
>
> which will generate the textual query:
>
> "to:emacs-devel AND (NOT is:spam OR is:important) AND \"info manual\""
> ---
>  emacs/Makefile.local   |   1 +
>  emacs/notmuch-expr-test.el |  96 
>  emacs/notmuch-expr.el  | 124 +
>  emacs/notmuch.el   |   1 +
>  4 files changed, 222 insertions(+)
>  create mode 100644 emacs/notmuch-expr-test.el
>  create mode 100644 emacs/notmuch-expr.el
>
> diff --git a/emacs/Makefile.local b/emacs/Makefile.local
> index d1b320c3..f68e6e31 100644
> --- a/emacs/Makefile.local
> +++ b/emacs/Makefile.local
> @@ -22,6 +22,7 @@ emacs_sources := \
>   $(dir)/notmuch-version.el \
>   $(dir)/notmuch-jump.el \
>   $(dir)/notmuch-company.el \
> + $(dir)/notmuch-expr.el \
>   $(dir)/notmuch-draft.el
>  
>  elpa_sources := ${emacs_sources} $(dir)/notmuch-pkg.el
> diff --git a/emacs/notmuch-expr-test.el b/emacs/notmuch-expr-test.el
> new file mode 100644
> index ..92029fec
> --- /dev/null
> +++ b/emacs/notmuch-expr-test.el
> @@ -0,0 +1,96 @@
> +(require 'ert)
> +(require 'notmuch-expr)
> +
> +(ert-deftest and ()
> +  (should
> +(equal
> +  "(\"valued\" AND is:unread AND from:s...@example.com)"
> +  (notmuch-expr
> +   '(and
> + "valued"
> + (is "unread")
> + (from "s...@example.com"))
> +
> +(ert-deftest body ()
> +  (should
> +   (equal
> +"(body:wallace AND from:gromit)"
> +(notmuch-expr
> + '(and
> +   (body "wallace")
> +   (from "gromit"))
> +
> +(ert-deftest regex ()
> +  (should
> +   (equal
> +"(subject:\"/Ca+sh/\" AND NOT is:important)"
> +(notmuch-expr
> + '(and
> +   (subject "/Ca+sh/")
> +   (not (is "important")))
> +
> +(ert-deftest precedence ()
> +  (should
> +   (equal
> +"(to:emacs-devel AND (NOT is:spam OR is:important))"
> +(notmuch-expr
> + '(and
> +   (to "emacs-devel")
> +   (or
> + (not (is "spam"))
> + (is "important")))
> +
> +(ert-deftest xor ()
> +  (should
> +   (equal
> +"is:inbox XOR is:sent"
> +(notmuch-expr
> + '(xor
> +   (is "inbox")
> +   (is "sent"))
> +
> +(ert-deftest literal ()
> +  (should
> +   (equal
> +"(is:inbox OR from:foo)"
> +(notmuch-expr
> + '(or
> +   (is "inbox")
> +   (literal "from:foo"))
> +
> +(ert-deftest string ()
> +  (should
> +   (equal
> +"(is:inbox OR \"from:foo\")"
> +(notmuch-expr
> + '(or
> +   (is "inbox")
> +   "from:foo")
> +
> +(ert-deftest tag-with-spaces ()
> +  (should
> +   (equal
> +"is:\"a tag\""
> +(notmuch-expr
> + '(tag "a tag")
> +
> +(ert-deftest quoted-spaces ()
> +  (should
> +   (equal
> +"subject:\"Hello there\""
> +(notmuch-expr
> + '(subject "Hello there")
> +
> +(ert-deftest quoted-backslash ()
> +  (should
> +   (equal
> +"subject:\"A celebration! \\o/ Woo.\""
> +(notmuch-expr
> + '(subject "A celebration! \\o/ Woo.")
> +
> +(ert-deftest quoted-quote ()
> +  (should
> +   (equal
> +"subject:\"Gandalf: \\\"Use the force!\\\" 2001\""
> +(notmuch-expr
> + '(subject "Gandalf: \"Use the force!\" 2001")
> diff --git a/emacs/notmuch-expr.el b/emacs/notmuch-expr.el
> new file mode 100644
> index ..f5a3429f
> --- /dev/null
> +++ b/emacs/notmuch-expr.el
> @@ -0,0 +1,124 @@
> +;;; notmuch-expr.el --- An S-exp library for building notmuch search queries 
> -*- lexical-binding: t; -*-
> +
> +;; Author: Tom Fitzhenry 
> +;; Package-Requires: ((emacs "24.1"))
> +;; URL: https://notmuchmail.org

I recently improved consistency of the library headers.  They
don't confirm to the Emacs conventions but its close enough,
and I think internal consistency would be nice to maintain here.

Don't specify "URL".  "Homepage" would be better, but since this
is not an entry point library its better to omit this.  I think
"notmuch.el" is the only library that specifies this currently.

Likewise because "notmuch-expr" is not a standalone _package_
"Package-Requires" should not be specified.  By the way, notmuch
now requires emacs 25.1, so specifying a lower version would not
make sense here anyway.

 Cheers,
 Jonas

> +
> +;;; Commentary:
> +
> +;; This package provides a way to build notmuch search queries via 
> s-expressions.
> +;;
> +;; For example, rather than write:
> +
> +;; "to:emacs-devel AND (NOT is:spam OR is:important) AND \"info manual\""
> +;;
> +;; this package allows you to generate the same query via s-expressions:
> +;;
> +;; (notmuch-expr
> +;;  '(and
> +;;(to "emacs-devel")
> +;;"info manual"
> +;;(or
> +;;  (not (is "spam"))
> +;;  (is "impor

[PATCH 00/23] Another set up Emacs cleanup

2020-11-16 Thread Jonas Bernoulli
This remove the first four commits, which have already been
applied to master.  It also makes requested minor changes
to the three marked commits.

Jonas Bernoulli (23):
  emacs: remove redundant notmuch-hello-trim
  emacs: fix old bug in notmuch-mua-mail
  emacs: remove kludge for Emacs 23 from notmuch-mua-mail
  emacs: more cleanup since dropping support for Emacs 24
  emacs: sanitize function that displays version
  emacs: define notmuch-hello-url as a constant
  emacs: shorten/replace first sentence of a few doc-strings
  emacs: place only first sentence on first doc-string line
* emacs: place complete first sentence on first doc-string line
  emacs: always use elisp quoting style in doc-strings
* emacs: misc doc-string improvements
  emacs: remove deprecated notmuch-folder command
  emacs: remove unnecessary notmuch-remove-if-not
  emacs: remove unused notmuch-address-locate-command
  emacs: remove unnecessary notmuch-tree-button-activate
  emacs: inline notmuch-documentation-first-line
  emacs: inline notmuch-split-content-type
  emacs: use defvar-local
  emacs: use setq-local
  emacs: use setq instead set
  emacs: do not quote self-quoting t
  emacs: avoid binding unnamed commands in keymaps
* emacs: various cosmetic improvements

 emacs/coolj.el   |   4 +-
 emacs/notmuch-address.el |  58 
 emacs/notmuch-company.el |   7 +-
 emacs/notmuch-compat.el  |   9 +-
 emacs/notmuch-crypto.el  |   7 +-
 emacs/notmuch-draft.el   |  17 ++--
 emacs/notmuch-hello.el   | 123 +
 emacs/notmuch-jump.el|   5 --
 emacs/notmuch-lib.el | 108 +-
 emacs/notmuch-maildir-fcc.el |  12 +--
 emacs/notmuch-mua.el |  64 ++---
 emacs/notmuch-parser.el  |   5 +-
 emacs/notmuch-show.el|  56 ++--
 emacs/notmuch-tag.el |  24 ++---
 emacs/notmuch-tree.el| 170 ++-
 emacs/notmuch.el | 108 +++---
 16 files changed, 331 insertions(+), 446 deletions(-)

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


[PATCH v2 05/23] emacs: sanitize function that displays version

2020-11-16 Thread Jonas Bernoulli
Previously it was defined in "notmuch-hello.el" and its name contained
"hello" solely because it replaced an anonymous function that was
mistakenly only bound in `notmuch-hello-mode-map'.  But it makes more
sense to bind it in all notmuch modes and even if we did not change
that aspect it still would make no sense to have "hello" in its name.
---
 emacs/notmuch-hello.el | 14 --
 emacs/notmuch-lib.el   | 16 
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index af170dd4..69d0ad64 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -652,26 +652,12 @@ (defun notmuch-hello-window-configuration-change ()
   (remove-hook 'window-configuration-change-hook
   #'notmuch-hello-window-configuration-change
 
-;; the following variable is defined as being defconst in notmuch-version.el
-(defvar notmuch-emacs-version)
-
-(defun notmuch-hello-versions ()
-  "Display the notmuch version(s)."
-  (interactive)
-  (let ((notmuch-cli-version (notmuch-cli-version)))
-(message "notmuch version %s"
-(if (string= notmuch-emacs-version notmuch-cli-version)
-notmuch-cli-version
-  (concat notmuch-cli-version
-  " (emacs mua version " notmuch-emacs-version ")")
-
 (defvar notmuch-hello-mode-map
   ;; Inherit both widget-keymap and notmuch-common-keymap.  We have
   ;; to use make-sparse-keymap to force this to be a new keymap (so
   ;; that when we modify map it does not modify widget-keymap).
   (let ((map (make-composed-keymap (list (make-sparse-keymap) widget-keymap
 (set-keymap-parent map notmuch-common-keymap)
-(define-key map "v" 'notmuch-hello-versions)
 (define-key map (kbd "") 'widget-backward)
 map)
   "Keymap for \"notmuch hello\" buffers.")
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index edb40533..8ee3f17f 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -147,6 +147,7 @@ (defcustom notmuch-archive-tags '("-inbox")
 (defvar notmuch-common-keymap
   (let ((map (make-sparse-keymap)))
 (define-key map "?" 'notmuch-help)
+(define-key map "v" 'notmuch-version)
 (define-key map "q" 'notmuch-bury-or-kill-this-buffer)
 (define-key map "s" 'notmuch-search)
 (define-key map "t" 'notmuch-search-by-tag)
@@ -218,6 +219,21 @@ (defun notmuch-cli-version ()
(match-string 2 long-string)
   "unknown")))
 
+(defvar notmuch-emacs-version)
+
+(defun notmuch-version ()
+  "Display the notmuch version.
+The versions of the Emacs package and the `notmuch' executable
+should match, but if and only if they don't, then this command
+displays both values separately."
+  (interactive)
+  (let ((cli-version (notmuch-cli-version)))
+(message "notmuch version %s"
+(if (string= notmuch-emacs-version cli-version)
+cli-version
+  (concat cli-version
+  " (emacs mua version " notmuch-emacs-version ")")
+
 (defun notmuch-config-get (item)
   "Return a value from the notmuch configuration."
   (let* ((val (notmuch-command-to-string "config" "get" item))
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 08/23] emacs: place only first sentence on first doc-string line

2020-11-16 Thread Jonas Bernoulli
---
 emacs/notmuch-mua.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 49bad00d..9d08c2c9 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -62,8 +62,8 @@ (defcustom notmuch-mua-compose-in 'current-window
 (const :tag "Compose mail in a new frame"   new-frame)))
 
 (defcustom notmuch-mua-user-agent-function nil
-  "Function used to generate a `User-Agent:' string. If this is
-`nil' then no `User-Agent:' will be generated."
+  "Function used to generate a `User-Agent:' string.
+If this is `nil' then no `User-Agent:' will be generated."
   :type '(choice (const :tag "No user agent string" nil)
 (const :tag "Full" notmuch-mua-user-agent-full)
 (const :tag "Notmuch" notmuch-mua-user-agent-notmuch)
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 07/23] emacs: shorten/replace first sentence of a few doc-strings

2020-11-16 Thread Jonas Bernoulli
The first sentence should fit on the first line.  It is okay if
the first sentence/line does not contain all the information that
the rest of the doc-string covers.
---
 emacs/notmuch-show.el | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 6a757687..14250d34 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -2347,7 +2347,9 @@ (defun notmuch-show-stash-mlarchive-link-and-go 
(&optional mla)
   (browse-url (current-kill 0 t)))
 
 (defun notmuch-show-stash-git-helper (addresses prefix)
-  "Escape, trim, quote, and add PREFIX to each address in list of ADDRESSES, 
and return the result as a single string."
+  "Normalize all ADDRESSES while adding PREFIX.
+Escape, trim, quote and add PREFIX to each address in list
+of ADDRESSES, and return the result as a single string."
   (mapconcat (lambda (x)
   (concat prefix "\""
   ;; escape double-quotes
@@ -2360,10 +2362,12 @@ (defun notmuch-show-stash-git-helper (addresses prefix)
 addresses " "))
 
 (put 'notmuch-show-stash-git-send-email 'notmuch-prefix-doc
- "Copy From/To/Cc of current message to kill-ring in a form suitable for 
pasting to git send-email command line.")
+ "Copy From/To/Cc of current message to kill-ring.
+Use a form suitable for pasting to git send-email command line.")
 
 (defun notmuch-show-stash-git-send-email (&optional no-in-reply-to)
-  "Copy From/To/Cc/Message-Id of current message to kill-ring in a form 
suitable for pasting to git send-email command line.
+  "Copy From/To/Cc/Message-Id of current message to kill-ring.
+Use a form suitable for pasting to git send-email command line.
 
 If invoked with a prefix argument (or NO-IN-REPLY-TO is non-nil),
 omit --in-reply-to=."
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 02/23] emacs: fix old bug in notmuch-mua-mail

2020-11-16 Thread Jonas Bernoulli
This fixes a regression introduced in [1: 7e20d264].  If the argument
RETURN-ACTION was non-nil then we should pass along the value of that
argument.  Instead we passed along the constant symbol `return-action'.

1: 7e20d26480553f57d53bd9ec28cae163c1ac91e3
   emacs: Fix mail composition under Emacs 23
---
 emacs/notmuch-mua.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 616b625c..1204fb6a 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -402,7 +402,7 @@ (defun notmuch-mua-mail (&optional to subject other-headers 
continue
 ;; argument. Pass it only if it is supplied by the caller. This
 ;; will never be the case when we're called by `compose-mail' in
 ;; Emacs 23.
-(when return-action (nconc args '(return-action)))
+(when return-action (nconc args (list return-action)))
 (apply 'message-setup-1 headers args))
   (notmuch-fcc-header-setup)
   (message-sort-headers)
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 01/23] emacs: remove redundant notmuch-hello-trim

2020-11-16 Thread Jonas Bernoulli
Use `string-trim', which exists since Emacs 24.4.
---
 emacs/notmuch-hello.el | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index bb60a890..b67a5e19 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -387,15 +387,9 @@ (defun notmuch-hello-nice-number (n)
 (format "%s%03d" notmuch-hello-thousands-separator elem))
   (cdr result)
 
-(defun notmuch-hello-trim (search)
-  "Trim whitespace."
-  (if (string-match "^[[:space:]]*\\(.*[^[:space:]]\\)[[:space:]]*$" search)
-  (match-string 1 search)
-search))
-
 (defun notmuch-hello-search (&optional search)
   (unless (null search)
-(setq search (notmuch-hello-trim 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))
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 03/23] emacs: remove kludge for Emacs 23 from notmuch-mua-mail

2020-11-16 Thread Jonas Bernoulli
Notmuch requires at least Emacs version 25.

The `return-action' argument was added prior to Emacs 24.1
in 25ca2e61403f97b5a023164f2924d5f8aca2492a.
---
 emacs/notmuch-mua.el | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 1204fb6a..869ec51a 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -394,16 +394,10 @@ (defun notmuch-mua-mail (&optional to subject 
other-headers continue
  (dolist (h other-headers other-headers)
(when (stringp (car h))
  (setcar h (intern (capitalize (car h
-   (args (list yank-action send-actions))
;; Cause `message-setup-1' to do things relevant for mail,
;; such as observe `message-default-mail-headers'.
(message-this-is-mail t))
-;; message-setup-1 in Emacs 23 does not accept return-action
-;; argument. Pass it only if it is supplied by the caller. This
-;; will never be the case when we're called by `compose-mail' in
-;; Emacs 23.
-(when return-action (nconc args (list return-action)))
-(apply 'message-setup-1 headers args))
+(message-setup-1 headers yank-action send-actions return-action))
   (notmuch-fcc-header-setup)
   (message-sort-headers)
   (message-hide-headers)
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 04/23] emacs: more cleanup since dropping support for Emacs 24

2020-11-16 Thread Jonas Bernoulli
Notmuch requires at least version 25 of Emacs now.

Adjust comments that previously referenced version 24 specifically,
even though they also apply to later releases. Remove documentation
and code that no longer applies.

- `mm-shr' no longer references `gnus-inhibit-images'.
---
 emacs/notmuch-compat.el |  9 +
 emacs/notmuch-hello.el  | 16 +---
 emacs/notmuch-jump.el   |  5 -
 emacs/notmuch-lib.el| 12 
 emacs/notmuch-mua.el| 17 ++---
 emacs/notmuch-show.el   | 10 --
 emacs/notmuch-tree.el   |  7 ---
 7 files changed, 24 insertions(+), 52 deletions(-)

diff --git a/emacs/notmuch-compat.el b/emacs/notmuch-compat.el
index 3ede6b36..2975f4c2 100644
--- a/emacs/notmuch-compat.el
+++ b/emacs/notmuch-compat.el
@@ -21,10 +21,11 @@
 
 ;;; Code:
 
-;; emacs master has a bugfix for folding long headers when sending
-;; messages. Include the fix for earlier versions of emacs. To avoid
-;; interfering with gnus we only run the hook when called from
-;; notmuch-message-mode.
+;; Before Emacs 26.1 lines that are longer than 998 octets were not.
+;; folded. Commit 77bbca8c82f6e553c42abbfafca28f55fc995d00 fixed
+;; that. Until we drop support for Emacs 25 we have to backport that
+;; fix. To avoid interfering with Gnus we only run the hook when
+;; called from notmuch-message-mode.
 
 (declare-function mail-header-fold-field "mail-parse" nil)
 
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index b67a5e19..af170dd4 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -645,6 +645,7 @@ (defun notmuch-hello-window-configuration-change ()
   ;; Refresh hello as soon as we get back to redisplay.  On Emacs
   ;; 24, we can't do it right here because something in this
   ;; hook's call stack overrides hello's point placement.
+  ;; FIXME And on Emacs releases that we still support?
   (run-at-time nil nil #'notmuch-hello t))
 (unless hello-buf
   ;; Clean up hook
@@ -665,17 +666,10 @@ (defun notmuch-hello-versions ()
   " (emacs mua version " notmuch-emacs-version ")")
 
 (defvar notmuch-hello-mode-map
-  (let ((map (if (fboundp 'make-composed-keymap)
-;; Inherit both widget-keymap and
-;; notmuch-common-keymap. We have to use
-;; make-sparse-keymap to force this to be a new
-;; keymap (so that when we modify map it does not
-;; modify widget-keymap).
-(make-composed-keymap (list (make-sparse-keymap) 
widget-keymap))
-  ;; Before Emacs 24, keymaps didn't support multiple
-  ;; inheritance,, so just copy the widget keymap since
-  ;; it's unlikely to change.
-  (copy-keymap widget-keymap
+  ;; Inherit both widget-keymap and notmuch-common-keymap.  We have
+  ;; to use make-sparse-keymap to force this to be a new keymap (so
+  ;; that when we modify map it does not modify widget-keymap).
+  (let ((map (make-composed-keymap (list (make-sparse-keymap) widget-keymap
 (set-keymap-parent map notmuch-common-keymap)
 (define-key map "v" 'notmuch-hello-versions)
 (define-key map (kbd "") 'widget-backward)
diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
index 1e2d0497..ff622055 100644
--- a/emacs/notmuch-jump.el
+++ b/emacs/notmuch-jump.el
@@ -29,11 +29,6 @@ (eval-when-compile
 (require 'notmuch-lib)
 (require 'notmuch-hello)
 
-(eval-and-compile
-  (unless (fboundp 'window-body-width)
-;; Compatibility for Emacs pre-24
-(defalias 'window-body-width 'window-width)))
-
 ;;;###autoload
 (defun notmuch-jump-search ()
   "Jump to a saved search by shortcut key.
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 118faf1e..edb40533 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -653,18 +653,6 @@ (defun notmuch-get-bodypart-text (msg part process-crypto 
&optional cache)
 MSG (if it isn't already)."
   (notmuch--get-bodypart-raw msg part process-crypto nil cache))
 
-;; Workaround: The call to `mm-display-part' below triggers a bug in
-;; Emacs 24 if it attempts to use the shr renderer to display an HTML
-;; part with images in it (demonstrated in 24.1 and 24.2 on Debian and
-;; Fedora 17, though unreproducible in other configurations).
-;; `mm-shr' references the variable `gnus-inhibit-images' without
-;; first loading gnus-art, which defines it, resulting in a
-;; void-variable error.  Hence, we advise `mm-shr' to ensure gnus-art
-;; is loaded.
-(define-advice mm-shr (:before (_handle) notmuch--load-gnus-args)
-  "Require `gnus-art' since we use its variables."
-  (require 'gnus-art nil t))
-
 (defun notmuch-mm-display-part-inline (msg part content-type process-crypto)
   "Use the mm-decode/mm-view functions to display a part in the
 current buffer, if possible."
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 869ec51a..49bad00d 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/n

[PATCH v2 13/23] emacs: remove unnecessary notmuch-remove-if-not

2020-11-16 Thread Jonas Bernoulli
We could just have switched to using `cl-remove-if-not' instead,
but the two uses of the *remove-if-not function are pretty strange
to begin with so we refactor to not use any such function at all.
---
 emacs/notmuch-hello.el | 43 --
 emacs/notmuch-lib.el   |  9 -
 2 files changed, 20 insertions(+), 32 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index f5d9e0ec..fa31694f 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -21,8 +21,7 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl-lib))
-
+(require 'cl-lib)
 (require 'widget)
 (require 'wid-edit) ; For `widget-forward'.
 
@@ -542,21 +541,19 @@ (defun notmuch-hello-query-counts (query-list &rest 
options)
 --batch'. In general we recommend running matching versions of
 the CLI and emacs interface."))
 (goto-char (point-min))
-(notmuch-remove-if-not
- #'identity
- (mapcar
-  (lambda (elem)
-   (let* ((elem-plist (notmuch-hello-saved-search-to-plist elem))
-  (search-query (plist-get elem-plist :query))
-  (filtered-query (notmuch-hello-filtered-query
-   search-query (plist-get options :filter)))
-  (message-count (prog1 (read (current-buffer))
-   (forward-line 1
- (when (and filtered-query (or (plist-get options :show-empty-searches)
-   (> message-count 0)))
-   (setq elem-plist (plist-put elem-plist :query filtered-query))
-   (plist-put elem-plist :count message-count
-  query-list
+(cl-mapcan
+ (lambda (elem)
+   (let* ((elem-plist (notmuch-hello-saved-search-to-plist elem))
+ (search-query (plist-get elem-plist :query))
+ (filtered-query (notmuch-hello-filtered-query
+  search-query (plist-get options :filter)))
+ (message-count (prog1 (read (current-buffer))
+  (forward-line 1
+(when (and filtered-query (or (plist-get options :show-empty-searches)
+  (> message-count 0)))
+  (setq elem-plist (plist-put elem-plist :query filtered-query))
+  (list (plist-put elem-plist :count message-count)
+ query-list)))
 
 (defun notmuch-hello-insert-buttons (searches)
   "Insert buttons for SEARCHES.
@@ -698,12 +695,12 @@ (define-derived-mode notmuch-hello-mode fundamental-mode 
"notmuch-hello"
 
 (defun notmuch-hello-generate-tag-alist (&optional hide-tags)
   "Return an alist from tags to queries to display in the all-tags section."
-  (mapcar (lambda (tag)
-   (cons tag (concat "tag:" (notmuch-escape-boolean-term tag
- (notmuch-remove-if-not
-  (lambda (tag)
-(not (member tag hide-tags)))
-  (process-lines notmuch-command "search" "--output=tags" "*"
+  (cl-mapcan (lambda (tag)
+  (and (not (member tag hide-tags))
+   (list (cons tag
+   (concat "tag:"
+   (notmuch-escape-boolean-term tag))
+(process-lines notmuch-command "search" "--output=tags" "*")))
 
 (defun notmuch-hello-insert-header ()
   "Insert the default notmuch-hello header."
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 8ee3f17f..d7c6b737 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -534,15 +534,6 @@ (defun notmuch-common-do-stash (text)
 
 ;;
 
-(defun notmuch-remove-if-not (predicate list)
-  "Return a copy of LIST with all items not satisfying PREDICATE removed."
-  (let (out)
-(while list
-  (when (funcall predicate (car list))
-   (push (car list) out))
-  (setq list (cdr list)))
-(nreverse out)))
-
 (defun notmuch-plist-delete (plist property)
   (let* ((xplist (cons nil plist))
 (pred xplist))
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 06/23] emacs: define notmuch-hello-url as a constant

2020-11-16 Thread Jonas Bernoulli
---
 emacs/notmuch-hello.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 69d0ad64..003bec33 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -282,7 +282,7 @@ (defcustom notmuch-hello-refresh-hook nil
   :group 'notmuch-hello
   :group 'notmuch-hooks)
 
-(defvar notmuch-hello-url "https://notmuchmail.org";
+(defconst notmuch-hello-url "https://notmuchmail.org";
   "The `notmuch' web site.")
 
 (defvar notmuch-hello-custom-section-options
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 11/23] emacs: misc doc-string improvements

2020-11-16 Thread Jonas Bernoulli
---
 emacs/notmuch-address.el | 6 +++---
 emacs/notmuch-crypto.el  | 4 ++--
 emacs/notmuch-mua.el | 7 ---
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 561cc140..2c51e89b 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -36,9 +36,9 @@ (defvar notmuch-address-completions (make-hash-table :test 
'equal)
 This variable is set by calling `notmuch-address-harvest'.")
 
 (defvar notmuch-address-full-harvest-finished nil
-  "t indicates that full completion address harvesting has been finished.
-Use notmuch-address--harvest-ready to access as that will load a
-saved hash if necessary (and available).")
+  "Whether full completion address harvesting has finished.
+Use `notmuch-address--harvest-ready' to access as that will load
+a saved hash if necessary (and available).")
 
 (defun notmuch-address--harvest-ready ()
   "Return t if there is a full address hash available.
diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index 4fab215a..9e6f3a9d 100644
--- a/emacs/notmuch-crypto.el
+++ b/emacs/notmuch-crypto.el
@@ -27,7 +27,7 @@ (require 'notmuch-lib)
 (declare-function notmuch-show-get-message-id "notmuch-show" (&optional bare))
 
 (defcustom notmuch-crypto-process-mime t
-  "Should cryptographic MIME parts be processed?
+  "Whether to process cryptographic MIME parts.
 
 If this variable is non-nil signatures in multipart/signed
 messages will be verified and multipart/encrypted parts will be
@@ -46,7 +46,7 @@ (defcustom notmuch-crypto-process-mime t
   :group 'notmuch-crypto)
 
 (defcustom notmuch-crypto-get-keys-asynchronously t
-  "Retrieve gpg keys asynchronously."
+  "Whether to retrieve openpgp keys asynchronously."
   :type 'boolean
   :group 'notmuch-crypto)
 
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 05763928..29a2538b 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -82,10 +82,11 @@ (defgroup notmuch-reply nil
   :group 'notmuch)
 
 (defcustom notmuch-mua-cite-function 'message-cite-original
-  "*Function for citing an original message.
+  "Function for citing an original message.
+
 Predefined functions include `message-cite-original' and
-`message-cite-original-without-signature'.
-Note that these functions use `mail-citation-hook' if that is non-nil."
+`message-cite-original-without-signature'.  Note that these
+functions use `mail-citation-hook' if that is non-nil."
   :type '(radio (function-item message-cite-original)
(function-item message-cite-original-without-signature)
(function-item sc-cite-original)
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 12/23] emacs: remove deprecated notmuch-folder command

2020-11-16 Thread Jonas Bernoulli
It has been deprecated for a decade and it's time to let go.
---
 emacs/notmuch-hello.el | 5 -
 1 file changed, 5 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index bc07c29c..f5d9e0ec 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -987,11 +987,6 @@ (defun notmuch-hello (&optional no-display)
   (run-hooks 'notmuch-hello-refresh-hook)
   (setq notmuch-hello-first-run nil))
 
-(defun notmuch-folder ()
-  "Deprecated function for invoking notmuch---calling `notmuch' is preferred 
now."
-  (interactive)
-  (notmuch-hello))
-
 ;;
 
 (provide 'notmuch-hello)
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 09/23] emacs: place complete first sentence on first doc-string line

2020-11-16 Thread Jonas Bernoulli
---
 emacs/notmuch-crypto.el |  3 +--
 emacs/notmuch-hello.el  |  3 +--
 emacs/notmuch-mua.el| 12 +---
 3 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index 276c9859..4fab215a 100644
--- a/emacs/notmuch-crypto.el
+++ b/emacs/notmuch-crypto.el
@@ -103,8 +103,7 @@ (define-button-type 'notmuch-crypto-status-button-type
   :supertype 'notmuch-button-type)
 
 (defun notmuch-crypto-insert-sigstatus-button (sigstatus from)
-  "Insert a button describing the signature status SIGSTATUS sent
-by user FROM."
+  "Insert a button describing the signature status SIGSTATUS sent by user 
FROM."
   (let* ((status (plist-get sigstatus :status))
 (show-button t)
 (face 'notmuch-crypto-signature-unknown)
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 003bec33..28784345 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -372,8 +372,7 @@ (defvar notmuch-hello-hidden-sections nil
   "List of sections titles whose contents are hidden.")
 
 (defvar notmuch-hello-first-run t
-  "True if `notmuch-hello' is run for the first time, set to nil
-afterwards.")
+  "True if `notmuch-hello' is run for the first time, set to nil afterwards.")
 
 (defun notmuch-hello-nice-number (n)
   (let (result)
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 9d08c2c9..05763928 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -73,8 +73,7 @@ (defcustom notmuch-mua-user-agent-function nil
   :group 'notmuch-send)
 
 (defcustom notmuch-mua-hidden-headers nil
-  "Headers that are added to the `message-mode' hidden headers
-list."
+  "Headers that are added to the `message-mode' hidden headers list."
   :type '(repeat string)
   :group 'notmuch-send)
 
@@ -167,8 +166,7 @@ (defun notmuch-mua-get-switch-function ()
(t (error "Invalid value for `notmuch-mua-compose-in'"
 
 (defun notmuch-mua-maybe-set-window-dedicated ()
-  "Set the selected window as dedicated according to
-`notmuch-mua-compose-in'."
+  "Set the selected window as dedicated according to `notmuch-mua-compose-in'."
   (when (or (eq notmuch-mua-compose-in 'new-frame)
(eq notmuch-mua-compose-in 'new-window))
 (set-window-dedicated-p (selected-window) t)))
@@ -335,9 +333,9 @@ (define-derived-mode notmuch-message-mode message-mode 
"Message[Notmuch]"
 (put 'notmuch-message-mode 'flyspell-mode-predicate 'mail-mode-flyspell-verify)
 
 (defun notmuch-mua-pop-to-buffer (name switch-function)
-  "Pop to buffer NAME, and warn if it already exists and is
-modified. This function is notmuch adaptation of
-`message-pop-to-buffer'."
+  "Pop to buffer NAME, and warn if it already exists and is modified.
+Like `message-pop-to-buffer' but enable `notmuch-message-mode'
+instead of `message-mode' and SWITCH-FUNCTION is mandatory."
   (let ((buffer (get-buffer name)))
 (if (and buffer
 (buffer-name buffer))
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 19/23] emacs: use setq-local

2020-11-16 Thread Jonas Bernoulli
It is available since Emacs 24.3 and we require at least Emacs 25.
It makes the variable buffer-local if it isn't always buffer-local
anyway.
---
 emacs/notmuch-company.el | 3 +--
 emacs/notmuch-parser.el  | 5 ++---
 emacs/notmuch.el | 2 +-
 3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-company.el b/emacs/notmuch-company.el
index 9e743029..b50e73c8 100644
--- a/emacs/notmuch-company.el
+++ b/emacs/notmuch-company.el
@@ -55,8 +55,7 @@ (defvar notmuch-address-command)
 ;;;###autoload
 (defun notmuch-company-setup ()
   (company-mode)
-  (make-local-variable 'company-backends)
-  (setq company-backends '(notmuch-company))
+  (setq-local company-backends '(notmuch-company))
   ;; Disable automatic company completion unless an internal
   ;; completion method is configured. Company completion (using
   ;; internal completion) can still be accessed via standard company
diff --git a/emacs/notmuch-parser.el b/emacs/notmuch-parser.el
index 3aa5bd8f..4a437016 100644
--- a/emacs/notmuch-parser.el
+++ b/emacs/notmuch-parser.el
@@ -168,9 +168,8 @@ (defun notmuch-sexp-parse-partial-list (result-function 
result-buffer)
 move point in the input buffer."
   ;; Set up the initial state
   (unless (local-variable-p 'notmuch-sexp--parser)
-(set (make-local-variable 'notmuch-sexp--parser)
-(notmuch-sexp-create-parser))
-(set (make-local-variable 'notmuch-sexp--state) 'begin))
+(setq-local notmuch-sexp--parser (notmuch-sexp-create-parser))
+(setq-local notmuch-sexp--state 'begin))
   (let (done)
 (while (not done)
   (cl-case notmuch-sexp--state
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 3ca27b26..95770fc3 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -391,7 +391,7 @@ (define-derived-mode notmuch-search-mode fundamental-mode 
"notmuch-search"
   (make-local-variable 'notmuch-search-target-thread)
   (make-local-variable 'notmuch-search-target-line)
   (setq notmuch-buffer-refresh-function #'notmuch-search-refresh-view)
-  (set (make-local-variable 'scroll-preserve-screen-position) t)
+  (setq-local scroll-preserve-screen-position t)
   (add-to-invisibility-spec (cons 'ellipsis t))
   (setq truncate-lines t)
   (setq buffer-read-only t)
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 17/23] emacs: inline notmuch-split-content-type

2020-11-16 Thread Jonas Bernoulli
This trivial helper function actually made things slightly
*less* readable by adding an unnecessary indirection.
---
 emacs/notmuch-lib.el  |  8 ++--
 emacs/notmuch-show.el | 16 
 2 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 61107e38..2c8de328 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -534,14 +534,10 @@ (defun notmuch-plist-delete (plist property)
   (setq pred (cddr pred)))
 (cdr xplist)))
 
-(defun notmuch-split-content-type (content-type)
-  "Split content/type into 'content' and 'type'."
-  (split-string content-type "/"))
-
 (defun notmuch-match-content-type (t1 t2)
   "Return t if t1 and t2 are matching content types, taking wildcards into 
account."
-  (let ((st1 (notmuch-split-content-type t1))
-   (st2 (notmuch-split-content-type t2)))
+  (let ((st1 (split-string t1 "/"))
+   (st2 (split-string t2 "/")))
 (if (or (string= (cadr st1) "*")
(string= (cadr st2) "*"))
;; Comparison of content types should be case insensitive.
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 14250d34..09cdeaaa 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -573,12 +573,13 @@ (defun notmuch-show--register-cids (msg part)
   ;; alternative (even if we can't render it).
   (push (list content-id msg part) notmuch-show--cids)))
   ;; Recurse on sub-parts
-  (let ((ctype (notmuch-split-content-type
-   (downcase (plist-get part :content-type)
-(cond ((equal (car ctype) "multipart")
+  (pcase-let ((`(,content ,type)
+  (split-string (downcase (plist-get part :content-type)) "/")))
+(cond ((equal content "multipart")
   (mapc (apply-partially #'notmuch-show--register-cids msg)
 (plist-get part :content)))
- ((equal ctype '("message" "rfc822"))
+ ((and (equal content "message")
+   (equal type "rfc822"))
   (notmuch-show--register-cids
msg
(car (plist-get (car (plist-get part :content)) :body)))
@@ -851,10 +852,9 @@ (defun notmuch-show-handlers-for (content-type)
  (push func result)))
  ;; Reverse order of prefrence.
  (list (intern (concat "notmuch-show-insert-part-*/*"))
-   (intern (concat
-"notmuch-show-insert-part-"
-(car (notmuch-split-content-type content-type))
-"/*"))
+   (intern (concat "notmuch-show-insert-part-"
+   (car (split-string content-type "/"))
+   "/*"))
(intern (concat "notmuch-show-insert-part-" content-type
 result))
 
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 10/23] emacs: always use elisp quoting style in doc-strings

2020-11-16 Thread Jonas Bernoulli
Emacs doc-strings use neither markdown nor lisp symbol quoting.
---
 emacs/notmuch-address.el |  2 +-
 emacs/notmuch-draft.el   |  8 
 emacs/notmuch-hello.el   |  4 ++--
 emacs/notmuch-maildir-fcc.el |  2 +-
 emacs/notmuch-tag.el | 20 ++--
 emacs/notmuch.el |  4 ++--
 6 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 8a6d299c..561cc140 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -294,7 +294,7 @@ (defun notmuch-address-harvest (&optional addr-prefix 
synchronous callback)
   "Collect addresses completion candidates.
 
 It queries the notmuch database for messages sent/received (as
-configured with `notmuch-address-command`) by the user, collects
+configured with `notmuch-address-command') by the user, collects
 destination/source addresses from those messages and stores them
 in `notmuch-address-completions'.
 
diff --git a/emacs/notmuch-draft.el b/emacs/notmuch-draft.el
index 283830ad..b13eb51c 100644
--- a/emacs/notmuch-draft.el
+++ b/emacs/notmuch-draft.el
@@ -101,7 +101,7 @@ (defun notmuch-draft--mark-deleted ()
 (notmuch-tag notmuch-draft-id '("+deleted"
 
 (defun notmuch-draft-quote-some-mml ()
-  "Quote the mml tags in `notmuch-draft-quoted-tags`."
+  "Quote the mml tags in `notmuch-draft-quoted-tags'."
   (save-excursion
 ;; First we deal with any secure tag separately.
 (message-goto-body)
@@ -122,7 +122,7 @@ (defun notmuch-draft-quote-some-mml ()
  (insert "!"))
 
 (defun notmuch-draft-unquote-some-mml ()
-  "Unquote the mml tags in `notmuch-draft-quoted-tags`."
+  "Unquote the mml tags in `notmuch-draft-quoted-tags'."
   (save-excursion
 (when notmuch-draft-quoted-tags
   (let ((re (concat "<#!+/?\\("
@@ -174,7 +174,7 @@ (defun notmuch-draft-save ()
   "Save the current draft message in the notmuch database.
 
 This saves the current message in the database with tags
-`notmuch-draft-tags` (in addition to any default tags
+`notmuch-draft-tags' (in addition to any default tags
 applied to newly inserted messages)."
   (interactive)
   (when (notmuch-draft--has-encryption-tag)
@@ -185,7 +185,7 @@ (defun notmuch-draft-save ()
  ;; so that it is easier to search for the message, and the
  ;; latter so we have a way of accessing the saved message (for
  ;; example to delete it at a later time). We check that the
- ;; user has these in `message-deletable-headers` (the default)
+ ;; user has these in `message-deletable-headers' (the default)
  ;; as otherwise they are doing something strange and we
  ;; shouldn't interfere. Note, since we are doing this in a new
  ;; buffer we don't change the version in the compose buffer.
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 28784345..bc07c29c 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -138,8 +138,8 @@ (defcustom notmuch-saved-searches
shown. If not present then the :query property
is used.
   :sort-order  Specify the sort order to be used for the search.
-   Possible values are 'oldest-first 'newest-first or
-   nil. Nil means use the default sort order.
+   Possible values are `oldest-first', `newest-first'
+   or nil. Nil means use the default sort order.
   :search-type Specify whether to run the search in search-mode,
tree mode or unthreaded mode. Set to 'tree to specify tree
mode, 'unthreaded to specify unthreaded mode, and set to nil
diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el
index a9103a20..b1da93e6 100644
--- a/emacs/notmuch-maildir-fcc.el
+++ b/emacs/notmuch-maildir-fcc.el
@@ -196,7 +196,7 @@ (defun notmuch-maildir-message-do-fcc ()
 (defun notmuch-fcc-handler (fcc-header)
   "Store message with notmuch insert or normal (file) fcc.
 
-If `notmuch-maildir-use-notmuch-insert` is set then store the
+If `notmuch-maildir-use-notmuch-insert' is set then store the
 message using notmuch insert. Otherwise store the message using
 normal fcc."
   (message "Doing Fcc...")
diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
index 5d4a6865..dc9a2186 100644
--- a/emacs/notmuch-tag.el
+++ b/emacs/notmuch-tag.el
@@ -68,15 +68,15 @@ (defcustom notmuch-tagging-keys
 be used (either as a key, or as the start of a key sequence) as
 it is already bound: it switches the menu to a menu of the
 reverse tagging operations. The reverse of a tagging operation is
-the same list of individual tag-ops but with `+tag` replaced by
-`-tag` and vice versa.
+the same list of individual tag-ops but with `+tag' replaced by
+`-tag' and vice versa.
 
 If setting this variable outside of customize then it should be a
 list of triples (lists of three elements). Each triple should be
 of the form (key-binding tagging-operations name). KEY-BI

[PATCH v2 14/23] emacs: remove unused notmuch-address-locate-command

2020-11-16 Thread Jonas Bernoulli
We stopped using it in [1: 0e671478].

1: 0e671478c6f37018973392f049979da5e1a8ff99
   emacs: replace use of notmuch-address-message-insinuate
---
 emacs/notmuch-address.el | 19 ---
 1 file changed, 19 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 2c51e89b..71985ed7 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -250,25 +250,6 @@ (defun notmuch-address-expand-name ()
(ding
(t nil)))
 
-;; Copied from `w3m-which-command'.
-(defun notmuch-address-locate-command (command)
-  "Return non-nil if `command' is an executable either on
-`exec-path' or an absolute pathname."
-  (and (stringp command)
-   (if (and (file-name-absolute-p command)
-   (file-executable-p command))
-  command
-(setq command (file-name-nondirectory command))
-(catch 'found-command
-  (let (bin)
-(dolist (dir exec-path)
-  (setq bin (expand-file-name command dir))
-  (when (or (and (file-executable-p bin)
- (not (file-directory-p bin)))
-(and (file-executable-p (setq bin (concat bin ".exe")))
- (not (file-directory-p bin
-(throw 'found-command bin
-
 (defun notmuch-address-harvest-addr (result)
   (let ((name-addr (plist-get result :name-addr)))
 (puthash name-addr t notmuch-address-completions)))
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 16/23] emacs: inline notmuch-documentation-first-line

2020-11-16 Thread Jonas Bernoulli
Inline a simplified version of `notmuch-documentation-first-line'
into its only caller.  The new code snippet differs from the
removed function in that it returns nil instead of the empty string
for symbols that have no function documentation.  That value is
ultimately used as an argument to `concat', which treats nil like
the empty string.  So we can do the logical thing without changing
the behavior.
---
 emacs/notmuch-lib.el | 17 -
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index d7c6b737..61107e38 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -287,18 +287,6 @@ (defun notmuch-bury-or-kill-this-buffer ()
   (bury-buffer)
 (kill-buffer)))
 
-(defun notmuch-documentation-first-line (symbol)
-  "Return the first line of the documentation string for SYMBOL."
-  (let ((doc (documentation symbol)))
-(if doc
-   (with-temp-buffer
- (insert (documentation symbol t))
- (goto-char (point-min))
- (let ((beg (point)))
-   (end-of-line)
-   (buffer-substring beg (point
-  "")))
-
 (defun notmuch-prefix-key-description (key)
   "Given a prefix key code, return a human-readable string representation.
 
@@ -331,7 +319,10 @@ (defun notmuch-describe-key (actual-key binding prefix 
ua-keys tail)
  (or (and (symbolp binding)
   (get binding 'notmuch-doc))
  (and (functionp binding)
-  (notmuch-documentation-first-line binding
+  (let ((doc (documentation binding)))
+(and doc
+ (string-match "\\`.+" doc)
+ (match-string 0 doc))
tail)))
   tail)
 
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 18/23] emacs: use defvar-local

2020-11-16 Thread Jonas Bernoulli
It is available since Emacs 24.3 and we require at least Emacs 25.
---
 emacs/coolj.el   |  4 +---
 emacs/notmuch-company.el |  4 ++--
 emacs/notmuch-draft.el   |  3 +--
 emacs/notmuch-lib.el |  8 ++--
 emacs/notmuch-show.el| 18 ++
 emacs/notmuch-tree.el| 27 +--
 6 files changed, 21 insertions(+), 43 deletions(-)

diff --git a/emacs/coolj.el b/emacs/coolj.el
index 39a8de2b..0385872f 100644
--- a/emacs/coolj.el
+++ b/emacs/coolj.el
@@ -50,9 +50,7 @@ (defcustom coolj-line-prefix-regexp "^\\(>+ \\)*"
   :group 'coolj
   :type 'regexp)
 
-(defvar coolj-wrap-point nil)
-
-(make-variable-buffer-local 'coolj-wrap-point)
+(defvar-local coolj-wrap-point nil)
 
 (defun coolj-determine-prefix ()
   "Determine the prefix for the current line."
diff --git a/emacs/notmuch-company.el b/emacs/notmuch-company.el
index 9ee8ceca..9e743029 100644
--- a/emacs/notmuch-company.el
+++ b/emacs/notmuch-company.el
@@ -36,8 +36,8 @@ (eval-when-compile (require 'cl-lib))
 
 (require 'notmuch-lib)
 
-(defvar notmuch-company-last-prefix nil)
-(make-variable-buffer-local 'notmuch-company-last-prefix)
+(defvar-local notmuch-company-last-prefix nil)
+
 (declare-function company-begin-backend "company")
 (declare-function company-grab "company")
 (declare-function company-mode "company")
diff --git a/emacs/notmuch-draft.el b/emacs/notmuch-draft.el
index b13eb51c..ca720384 100644
--- a/emacs/notmuch-draft.el
+++ b/emacs/notmuch-draft.el
@@ -89,9 +89,8 @@ (defvar notmuch-draft-encryption-tag-regex
   "<#\\(part encrypt\\|secure.*mode=.*encrypt>\\)"
   "Regular expression matching mml tags indicating encryption of part or 
message.")
 
-(defvar notmuch-draft-id nil
+(defvar-local notmuch-draft-id nil
   "Message-id of the most recent saved draft of this message.")
-(make-variable-buffer-local 'notmuch-draft-id)
 
 (defun notmuch-draft--mark-deleted ()
   "Tag the last saved draft deleted.
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 2c8de328..e23999ad 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -435,9 +435,8 @@ (defun notmuch-subkeymap-help ()
  (insert desc)))
   (pop-to-buffer (help-buffer)
 
-(defvar notmuch-buffer-refresh-function nil
+(defvar-local notmuch-buffer-refresh-function nil
   "Function to call to refresh the current buffer.")
-(make-variable-buffer-local 'notmuch-buffer-refresh-function)
 
 (defun notmuch-refresh-this-buffer ()
   "Refresh the current buffer."
@@ -989,10 +988,7 @@ (defun notmuch-start-notmuch-error-sentinel (proc event)
 (find-file-noselect err-file
 (when err-buffer (kill-buffer err-buffer
 
-;; This variable is used only buffer local, but it needs to be
-;; declared globally first to avoid compiler warnings.
-(defvar notmuch-show-process-crypto nil)
-(make-variable-buffer-local 'notmuch-show-process-crypto)
+(defvar-local notmuch-show-process-crypto nil)
 
 (defun notmuch-interactive-region ()
   "Return the bounds of the current interactive region.
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 09cdeaaa..c9b1e966 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -162,23 +162,17 @@ (defcustom notmuch-show-text/html-blocked-images "."
   :type '(choice (const nil) regexp)
   :group 'notmuch-show)
 
-(defvar notmuch-show-thread-id nil)
-(make-variable-buffer-local 'notmuch-show-thread-id)
+(defvar-local notmuch-show-thread-id nil)
 
-(defvar notmuch-show-parent-buffer nil)
-(make-variable-buffer-local 'notmuch-show-parent-buffer)
+(defvar-local notmuch-show-parent-buffer nil)
 
-(defvar notmuch-show-query-context nil)
-(make-variable-buffer-local 'notmuch-show-query-context)
+(defvar-local notmuch-show-query-context nil)
 
-(defvar notmuch-show-process-crypto nil)
-(make-variable-buffer-local 'notmuch-show-process-crypto)
+(defvar-local notmuch-show-process-crypto nil)
 
-(defvar notmuch-show-elide-non-matching-messages nil)
-(make-variable-buffer-local 'notmuch-show-elide-non-matching-messages)
+(defvar-local notmuch-show-elide-non-matching-messages nil)
 
-(defvar notmuch-show-indent-content t)
-(make-variable-buffer-local 'notmuch-show-indent-content)
+(defvar-local notmuch-show-indent-content t)
 
 (defvar notmuch-show-attachment-debug nil
   "If t log stdout and stderr from attachment handlers.
diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 71b6387a..3b5dab3e 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -51,9 +51,8 @@ (declare-function notmuch-tree-from-search-thread "notmuch" 
())
 (defvar notmuch-search-query-string)
 
 ;; this variable distinguishes the unthreaded display from the normal tree 
display
-(defvar notmuch-tree-unthreaded nil
+(defvar-local notmuch-tree-unthreaded nil
   "A buffer local copy of argument unthreaded to the function notmuch-tree.")
-(make-variable-buffer-local 'notmuch-tree-unthreaded)
 
 (defgroup notmuch-tree nil
   "Showing message and thread structure

[PATCH v2 15/23] emacs: remove unnecessary notmuch-tree-button-activate

2020-11-16 Thread Jonas Bernoulli
Since [1: f8bdba37] no key is bound to this command and it is
redundant because the behavior of `push-command' is identical
when called as a command.

1: f8bdba37d3f4c877e05e17b5b1c7d2d512106538
   emacs: tree: remove binding for pressing button in message pane
---
 emacs/notmuch-tree.el | 8 
 1 file changed, 8 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 28c9372e..71b6387a 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -267,14 +267,6 @@ (defun notmuch-tree-inherit-from-message-pane (sym)
(symbol-value sym))
 (symbol-value sym)))
 
-(defun notmuch-tree-button-activate (&optional button)
-  "Activate BUTTON or button at point.
-
-This function does not give an error if there is no button."
-  (interactive)
-  (let ((button (or button (button-at (point)
-(when button (button-activate button
-
 (defun notmuch-tree-close-message-pane-and (func)
   "Close message pane and execute FUNC.
 
-- 
2.29.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 20/23] emacs: use setq instead set

2020-11-16 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 3b5dab3e..7cc28b62 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -1115,7 +1115,7 @@ (defun notmuch-tree (&optional 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 (&optional 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 v2 21/23] emacs: do not quote self-quoting t

2020-11-16 Thread Jonas Bernoulli
---
 emacs/notmuch-draft.el   |  6 +++---
 emacs/notmuch-maildir-fcc.el | 10 +-
 emacs/notmuch-mua.el |  6 +++---
 emacs/notmuch-show.el|  2 +-
 emacs/notmuch-tag.el |  2 +-
 5 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/emacs/notmuch-draft.el b/emacs/notmuch-draft.el
index ca720384..f928be87 100644
--- a/emacs/notmuch-draft.el
+++ b/emacs/notmuch-draft.el
@@ -135,7 +135,7 @@ (defun notmuch-draft-unquote-some-mml ()
 (let (secure-tag)
   (save-restriction
(message-narrow-to-headers)
-   (setq secure-tag (message-fetch-field "X-Notmuch-Emacs-Secure" 't))
+   (setq secure-tag (message-fetch-field "X-Notmuch-Emacs-Secure" t))
(message-remove-header "X-Notmuch-Emacs-Secure"))
   (message-goto-body)
   (when secure-tag
@@ -145,7 +145,7 @@ (defun notmuch-draft--has-encryption-tag ()
   "Returns t if there is an mml secure tag."
   (save-excursion
 (message-goto-body)
-(re-search-forward notmuch-draft-encryption-tag-regex nil 't)))
+(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.
@@ -207,7 +207,7 @@ (defun notmuch-draft-save ()
  (notmuch-draft-quote-some-mml)
  (notmuch-maildir-setup-message-for-saving)
  (notmuch-maildir-notmuch-insert-current-buffer
-  notmuch-draft-folder 't notmuch-draft-tags))
+  notmuch-draft-folder t notmuch-draft-tags))
 ;; We are now back in the original compose buffer. Note the
 ;; function notmuch-call-notmuch-process (called by
 ;; notmuch-maildir-notmuch-insert-current-buffer) signals an error
diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el
index b1da93e6..32b8100e 100644
--- a/emacs/notmuch-maildir-fcc.el
+++ b/emacs/notmuch-maildir-fcc.el
@@ -76,7 +76,7 @@ (defcustom notmuch-fcc-dirs "sent"
   :require 'notmuch-fcc-initialization
   :group 'notmuch-send)
 
-(defcustom notmuch-maildir-use-notmuch-insert 't
+(defcustom notmuch-maildir-use-notmuch-insert t
   "Should fcc use notmuch insert instead of simple fcc."
   :type '(choice :tag "Fcc Method"
 (const :tag "Use notmuch insert" t)
@@ -246,8 +246,8 @@ (defun notmuch-maildir-fcc-with-notmuch-insert (fcc-header 
&optional create)
 \(r)etry, (c)reate folder, (i)gnore, or (e)dit the header? " '(?r ?c ?i ?e
 (cl-case response
   (?r (notmuch-maildir-fcc-with-notmuch-insert fcc-header))
-  (?c (notmuch-maildir-fcc-with-notmuch-insert fcc-header 't))
-  (?i 't)
+  (?c (notmuch-maildir-fcc-with-notmuch-insert fcc-header t))
+  (?i t)
   (?e (notmuch-maildir-fcc-with-notmuch-insert
(read-from-minibuffer "Fcc header: " fcc-header)
 
@@ -322,7 +322,7 @@ (defun notmuch-maildir-fcc-file-fcc (fcc-header)
 It offers the user a chance to correct the header, or filesystem,
 if needed."
   (if (notmuch-maildir-fcc-dir-is-maildir-p fcc-header)
-  (notmuch-maildir-fcc-write-buffer-to-maildir fcc-header 't)
+  (notmuch-maildir-fcc-write-buffer-to-maildir fcc-header t)
 ;; The fcc-header is not a valid maildir see if the user wants to
 ;; fix it in some way.
 (let* ((prompt (format "Fcc %s is not a maildir: \
@@ -335,7 +335,7 @@ (defun notmuch-maildir-fcc-file-fcc (fcc-header)
  (message "No permission to create %s." fcc-header)
  (sit-for 2))
(notmuch-maildir-fcc-file-fcc fcc-header))
-   (?i 't)
+   (?i t)
(?e (notmuch-maildir-fcc-file-fcc
 (read-from-minibuffer "Fcc header: " fcc-header)))
 
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 29a2538b..c38cb5aa 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -539,11 +539,11 @@ (defun notmuch-mua-check-no-misplaced-secure-tag ()
   (goto-char (point-max))
   (or
;; We are always fine if there is no secure tag.
-   (not (search-backward "<#secure" nil 't))
+   (not (search-backward "<#secure" nil t))
;; There is a secure tag, so it must be at the start of the
;; body, with no secure tag earlier (i.e., in the headers).
(and (= (point) body-start)
-   (not (search-backward "<#secure" nil 't)))
+   (not (search-backward "<#secure" nil t)))
;; The user confirms they means it.
(yes-or-no-p "\
 There is a <#secure> tag not at the start of the body. It is
@@ -583,7 +583,7 @@ (defun notmuch-mua-send-common (arg &optional exit)
 
 (defun notmuch-mua-send-and-exit (&optional arg)
   (interactive "P")
-  (notmuch-mua-send-common arg 't))
+  (notmuch-mua-send-common arg t))
 
 (defun notmuch-mua-send (&optional arg)
   (interactive "P")
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index c9b1e966..056c4e30 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1751,7 +1751,7 @@ (defun notmuch-show-command-hook ()
  

[PATCH v2 22/23] emacs: avoid binding unnamed commands in keymaps

2020-11-16 Thread Jonas Bernoulli
One should never bind unnamed commands in keymaps because doing that
makes it needlessly hard for users to change these bindings.

Replace such anonymous bindings with named commands that are generated
using macros and some boilerplate. Using macros is better than using a
simple loop because that makes it possible for `find-function' to find
the definitions. Eat your boilerplate--it forms character.

Admittedly this approach is quite ugly and it might be better to teach
the original commands to support different buffers directly instead of
requiring wrapper commands to do just that.

Never-the-less as a short-term solution this is better than what we
had before.
---
 emacs/notmuch-tree.el | 126 --
 1 file changed, 72 insertions(+), 54 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 7cc28b62..17863f6a 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -238,57 +238,83 @@ (defvar-local notmuch-tree-message-buffer nil
 if the user has loaded a different buffer in that window.")
 (put 'notmuch-tree-message-buffer 'permanent-local t)
 
-(defun notmuch-tree-to-message-pane (func)
-  "Execute FUNC in message pane.
-
-This function returns a function (so can be used as a keybinding)
-which executes function FUNC in the message pane if it is
-open (if the message pane is closed it does nothing)."
-  `(lambda ()
- ,(concat "(In message pane) " (documentation func t))
+(defmacro notmuch-tree--define-do-in-message-window (name cmd)
+  "Define NAME as a command that calls CMD interactively in the message window.
+If the message pane is closed then this command does nothing.
+Avoid using this macro in new code; it will be removed."
+  `(defun ,name ()
+ ,(concat "(In message window) " (documentation cmd t))
  (interactive)
  (when (window-live-p notmuch-tree-message-window)
(with-selected-window notmuch-tree-message-window
-(call-interactively #',func)
-
-(defun notmuch-tree-inherit-from-message-pane (sym)
-  "Return value of SYM in message-pane if open, or tree-pane if not."
+(call-interactively #',cmd)
+
+(notmuch-tree--define-do-in-message-window
+ notmuch-tree-previous-message-button
+ notmuch-show-previous-button)
+(notmuch-tree--define-do-in-message-window
+ notmuch-tree-next-message-button
+ notmuch-show-next-button)
+(notmuch-tree--define-do-in-message-window
+ notmuch-tree-toggle-message-process-crypto
+ notmuch-show-toggle-process-crypto)
+
+(defun notmuch-tree--message-process-crypto ()
+  "Return value of `notmuch-show-process-crypto' in the message window.
+If that window isn't alive, then return the current value.
+Avoid using this function in new code; it will be removed."
   (if (window-live-p notmuch-tree-message-window)
   (with-selected-window notmuch-tree-message-window
-   (symbol-value sym))
-(symbol-value sym)))
-
-(defun notmuch-tree-close-message-pane-and (func)
-  "Close message pane and execute FUNC.
-
-This function returns a function (so can be used as a keybinding)
-which closes the message pane if open and then executes function
-FUNC."
-  `(lambda ()
- ,(concat "(Close message pane and) " (documentation func t))
+   notmuch-show-process-crypto)
+notmuch-show-process-crypto))
+
+(defmacro notmuch-tree--define-close-message-window-and (name cmd)
+  "Define NAME as a variant of CMD.
+
+NAME determines the value of `notmuch-show-process-crypto' in the
+message window, closes the window, and then call CMD interactively
+with that value let-bound.  If the message window does not exist,
+then NAME behaves like CMD."
+  `(defun ,name ()
+ ,(concat "(Close message pane and) " (documentation cmd t))
  (interactive)
  (let ((notmuch-show-process-crypto
-   (notmuch-tree-inherit-from-message-pane 
'notmuch-show-process-crypto)))
+   (notmuch-tree--message-process-crypto)))
(notmuch-tree-close-message-window)
-   (call-interactively #',func
+   (call-interactively #',cmd
+
+(notmuch-tree--define-close-message-window-and
+ notmuch-tree-help
+ notmuch-help)
+(notmuch-tree--define-close-message-window-and
+ notmuch-tree-new-mail
+ notmuch-mua-new-mail)
+(notmuch-tree--define-close-message-window-and
+ notmuch-tree-jump-search
+ notmuch-jump-search)
+(notmuch-tree--define-close-message-window-and
+ notmuch-tree-forward-message
+ notmuch-show-forward-message)
+(notmuch-tree--define-close-message-window-and
+ notmuch-tree-reply-sender
+ notmuch-show-reply-sender)
+(notmuch-tree--define-close-message-window-and
+ notmuch-tree-reply
+ notmuch-show-reply)
+(notmuch-tree--define-close-message-window-and
+ notmuch-tree-view-raw-message
+ notmuch-show-view-raw-message)
 
 (defvar notmuch-tree-mode-map
   (let ((map (make-sparse-keymap)))
 (set-keymap-parent map notmuch-common-keymap)
-;; The following override the global keymap.
-;; Override because we want to close message pane first.
-(defi

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

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

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

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

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

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

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

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

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

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

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

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


[PATCH 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 (&optional 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 (&optional 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


[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 &rest 
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 &rest 
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 notmuch-le..

[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 (&optional 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 &rest _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 &rest _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 &rest _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 &rest 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 &rest ignore)
-  (notmuch-hello-search 
(widget-value widget)))
+:action #'notmuch-hello-search
 search))
 (widget-insert " ")
 (widget-create 'push-button
-   :notify (lambda (widget &rest 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 &rest 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-hist

[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 &rest _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 (&rest 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 (&rest _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 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 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 &rest 
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 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 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 &rest 
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 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 
&optional 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 
&optional 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 &rest 
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 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
 ;;
diff

[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 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


<    1   2   3   >