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

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

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

Apologies, I should have experimented / asked before. I can't seem to
duplicate the problem being fixed here. Is it non-deterministic, or
should I expect it to always happen? If the latter, can you give me a
further hint / instructions how to reproduce? For me, whether in
tree-mode or search-mode, if I hit return the message at point is marked
unread.

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


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

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

> A let binding without a value is just an obfuscated way of saying
> nil, especially if you are not going to mutate the variable.

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


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

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

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


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

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

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


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

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

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

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

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

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


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

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

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


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

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

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

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

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


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

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

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

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

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


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

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

David Bremner  writes:

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