Re: [PATCH] emacs/tree: add notmuch-tree-quit-all

2021-06-06 Thread William Casarin

On Sat, Jun 05, 2021 at 08:35:41AM -0300, David Bremner wrote:

William Casarin  writes:


This is a simple binding in notmuch-tree-mode that closes both the
message buffer and thread buffer at the same time. This is a common
action after entering a thread from search with M-Enter.

Signed-off-by: William Casarin 


Apologies for the epic delay. Should this binding also be added to the
message window?


ah sure, I don't use emacs anymore so I won't have time to update
these patches. sorry about that :( 


feel free to mark these as abandoned unless someone wants to pick it up.

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


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

2020-11-11 Thread William Casarin
Jonas Bernoulli  writes:

> 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

I believe this makes sense. Looks like they were first introduced in
early versions of the code...

Reviewed-by: William Casarin 
Tested-by: William Casarin 
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


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

2020-11-11 Thread William Casarin
Jonas Bernoulli  writes:

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

Tested-by: William Casarin 
___
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 William Casarin
Jonas Bernoulli  writes:
> 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.

More so I got a bug report from a user that I couldn't replicate. I
haven't run the tests.

> 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 ;-).

Sounds good, happy to use this patch instead.

Cheers,
Will
___
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-08 Thread William Casarin
Jonas Bernoulli  writes:

> ---
>  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" ( 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)

LGTM, I have a similar patch here: id:20200908171536.20679-1-j...@jb55.com

Reviewed-by: William Casarin 
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH] emacs/tree: declare notmuch-search functions

2020-09-08 Thread William Casarin
Some are running into undeclarated function errors:

> emacs/notmuch-tree.el:1143:1:Warning: the following functions are
> not known to be defined: notmuch-search-previous-thread,
> notmuch-search-next-thread, notmuch-tree-from-search-thread

Fixes: 874f14ec ("emacs/tree: enable moving to next thread in search results")
Reported-by: Danilo G. Baio 
Signed-off-by: William Casarin 
---

Hey there,

"Danilo G. Baio"  writes:
> Hi William.
>
> I'm updating notmuch on FreeBSD (to 0.31) and I'm getting this issue:
>
>
> ```
> [...]
> ===
> ===>  Staging for notmuch-emacs27-0.31
> ===>   notmuch-emacs27-0.31 depends on executable: notmuch - found
> ===>   notmuch-emacs27-0.31 depends on file: /usr/local/bin/emacs-27.1 - found
> ===>   notmuch-emacs27-0.31 depends on executable: indexinfo - found
> ===>   Generating temporary packing list
> gmake[1]: Entering directory 
> '/wrkdirs/usr/ports/mail/notmuch-emacs/work-full/notmuch-0.31'
> /usr/local/bin/emacs-27.1 --directory emacs -batch -f batch-byte-compile 
> emacs/notmuch-compat.el
> /usr/local/bin/emacs-27.1 --directory emacs -batch -f batch-byte-compile 
> emacs/notmuch-version.el
> /usr/local/bin/emacs-27.1 --directory emacs -batch -f batch-byte-compile 
> emacs/notmuch-lib.el
> /usr/local/bin/emacs-27.1 --directory emacs -batch -f batch-byte-compile 
> emacs/notmuch-parser.el
> /usr/local/bin/emacs-27.1 --directory emacs -batch -f batch-byte-compile 
> emacs/notmuch-tag.el
> /usr/local/bin/emacs-27.1 --directory emacs -batch -f batch-byte-compile 
> emacs/notmuch-query.el
> /usr/local/bin/emacs-27.1 --directory emacs -batch -f batch-byte-compile 
> emacs/coolj.el
> /usr/local/bin/emacs-27.1 --directory emacs -batch -f batch-byte-compile 
> emacs/notmuch-wash.el
> /usr/local/bin/emacs-27.1 --directory emacs -batch -f batch-byte-compile 
> emacs/notmuch-company.el
> /usr/local/bin/emacs-27.1 --directory emacs -batch -f batch-byte-compile 
> emacs/notmuch-address.el
> /usr/local/bin/emacs-27.1 --directory emacs -batch -f batch-byte-compile 
> emacs/notmuch-maildir-fcc.el
> /usr/local/bin/emacs-27.1 --directory emacs -batch -f batch-byte-compile 
> emacs/notmuch-draft.el
> /usr/local/bin/emacs-27.1 --directory emacs -batch -f batch-byte-compile 
> emacs/notmuch-message.el
> /usr/local/bin/emacs-27.1 --directory emacs -batch -f batch-byte-compile 
> emacs/notmuch-mua.el
> /usr/local/bin/emacs-27.1 --directory emacs -batch -f batch-byte-compile 
> emacs/notmuch-crypto.el
> /usr/local/bin/emacs-27.1 --directory emacs -batch -f batch-byte-compile 
> emacs/notmuch-print.el
> /usr/local/bin/emacs-27.1 --directory emacs -batch -f batch-byte-compile 
> emacs/notmuch-show.el
> /usr/local/bin/emacs-27.1 --directory emacs -batch -f batch-byte-compile 
> emacs/notmuch-hello.el
> /usr/local/bin/emacs-27.1 --directory emacs -batch -f batch-byte-compile 
> emacs/notmuch-jump.el
> /usr/local/bin/emacs-27.1 --directory emacs -batch -f batch-byte-compile 
> emacs/notmuch-tree.el
>
> In end of data:
> emacs/notmuch-tree.el:1143:1:Warning: the following functions are not known to
> be defined: notmuch-search-previous-thread, notmuch-search-next-thread,
> notmuch-tree-from-search-thread
>
> [...]
> ```
>
> I don't use Emacs and don't have a clue in how fix this.
>
> Could you help me?
>
> Regards.
> -- 
> Danilo G. Baio (dbaio)

I got this report from user with the new notmuch-tree updates. I didn't
run into this, but it looks like these functions are supposed to be
forwardly declared first? 

I don't have a way of testing this and I'm waiting to see if it fixes
their issue, but thought I'd would post the patch here as well for
review.

Cheers,
Will

emacs/notmuch-tree.el | 3 +++
1 file changed, 3 insertions(+)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index f342f85a..3336139e 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -41,6 +41,9 @@
 (declare-function notmuch-read-query "notmuch" (prompt))
 (declare-function notmuch-search-find-thread-id "notmuch" ( bare))
 (declare-function notmuch-search-find-subject "notmuch" ())
+(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.28.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 2/5] NEWS: mention exception handling changes

2020-08-23 Thread William Casarin
David Bremner  writes:

> ---
>  NEWS | 8 
>  1 file changed, 8 insertions(+)
>
> diff --git a/NEWS b/NEWS
> index c1f09b18..e6392e81 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -16,6 +16,14 @@ files to a maildir for mutt to access is replaced with 
> internal perl
>  processing. This search operation is now more portable, and somewhat
>  faster.
>  
> +Library
> +---
> +
> +Many small changes to exception handling in the library; this should
> +largely eliminate terminations inside the library due to uncaught
> +exceptions or internal errors.  No doubt there are a few uncovered
> +code paths still; please report them as bugs.

subjective nit: 

  Many small changes to exception handling in the library. This should
  largely eliminate terminations due to uncaught exceptions or internal
  errors. No doubt there are a few uncovered code paths still; please
  report them as bugs.

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


Re: [PATCH] NEWS: add news entry for tree navigation changes

2020-08-23 Thread William Casarin
David Bremner  writes:

> William Casarin  writes:
>
>> Signed-off-by: William Casarin 
>> ---
>>  NEWS | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>
> Applied to master and release, with a tiny wording change.
>
> I realized when looking at this that I had completely forgotten
> notmuch-tree-from-search-thread.  I suspect some of emacs interface is
> not as discoverable as we think it is

Indeed, I only discovered this function after Teemu mentioned[1] it in a
mailing list thread. I've always like the magit docs, maybe we can get
to something like that eventually.

[1] id:87pnhxceoy@iki.fi

The elisp code has plenty of comments that document each function,
perhaps there could be a way to generate documentation from that? Not
sure how magit does it.

> and it would be worth updating
> (not for the upcoming release, but afterwards) doc/notmuch-emacs.rst
> with some of the nifty features that have been added since I
> optimistically wrote (eb6fb36d)
>
> This is pretty minimal, but will hopefully inspire others to
> contribute more complete documentation

Oh good to know! Didn't realize this was a thing.

Cheers,
Will

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


[PATCH] NEWS: add news entry for tree navigation changes

2020-08-22 Thread William Casarin
Signed-off-by: William Casarin 
---
 NEWS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/NEWS b/NEWS
index b25bfaa3..9e635ab6 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,8 @@ Emacs
 
 The minimum supported major version of GNU Emacs is now 25.1.
 
+Support for moving between threads after notmuch-tree-from-search-thread.
+
 Notmuch-Mutt
 
 
-- 
2.28.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 2/3] emacs/tree: enable moving to next thread in search results

2020-08-11 Thread William Casarin
This introduces a new function called
notmuch-tree-next-thread-from-search which is analogous to
notmuch-show-next-thread. It will switch to the next or previous
thread from the parent search results.

We rename notmuch-tree-{prev,next}-thread to a more descriptive
notmuch-tree-{prev,next}-thread-in-tree to reflect the fact that it
only moves to the next thread in the current tree.

notmuch-tree-next-thread now switches to the next thread in the
current tree first, but if there are none, it looks for the next tree
in the search results.

This makes notmuch-tree feel more like notmuch-show when using the
M-Enter, M-n and M-p bindings.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 40 +---
 1 file changed, 37 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 29f64851..bf500b60 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -725,12 +725,14 @@ nil otherwise."
 (while (not (or (notmuch-tree-get-prop :first) (eobp)))
   (forward-line -1
 
-(defun notmuch-tree-prev-thread ()
+(defun notmuch-tree-prev-thread-in-tree ()
+  "Move to the previous thread in the current tree"
   (interactive)
   (forward-line -1)
-  (notmuch-tree-thread-top))
+  (notmuch-tree-thread-top)
+  (not (bobp)))
 
-(defun notmuch-tree-next-thread ()
+(defun notmuch-tree-next-thread-in-tree ()
   "Get the next thread in the current tree. Returns t if a thread was
 found or nil if not."
   (interactive)
@@ -739,6 +741,38 @@ found or nil if not."
 (forward-line 1))
   (not (eobp)))
 
+(defun notmuch-tree-next-thread-from-search ( previous)
+  "Move to the next thread in the parent search results, if any.
+
+If PREVIOUS is non-nil, move to the previous item in the
+search results instead."
+  (interactive "P")
+  (let ((parent-buffer notmuch-tree-parent-buffer))
+(notmuch-tree-quit t)
+(when (buffer-live-p parent-buffer)
+  (switch-to-buffer parent-buffer)
+  (if previous
+ (notmuch-search-previous-thread)
+   (notmuch-search-next-thread))
+  (notmuch-tree-from-search-thread
+
+(defun notmuch-tree-next-thread ( previous)
+  "Move to the next thread in the current tree or parent search
+results
+
+If PREVIOUS is non-nil, move to the previous thread in the tree or
+search results instead."
+  (interactive)
+  (unless (if previous (notmuch-tree-prev-thread-in-tree)
+   (notmuch-tree-next-thread-in-tree))
+(notmuch-tree-next-thread-from-search previous)))
+
+(defun notmuch-tree-prev-thread ()
+  "Move to the previous thread in the current tree or parent search
+results"
+  (interactive)
+  (notmuch-tree-next-thread t))
+
 (defun notmuch-tree-thread-mapcar (function)
   "Iterate through all messages in the current thread
  and call FUNCTION for side effects."
-- 
2.28.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 3/3] emacs/tree: add notmuch-tree-archive-thread-then-next

2020-08-11 Thread William Casarin
Now that notmuch-tree-next-thread acts more like its notmuch-show
counterpart, let's update the binding to move to the next thread after
archiving.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index bf500b60..2bb7c80f 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -338,7 +338,7 @@ FUNC."
 (define-key map [mouse-1] 'notmuch-tree-show-message)
 (define-key map "x" 'notmuch-tree-archive-message-then-next-or-exit)
 (define-key map "X" 'notmuch-tree-archive-thread-then-exit)
-(define-key map "A" 'notmuch-tree-archive-thread)
+(define-key map "A" 'notmuch-tree-archive-thread-then-next)
 (define-key map "a" 'notmuch-tree-archive-message-then-next)
 (define-key map "z" 'notmuch-tree-to-tree)
 (define-key map "n" 'notmuch-tree-next-matching-message)
@@ -497,6 +497,12 @@ NOT change the database."
 (notmuch-tree-close-message-window)
 (notmuch-tree query)))
 
+(defun notmuch-tree-archive-thread-then-next ()
+  "Archive all messages in the current buffer, then show next thread from 
search."
+  (interactive)
+  (notmuch-tree-archive-thread)
+  (notmuch-tree-next-thread))
+
 (defun notmuch-unthreaded-from-tree-current-query ()
   "Switch from tree view to unthreaded view."
   (interactive)
-- 
2.28.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v2 1/3] emacs/tree: introduce notmuch-tree-parent-buffer variable

2020-08-11 Thread William Casarin
This variable will be used in a similar fashion to
notmuch-show-parent-buffer. It will be used to navigate between
threads from the parent search buffer.

Signed-off-by: William Casarin 
---

This is a rebased version of id:20200423234715.6633-1-j...@jb55.com on
top of Jonas' emacs cleanups.

This patch series makes it easier to navigate threads in tree mode.

Basic usage: a thread is entered via M-RET. Then you can use A to
archive and jump to the next thread.

 emacs/notmuch-tree.el | 6 +-
 emacs/notmuch.el  | 2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index fbba4bb3..29f64851 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -222,6 +222,9 @@ For example:
   "A buffer local copy of argument open-target to the function notmuch-tree.")
 (make-variable-buffer-local 'notmuch-tree-open-target)
 
+(defvar notmuch-tree-parent-buffer nil)
+(make-variable-buffer-local 'notmuch-tree-parent-buffer)
+
 (defvar notmuch-tree-message-window nil
   "The window of the message pane.
 
@@ -1050,7 +1053,7 @@ the same as for the function notmuch-tree."
  ")")
 notmuch-tree-basic-query))
 
-(defun notmuch-tree ( query query-context target buffer-name 
open-target unthreaded)
+(defun notmuch-tree ( query query-context target buffer-name 
open-target unthreaded parent-buffer)
   "Display threads matching QUERY in tree view.
 
 The arguments are:
@@ -1080,6 +1083,7 @@ The arguments are:
   ;; Don't track undo information for this buffer
   (set '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))
 
 (defun notmuch-unthreaded ( query query-context target buffer-name 
open-target)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index babddbb6..8132cea6 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -545,7 +545,7 @@ thread."
notmuch-search-query-string
nil
(notmuch-prettify-subject (notmuch-search-find-subject))
-   t))
+   t nil (current-buffer)))
 
 (defun notmuch-search-reply-to-thread ( prompt-for-sender)
   "Begin composing a reply-all to the entire current thread in a new buffer."

base-commit: 1c80020e701c7323de137c0616fc8864443d7bd3
-- 
2.28.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH] emacs/tree: add notmuch-tree-filter

2020-05-31 Thread William Casarin
Tomi Ollila  writes:

> On Sat, Apr 25 2020, William Casarin wrote:
>
>> This implements the notmuch-tree version of notmuch-show-filter-thread
>> and binds it to the L key.
>
> No reasoning in commit message why 'L' is chosen...

oh right this should probably be `l`. I think I thought it was L because
evil rebinds notmuch-show-filter-thread from `l` to `L` and I didn't
realize this until now.
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] emacs/tree: add notmuch-tree-filter

2020-04-25 Thread William Casarin
This implements the notmuch-tree version of notmuch-show-filter-thread
and binds it to the L key.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 9 +
 1 file changed, 9 insertions(+)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index e5c23de2..8f7738d7 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -328,6 +328,7 @@ FUNC."
 (define-key map "p" 'notmuch-tree-prev-matching-message)
 (define-key map "N" 'notmuch-tree-next-message)
 (define-key map "P" 'notmuch-tree-prev-message)
+(define-key map "L" 'notmuch-tree-filter)
 (define-key map (kbd "M-p") 'notmuch-tree-prev-thread)
 (define-key map (kbd "M-n") 'notmuch-tree-next-thread)
 (define-key map "k" 'notmuch-tag-jump)
@@ -965,6 +966,14 @@ Complete list of currently available key bindings:
  (insert (format " (process returned %d)" exit-status)))
(insert "\n")
 
+(defun notmuch-tree-filter (query)
+  "Filter or LIMIT the current tree based on a new query string.
+
+Reshows the current tree with matches defined by the new query-string."
+  (interactive (list (notmuch-read-query "Filter tree: ")))
+  (setq notmuch-tree-query-context (if (string= query "") nil query))
+  (notmuch-tree-refresh-view t))
+
 (defun notmuch-tree-process-filter (proc string)
   "Process and filter the output of \"notmuch show\" for tree view"
   (let ((results-buf (process-buffer proc))
-- 
2.25.1

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


Re: [PATCH 2/3] emacs/tree: enable moving to next thread in search results

2020-04-23 Thread William Casarin
William Casarin  writes:

> This introduces a new function called
> notmuch-tree-next-thread-from-search which is analogous to
> notmuch-show-next-thread. It will switch to the next or previous
> thread from the parent search results.
>
> We rename notmuch-tree-{prev,next}-thread to a more descriptive
> notmuch-tree-{prev,next}-thread-in-tree to reflect the fact that it
> only moves to the next thread in the current tree.
>
> notmuch-tree-next-thread now switches to the next thread in the
> current tree first, but if there are none, it looks for the next tree
> in the search results.
>
> This makes notmuch-tree feel more like notmuch-show when using the
> M-Enter, M-n and M-p bindings.
>
> Signed-off-by: William Casarin 
> ---
>  emacs/notmuch-tree.el | 36 ++--
>  1 file changed, 34 insertions(+), 2 deletions(-)
>
> diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
> index f38fef98..dcd335e5 100644
> --- a/emacs/notmuch-tree.el
> +++ b/emacs/notmuch-tree.el
> @@ -710,12 +710,13 @@ nil otherwise."
>  (while (not (or (notmuch-tree-get-prop :first) (eobp)))
>(forward-line -1
>  
> -(defun notmuch-tree-prev-thread ()
> +(defun notmuch-tree-prev-thread-in-tree ()
> +  "Move to the next thread in the current tree"
>(interactive)
>(forward-line -1)
>(notmuch-tree-thread-top))
>  
> -(defun notmuch-tree-next-thread ()
> +(defun notmuch-tree-next-thread-in-tree ()
>"Get the next thread in the current tree. Returns t if a thread was
>  found or nil if not."
>(interactive)
> @@ -724,6 +725,37 @@ found or nil if not."
>  (forward-line 1))
>(not (eobp)))
>  
> +(defun notmuch-tree-next-thread-from-search ( previous)
> +  "Move to the next thread in the parent search results, if any.
> +
> +If PREVIOUS is non-nil, move to the previous item in the
> +search results instead."
> +  (interactive "P")
> +  (let ((parent-buffer notmuch-tree-parent-buffer))
> +(notmuch-tree-quit t)
> +(when (buffer-live-p parent-buffer)
> +  (switch-to-buffer parent-buffer)
> +  (if previous
> +   (notmuch-search-previous-thread)
> + (notmuch-search-next-thread))
> +  (notmuch-tree-from-search-thread
> +
> +(defun notmuch-tree-next-thread ( previous)
> +  "Move to the next thread in the current tree or parent search
> +results
> +
> +If PREVIOUS is non-nil, move to the previous thread in the tree or
> +search results instead."
> +  (interactive)
> +  (unless (notmuch-tree-next-thread-in-tree)
> +(notmuch-tree-next-thread-from-search previous)))

I only have one more small fix for this in multi-threaded tree mode:


diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 6661b12e..20dd1141 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -717,10 +717,11 @@ nil otherwise."
   (forward-line -1
 
 (defun notmuch-tree-prev-thread-in-tree ()
-  "Move to the next thread in the current tree"
+  "Move to the previous thread in the current tree"
   (interactive)
   (forward-line -1)
-  (notmuch-tree-thread-top))
+  (notmuch-tree-thread-top)
+  (not (bobp)))
 
 (defun notmuch-tree-next-thread-in-tree ()
   "Get the next thread in the current tree. Returns t if a thread was
@@ -753,7 +754,8 @@ results
 If PREVIOUS is non-nil, move to the previous thread in the tree or
 search results instead."
   (interactive)
-  (unless (notmuch-tree-next-thread-in-tree)
+  (unless (if previous (notmuch-tree-prev-thread-in-tree)
+   (notmuch-tree-next-thread-in-tree))
 (notmuch-tree-next-thread-from-search previous)))
 
 (defun notmuch-tree-prev-thread ()



which I will send in a v2 once this gets some Concept ACKs. Feel free to
test in the meantime! Hopefully this makes tree-mode more usable for
people who only use notmuch-show.

Basic usage following the previous emacs/tree improvements:

Press M-Enter on a thread from search-mode to enter that thread in
notmuch-tree mode. With these patches, M-n and M-p move between search
result threads, and A works as you would expect as well (archive and
then move to next thread)

Let me know what ya'll think!

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


[PATCH 2/3] emacs/tree: enable moving to next thread in search results

2020-04-23 Thread William Casarin
This introduces a new function called
notmuch-tree-next-thread-from-search which is analogous to
notmuch-show-next-thread. It will switch to the next or previous
thread from the parent search results.

We rename notmuch-tree-{prev,next}-thread to a more descriptive
notmuch-tree-{prev,next}-thread-in-tree to reflect the fact that it
only moves to the next thread in the current tree.

notmuch-tree-next-thread now switches to the next thread in the
current tree first, but if there are none, it looks for the next tree
in the search results.

This makes notmuch-tree feel more like notmuch-show when using the
M-Enter, M-n and M-p bindings.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 36 ++--
 1 file changed, 34 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index f38fef98..dcd335e5 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -710,12 +710,13 @@ nil otherwise."
 (while (not (or (notmuch-tree-get-prop :first) (eobp)))
   (forward-line -1
 
-(defun notmuch-tree-prev-thread ()
+(defun notmuch-tree-prev-thread-in-tree ()
+  "Move to the next thread in the current tree"
   (interactive)
   (forward-line -1)
   (notmuch-tree-thread-top))
 
-(defun notmuch-tree-next-thread ()
+(defun notmuch-tree-next-thread-in-tree ()
   "Get the next thread in the current tree. Returns t if a thread was
 found or nil if not."
   (interactive)
@@ -724,6 +725,37 @@ found or nil if not."
 (forward-line 1))
   (not (eobp)))
 
+(defun notmuch-tree-next-thread-from-search ( previous)
+  "Move to the next thread in the parent search results, if any.
+
+If PREVIOUS is non-nil, move to the previous item in the
+search results instead."
+  (interactive "P")
+  (let ((parent-buffer notmuch-tree-parent-buffer))
+(notmuch-tree-quit t)
+(when (buffer-live-p parent-buffer)
+  (switch-to-buffer parent-buffer)
+  (if previous
+ (notmuch-search-previous-thread)
+   (notmuch-search-next-thread))
+  (notmuch-tree-from-search-thread
+
+(defun notmuch-tree-next-thread ( previous)
+  "Move to the next thread in the current tree or parent search
+results
+
+If PREVIOUS is non-nil, move to the previous thread in the tree or
+search results instead."
+  (interactive)
+  (unless (notmuch-tree-next-thread-in-tree)
+(notmuch-tree-next-thread-from-search previous)))
+
+(defun notmuch-tree-prev-thread ()
+  "Move to the previous thread in the current tree or parent search
+results"
+  (interactive)
+  (notmuch-tree-next-thread t))
+
 (defun notmuch-tree-thread-mapcar (function)
   "Iterate through all messages in the current thread
  and call FUNCTION for side effects."
-- 
2.25.1

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


[PATCH 3/3] emacs/tree: add notmuch-tree-archive-thread-then-next

2020-04-23 Thread William Casarin
Now that notmuch-tree-next-thread acts more like its notmuch-show
counterpart, let's update the binding to move to the next thread after
archiving.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index dcd335e5..6661b12e 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -325,7 +325,7 @@ FUNC."
 (define-key map [mouse-1] 'notmuch-tree-show-message)
 (define-key map "x" 'notmuch-tree-archive-message-then-next-or-exit)
 (define-key map "X" 'notmuch-tree-archive-thread-then-exit)
-(define-key map "A" 'notmuch-tree-archive-thread)
+(define-key map "A" 'notmuch-tree-archive-thread-then-next)
 (define-key map "a" 'notmuch-tree-archive-message-then-next)
 (define-key map "z" 'notmuch-tree-to-tree)
 (define-key map "n" 'notmuch-tree-next-matching-message)
@@ -481,6 +481,12 @@ NOT change the database."
 (notmuch-tree-close-message-window)
 (notmuch-tree query)))
 
+(defun notmuch-tree-archive-thread-then-next ()
+  "Archive all messages in the current buffer, then show next thread from 
search."
+  (interactive)
+  (notmuch-tree-archive-thread)
+  (notmuch-tree-next-thread))
+
 (defun notmuch-unthreaded-from-tree-current-query ()
   "Switch from tree view to unthreaded view"
   (interactive)
-- 
2.25.1

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


[PATCH 1/3] emacs/tree: introduce notmuch-tree-parent-buffer variable

2020-04-23 Thread William Casarin
This variable will be used in a similar fashion to
notmuch-show-parent-buffer. It will be used to navigate between
threads from the parent search buffer.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 7 ++-
 emacs/notmuch.el  | 4 +++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 701d12f8..f38fef98 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -219,6 +219,9 @@ Note the author string should not contain
   "A buffer local copy of argument open-target to the function notmuch-tree")
 (make-variable-buffer-local 'notmuch-tree-open-target)
 
+(defvar notmuch-tree-parent-buffer nil)
+(make-variable-buffer-local 'notmuch-tree-parent-buffer)
+
 (defvar notmuch-tree-message-window nil
   "The window of the message pane.
 
@@ -1037,7 +1040,7 @@ the same as for the function notmuch-tree."
  ")")
 notmuch-tree-basic-query))
 
-(defun notmuch-tree ( query query-context target buffer-name 
open-target unthreaded)
+(defun notmuch-tree ( query query-context target buffer-name 
open-target unthreaded parent-buffer)
   "Display threads matching QUERY in Tree View.
 
 The arguments are:
@@ -1070,6 +1073,8 @@ The arguments are:
 
   (notmuch-tree-worker query query-context target open-target unthreaded)
 
+  (setq notmuch-tree-parent-buffer parent-buffer)
+
   (setq truncate-lines t))
 
 (defun notmuch-unthreaded ( query query-context target buffer-name 
open-target)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index f5f03244..a7cdd893 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -536,7 +536,9 @@ thread."
 notmuch-search-query-string
nil
 (notmuch-prettify-subject (notmuch-search-find-subject))
-   t))
+   t
+   nil
+   (current-buffer)))
 
 (defun notmuch-search-reply-to-thread ( prompt-for-sender)
   "Begin composing a reply-all to the entire current thread in a new buffer."
-- 
2.25.1

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


[PATCH] emacs/tree: add notmuch-tree-quit-all

2020-04-23 Thread William Casarin
This is a simple binding in notmuch-tree-mode that closes both the
message buffer and thread buffer at the same time. This is a common
action after entering a thread from search with M-Enter.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 5 +
 1 file changed, 5 insertions(+)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index e5c23de2..701d12f8 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -293,6 +293,7 @@ FUNC."
 ;; Override because we want to close message pane first.
 (define-key map [remap notmuch-jump-search] 
(notmuch-tree-close-message-pane-and #'notmuch-jump-search))
 
+(define-key map "Q" 'notmuch-tree-quit-all)
 (define-key map "S" 'notmuch-search-from-tree-current-query)
 (define-key map "U" 'notmuch-unthreaded-from-tree-current-query)
 (define-key map "Z" 'notmuch-tree-from-unthreaded-current-query)
@@ -591,6 +592,10 @@ Shows in split pane or whole window according to value of
   (when (or (not (notmuch-tree-close-message-window)) kill-both)
 (kill-buffer (current-buffer
 
+(defun notmuch-tree-quit-all ()
+  (interactive)
+  (notmuch-tree-quit t))
+
 (defun notmuch-tree-close-message-window ()
   "Close the message-window. Return t if close succeeds."
   (interactive)
-- 
2.25.1

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


[PATCH] emacs: Use `cl-lib' instead of deprecated `cl'

2020-04-16 Thread William Casarin
From: Jonas Bernoulli 

Starting with Emacs 27 the old `cl' implementation is finally
considered obsolete.  Previously its use was strongly discouraged
at run-time but one was still allowed to use it at compile-time.

For the most part the transition is very simple and boils down to
adding the "cl-" prefix to some symbols.  A few replacements do not
follow that simple pattern; e.g. `first' is replaced with `car',
even though the alias `cl-first' exists, because the latter is not
idiomatic emacs-lisp.

In a few cases we start using `pcase-let' or `pcase-lambda' instead
of renaming e.g. `first' to `car'.  That way we can remind the reader
of the meaning of the various parts of the data that is being
deconstructed.

An obsolete `lexical-let' and a `lexical-let*' are replaced with their
regular variants `let' and `let*' even though we do not at the same
time enable `lexical-binding' for that file.  That is the right thing
to do because it does not actually make a difference in those cases
whether lexical bindings are used or not, and because this should be
enabled in a separate commit.

We need to explicitly depend on the `cl-lib' package because Emacs
24.1 and 24.2 lack that library.  When using these releases we end
up using the backport from GNU Elpa.

We need to explicitly require the `pcase' library because
`pcase-dolist' was not autoloaded until Emacs 25.1.
---

Thanks Jonas!

I couldn't get this patch to cleanly apply, so I've rebased it on master
for anyone who wants to test.

Cheers,
Will

 emacs/notmuch-company.el |   5 +-
 emacs/notmuch-draft.el   |   2 +-
 emacs/notmuch-hello.el   | 147 ++-
 emacs/notmuch-jump.el|  45 +--
 emacs/notmuch-lib.el |  18 ++---
 emacs/notmuch-maildir-fcc.el |  35 +
 emacs/notmuch-mua.el |  76 +-
 emacs/notmuch-parser.el  |  18 ++---
 emacs/notmuch-pkg.el.tmpl|   3 +-
 emacs/notmuch-show.el| 103 
 emacs/notmuch-tag.el |  45 ++-
 emacs/notmuch-tree.el|  20 ++---
 emacs/notmuch.el |  62 +++
 test/test-lib.el |   2 +-
 14 files changed, 292 insertions(+), 289 deletions(-)

diff --git a/emacs/notmuch-company.el b/emacs/notmuch-company.el
index 3e12e7a9..ac998f9b 100644
--- a/emacs/notmuch-company.el
+++ b/emacs/notmuch-company.el
@@ -27,7 +27,8 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
+
 (require 'notmuch-lib)
 
 (defvar notmuch-company-last-prefix nil)
@@ -65,7 +66,7 @@
   (require 'company)
   (let ((case-fold-search t)
(completion-ignore-case t))
-(case command
+(cl-case command
   (interactive (company-begin-backend 'notmuch-company))
   (prefix (and (derived-mode-p 'message-mode)
   (looking-back (concat 
notmuch-address-completion-headers-regexp ".*")
diff --git a/emacs/notmuch-draft.el b/emacs/notmuch-draft.el
index e22e0d16..504b33be 100644
--- a/emacs/notmuch-draft.el
+++ b/emacs/notmuch-draft.el
@@ -152,7 +152,7 @@ Used when a new version is saved, or the message is sent."
   "Checks if we should save a message that should be encrypted.
 
 `notmuch-draft-save-plaintext' controls the behaviour."
-  (case notmuch-draft-save-plaintext
+  (cl-case notmuch-draft-save-plaintext
((ask)
 (unless (yes-or-no-p "(Customize `notmuch-draft-save-plaintext' to 
avoid this warning)
 This message contains mml tags that suggest it is intended to be encrypted.
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index ab6ee798..bdf584e6 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -21,7 +21,8 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
+
 (require 'widget)
 (require 'wid-edit) ; For `widget-forward'.
 
@@ -47,17 +48,19 @@ lists (NAME QUERY COUNT-QUERY)."
((keywordp (car saved-search))
 (plist-get saved-search field))
;; It is not a plist so it is an old-style entry.
-   ((consp (cdr saved-search)) ;; It is a list (NAME QUERY COUNT-QUERY)
-(case field
-  (:name (first saved-search))
-  (:query (second saved-search))
-  (:count-query (third saved-search))
-  (t nil)))
-   (t  ;; It is a cons-cell (NAME . QUERY)
-(case field
-  (:name (car saved-search))
-  (:query (cdr saved-search))
-  (t nil)
+   ((consp (cdr saved-search))
+(pcase-let ((`(,name ,query ,count-query) saved-search))
+  (cl-case field
+   (:name name)
+   (:query query)
+   (:count-query count-query)
+   (t nil
+   (t
+(pcase-let ((`(,name . ,query) saved-search))
+  (cl-case field
+   (:name name)
+   (:query query)
+   (t nil))
 
 (defun notmuch-hello-saved-search-to-plist (saved-search)
   "Return a copy of SAVED-SEARCH in plist form.
@@ -66,7 +69,7 @@ If saved search is a plist then just return a copy. In other
 cases, for backwards 

Re: [PATCH 1/7] emacs/tree: return true if a thread was found in next-thread

2020-04-04 Thread William Casarin


William Casarin  writes:

> This will allow us to pop back to parent buffers when there are no
> more threads to jump to.
>
> Signed-off-by: William Casarin 
> ---
>
>  This is as rebased version of id:20191228150124.20630-1-j...@jb55.com
>  as requested in id:87v9mg3gut@tethera.net 

sorry I included some duplicate patches in here, but they should be identical.
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v4 4/7] emacs/tree: add kill-both prefix argument to notmuch-tree-quit

2020-04-04 Thread William Casarin
This allows us to close both windows at the same time.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index e6a6e67f..b405e9e3 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -584,10 +584,10 @@ Shows in split pane or whole window according to value of
   (when (notmuch-tree-scroll-message-window)
 (notmuch-tree-next-matching-message)))
 
-(defun notmuch-tree-quit ()
+(defun notmuch-tree-quit ( kill-both)
   "Close the split view or exit tree."
-  (interactive)
-  (unless (notmuch-tree-close-message-window)
+  (interactive "P")
+  (when (or (not (notmuch-tree-close-message-window)) kill-both)
 (kill-buffer (current-buffer
 
 (defun notmuch-tree-close-message-window ()
-- 
2.25.1

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


[PATCH v4 5/7] emacs/tree: add notmuch-tree-archive-message-than-next-or-exit

2020-04-04 Thread William Casarin
This is the notmuch-tree version of
notmuch-show-archive-message-than-next-or-exit.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 30 --
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index b405e9e3..02bdd1ee 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -617,6 +617,15 @@ message will be \"unarchived\", i.e. the tag changes in
   (notmuch-tree-archive-message unarchive)
   (notmuch-tree-next-matching-message))
 
+(defun notmuch-tree-archive-message-then-next-or-exit ()
+  "Archive current message, then show next open message in current thread.
+
+If at the last open message in the current thread, then exit back
+to search results."
+  (interactive)
+  (notmuch-tree-archive-message)
+  (notmuch-tree-next-matching-message t))
+
 (defun notmuch-tree-next-message ()
   "Move to next message."
   (interactive)
@@ -643,23 +652,24 @@ nil otherwise."
   (forward-line dir))
 (not (funcall eobfn
 
-(defun notmuch-tree-matching-message ( prev)
+(defun notmuch-tree-matching-message ( prev pop-at-end)
   "Move to the next or previous matching message"
   (interactive "P")
   (forward-line (if prev -1 nil))
-  (notmuch-tree-goto-matching-message prev)
-  (when (window-live-p notmuch-tree-message-window)
-(notmuch-tree-show-message-in)))
+  (if (and (not (notmuch-tree-goto-matching-message prev)) pop-at-end)
+  (notmuch-tree-quit pop-at-end)
+(when (window-live-p notmuch-tree-message-window)
+  (notmuch-tree-show-message-in
 
-(defun notmuch-tree-prev-matching-message ()
+(defun notmuch-tree-prev-matching-message ( pop-at-end)
   "Move to previous matching message."
-  (interactive)
-  (notmuch-tree-matching-message t))
+  (interactive "P")
+  (notmuch-tree-matching-message t pop-at-end))
 
-(defun notmuch-tree-next-matching-message ()
+(defun notmuch-tree-next-matching-message ( pop-at-end)
   "Move to next matching message."
-  (interactive)
-  (notmuch-tree-matching-message))
+  (interactive "P")
+  (notmuch-tree-matching-message nil pop-at-end))
 
 (defun notmuch-tree-refresh-view ( view)
   "Refresh view."
-- 
2.25.1

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


[PATCH v4 7/7] emacs/tree: add x/X bindings

2020-04-04 Thread William Casarin
Add x and X binds to notmuch-tree for functionally that we have in
notmuch-show.

The notmuch-tree-quit binding is somewhat redundant, since it is
handled by notmuch-bury-or-kill-this-buffer which is bound to q.

Signed-off-by: William Casarin 
---
 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 470cd517..e5c23de2 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -319,7 +319,8 @@ FUNC."
 ;; The main tree view bindings
 (define-key map (kbd "RET") 'notmuch-tree-show-message)
 (define-key map [mouse-1] 'notmuch-tree-show-message)
-(define-key map "x" 'notmuch-tree-quit)
+(define-key map "x" 'notmuch-tree-archive-message-then-next-or-exit)
+(define-key map "X" 'notmuch-tree-archive-thread-then-exit)
 (define-key map "A" 'notmuch-tree-archive-thread)
 (define-key map "a" 'notmuch-tree-archive-message-then-next)
 (define-key map "z" 'notmuch-tree-to-tree)
-- 
2.25.1

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


[PATCH v4 3/7] emacs/tree: add notmuch-tree-matching-message

2020-04-04 Thread William Casarin
This functions removes some duplicate logic between
notmuch-tree-{next,prev}-matching-message

We do this because we will be adding some additional logic similar to
the notmuch-show-next-open-message function, and it will help if this
logic is all in one place.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 7f68efba..e6a6e67f 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -643,21 +643,23 @@ nil otherwise."
   (forward-line dir))
 (not (funcall eobfn
 
+(defun notmuch-tree-matching-message ( prev)
+  "Move to the next or previous matching message"
+  (interactive "P")
+  (forward-line (if prev -1 nil))
+  (notmuch-tree-goto-matching-message prev)
+  (when (window-live-p notmuch-tree-message-window)
+(notmuch-tree-show-message-in)))
+
 (defun notmuch-tree-prev-matching-message ()
   "Move to previous matching message."
   (interactive)
-  (forward-line -1)
-  (notmuch-tree-goto-matching-message t)
-  (when (window-live-p notmuch-tree-message-window)
-(notmuch-tree-show-message-in)))
+  (notmuch-tree-matching-message t))
 
 (defun notmuch-tree-next-matching-message ()
   "Move to next matching message."
   (interactive)
-  (forward-line)
-  (notmuch-tree-goto-matching-message)
-  (when (window-live-p notmuch-tree-message-window)
-(notmuch-tree-show-message-in)))
+  (notmuch-tree-matching-message))
 
 (defun notmuch-tree-refresh-view ( view)
   "Refresh view."
-- 
2.25.1

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


[PATCH v4 6/7] emacs/tree: add notmuch-tree-archive-thread-then-exit

2020-04-04 Thread William Casarin
This is the notmuch-tree version of
notmuch-show-archive-thread-then-exit

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 02bdd1ee..470cd517 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -617,6 +617,12 @@ message will be \"unarchived\", i.e. the tag changes in
   (notmuch-tree-archive-message unarchive)
   (notmuch-tree-next-matching-message))
 
+(defun notmuch-tree-archive-thread-then-exit ()
+  "Archive all messages in the current buffer, then exit notmuch-tree."
+  (interactive)
+  (notmuch-tree-archive-thread)
+  (notmuch-tree-quit t))
+
 (defun notmuch-tree-archive-message-then-next-or-exit ()
   "Archive current message, then show next open message in current thread.
 
-- 
2.25.1

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


[PATCH v4 2/7] emacs/tree: add notmuch-tree-goto-matching-message

2020-04-04 Thread William Casarin
This function captures some common logic when jumping to matching
messages in notmuch-tree mode.

We also add a new return value (t or nil), that indicates if there was
a next matching message in the thread to show.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 1bcf6cf9..7f68efba 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -631,12 +631,23 @@ message will be \"unarchived\", i.e. the tag changes in
   (when (window-live-p notmuch-tree-message-window)
 (notmuch-tree-show-message-in)))
 
+(defun notmuch-tree-goto-matching-message ( prev)
+  "Move to the next or previous matching message.
+
+Returns t if there was a next matching message in the thread to show,
+nil otherwise."
+  (let ((dir (if prev -1 nil))
+   (eobfn (if prev #'bobp #'eobp)))
+(while (and (not (funcall eobfn))
+   (not (notmuch-tree-get-match)))
+  (forward-line dir))
+(not (funcall eobfn
+
 (defun notmuch-tree-prev-matching-message ()
   "Move to previous matching message."
   (interactive)
   (forward-line -1)
-  (while (and (not (bobp)) (not (notmuch-tree-get-match)))
-(forward-line -1))
+  (notmuch-tree-goto-matching-message t)
   (when (window-live-p notmuch-tree-message-window)
 (notmuch-tree-show-message-in)))
 
@@ -644,8 +655,7 @@ message will be \"unarchived\", i.e. the tag changes in
   "Move to next matching message."
   (interactive)
   (forward-line)
-  (while (and (not (eobp)) (not (notmuch-tree-get-match)))
-(forward-line))
+  (notmuch-tree-goto-matching-message)
   (when (window-live-p notmuch-tree-message-window)
 (notmuch-tree-show-message-in)))
 
-- 
2.25.1

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


[PATCH v4 1/7] emacs/tree: return true if a thread was found in next-thread

2020-04-04 Thread William Casarin
This will allow us to pop back to parent buffers when there are no
more threads to jump to.

Signed-off-by: William Casarin 
---

This is just a rebased version of v3 id:20191228150124.20630-1-j...@jb55.com
as requested in id:87v9mg3gut@tethera.net 

 emacs/notmuch-tree.el | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 9a83292c..1bcf6cf9 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -679,10 +679,13 @@ message will be \"unarchived\", i.e. the tag changes in
   (notmuch-tree-thread-top))
 
 (defun notmuch-tree-next-thread ()
+  "Get the next thread in the current tree. Returns t if a thread was
+found or nil if not."
   (interactive)
   (forward-line 1)
   (while (not (or (notmuch-tree-get-prop :first) (eobp)))
-(forward-line 1)))
+(forward-line 1))
+  (not (eobp)))
 
 (defun notmuch-tree-thread-mapcar (function)
   "Iterate through all messages in the current thread

base-commit: 144cf30e2c71d57795b5fbdec10af0ef73aa01ff
-- 
2.25.1
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 2/7] emacs/tree: add notmuch-tree-goto-matching-message

2020-04-04 Thread William Casarin
This function captures some common logic when jumping to matching
messages in notmuch-tree mode.

We also add a new return value (t or nil), that indicates if there was
a next matching message in the thread to show.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 1bcf6cf9..7f68efba 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -631,12 +631,23 @@ message will be \"unarchived\", i.e. the tag changes in
   (when (window-live-p notmuch-tree-message-window)
 (notmuch-tree-show-message-in)))
 
+(defun notmuch-tree-goto-matching-message ( prev)
+  "Move to the next or previous matching message.
+
+Returns t if there was a next matching message in the thread to show,
+nil otherwise."
+  (let ((dir (if prev -1 nil))
+   (eobfn (if prev #'bobp #'eobp)))
+(while (and (not (funcall eobfn))
+   (not (notmuch-tree-get-match)))
+  (forward-line dir))
+(not (funcall eobfn
+
 (defun notmuch-tree-prev-matching-message ()
   "Move to previous matching message."
   (interactive)
   (forward-line -1)
-  (while (and (not (bobp)) (not (notmuch-tree-get-match)))
-(forward-line -1))
+  (notmuch-tree-goto-matching-message t)
   (when (window-live-p notmuch-tree-message-window)
 (notmuch-tree-show-message-in)))
 
@@ -644,8 +655,7 @@ message will be \"unarchived\", i.e. the tag changes in
   "Move to next matching message."
   (interactive)
   (forward-line)
-  (while (and (not (eobp)) (not (notmuch-tree-get-match)))
-(forward-line))
+  (notmuch-tree-goto-matching-message)
   (when (window-live-p notmuch-tree-message-window)
 (notmuch-tree-show-message-in)))
 
-- 
2.25.1

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


[PATCH 3/7] emacs/tree: add notmuch-tree-matching-message

2020-04-04 Thread William Casarin
This functions removes some duplicate logic between
notmuch-tree-{next,prev}-matching-message

We do this because we will be adding some additional logic similar to
the notmuch-show-next-open-message function, and it will help if this
logic is all in one place.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 7f68efba..e6a6e67f 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -643,21 +643,23 @@ nil otherwise."
   (forward-line dir))
 (not (funcall eobfn
 
+(defun notmuch-tree-matching-message ( prev)
+  "Move to the next or previous matching message"
+  (interactive "P")
+  (forward-line (if prev -1 nil))
+  (notmuch-tree-goto-matching-message prev)
+  (when (window-live-p notmuch-tree-message-window)
+(notmuch-tree-show-message-in)))
+
 (defun notmuch-tree-prev-matching-message ()
   "Move to previous matching message."
   (interactive)
-  (forward-line -1)
-  (notmuch-tree-goto-matching-message t)
-  (when (window-live-p notmuch-tree-message-window)
-(notmuch-tree-show-message-in)))
+  (notmuch-tree-matching-message t))
 
 (defun notmuch-tree-next-matching-message ()
   "Move to next matching message."
   (interactive)
-  (forward-line)
-  (notmuch-tree-goto-matching-message)
-  (when (window-live-p notmuch-tree-message-window)
-(notmuch-tree-show-message-in)))
+  (notmuch-tree-matching-message))
 
 (defun notmuch-tree-refresh-view ( view)
   "Refresh view."
-- 
2.25.1

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


[PATCH 1/7] emacs/tree: return true if a thread was found in next-thread

2020-04-04 Thread William Casarin
This will allow us to pop back to parent buffers when there are no
more threads to jump to.

Signed-off-by: William Casarin 
---

 This is as rebased version of id:20191228150124.20630-1-j...@jb55.com
 as requested in id:87v9mg3gut@tethera.net 

 emacs/notmuch-tree.el | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 9a83292c..1bcf6cf9 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -679,10 +679,13 @@ message will be \"unarchived\", i.e. the tag changes in
   (notmuch-tree-thread-top))
 
 (defun notmuch-tree-next-thread ()
+  "Get the next thread in the current tree. Returns t if a thread was
+found or nil if not."
   (interactive)
   (forward-line 1)
   (while (not (or (notmuch-tree-get-prop :first) (eobp)))
-(forward-line 1)))
+(forward-line 1))
+  (not (eobp)))
 
 (defun notmuch-tree-thread-mapcar (function)
   "Iterate through all messages in the current thread
-- 
2.25.1

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


[PATCH 5/7] emacs/tree: add notmuch-tree-archive-message-than-next-or-exit

2020-04-04 Thread William Casarin
This is the notmuch-tree version of
notmuch-show-archive-message-than-next-or-exit.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 30 --
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index b405e9e3..02bdd1ee 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -617,6 +617,15 @@ message will be \"unarchived\", i.e. the tag changes in
   (notmuch-tree-archive-message unarchive)
   (notmuch-tree-next-matching-message))
 
+(defun notmuch-tree-archive-message-then-next-or-exit ()
+  "Archive current message, then show next open message in current thread.
+
+If at the last open message in the current thread, then exit back
+to search results."
+  (interactive)
+  (notmuch-tree-archive-message)
+  (notmuch-tree-next-matching-message t))
+
 (defun notmuch-tree-next-message ()
   "Move to next message."
   (interactive)
@@ -643,23 +652,24 @@ nil otherwise."
   (forward-line dir))
 (not (funcall eobfn
 
-(defun notmuch-tree-matching-message ( prev)
+(defun notmuch-tree-matching-message ( prev pop-at-end)
   "Move to the next or previous matching message"
   (interactive "P")
   (forward-line (if prev -1 nil))
-  (notmuch-tree-goto-matching-message prev)
-  (when (window-live-p notmuch-tree-message-window)
-(notmuch-tree-show-message-in)))
+  (if (and (not (notmuch-tree-goto-matching-message prev)) pop-at-end)
+  (notmuch-tree-quit pop-at-end)
+(when (window-live-p notmuch-tree-message-window)
+  (notmuch-tree-show-message-in
 
-(defun notmuch-tree-prev-matching-message ()
+(defun notmuch-tree-prev-matching-message ( pop-at-end)
   "Move to previous matching message."
-  (interactive)
-  (notmuch-tree-matching-message t))
+  (interactive "P")
+  (notmuch-tree-matching-message t pop-at-end))
 
-(defun notmuch-tree-next-matching-message ()
+(defun notmuch-tree-next-matching-message ( pop-at-end)
   "Move to next matching message."
-  (interactive)
-  (notmuch-tree-matching-message))
+  (interactive "P")
+  (notmuch-tree-matching-message nil pop-at-end))
 
 (defun notmuch-tree-refresh-view ( view)
   "Refresh view."
-- 
2.25.1

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


[PATCH 4/7] emacs/tree: add kill-both prefix argument to notmuch-tree-quit

2020-04-04 Thread William Casarin
This allows us to close both windows at the same time.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index e6a6e67f..b405e9e3 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -584,10 +584,10 @@ Shows in split pane or whole window according to value of
   (when (notmuch-tree-scroll-message-window)
 (notmuch-tree-next-matching-message)))
 
-(defun notmuch-tree-quit ()
+(defun notmuch-tree-quit ( kill-both)
   "Close the split view or exit tree."
-  (interactive)
-  (unless (notmuch-tree-close-message-window)
+  (interactive "P")
+  (when (or (not (notmuch-tree-close-message-window)) kill-both)
 (kill-buffer (current-buffer
 
 (defun notmuch-tree-close-message-window ()
-- 
2.25.1

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


Re: [PATCH v3 0/7] Port notmuch-show's x/X bindings to notmuch-tree

2020-03-23 Thread William Casarin


Hey there,

David Edmondson  writes:
> On Friday, 2020-02-21 at 09:06:46 -08, William Casarin wrote:
>
>> Daniel Kahn Gillmor  writes:
>>
>>> On Sat 2019-12-28 10:01:17 -0500, William Casarin wrote:
>>>> These patches bring notmuch-tree more in line with the user experience
>>>> of notmuch-show by adding the x/X bindings.
>>>
>>> It looks like this series has been reviewed by dme, and is presumably
>>> approved by him, with the exception of patch 3/7, which
>>> id:m25zhyxasu@dme.org suggests some improvement on.
>>>
>>> William, would you be up for doing one last re-spin of this series to
>>> address dme's comments?  it'd be nice to land this series unless someone
>>> raises objections.
>>
>> I was planning on it but it fell by the wayside. The only comment was
>> just a naming thing, perhaps we can just pull this and rename it in a
>> future patch?
>
> That would be fine with me.

This set should be ready to go!

One thing that I want to do after this is start working on the 'A'
binding for notmuch-tree. It will be nice to skip through threads in
notmuch-tree from the search results like you can do in notmuch-show.

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


Re: [PATCH v3 0/7] Port notmuch-show's x/X bindings to notmuch-tree

2020-02-21 Thread William Casarin
Daniel Kahn Gillmor  writes:

> On Sat 2019-12-28 10:01:17 -0500, William Casarin wrote:
>> These patches bring notmuch-tree more in line with the user experience
>> of notmuch-show by adding the x/X bindings.
>
> It looks like this series has been reviewed by dme, and is presumably
> approved by him, with the exception of patch 3/7, which
> id:m25zhyxasu@dme.org suggests some improvement on.
>
> William, would you be up for doing one last re-spin of this series to
> address dme's comments?  it'd be nice to land this series unless someone
> raises objections.

I was planning on it but it fell by the wayside. The only comment was
just a naming thing, perhaps we can just pull this and rename it in a
future patch? I could do a whole new series but I feel like that is
overkill.
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v3 6/7] emacs/tree: add notmuch-tree-archive-thread-then-exit

2019-12-28 Thread William Casarin
This is the notmuch-tree version of
notmuch-show-archive-thread-then-exit

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index cdf68ed4..e9c0433c 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -563,6 +563,12 @@ message will be \"unarchived\", i.e. the tag changes in
   (notmuch-tree-archive-message unarchive)
   (notmuch-tree-next-matching-message))
 
+(defun notmuch-tree-archive-thread-then-exit ()
+  "Archive all messages in the current buffer, then exit notmuch-tree."
+  (interactive)
+  (notmuch-tree-archive-thread)
+  (notmuch-tree-quit t))
+
 (defun notmuch-tree-archive-message-then-next-or-exit ()
   "Archive current message, then show next open message in current thread.
 
-- 
2.24.0

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


[PATCH v3 7/7] emacs/tree: add x/X bindings

2019-12-28 Thread William Casarin
Add x and X binds to notmuch-tree for functionally that we have in
notmuch-show.

The notmuch-tree-quit binding is somewhat redundant, since it is
handled by notmuch-bury-or-kill-this-buffer which is bound to q.

Signed-off-by: William Casarin 
---
 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 e9c0433c..987cc81e 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -277,7 +277,8 @@ FUNC."
 ;; The main tree view bindings
 (define-key map (kbd "RET") 'notmuch-tree-show-message)
 (define-key map [mouse-1] 'notmuch-tree-show-message)
-(define-key map "x" 'notmuch-tree-quit)
+(define-key map "x" 'notmuch-tree-archive-message-then-next-or-exit)
+(define-key map "X" 'notmuch-tree-archive-thread-then-exit)
 (define-key map "A" 'notmuch-tree-archive-thread)
 (define-key map "a" 'notmuch-tree-archive-message-then-next)
 (define-key map "z" 'notmuch-tree-to-tree)
-- 
2.24.0

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


[PATCH v3 5/7] emacs/tree: add notmuch-tree-archive-message-than-next-or-exit

2019-12-28 Thread William Casarin
This is the notmuch-tree version of
notmuch-show-archive-message-than-next-or-exit.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 30 --
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index f66219c5..cdf68ed4 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -563,6 +563,15 @@ message will be \"unarchived\", i.e. the tag changes in
   (notmuch-tree-archive-message unarchive)
   (notmuch-tree-next-matching-message))
 
+(defun notmuch-tree-archive-message-then-next-or-exit ()
+  "Archive current message, then show next open message in current thread.
+
+If at the last open message in the current thread, then exit back
+to search results."
+  (interactive)
+  (notmuch-tree-archive-message)
+  (notmuch-tree-next-matching-message t))
+
 (defun notmuch-tree-next-message ()
   "Move to next message."
   (interactive)
@@ -589,23 +598,24 @@ nil otherwise."
   (forward-line dir))
 (not (funcall eobfn
 
-(defun notmuch-tree-matching-message ( prev)
+(defun notmuch-tree-matching-message ( prev pop-at-end)
   "Move to the next or previous matching message"
   (interactive "P")
   (forward-line (if prev -1 nil))
-  (notmuch-tree-goto-matching-message prev)
-  (when (window-live-p notmuch-tree-message-window)
-(notmuch-tree-show-message-in)))
+  (if (and (not (notmuch-tree-goto-matching-message prev)) pop-at-end)
+  (notmuch-tree-quit pop-at-end)
+(when (window-live-p notmuch-tree-message-window)
+  (notmuch-tree-show-message-in
 
-(defun notmuch-tree-prev-matching-message ()
+(defun notmuch-tree-prev-matching-message ( pop-at-end)
   "Move to previous matching message."
-  (interactive)
-  (notmuch-tree-matching-message t))
+  (interactive "P")
+  (notmuch-tree-matching-message t pop-at-end))
 
-(defun notmuch-tree-next-matching-message ()
+(defun notmuch-tree-next-matching-message ( pop-at-end)
   "Move to next matching message."
-  (interactive)
-  (notmuch-tree-matching-message))
+  (interactive "P")
+  (notmuch-tree-matching-message nil pop-at-end))
 
 (defun notmuch-tree-refresh-view ()
   "Refresh view."
-- 
2.24.0

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


[PATCH v3 3/7] emacs/tree: add notmuch-tree-matching-message

2019-12-28 Thread William Casarin
This functions removes some duplicate logic between
notmuch-tree-{next,prev}-matching-message

We do this because we will be adding some additional logic similar to
the notmuch-show-next-open-message function, and it will help if this
logic is all in one place.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 18fdb1c0..25d84f45 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -589,21 +589,23 @@ nil otherwise."
   (forward-line dir))
 (not (funcall eobfn
 
+(defun notmuch-tree-matching-message ( prev)
+  "Move to the next or previous matching message"
+  (interactive "P")
+  (forward-line (if prev -1 nil))
+  (notmuch-tree-goto-matching-message prev)
+  (when (window-live-p notmuch-tree-message-window)
+(notmuch-tree-show-message-in)))
+
 (defun notmuch-tree-prev-matching-message ()
   "Move to previous matching message."
   (interactive)
-  (forward-line -1)
-  (notmuch-tree-goto-matching-message t)
-  (when (window-live-p notmuch-tree-message-window)
-(notmuch-tree-show-message-in)))
+  (notmuch-tree-matching-message t))
 
 (defun notmuch-tree-next-matching-message ()
   "Move to next matching message."
   (interactive)
-  (forward-line)
-  (notmuch-tree-goto-matching-message)
-  (when (window-live-p notmuch-tree-message-window)
-(notmuch-tree-show-message-in)))
+  (notmuch-tree-matching-message))
 
 (defun notmuch-tree-refresh-view ()
   "Refresh view."
-- 
2.24.0

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


[PATCH v3 2/7] emacs/tree: add notmuch-tree-goto-matching-message

2019-12-28 Thread William Casarin
This function captures some common logic when jumping to matching
messages in notmuch-tree mode.

We also add a new return value (t or nil), that indicates if there was
a next matching message in the thread to show.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index d262ba26..18fdb1c0 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -577,12 +577,23 @@ message will be \"unarchived\", i.e. the tag changes in
   (when (window-live-p notmuch-tree-message-window)
 (notmuch-tree-show-message-in)))
 
+(defun notmuch-tree-goto-matching-message ( prev)
+  "Move to the next or previous matching message.
+
+Returns t if there was a next matching message in the thread to show,
+nil otherwise."
+  (let ((dir (if prev -1 nil))
+   (eobfn (if prev #'bobp #'eobp)))
+(while (and (not (funcall eobfn))
+   (not (notmuch-tree-get-match)))
+  (forward-line dir))
+(not (funcall eobfn
+
 (defun notmuch-tree-prev-matching-message ()
   "Move to previous matching message."
   (interactive)
   (forward-line -1)
-  (while (and (not (bobp)) (not (notmuch-tree-get-match)))
-(forward-line -1))
+  (notmuch-tree-goto-matching-message t)
   (when (window-live-p notmuch-tree-message-window)
 (notmuch-tree-show-message-in)))
 
@@ -590,8 +601,7 @@ message will be \"unarchived\", i.e. the tag changes in
   "Move to next matching message."
   (interactive)
   (forward-line)
-  (while (and (not (eobp)) (not (notmuch-tree-get-match)))
-(forward-line))
+  (notmuch-tree-goto-matching-message)
   (when (window-live-p notmuch-tree-message-window)
 (notmuch-tree-show-message-in)))
 
-- 
2.24.0

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


[PATCH v3 4/7] emacs/tree: add kill-both prefix argument to notmuch-tree-quit

2019-12-28 Thread William Casarin
This allows us to close both windows at the same time.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 25d84f45..f66219c5 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -530,10 +530,10 @@ Shows in split pane or whole window according to value of
   (when (notmuch-tree-scroll-message-window)
 (notmuch-tree-next-matching-message)))
 
-(defun notmuch-tree-quit ()
+(defun notmuch-tree-quit ( kill-both)
   "Close the split view or exit tree."
-  (interactive)
-  (unless (notmuch-tree-close-message-window)
+  (interactive "P")
+  (when (or (not (notmuch-tree-close-message-window)) kill-both)
 (kill-buffer (current-buffer
 
 (defun notmuch-tree-close-message-window ()
-- 
2.24.0

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


[PATCH v3 0/7] Port notmuch-show's x/X bindings to notmuch-tree

2019-12-28 Thread William Casarin
These patches bring notmuch-tree more in line with the user experience
of notmuch-show by adding the x/X bindings.

v3:
  - Removed dubious setq assignments in notmuch-tree-next-thread
notmuch-tree-goto-matching-message as suggested in id:m2zhgg3r5y@dme.org

  - Implement "A function scope variable to store the direction would
save testing `prev' every time around the loop." as suggested in
id:m2wobk3r4v@dme.org

  - Will address id:87k17cauth@iki.fi in future work as it's a bit
out of scope for this patch set

  - Dropped id:20191113225752.26502-1-j...@jb55.com since it has already
been upstreamed

v2: id:20191128161401.28844-1-j...@jb55.com
  - fix a bug when moving between open messages
  - include M-RET keybinding patch from id:20191113225752.26502-1-j...@jb55.com

v1: id:20191117222929.1064-1-j...@jb55.com


William Casarin (7):
  emacs/tree: return true if a thread was found in next-thread
  emacs/tree: add notmuch-tree-goto-matching-message
  emacs/tree: add notmuch-tree-matching-message
  emacs/tree: add kill-both prefix argument to notmuch-tree-quit
  emacs/tree: add notmuch-tree-archive-message-than-next-or-exit
  emacs/tree: add notmuch-tree-archive-thread-then-exit
  emacs/tree: add x/X bindings

 emacs/notmuch-tree.el | 70 +++
 1 file changed, 51 insertions(+), 19 deletions(-)

base-commit: 757ed001aad27d3c5ee8828174778b71013e4afd

Range-diff:
 8:  ac0f03a2 =  9:  5f9ea4d2 emacs: bind M-RET to 
notmuch-tree-from-search-thread
 1:  16972fa8 ! 36:  6ec4e58f emacs/tree: return true if a thread was found in 
next-thread
  (defun notmuch-tree-next-thread ()
 +  "Get the next thread in the current tree. Returns t if a thread was
 +found or nil if not."
(interactive)
(forward-line 1)
--  (while (not (or (notmuch-tree-get-prop :first) (eobp)))
+   (while (not (or (notmuch-tree-get-prop :first) (eobp)))
 -(forward-line 1)))
-+  (let (end)
-+(while (not (or (notmuch-tree-get-prop :first) (setq end (eobp
-+  (forward-line 1))
-+(not end)))
++(forward-line 1))
++  (not (eobp)))
  
  (defun notmuch-tree-thread-mapcar (function)
"Iterate through all messages in the current thread
 2:  54e166a9 ! 37:  3db9faf8 emacs/tree: add notmuch-tree-goto-matching-message
 +(defun notmuch-tree-goto-matching-message ( prev)
 +  "Move to the next or previous matching message.
 +
 +Returns t if there was a next matching message in the thread to show,
 +nil otherwise."
-+  (let (last)
-+(while (and (not (setq last (if prev (bobp) (eobp
-+(not (notmuch-tree-get-match)))
-+  (forward-line (if prev -1 nil)))
-+(not last)))
++  (let ((dir (if prev -1 nil))
++  (eobfn (if prev #'bobp #'eobp)))
++(while (and (not (funcall eobfn))
++  (not (notmuch-tree-get-match)))
++  (forward-line dir))
++(not (funcall eobfn
 3:  d68d2050 ! 38:  e42d6032 emacs/tree: add notmuch-tree-matching-message
 4:  8432bc9a = 39:  caca76d3 emacs/tree: add kill-both prefix argument to 
notmuch-tree-quit
 5:  0c3f996d ! 40:  02b84adb emacs/tree: add 
notmuch-tree-archive-message-than-next-or-exit
 6:  17545910 = 41:  b432dd49 emacs/tree: add 
notmuch-tree-archive-thread-then-exit
 7:  fbcb3ee0 = 42:  48ea3edb emacs/tree: add x/X bindings
-- 
2.24.0

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


[PATCH v3 1/7] emacs/tree: return true if a thread was found in next-thread

2019-12-28 Thread William Casarin
This will allow us to pop back to parent buffers when there are no
more threads to jump to.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index c00315e8..d262ba26 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -620,10 +620,13 @@ message will be \"unarchived\", i.e. the tag changes in
   (notmuch-tree-thread-top))
 
 (defun notmuch-tree-next-thread ()
+  "Get the next thread in the current tree. Returns t if a thread was
+found or nil if not."
   (interactive)
   (forward-line 1)
   (while (not (or (notmuch-tree-get-prop :first) (eobp)))
-(forward-line 1)))
+(forward-line 1))
+  (not (eobp)))
 
 (defun notmuch-tree-thread-mapcar (function)
   "Iterate through all messages in the current thread
-- 
2.24.0

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


Re: Handle PKCS#7 signedData (S/MIME single-part clearsigned)

2019-12-09 Thread William Casarin
Hey Daniel,

Daniel Kahn Gillmor  writes:
> Several of the patches should be simple to read and uncontroversial (I
> hope!), and I welcome/encourage merging of those patches to reduce the
> length of the remaining series.

I did a quick skim and it looks ok, although I'm not super familiar with
S/MIME. Any steps toward S/MIME support gets a Concept ACK from me!

Cheers,
Will

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


Re: [PATCH v2 0/8] Port notmuch-show's x/X bindings to notmuch-tree

2019-12-04 Thread William Casarin
Teemu Likonen  writes:

> William Casarin [2019-11-28T08:13:53-08] wrote:
>
>> These patches bring notmuch-tree more in line with the user experience
>> of notmuch-show by adding the x/X bindings.
>>
>> v2:
>>   - fix a bug when moving between open messages
>>   - include M-RET keybinding patch from 
>> id:20191113225752.26502-1-j...@jb55.com
>
> A minor inconvenience: In "show" mode X key
> (notmuch-show-archive-thread-then-exit) archives, exits and moves the
> cursor above the next thread in the list. In "tree" mode this new X key
> (notmuch-tree-archive-thread-then-exit) does not move the cursor to the
> next thread.

I didn't even realize notmuch-show does this, I never noticed it before.
I'll see if there's a quick fix.

Another thing I noticed is that X won't work if it moves past the last
message. This is a minor inconvenience, perhaps I can make it so it
doesn't move down a line if there are no more messages.
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v2 2/8] emacs/tree: add notmuch-tree-goto-matching-message

2019-12-04 Thread William Casarin
David Edmondson  writes:

> On Thursday, 2019-11-28 at 08:13:55 -08, William Casarin wrote:
>
>> This function captures some common logic when jumping to matching
>> messages in notmuch-tree mode.
>>
>> We also add a new return value (t or nil), that indicates if there was
>> a next matching message in the thread to show.
>>
>> Signed-off-by: William Casarin 
>> ---
>>  emacs/notmuch-tree.el | 17 +
>>  1 file changed, 13 insertions(+), 4 deletions(-)
>>
>> diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
>> index 4bc05160..9f2d87b5 100644
>> --- a/emacs/notmuch-tree.el
>> +++ b/emacs/notmuch-tree.el
>> @@ -577,12 +577,22 @@ message will be \"unarchived\", i.e. the tag changes in
>>(when (window-live-p notmuch-tree-message-window)
>>  (notmuch-tree-show-message-in)))
>>  
>> +(defun notmuch-tree-goto-matching-message ( prev)
>> +  "Move to the next or previous matching message.
>> +
>> +Returns t if there was a next matching message in the thread to show,
>> +nil otherwise."
>> +  (let (last)
>> +(while (and (not (setq last (if prev (bobp) (eobp
>> +(not (notmuch-tree-get-match)))
>> +  (forward-line (if prev -1 nil)))
>
> A function scope variable to store the direction would save testing
> `prev' every time around the loop.
>
> Same question about the local variable as for the last patch.

yup I believe this makes sense, I send out a new version in a bit.

>
>> +(not last)))
>> +
>>  (defun notmuch-tree-prev-matching-message ()
>>"Move to previous matching message."
>>(interactive)
>>(forward-line -1)
>> -  (while (and (not (bobp)) (not (notmuch-tree-get-match)))
>> -(forward-line -1))
>> +  (notmuch-tree-goto-matching-message t)
>>(when (window-live-p notmuch-tree-message-window)
>>  (notmuch-tree-show-message-in)))
>>  
>> @@ -590,8 +600,7 @@ message will be \"unarchived\", i.e. the tag changes in
>>"Move to next matching message."
>>(interactive)
>>(forward-line)
>> -  (while (and (not (eobp)) (not (notmuch-tree-get-match)))
>> -(forward-line))
>> +  (notmuch-tree-goto-matching-message)
>>(when (window-live-p notmuch-tree-message-window)
>>  (notmuch-tree-show-message-in)))
>>  
>> -- 
>> 2.23.0
>>
>> ___
>> notmuch mailing list
>> notmuch@notmuchmail.org
>> https://notmuchmail.org/mailman/listinfo/notmuch
>
> dme.
> -- 
> Oh by the way, which one's Pink?
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v2 1/8] emacs/tree: return true if a thread was found in next-thread

2019-12-04 Thread William Casarin
David Edmondson  writes:

> On Thursday, 2019-11-28 at 08:13:54 -08, William Casarin wrote:
>
>> This will allow us to pop back to parent buffers when there are no
>> more threads to jump to.
>>
>> Signed-off-by: William Casarin 
>> ---
>>  emacs/notmuch-tree.el | 8 ++--
>>  1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
>> index c00315e8..4bc05160 100644
>> --- a/emacs/notmuch-tree.el
>> +++ b/emacs/notmuch-tree.el
>> @@ -620,10 +620,14 @@ message will be \"unarchived\", i.e. the tag changes in
>>(notmuch-tree-thread-top))
>>  
>>  (defun notmuch-tree-next-thread ()
>> +  "Get the next thread in the current tree. Returns t if a thread was
>> +found or nil if not."
>>(interactive)
>>(forward-line 1)
>> -  (while (not (or (notmuch-tree-get-prop :first) (eobp)))
>> -(forward-line 1)))
>> +  (let (end)
>> +(while (not (or (notmuch-tree-get-prop :first) (setq end (eobp
>> +  (forward-line 1))
>> +(not end)))
>
> Does using the variable add much value here? It makes the code look more
> strange and removing it would add the cost of just one more call to
> `eobp'.

agreed, will update this in the next version

>
>>  
>>  (defun notmuch-tree-thread-mapcar (function)
>>"Iterate through all messages in the current thread
>> -- 
>> 2.23.0
>>
>> ___
>> notmuch mailing list
>> notmuch@notmuchmail.org
>> https://notmuchmail.org/mailman/listinfo/notmuch
>
> dme.
> -- 
> But uh oh, I love her because, she moves in her own way.
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v2 6/8] emacs/tree: add notmuch-tree-archive-thread-then-exit

2019-11-28 Thread William Casarin
This is the notmuch-tree version of
notmuch-show-archive-thread-then-exit

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 8e596459..40838487 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -563,6 +563,12 @@ message will be \"unarchived\", i.e. the tag changes in
   (notmuch-tree-archive-message unarchive)
   (notmuch-tree-next-matching-message))
 
+(defun notmuch-tree-archive-thread-then-exit ()
+  "Archive all messages in the current buffer, then exit notmuch-tree."
+  (interactive)
+  (notmuch-tree-archive-thread)
+  (notmuch-tree-quit t))
+
 (defun notmuch-tree-archive-message-then-next-or-exit ()
   "Archive current message, then show next open message in current thread.
 
-- 
2.23.0

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


[PATCH v2 8/8] emacs: bind M-RET to notmuch-tree-from-search-thread

2019-11-28 Thread William Casarin
This is an unbound function that is quite useful. It opens a selected
thread in notmuch-tree from the current search query.

Signed-off-by: William Casarin 
---
 emacs/notmuch.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 773d1206..0d68d123 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -188,6 +188,7 @@ there will be called at other points of notmuch execution."
 (define-key map "-" 'notmuch-search-remove-tag)
 (define-key map "+" 'notmuch-search-add-tag)
 (define-key map (kbd "RET") 'notmuch-search-show-thread)
+(define-key map (kbd "M-RET") 'notmuch-tree-from-search-thread)
 (define-key map "Z" 'notmuch-tree-from-search-current-query)
 map)
   "Keymap for \"notmuch search\" buffers.")
-- 
2.23.0

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


[PATCH v2 5/8] emacs/tree: add notmuch-tree-archive-message-than-next-or-exit

2019-11-28 Thread William Casarin
This is the notmuch-tree version of
notmuch-show-archive-message-than-next-or-exit.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 30 --
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 367b10c4..8e596459 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -563,6 +563,15 @@ message will be \"unarchived\", i.e. the tag changes in
   (notmuch-tree-archive-message unarchive)
   (notmuch-tree-next-matching-message))
 
+(defun notmuch-tree-archive-message-then-next-or-exit ()
+  "Archive current message, then show next open message in current thread.
+
+If at the last open message in the current thread, then exit back
+to search results."
+  (interactive)
+  (notmuch-tree-archive-message)
+  (notmuch-tree-next-matching-message t))
+
 (defun notmuch-tree-next-message ()
   "Move to next message."
   (interactive)
@@ -588,23 +597,24 @@ nil otherwise."
   (forward-line (if prev -1 nil)))
 (not last)))
 
-(defun notmuch-tree-matching-message ( prev)
+(defun notmuch-tree-matching-message ( prev pop-at-end)
   "Move to the next or previous matching message"
   (interactive "P")
   (forward-line (if prev -1 nil))
-  (notmuch-tree-goto-matching-message prev)
-  (when (window-live-p notmuch-tree-message-window)
-(notmuch-tree-show-message-in)))
+  (if (and (not (notmuch-tree-goto-matching-message prev)) pop-at-end)
+  (notmuch-tree-quit pop-at-end)
+(when (window-live-p notmuch-tree-message-window)
+  (notmuch-tree-show-message-in
 
-(defun notmuch-tree-prev-matching-message ()
+(defun notmuch-tree-prev-matching-message ( pop-at-end)
   "Move to previous matching message."
-  (interactive)
-  (notmuch-tree-matching-message t))
+  (interactive "P")
+  (notmuch-tree-matching-message t pop-at-end))
 
-(defun notmuch-tree-next-matching-message ()
+(defun notmuch-tree-next-matching-message ( pop-at-end)
   "Move to next matching message."
-  (interactive)
-  (notmuch-tree-matching-message))
+  (interactive "P")
+  (notmuch-tree-matching-message nil pop-at-end))
 
 (defun notmuch-tree-refresh-view ()
   "Refresh view."
-- 
2.23.0

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


[PATCH v2 7/8] emacs/tree: add x/X bindings

2019-11-28 Thread William Casarin
Add x and X binds to notmuch-tree for functionally that we have in
notmuch-show.

The notmuch-tree-quit binding is somewhat redundant, since it is
handled by notmuch-bury-or-kill-this-buffer which is bound to q.

Signed-off-by: William Casarin 
---
 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 40838487..bdf0d832 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -277,7 +277,8 @@ FUNC."
 ;; The main tree view bindings
 (define-key map (kbd "RET") 'notmuch-tree-show-message)
 (define-key map [mouse-1] 'notmuch-tree-show-message)
-(define-key map "x" 'notmuch-tree-quit)
+(define-key map "x" 'notmuch-tree-archive-message-then-next-or-exit)
+(define-key map "X" 'notmuch-tree-archive-thread-then-exit)
 (define-key map "A" 'notmuch-tree-archive-thread)
 (define-key map "a" 'notmuch-tree-archive-message-then-next)
 (define-key map "z" 'notmuch-tree-to-tree)
-- 
2.23.0

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


[PATCH v2 3/8] emacs/tree: add notmuch-tree-matching-message

2019-11-28 Thread William Casarin
This functions removes some duplicate logic between
notmuch-tree-{next,prev}-matching-message

We do this because we will be adding some additional logic similar to
the notmuch-show-next-open-message function, and it will help if this
logic is all in one place.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 9f2d87b5..b9173790 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -588,21 +588,23 @@ nil otherwise."
   (forward-line (if prev -1 nil)))
 (not last)))
 
+(defun notmuch-tree-matching-message ( prev)
+  "Move to the next or previous matching message"
+  (interactive "P")
+  (forward-line (if prev -1 nil))
+  (notmuch-tree-goto-matching-message prev)
+  (when (window-live-p notmuch-tree-message-window)
+(notmuch-tree-show-message-in)))
+
 (defun notmuch-tree-prev-matching-message ()
   "Move to previous matching message."
   (interactive)
-  (forward-line -1)
-  (notmuch-tree-goto-matching-message t)
-  (when (window-live-p notmuch-tree-message-window)
-(notmuch-tree-show-message-in)))
+  (notmuch-tree-matching-message t))
 
 (defun notmuch-tree-next-matching-message ()
   "Move to next matching message."
   (interactive)
-  (forward-line)
-  (notmuch-tree-goto-matching-message)
-  (when (window-live-p notmuch-tree-message-window)
-(notmuch-tree-show-message-in)))
+  (notmuch-tree-matching-message))
 
 (defun notmuch-tree-refresh-view ()
   "Refresh view."
-- 
2.23.0

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


[PATCH v2 4/8] emacs/tree: add kill-both prefix argument to notmuch-tree-quit

2019-11-28 Thread William Casarin
This allows us to close both windows at the same time.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index b9173790..367b10c4 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -530,10 +530,10 @@ Shows in split pane or whole window according to value of
   (when (notmuch-tree-scroll-message-window)
 (notmuch-tree-next-matching-message)))
 
-(defun notmuch-tree-quit ()
+(defun notmuch-tree-quit ( kill-both)
   "Close the split view or exit tree."
-  (interactive)
-  (unless (notmuch-tree-close-message-window)
+  (interactive "P")
+  (when (or (not (notmuch-tree-close-message-window)) kill-both)
 (kill-buffer (current-buffer
 
 (defun notmuch-tree-close-message-window ()
-- 
2.23.0

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


[PATCH v2 0/8] Port notmuch-show's x/X bindings to notmuch-tree

2019-11-28 Thread William Casarin
These patches bring notmuch-tree more in line with the user experience
of notmuch-show by adding the x/X bindings.

v2:
  - fix a bug when moving between open messages
  - include M-RET keybinding patch from id:20191113225752.26502-1-j...@jb55.com

v1: id:20191117222929.1064-1-j...@jb55.com

William Casarin (8):
  emacs/tree: return true if a thread was found in next-thread
  emacs/tree: add notmuch-tree-goto-matching-message
  emacs/tree: add notmuch-tree-matching-message
  emacs/tree: add kill-both prefix argument to notmuch-tree-quit
  emacs/tree: add notmuch-tree-archive-message-than-next-or-exit
  emacs/tree: add notmuch-tree-archive-thread-then-exit
  emacs/tree: add x/X bindings
  emacs: bind M-RET to notmuch-tree-from-search-thread

 emacs/notmuch-tree.el | 72 +++
 emacs/notmuch.el  |  1 +
 2 files changed, 53 insertions(+), 20 deletions(-)

Range-diff:
1:  04f7138f = 1:  16972fa8 emacs/tree: return true if a thread was found in 
next-thread
2:  c1f58bf3 = 2:  54e166a9 emacs/tree: add notmuch-tree-goto-matching-message
3:  ef6d5da3 = 3:  d68d2050 emacs/tree: add notmuch-tree-matching-message
4:  777ea3eb = 4:  8432bc9a emacs/tree: add kill-both prefix argument to 
notmuch-tree-quit
5:  fc2497ad ! 5:  0c3f996d emacs/tree: add 
notmuch-tree-archive-message-than-next-or-exit
@@ emacs/notmuch-tree.el: nil otherwise."
 -  (notmuch-tree-goto-matching-message prev)
 -  (when (window-live-p notmuch-tree-message-window)
 -(notmuch-tree-show-message-in)))
-+  (if (and pop-at-end (not (notmuch-tree-goto-matching-message prev)))
++  (if (and (not (notmuch-tree-goto-matching-message prev)) pop-at-end)
 +  (notmuch-tree-quit pop-at-end)
 +(when (window-live-p notmuch-tree-message-window)
 +  (notmuch-tree-show-message-in
6:  bf3107fa = 6:  17545910 emacs/tree: add 
notmuch-tree-archive-thread-then-exit
7:  9fea4f9e = 7:  fbcb3ee0 emacs/tree: add x/X bindings
-:   > 8:  ac0f03a2 emacs: bind M-RET to notmuch-tree-from-search-thread

base-commit: 7ad7cfbff232431377562271901ee00202bf0bd0
-- 
2.23.0

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


[PATCH v2 2/8] emacs/tree: add notmuch-tree-goto-matching-message

2019-11-28 Thread William Casarin
This function captures some common logic when jumping to matching
messages in notmuch-tree mode.

We also add a new return value (t or nil), that indicates if there was
a next matching message in the thread to show.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 4bc05160..9f2d87b5 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -577,12 +577,22 @@ message will be \"unarchived\", i.e. the tag changes in
   (when (window-live-p notmuch-tree-message-window)
 (notmuch-tree-show-message-in)))
 
+(defun notmuch-tree-goto-matching-message ( prev)
+  "Move to the next or previous matching message.
+
+Returns t if there was a next matching message in the thread to show,
+nil otherwise."
+  (let (last)
+(while (and (not (setq last (if prev (bobp) (eobp
+(not (notmuch-tree-get-match)))
+  (forward-line (if prev -1 nil)))
+(not last)))
+
 (defun notmuch-tree-prev-matching-message ()
   "Move to previous matching message."
   (interactive)
   (forward-line -1)
-  (while (and (not (bobp)) (not (notmuch-tree-get-match)))
-(forward-line -1))
+  (notmuch-tree-goto-matching-message t)
   (when (window-live-p notmuch-tree-message-window)
 (notmuch-tree-show-message-in)))
 
@@ -590,8 +600,7 @@ message will be \"unarchived\", i.e. the tag changes in
   "Move to next matching message."
   (interactive)
   (forward-line)
-  (while (and (not (eobp)) (not (notmuch-tree-get-match)))
-(forward-line))
+  (notmuch-tree-goto-matching-message)
   (when (window-live-p notmuch-tree-message-window)
 (notmuch-tree-show-message-in)))
 
-- 
2.23.0

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


[PATCH v2 1/8] emacs/tree: return true if a thread was found in next-thread

2019-11-28 Thread William Casarin
This will allow us to pop back to parent buffers when there are no
more threads to jump to.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index c00315e8..4bc05160 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -620,10 +620,14 @@ message will be \"unarchived\", i.e. the tag changes in
   (notmuch-tree-thread-top))
 
 (defun notmuch-tree-next-thread ()
+  "Get the next thread in the current tree. Returns t if a thread was
+found or nil if not."
   (interactive)
   (forward-line 1)
-  (while (not (or (notmuch-tree-get-prop :first) (eobp)))
-(forward-line 1)))
+  (let (end)
+(while (not (or (notmuch-tree-get-prop :first) (setq end (eobp
+  (forward-line 1))
+(not end)))
 
 (defun notmuch-tree-thread-mapcar (function)
   "Iterate through all messages in the current thread
-- 
2.23.0

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


Re: [PATCH 5/7] emacs/tree: add notmuch-tree-archive-message-than-next-or-exit

2019-11-18 Thread William Casarin
David Edmondson  writes:

> On Sunday, 2019-11-17 at 15:17:58 -08, William Casarin wrote:
>
>> I'll push out a v2 later if this gets enough Concept ACKs.
>
> The changes make sense to me in principle, but I don't use
> notmuch-tree. It would be good if someone who does could try them and
> comment.

I didn't either but I realized it's quite nice for viewing long threaded
discussions. The main  reason I never used it before  was because of the
different keybinds and missing functionality. My goal is to try to bring
as many  things over  as possible  so that  notmuch-show users  can feel
comfortable in notmuch-tree.

x/X was the  big one for me. The  only else perhaps is a  button to quit
both windows at the same time. I  added this functionality in one of the
patches (prefix argument to notmuch-tree-quit) so we just need a keybind
for it now.

If anyone  is interested in  trying this  out I've pushed  these patches
plus the M-RET binding to my github:

git fetch https://github.com/jb55/notmuch tree-improvements

Cheers,
Will

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


Re: [PATCH 5/7] emacs/tree: add notmuch-tree-archive-message-than-next-or-exit

2019-11-17 Thread William Casarin
William Casarin  writes:

> This is the notmuch-tree version of
> notmuch-show-archive-message-than-next-or-exit.
>
> Signed-off-by: William Casarin 
> ---
>  emacs/notmuch-tree.el | 30 --
>  1 file changed, 20 insertions(+), 10 deletions(-)
>
> diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
> index 367b10c4..fd6f9f83 100644
> --- a/emacs/notmuch-tree.el
> +++ b/emacs/notmuch-tree.el
> @@ -563,6 +563,15 @@ message will be \"unarchived\", i.e. the tag changes in
>(notmuch-tree-archive-message unarchive)
>(notmuch-tree-next-matching-message))
>  
> +(defun notmuch-tree-archive-message-then-next-or-exit ()
> +  "Archive current message, then show next open message in current thread.
> +
> +If at the last open message in the current thread, then exit back
> +to search results."
> +  (interactive)
> +  (notmuch-tree-archive-message)
> +  (notmuch-tree-next-matching-message t))
> +
>  (defun notmuch-tree-next-message ()
>"Move to next message."
>(interactive)
> @@ -588,23 +597,24 @@ nil otherwise."
>(forward-line (if prev -1 nil)))
>  (not last)))
>  
> -(defun notmuch-tree-matching-message ( prev)
> +(defun notmuch-tree-matching-message ( prev pop-at-end)
>"Move to the next or previous matching message"
>(interactive "P")
>(forward-line (if prev -1 nil))
> -  (notmuch-tree-goto-matching-message prev)
> -  (when (window-live-p notmuch-tree-message-window)
> -(notmuch-tree-show-message-in)))
> +  (if (and pop-at-end (not (notmuch-tree-goto-matching-message prev)))

bah, this should be

  (if (and (not (notmuch-tree-goto-matching-message prev)) pop-at-end)

since short-circuit evaulation prevents the goto-matching-message from
getting called.

I'll push out a v2 later if this gets enough Concept ACKs.

> +  (notmuch-tree-quit pop-at-end)
> +(when (window-live-p notmuch-tree-message-window)
> +  (notmuch-tree-show-message-in
>  
> -(defun notmuch-tree-prev-matching-message ()
> +(defun notmuch-tree-prev-matching-message ( pop-at-end)
>"Move to previous matching message."
> -  (interactive)
> -  (notmuch-tree-matching-message t))
> +  (interactive "P")
> +  (notmuch-tree-matching-message t pop-at-end))
>  
> -(defun notmuch-tree-next-matching-message ()
> +(defun notmuch-tree-next-matching-message ( pop-at-end)
>"Move to next matching message."
> -  (interactive)
> -  (notmuch-tree-matching-message))
> +  (interactive "P")
> +  (notmuch-tree-matching-message nil pop-at-end))
>  
>  (defun notmuch-tree-refresh-view ()
>"Refresh view."
> -- 
> 2.23.0
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 0/7] Port notmuch-show's x/X bindings to notmuch-tree

2019-11-17 Thread William Casarin
These patches bring notmuch-tree more in line with the user experience
of notmuch-show by adding the x/X bindings.

id:20191113225752.26502-1-j...@jb55.com is also recommended, it adds a
bind for opening a thread in notmuch-tree mode.

William Casarin (7):
  emacs/tree: return true if a thread was found in next-thread
  emacs/tree: add notmuch-tree-goto-matching-message
  emacs/tree: add notmuch-tree-matching-message
  emacs/tree: add kill-both prefix argument to notmuch-tree-quit
  emacs/tree: add notmuch-tree-archive-message-than-next-or-exit
  emacs/tree: add notmuch-tree-archive-thread-then-exit
  emacs/tree: add x/X bindings

 emacs/notmuch-tree.el | 72 +++
 1 file changed, 52 insertions(+), 20 deletions(-)


base-commit: 7ad7cfbff232431377562271901ee00202bf0bd0
-- 
2.23.0

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


[PATCH 7/7] emacs/tree: add x/X bindings

2019-11-17 Thread William Casarin
Add x and X binds to notmuch-tree for functionally that we have in
notmuch-show.

The notmuch-tree-quit binding is somewhat redundant, since it is
handled by notmuch-bury-or-kill-this-buffer which is bound to q.

Signed-off-by: William Casarin 
---
 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 b8844b64..d3a54bcb 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -277,7 +277,8 @@ FUNC."
 ;; The main tree view bindings
 (define-key map (kbd "RET") 'notmuch-tree-show-message)
 (define-key map [mouse-1] 'notmuch-tree-show-message)
-(define-key map "x" 'notmuch-tree-quit)
+(define-key map "x" 'notmuch-tree-archive-message-then-next-or-exit)
+(define-key map "X" 'notmuch-tree-archive-thread-then-exit)
 (define-key map "A" 'notmuch-tree-archive-thread)
 (define-key map "a" 'notmuch-tree-archive-message-then-next)
 (define-key map "z" 'notmuch-tree-to-tree)
-- 
2.23.0

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


[PATCH 4/7] emacs/tree: add kill-both prefix argument to notmuch-tree-quit

2019-11-17 Thread William Casarin
This allows us to close both windows at the same time.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index b9173790..367b10c4 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -530,10 +530,10 @@ Shows in split pane or whole window according to value of
   (when (notmuch-tree-scroll-message-window)
 (notmuch-tree-next-matching-message)))
 
-(defun notmuch-tree-quit ()
+(defun notmuch-tree-quit ( kill-both)
   "Close the split view or exit tree."
-  (interactive)
-  (unless (notmuch-tree-close-message-window)
+  (interactive "P")
+  (when (or (not (notmuch-tree-close-message-window)) kill-both)
 (kill-buffer (current-buffer
 
 (defun notmuch-tree-close-message-window ()
-- 
2.23.0

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


[PATCH 3/7] emacs/tree: add notmuch-tree-matching-message

2019-11-17 Thread William Casarin
This functions removes some duplicate logic between
notmuch-tree-{next,prev}-matching-message

We do this because we will be adding some additional logic similar to
the notmuch-show-next-open-message function, and it will help if this
logic is all in one place.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 9f2d87b5..b9173790 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -588,21 +588,23 @@ nil otherwise."
   (forward-line (if prev -1 nil)))
 (not last)))
 
+(defun notmuch-tree-matching-message ( prev)
+  "Move to the next or previous matching message"
+  (interactive "P")
+  (forward-line (if prev -1 nil))
+  (notmuch-tree-goto-matching-message prev)
+  (when (window-live-p notmuch-tree-message-window)
+(notmuch-tree-show-message-in)))
+
 (defun notmuch-tree-prev-matching-message ()
   "Move to previous matching message."
   (interactive)
-  (forward-line -1)
-  (notmuch-tree-goto-matching-message t)
-  (when (window-live-p notmuch-tree-message-window)
-(notmuch-tree-show-message-in)))
+  (notmuch-tree-matching-message t))
 
 (defun notmuch-tree-next-matching-message ()
   "Move to next matching message."
   (interactive)
-  (forward-line)
-  (notmuch-tree-goto-matching-message)
-  (when (window-live-p notmuch-tree-message-window)
-(notmuch-tree-show-message-in)))
+  (notmuch-tree-matching-message))
 
 (defun notmuch-tree-refresh-view ()
   "Refresh view."
-- 
2.23.0

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


[PATCH 5/7] emacs/tree: add notmuch-tree-archive-message-than-next-or-exit

2019-11-17 Thread William Casarin
This is the notmuch-tree version of
notmuch-show-archive-message-than-next-or-exit.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 30 --
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 367b10c4..fd6f9f83 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -563,6 +563,15 @@ message will be \"unarchived\", i.e. the tag changes in
   (notmuch-tree-archive-message unarchive)
   (notmuch-tree-next-matching-message))
 
+(defun notmuch-tree-archive-message-then-next-or-exit ()
+  "Archive current message, then show next open message in current thread.
+
+If at the last open message in the current thread, then exit back
+to search results."
+  (interactive)
+  (notmuch-tree-archive-message)
+  (notmuch-tree-next-matching-message t))
+
 (defun notmuch-tree-next-message ()
   "Move to next message."
   (interactive)
@@ -588,23 +597,24 @@ nil otherwise."
   (forward-line (if prev -1 nil)))
 (not last)))
 
-(defun notmuch-tree-matching-message ( prev)
+(defun notmuch-tree-matching-message ( prev pop-at-end)
   "Move to the next or previous matching message"
   (interactive "P")
   (forward-line (if prev -1 nil))
-  (notmuch-tree-goto-matching-message prev)
-  (when (window-live-p notmuch-tree-message-window)
-(notmuch-tree-show-message-in)))
+  (if (and pop-at-end (not (notmuch-tree-goto-matching-message prev)))
+  (notmuch-tree-quit pop-at-end)
+(when (window-live-p notmuch-tree-message-window)
+  (notmuch-tree-show-message-in
 
-(defun notmuch-tree-prev-matching-message ()
+(defun notmuch-tree-prev-matching-message ( pop-at-end)
   "Move to previous matching message."
-  (interactive)
-  (notmuch-tree-matching-message t))
+  (interactive "P")
+  (notmuch-tree-matching-message t pop-at-end))
 
-(defun notmuch-tree-next-matching-message ()
+(defun notmuch-tree-next-matching-message ( pop-at-end)
   "Move to next matching message."
-  (interactive)
-  (notmuch-tree-matching-message))
+  (interactive "P")
+  (notmuch-tree-matching-message nil pop-at-end))
 
 (defun notmuch-tree-refresh-view ()
   "Refresh view."
-- 
2.23.0

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


[PATCH 2/7] emacs/tree: add notmuch-tree-goto-matching-message

2019-11-17 Thread William Casarin
This function captures some common logic when jumping to matching
messages in notmuch-tree mode.

We also add a new return value (t or nil), that indicates if there was
a next matching message in the thread to show.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 4bc05160..9f2d87b5 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -577,12 +577,22 @@ message will be \"unarchived\", i.e. the tag changes in
   (when (window-live-p notmuch-tree-message-window)
 (notmuch-tree-show-message-in)))
 
+(defun notmuch-tree-goto-matching-message ( prev)
+  "Move to the next or previous matching message.
+
+Returns t if there was a next matching message in the thread to show,
+nil otherwise."
+  (let (last)
+(while (and (not (setq last (if prev (bobp) (eobp
+(not (notmuch-tree-get-match)))
+  (forward-line (if prev -1 nil)))
+(not last)))
+
 (defun notmuch-tree-prev-matching-message ()
   "Move to previous matching message."
   (interactive)
   (forward-line -1)
-  (while (and (not (bobp)) (not (notmuch-tree-get-match)))
-(forward-line -1))
+  (notmuch-tree-goto-matching-message t)
   (when (window-live-p notmuch-tree-message-window)
 (notmuch-tree-show-message-in)))
 
@@ -590,8 +600,7 @@ message will be \"unarchived\", i.e. the tag changes in
   "Move to next matching message."
   (interactive)
   (forward-line)
-  (while (and (not (eobp)) (not (notmuch-tree-get-match)))
-(forward-line))
+  (notmuch-tree-goto-matching-message)
   (when (window-live-p notmuch-tree-message-window)
 (notmuch-tree-show-message-in)))
 
-- 
2.23.0

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


[PATCH 1/7] emacs/tree: return true if a thread was found in next-thread

2019-11-17 Thread William Casarin
This will allow us to pop back to parent buffers when there are no
more threads to jump to.

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index c00315e8..4bc05160 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -620,10 +620,14 @@ message will be \"unarchived\", i.e. the tag changes in
   (notmuch-tree-thread-top))
 
 (defun notmuch-tree-next-thread ()
+  "Get the next thread in the current tree. Returns t if a thread was
+found or nil if not."
   (interactive)
   (forward-line 1)
-  (while (not (or (notmuch-tree-get-prop :first) (eobp)))
-(forward-line 1)))
+  (let (end)
+(while (not (or (notmuch-tree-get-prop :first) (setq end (eobp
+  (forward-line 1))
+(not end)))
 
 (defun notmuch-tree-thread-mapcar (function)
   "Iterate through all messages in the current thread
-- 
2.23.0

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


[PATCH 6/7] emacs/tree: add notmuch-tree-archive-thread-then-exit

2019-11-17 Thread William Casarin
This is the notmuch-tree version of
notmuch-show-archive-thread-then-exit

Signed-off-by: William Casarin 
---
 emacs/notmuch-tree.el | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index fd6f9f83..b8844b64 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -563,6 +563,12 @@ message will be \"unarchived\", i.e. the tag changes in
   (notmuch-tree-archive-message unarchive)
   (notmuch-tree-next-matching-message))
 
+(defun notmuch-tree-archive-thread-then-exit ()
+  "Archive all messages in the current buffer, then exit notmuch-tree."
+  (interactive)
+  (notmuch-tree-archive-thread)
+  (notmuch-tree-quit t))
+
 (defun notmuch-tree-archive-message-then-next-or-exit ()
   "Archive current message, then show next open message in current thread.
 
-- 
2.23.0

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


[PATCH] emacs: bind M-RET to notmuch-tree-from-search-thread

2019-11-13 Thread William Casarin
This is an unbound function that is quite useful. It opens a selected
thread in notmuch-tree from the current search query.

Signed-off-by: William Casarin 

---

This is a simpler alternative to id:20191113080004.32214-1-j...@jb55.com

 emacs/notmuch.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 773d1206..0d68d123 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -188,6 +188,7 @@ there will be called at other points of notmuch execution."
 (define-key map "-" 'notmuch-search-remove-tag)
 (define-key map "+" 'notmuch-search-add-tag)
 (define-key map (kbd "RET") 'notmuch-search-show-thread)
+(define-key map (kbd "M-RET") 'notmuch-tree-from-search-thread)
 (define-key map "Z" 'notmuch-tree-from-search-current-query)
 map)
   "Keymap for \"notmuch search\" buffers.")

base-commit: 7ad7cfbff232431377562271901ee00202bf0bd0
-- 
2.23.0

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


Re: [PATCH] emacs: bind C-u Z to notmuch-tree-from-search-thread

2019-11-13 Thread William Casarin
Teemu Likonen  writes:

> William Casarin [2019-11-13T00:00:04-08] wrote:
>
>> This is an unbound function that is quite useful. It opens a selected
>> thread in notmuch-tree from the current search query.
>
> I agree that it is good idea to bind notmuch-tree-from-search-thread
> command and thus make it show in "C-h m" *Help* buffer. I prefer M-RET
> because
>   - it is quick to type
>   - it feels like variant of RET (notmuch-search-show-thread).

I never thought of that but it I like it.
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: bind C-u Z to notmuch-tree-from-search-thread

2019-11-13 Thread William Casarin
David Edmondson  writes:

> On Wednesday, 2019-11-13 at 00:00:04 -08, William Casarin wrote:
>
>> This is an unbound function that is quite useful. It opens a selected
>> thread in notmuch-tree from the current search query.
>
> Seems fine to me. Not crazy about the binding, but it will suffice.

yeah I use this more than Z, so I would like a single-char binding. I
wasn't sure and was hoping someone else had a better idea.

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


Re: Unread handling

2019-11-12 Thread William Casarin
Teemu Likonen  writes:

> Teemu Likonen [2019-11-12T16:54:35+02] wrote:
>
>> But indeed, a command like "notmuch-search-show-thread-tree" (M-RET,
>> C-u RET, C-RET...) would be useful: open current thread directly in
>> tree view and with current search terms.
>
> But that is already there (without keybinding):
>
> (defun notmuch-tree-from-search-thread ()
>   "Show the selected thread with notmuch-tree"
>   (interactive)
>   (notmuch-tree (notmuch-search-find-thread-id)
> notmuch-search-query-string
> nil
> (notmuch-prettify-subject (notmuch-search-find-subject))
> t))

oh!! This is exactly what I was looking for. Just need to bind this.

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


Re: Unread handling

2019-11-12 Thread William Casarin
David Edmondson  writes:

> On Tuesday, 2019-11-12 at 05:17:46 -08, William Casarin wrote: 
>
>> David Edmondson  writes: 
>>> On Monday, 2019-11-11 at 00:16:17 +01, Johan Parin wrote:  
>>>> I'm trying instead to use the tree view, this seems to me the 
>>>> more natural way to view threads. So I immediately do `Z' 
>>>> whenever I enter a thread. I would like to have the option to 
>>>> enter tree view automatically for a thread from the search 
>>>> buffer. Is it possible?  
>>> 
>>> ā€œZā€ in search mode should take you directly to tree mode. 
>> 
>> true, but it opens tree mode for the entire search result. I 
>> find myself doing `c i z Ctrl-v` to open the tree view for a 
>> specific thread, but perhaps it would make sense if there was a 
>> default keybind for this. 
>
> Hmm, yes, that's a bit annoying.
>
> I'd suggest 'z' as a good binding, but obviously it's already 
> used. What would make sense?

C-u Z perhaps?
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: Unread handling

2019-11-12 Thread William Casarin
Teemu Likonen  writes:

> William Casarin [2019-11-12T05:17:46-08] wrote:
>
>> I find myself doing `c i z Ctrl-v` to open the tree view for a
>> specific thread, but perhaps it would make sense if there was a
>> default keybind for this.
>
> Seems like the same as pressing Enter to select a thread and then Z to
> see the thread it in tree view. No?

Yes, but this has performance implications on large threads. Pressing
Enter will load all of the messages. Opening tree view with the thread
id is much faster, as it only loads the messages when you click them
from what I can tell.

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


Re: Unread handling

2019-11-12 Thread William Casarin
David Edmondson  writes:
> On Monday, 2019-11-11 at 00:16:17 +01, Johan Parin wrote: 
>> I'm trying instead to use the tree view, this seems to me the 
>> more natural way to view threads. So I immediately do `Z' 
>> whenever I enter a thread. I would like to have the option to 
>> enter tree view automatically for a thread from the search 
>> buffer. Is it possible? 
>
> ā€œZā€ in search mode should take you directly to tree mode.

true, but it opens tree mode for the entire search result. I find myself
doing `c i z Ctrl-v` to open the tree view for a specific thread, but
perhaps it would make sense if there was a default keybind for this.

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


Re: v3 of legacy-display cleanup

2019-06-24 Thread William Casarin
Daniel Kahn Gillmor  writes:

> This is the third revision of the series that cleans up legacy-display
> protected headers parts so that notmuch users only have to look at one
> subject line.
>
> version 2 can be found at id:20190531075907.17035-1-...@fifthhorseman.net
> version 1 can be found at id:20190531042825.27774-1-...@fifthhorseman.net
>
> --
> Now that notmuch can handle and interpret protected subject lines, it
> should also avoid forcing the user to look at "legacy display" parts
> that some MUAs (notably enigmail) copies of the protected headers that
> are intended to be rendered only by legacy clients -- clients capable
> of decryption but which don't understand how to handle protected
> headers.
> --
>
> The main differences from version 2 are:
>
>  * i've directly included the two-patch "repair" series (originally
>found at id:20190531074027.16337-1-...@fifthhorseman.net), and
>
>  * i've rebased against the uncrustified master, as well as applying
>the uncrustify rules to my changes here.
>
> If we can get this merged, i'll send a subsequent revision of the
> series that repairs "mixed-up MIME" mangled messages.
>
> I would appreciate any feedback!

Looks good to me, didn't get a chance to test it out yet. Thanks for
working on this!

Cheers,
Will

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


Re: [PATCH 5/7] util/repair: add _notmuch_repair_crypto_payload_skip_legacy_display

2019-06-24 Thread William Casarin
Daniel Kahn Gillmor  writes:

> This is a utility function designed to make it easier to
> "fast-forward" past a legacy-display part associated with a
> cryptographic envelope, and show the user the intended message body.
>
> The bulk of the ugliness in here is in the test function
> _notmuch_crypto_payload_has_legacy_display, which tests all of the
> things we'd expect to be true in a a cryptographic payload that
> contains a legacy display part.
>
> Signed-off-by: Daniel Kahn Gillmor 
> ---
>  util/repair.c | 98 +++
>  util/repair.h | 17 +
>  2 files changed, 115 insertions(+)
>
> diff --git a/util/repair.c b/util/repair.c
> index f91c1244..0809f7b4 100644
> --- a/util/repair.c
> +++ b/util/repair.c
> @@ -18,4 +18,102 @@
>   * Authors: Daniel Kahn Gillmor 
>   */
>  
> +#include 
>  #include "repair.h"
> +
> +
> +static bool
> +_notmuch_crypto_payload_has_legacy_display (GMimeObject *payload)
> +{
> +GMimeMultipart *mpayload;
> +const char *protected_header_parameter;
> +GMimeTextPart *legacy_display;
> +char *legacy_display_header_text = NULL;
> +GMimeStream *stream = NULL;
> +GMimeParser *parser = NULL;
> +GMimeObject *legacy_header_object = NULL, *first;
> +GMimeHeaderList *legacy_display_headers = NULL, *protected_headers = 
> NULL;
> +bool ret = false;
> +
> +if (! g_mime_content_type_is_type (g_mime_object_get_content_type 
> (payload),
> +"multipart", "mixed"))
> + return false;
> +protected_header_parameter = g_mime_object_get_content_type_parameter 
> (payload, "protected-headers");
> +if ((! protected_header_parameter) || strcmp 
> (protected_header_parameter, "v1"))
> + return false;
> +if (! GMIME_IS_MULTIPART (payload))
> + return false;
> +mpayload = GMIME_MULTIPART (payload);
> +if (mpayload == NULL)
> + return false;
> +if (g_mime_multipart_get_count (mpayload) != 2)
> + return false;
> +first = g_mime_multipart_get_part (mpayload, 0);
> +if (! g_mime_content_type_is_type (g_mime_object_get_content_type 
> (first),
> +"text", "rfc822-headers"))
> + return false;
> +protected_header_parameter = g_mime_object_get_content_type_parameter 
> (first, "protected-headers");
> +if ((! protected_header_parameter) || strcmp 
> (protected_header_parameter, "v1"))
> + return false;
> +if (! GMIME_IS_TEXT_PART (first))
> + return false;
> +
> +/* ensure that the headers in the first part all match the values
> + * found in the payload's own protected headers!  if they don't,
> + * we should not treat this as a valid "legacy-display" part.
> + *
> + * Crafting a GMimeHeaderList object from the content of the
> + * text/rfc822-headers part is pretty clumsy; we should probably
> + * push something into GMime that makes this a one-shot
> + * operation. */
> +if ((protected_headers = g_mime_object_get_header_list (payload), 
> protected_headers) &&
> + (legacy_display = GMIME_TEXT_PART (first), legacy_display) &&
> + (legacy_display_header_text = g_mime_text_part_get_text 
> (legacy_display), legacy_display_header_text) &&
> + (stream = g_mime_stream_mem_new_with_buffer 
> (legacy_display_header_text, strlen (legacy_display_header_text)), stream) &&
> + (g_mime_stream_write (stream, "\r\n\r\n", 4) == 4) &&
> + (g_mime_stream_seek (stream, 0, GMIME_STREAM_SEEK_SET) == 0) &&
> + (parser = g_mime_parser_new_with_stream (stream), parser) &&
> + (legacy_header_object = g_mime_parser_construct_part (parser, NULL), 
> legacy_header_object) &&
> + (legacy_display_headers = g_mime_object_get_header_list 
> (legacy_header_object), legacy_display_headers)) {
> + /* walk through legacy_display_headers, comparing them against

This may be a noob question, but why the comma operators after the
assignment expressions? Wouldn't they evaluate to the same thing?

> +  * their values in the protected_headers: */
> + ret = true;
> + for (int i = 0; i < g_mime_header_list_get_count 
> (legacy_display_headers); i++) {
> + GMimeHeader *dh = g_mime_header_list_get_header_at 
> (legacy_display_headers, i);
> + if (dh == NULL) {
> + ret = false;
> + break;
> + }
> + GMimeHeader *ph = g_mime_header_list_get_header (protected_headers, 
> g_mime_header_get_name (dh));
> + if (ph == NULL) {
> + ret = false;
> + break;
> + }
> + if (strcmp (g_mime_header_get_value (dh), g_mime_header_get_value 
> (ph))) {
> + ret = false;
> + break;
> + }
> + }
> +}
> +
> +if (legacy_display_header_text)
> + g_free (legacy_display_header_text);
> +if (stream)
> + g_object_unref (stream);
> +if (parser)
> + g_object_unref (parser);
> +if (legacy_header_object)
> + 

Re: [PATCH 1/7] mime-node: split out _mime_node_set_up_part

2019-06-24 Thread William Casarin
Daniel Kahn Gillmor  writes:

> This is a code reorganization that should have no functional effect,
> but will make future changes simpler, because a future commit will
> reuse the _mime_node_set_up_part functionality without touching
> _mime_node_create.
>
> In the course of splitting out this function, I noticed a comment in
> the codebase that referred to an older name of _mime_node_create
> (message_part_create), where this functionality originally resided.
> I've fixed that comment to refer to the new function instead.
>
> Signed-off-by: Daniel Kahn Gillmor 
> ---
>  mime-node.c | 30 ++
>  1 file changed, 22 insertions(+), 8 deletions(-)
>
> diff --git a/mime-node.c b/mime-node.c
> index 3133ca44..d2125f90 100644
> --- a/mime-node.c
> +++ b/mime-node.c
> @@ -264,14 +264,15 @@ node_decrypt_and_verify (mime_node_t *node, GMimeObject 
> *part)
>   g_error_free (err);
>  }
>  
> +static bool
> +_mime_node_set_up_part (mime_node_t *node, GMimeObject *part, int numchild);
> +

nit: Instead of a forward declaration, could _mime_node_create be moved after
_mime_node_set_up_part instead?

>  static mime_node_t *
>  _mime_node_create (mime_node_t *parent, GMimeObject *part, int numchild)
>  {
>  mime_node_t *node = talloc_zero (parent, mime_node_t);
> -notmuch_status_t status;
>  
>  /* Set basic node properties */
> -node->part = part;
>  node->ctx = parent->ctx;
>  if (! talloc_reference (node, node->ctx)) {
>   fprintf (stderr, "Out of memory.\n");
> @@ -282,10 +283,24 @@ _mime_node_create (mime_node_t *parent, GMimeObject 
> *part, int numchild)
>  node->part_num = node->next_part_num = -1;
>  node->next_child = 0;
>  
> +if (_mime_node_set_up_part (node, part, numchild))
> + return node;
> +talloc_free (node);
> +return NULL;
> +}
> +
> +/* associate a MIME part with a node. */
> +static bool
> +_mime_node_set_up_part (mime_node_t *node, GMimeObject *part, int numchild)
> +{
> +notmuch_status_t status;
> +
>  /* Deal with the different types of parts */
>  if (GMIME_IS_PART (part)) {
> + node->part = part;
>   node->nchildren = 0;
>  } else if (GMIME_IS_MULTIPART (part)) {
> + node->part = part;
>   node->nchildren = g_mime_multipart_get_count (GMIME_MULTIPART (part));
>  } else if (GMIME_IS_MESSAGE_PART (part)) {
>   /* Promote part to an envelope and open it */
> @@ -297,11 +312,10 @@ _mime_node_create (mime_node_t *parent, GMimeObject 
> *part, int numchild)
>  } else {
>   fprintf (stderr, "Warning: Unknown mime part type: %s.\n",
>g_type_name (G_OBJECT_TYPE (part)));
> - talloc_free (node);
> - return NULL;
> + return false;
>  }
>  
> -/* Handle PGP/MIME parts */
> +/* Handle PGP/MIME parts (by definition not cryptographic payload parts) 
> */
>  if (GMIME_IS_MULTIPART_ENCRYPTED (part) && (node->ctx->crypto->decrypt 
> != NOTMUCH_DECRYPT_FALSE)) {
>   if (node->nchildren != 2) {
>   /* this violates RFC 3156 section 4, so we won't bother with it. */
> @@ -321,12 +335,12 @@ _mime_node_create (mime_node_t *parent, GMimeObject 
> *part, int numchild)
>   node_verify (node, part);
>   }
>  } else {
> - status = _notmuch_message_crypto_potential_payload 
> (node->ctx->msg_crypto, part, parent ? parent->part : NULL, numchild);
> + status = _notmuch_message_crypto_potential_payload 
> (node->ctx->msg_crypto, part, node->parent ? node->parent->part : NULL, 
> numchild);
>   if (status)
>   fprintf (stderr, "Warning: failed to record potential crypto 
> payload (%s).\n", notmuch_status_to_string (status));
>  }
>  
> -return node;
> +return true;
>  }
>  
>  mime_node_t *
> @@ -347,7 +361,7 @@ mime_node_child (mime_node_t *parent, int child)
>  } else if (GMIME_IS_MESSAGE (parent->part)) {
>   sub = g_mime_message_get_mime_part (GMIME_MESSAGE (parent->part));
>  } else {
> - /* This should have been caught by message_part_create */
> + /* This should have been caught by _mime_node_set_up_part */
>   INTERNAL_ERROR ("Unexpected GMimeObject type: %s",
>   g_type_name (G_OBJECT_TYPE (parent->part)));
>  }
> -- 
> 2.20.1
>
> ___
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch

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


Re: [PATCH] emacs: add keywords to notmuch-emacs-mua.desktop

2019-06-24 Thread William Casarin
Daniel Kahn Gillmor  writes:

> Ping! If there is a reason that this trivial patch has languished, i'd
> be happy to receive critical feedback.  Or maybe we can just merge it?
>
>--dkg

Looks good to me!

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


[PATCH] perf-tests: #!/bin/bash -> #!/usr/bin/env bash

2019-05-31 Thread William Casarin
I couldn't run the performance tests on my machines due to a hardcoded
bash path. Use env for finding bash in weird systems like NixOS.

Signed-off-by: William Casarin 
---
 performance-test/M00-new.sh | 2 +-
 performance-test/M01-dump-restore.sh| 2 +-
 performance-test/M02-show.sh| 2 +-
 performance-test/M03-search.sh  | 2 +-
 performance-test/M04-reply.sh   | 2 +-
 performance-test/M05-reindex.sh | 2 +-
 performance-test/M06-insert.sh  | 2 +-
 performance-test/T00-new.sh | 2 +-
 performance-test/T01-dump-restore.sh| 2 +-
 performance-test/T02-tag.sh | 2 +-
 performance-test/T03-reindex.sh | 2 +-
 performance-test/T04-thread-subquery.sh | 2 +-
 12 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/performance-test/M00-new.sh b/performance-test/M00-new.sh
index aab36e69..5858ab33 100755
--- a/performance-test/M00-new.sh
+++ b/performance-test/M00-new.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 test_description='notmuch new'
 
diff --git a/performance-test/M01-dump-restore.sh 
b/performance-test/M01-dump-restore.sh
index 32ab8dc9..7850b411 100755
--- a/performance-test/M01-dump-restore.sh
+++ b/performance-test/M01-dump-restore.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 test_description='dump and restore'
 
diff --git a/performance-test/M02-show.sh b/performance-test/M02-show.sh
index 2e218fd3..40c5d4d7 100755
--- a/performance-test/M02-show.sh
+++ b/performance-test/M02-show.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 test_description='show'
 
diff --git a/performance-test/M03-search.sh b/performance-test/M03-search.sh
index 343f5c7c..a73a36ab 100755
--- a/performance-test/M03-search.sh
+++ b/performance-test/M03-search.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 test_description='search'
 
diff --git a/performance-test/M04-reply.sh b/performance-test/M04-reply.sh
index 3c1205db..3b0f9e78 100755
--- a/performance-test/M04-reply.sh
+++ b/performance-test/M04-reply.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 test_description='search'
 
diff --git a/performance-test/M05-reindex.sh b/performance-test/M05-reindex.sh
index 17e2c824..8ea7e7ee 100755
--- a/performance-test/M05-reindex.sh
+++ b/performance-test/M05-reindex.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 test_description='reindex'
 
diff --git a/performance-test/M06-insert.sh b/performance-test/M06-insert.sh
index 5ae0656a..12330c76 100755
--- a/performance-test/M06-insert.sh
+++ b/performance-test/M06-insert.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 test_description='search'
 
diff --git a/performance-test/T00-new.sh b/performance-test/T00-new.sh
index 25391136..a14dd13f 100755
--- a/performance-test/T00-new.sh
+++ b/performance-test/T00-new.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 test_description='notmuch new'
 
diff --git a/performance-test/T01-dump-restore.sh 
b/performance-test/T01-dump-restore.sh
index 12f12e66..2a53e3b8 100755
--- a/performance-test/T01-dump-restore.sh
+++ b/performance-test/T01-dump-restore.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 test_description='dump and restore'
 
diff --git a/performance-test/T02-tag.sh b/performance-test/T02-tag.sh
index 8c5dfd68..9c895d6a 100755
--- a/performance-test/T02-tag.sh
+++ b/performance-test/T02-tag.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 test_description='tagging'
 
diff --git a/performance-test/T03-reindex.sh b/performance-test/T03-reindex.sh
index 8e0a77f4..8db52a33 100755
--- a/performance-test/T03-reindex.sh
+++ b/performance-test/T03-reindex.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 test_description='reindexing'
 
diff --git a/performance-test/T04-thread-subquery.sh 
b/performance-test/T04-thread-subquery.sh
index 665d5a64..ba81f383 100755
--- a/performance-test/T04-thread-subquery.sh
+++ b/performance-test/T04-thread-subquery.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 test_description='thread subqueries'
 
-- 
2.21.0

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


Re: [PATCH] Fix notmuch-describe-key

2019-03-03 Thread William Casarin
Yang Sheng  writes:

> Fix notmuch-describe-key crashing for the following two cases
> 1. format-kbd-macro cannot deal with keys like [(32 . 126)], switch to
> use key-description instead.
> 2. if a function in the current keymap is not bounded, it will crash
> the whole process. We check if it is bounded and silently skip it to
> avoid crashing.
> ---
>  emacs/notmuch-lib.el | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
> index 8cf7261e..546ab6fd 100644
> --- a/emacs/notmuch-lib.el
> +++ b/emacs/notmuch-lib.el
> @@ -298,7 +298,7 @@ This is basically just `format-kbd-macro' but we also 
> convert ESC to M-."
>"Prepend cons cells describing prefix-arg ACTUAL-KEY and ACTUAL-KEY to TAIL
>  
>  It does not prepend if ACTUAL-KEY is already listed in TAIL."
> -  (let ((key-string (concat prefix (format-kbd-macro actual-key
> +  (let ((key-string (concat prefix (key-description actual-key
>  ;; We don't include documentation if the key-binding is
>  ;; over-ridden. Note, over-riding a binding automatically hides the
>  ;; prefixed version too.
> @@ -313,7 +313,7 @@ It does not prepend if ACTUAL-KEY is already listed in 
> TAIL."
>;; Documentation for command
>(push (cons key-string
> (or (and (symbolp binding) (get binding 'notmuch-doc))
> -   (notmuch-documentation-first-line binding)))
> +   (and (functionp binding) 
> (notmuch-documentation-first-line binding
>   tail)))
>  tail)
>  

Thanks!

Some context: this fixes an issue in spacemacs where the help key is
broken:

  https://github.com/syl20bnr/spacemacs/issues/10123


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


Re: [PATCH] emacs: filter tag completions by current query

2018-11-24 Thread William Casarin
William Casarin  writes:

> When filtering by tags in notmuch-search-filter-by-tag, only return tags
> related to the current query.
>
> Before, it was returning all tags. There's no reason to refine the
> current query with tags that don't exist in the current result set.
>
> Signed-off-by: William Casarin 
> ---
>  emacs/notmuch.el | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index 44402f8a..28c50425 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -1076,7 +1076,7 @@ current search results AND the additional query string 
> provided."
>  Runs a new search matching only messages that match both the
>  current search results AND that are tagged with the given tag."
>(interactive
> -   (list (notmuch-select-tag-with-completion "Filter by tag: ")))
> +   (list (notmuch-select-tag-with-completion "Filter by tag: " 
> notmuch-search-query-string)))

For some more context here to move this patch along:

notmuch-select-tag-with-completion only has one caller, this one.
notmuch-select-tag-with-completion seems to expect this argument, for
some reason it was never passed along.

When it is not passed, it uses all tags ("*") for further refinement,
which doesn't make sense in this context.

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


Re: Proposed New sort API

2018-10-20 Thread William Casarin
David Bremner  writes:

> William Casarin  writes:
>
>> Another thought I had that I wanted to throw out there for
>> consideration. It would be nice to be able to sort by "popular" threads,
>> aka sort by the number of messages in each thread. Not sure if this is
>> an easy thing to do at the query level?
>
> I don't see how to manage it as a xapian query. In the current database
> schema xapian doesn't really know about threads, except that messages
> know what thread they belong to.

I noticed notmuch-search shows the number of messages in the thread,
perhaps you could just sort on that value when returning the results?
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH RFC] index: add body: search query term

2018-10-10 Thread William Casarin
William Casarin  writes:

> I wonder if it's all worth the effort though, since a workaround could
> be:
>
> notmuch search  and not subject:
>
> If it's too annoying to have a body prefix, due to index bloat or
> performance issues, would doing something hacky such as translating
> 'body:' to ' and not subject:' make sense?

Thinking about this some more, this is not exactly the same, since this
would explicitly exclude subjects, whereas the body query wouldn't care
what the subject was.

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


Re: [PATCH RFC] index: add body: search query term

2018-10-10 Thread William Casarin
David Bremner  writes:

> William Casarin  writes:

> I think you'll find you broke non-prefixed queries. Does the test suite
> still pass? If so, we need more tests.

yeah they seem to pass. but you're right, something seems a bit off:

./notmuch count subject:github or body:github and tag:notmuch
3271

./notmuch count github and tag:notmuch
665

> of terms I'd be intersted how much this bloats the index. Ideally with
> the performance corpus so we can all reproduce the experiment.

sounds good, I was wondering that as well.

I wonder if it's all worth the effort though, since a workaround could
be:

notmuch search  and not subject:

If it's too annoying to have a body prefix, due to index bloat or
performance issues, would doing something hacky such as translating
'body:' to ' and not subject:' make sense?

Will

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


[PATCH RFC] index: add body: search query term

2018-10-09 Thread William Casarin
This adds the ability to search specifically on the body

eg.

notmuch search tag:notmuch and body:PATCH

Signed-off-by: William Casarin 
---

Hey there,

I'm looking to add the ability to search specifically on the body. I
was poking around in the indexer, added these lines and reindexed a
few tags. It appears to work!

I was just wondering if there's anything I'm missing? That seemed a
bit too easy. I noticed there are some NOTMUCH_FIELDS that I'm not
sure what they do.

If anyone has any xapian knowledge that could shine some insight into
what the next steps might be, if any.

Thanks!
Will


 lib/database.cc | 3 +++
 lib/index.cc| 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/database.cc b/lib/database.cc
index 9cf8062c..0b085b21 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -297,6 +297,9 @@ prefix_t prefix_table[] = {
 { "subject",   "XSUBJECT", NOTMUCH_FIELD_EXTERNAL |
NOTMUCH_FIELD_PROBABILISTIC |
NOTMUCH_FIELD_PROCESSOR},
+{ "body",  "XBODY",NOTMUCH_FIELD_EXTERNAL |
+   NOTMUCH_FIELD_PROBABILISTIC |
+   NOTMUCH_FIELD_PROCESSOR},
 };
 
 static void
diff --git a/lib/index.cc b/lib/index.cc
index 3f694387..299b8770 100644
--- a/lib/index.cc
+++ b/lib/index.cc
@@ -506,7 +506,7 @@ _index_mime_part (notmuch_message_t *message,
 body = (char *) g_byte_array_free (byte_array, false);
 
 if (body) {
-   _notmuch_message_gen_terms (message, NULL, body);
+   _notmuch_message_gen_terms (message, "body", body);
 
free (body);
 }
-- 
2.19.0

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


Re: Proposed New sort API

2018-10-08 Thread William Casarin
David Bremner  writes:

> I started looking at William's sorting patches [1], but the
> proliferation of sorting options bugged me a bit. I decided to sketch
> out a new more flexible API.
>
> In the new API, there is is a sort "key", currently mapped one-to-one
> to value slots, but potentially could do more sophisticated things
> like making keys up dynamically (e.g. preprocessing subjects).
>
> The second parameter is a sort "type". Currently this is just
> ascending or descending, but other potential options include
> sort_by_relevance_then_value


Another thought I had that I wanted to throw out there for
consideration. It would be nice to be able to sort by "popular" threads,
aka sort by the number of messages in each thread. Not sure if this is
an easy thing to do at the query level?


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


Re: [PATCH 1/2] WIP: groundwork for new sorting API

2018-10-08 Thread William Casarin
David Bremner  writes:

> --- a/lib/notmuch.h
> +++ b/lib/notmuch.h
> @@ -773,6 +773,10 @@ notmuch_query_create (notmuch_database_t *database,
>   * Sort values for notmuch_query_set_sort.
>   */
>  typedef enum {
> +/**
> + * Value was not set
> + */
> +NOTMUCH_SORT_UNSET = -1,
>  /**
>   * Oldest first.
>   */
> @@ -791,6 +795,42 @@ typedef enum {
>  NOTMUCH_SORT_UNSORTED
>  } notmuch_sort_t;


I'm adding a few new keys (from, subject, etc). I don't want to
duplicate them in the old notmuch_sort_t enum, I assume to move to the
new API there should be something like this as well?


diff --git a/lib/notmuch.h b/lib/notmuch.h
index d26cc09b..81a9d72f 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -787,10 +787,14 @@ typedef enum {
 NOTMUCH_SORT_NEWEST_FIRST,
 /**
  * Sort by message-id.
  */
 NOTMUCH_SORT_MESSAGE_ID,
+/**
+ * Sort by keys.
+ */
+NOTMUCH_SORT_KEYS,
 /**
  * Do not sort.
  */
 NOTMUCH_SORT_UNSORTED
 } notmuch_sort_t;


I've been wanting to sort by multiple keys recently so I figured
generalizing this to multiple (key, order) pairs might be a good idea
now that we're rethinking the sort api.

so then if I wanted to add my current changes I could just add a few
more keys like so:


diff --git a/lib/notmuch.h b/lib/notmuch.h
index a035bdb2..d26cc09b 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -809,10 +809,18 @@ typedef enum {
 NOTMUCH_SORT_KEY_TIMESTAMP,
 /**
  * Sort by message-id.
  */
 NOTMUCH_SORT_KEY_MESSAGE_ID,
+/**
+ * Sort by subject.
+ */
+NOTMUCH_SORT_KEY_SUBJECT,
+/**
+ * Sort by from.
+ */
+NOTMUCH_SORT_KEY_FROM,
 } notmuch_sort_key_t;
 

Then we could eventually do something like:

  --sort date:desc,from:asc

Which would mean: sort by date, and then by from.

Perhaps it could do something sensible by default without order
qualifiers as well:

  --sort date,from

LMK what you think


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


[PATCH] emacs: filter tag completions by current query

2018-10-08 Thread William Casarin
When filtering by tags in notmuch-search-filter-by-tag, only return tags
related to the current query.

Before, it was returning all tags. There's no reason to refine the
current query with tags that don't exist in the current result set.

Signed-off-by: William Casarin 
---
 emacs/notmuch.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 44402f8a..28c50425 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -1076,7 +1076,7 @@ current search results AND the additional query string 
provided."
 Runs a new search matching only messages that match both the
 current search results AND that are tagged with the given tag."
   (interactive
-   (list (notmuch-select-tag-with-completion "Filter by tag: ")))
+   (list (notmuch-select-tag-with-completion "Filter by tag: " 
notmuch-search-query-string)))
   (notmuch-search (concat notmuch-search-query-string " and tag:" tag) 
notmuch-search-oldest-first))
 
 ;;;###autoload
-- 
2.19.0

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


Re: unused/total message counts in hello screen?

2018-09-30 Thread William Casarin
Jeff Templon  writes:

> An alternative would be if I could toggle the entire page to show just
> the unread tags (so any tags for which all messages were read would
> just not show up). Maybe even preferable, that last one.

This can be done setting "notmuch-hello-tag-list-make-query" to "tag:unread"

I have mine set to "tag:inbox" so that I only see tag counts on the home
screen that haven't been archived yet.


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


Re: Sorting & grouping

2018-07-23 Thread William Casarin
Leonard Lausen  writes:

> What do you think about adding a 'group' option that will group mails
> with the same set of tags (possibly minus a list of tags to be ignored
> when grouping) and apply the normal search.

Hmm. I think could be simplified by sorting by a specific tag, and then
by date, etc

Once sorted by a tag, grouping could be a UI thing. Clients would be
able to create visual groupings once they know what tag they are sorting on.

Cheers,
Will

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


Re: GitHub + notmuch scripts/hacks

2018-06-24 Thread William Casarin
William Casarin  writes:

> I've started collecting[1] a bunch of notmuch+GitHub hacks from some of
> the discussions @ id:87d16jtsdj@kyleam.com
> [..]
>
> [1] https://github.com/jb55/notmuch-github
> [2] 
> https://github.com/jb55/notmuch-github/commit/fb2d80cf9ee9a5967c78ae6ccda866ee98cdd547
> [3] https://jb55.com/s/notmuch-github.mp4

Hey notmuch peoples,

I've started looking into possible ways to tag github pull requests and
issues. So far I've been able to put together these semi-reliable
tagging methods for pull requests:

notmuch tag +github from:github.com and tag:inbox

notmuch tag +pr '"You can view, comment on, or merge this pull request 
online at"' \
  and tag:github and not tag:pr and tag:inbox and not tag:issue

# tag all messages in the thread that have a pr tag
notmuch tag +pr $(notmuch search --output=threads tag:pr and tag:inbox)

# this seems to be a semi reliable way to find github merge emails
notmuch tag +merged Merged and event from:notificati...@github.com \
  and not tag:merged and tag:inbox and tag:pr

# tag the entire pr thread as merged
notmuch tag +merged $(notmuch search --output=threads tag:merged and 
tag:inbox)

I still haven't found a reliable way to tag issues and their closed
status. If anyone has something more reliable feel free to share here or
at https://github.com/jb55/notmuch-github#tagging

Cheers,
Will


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


Re: Proposed New sort API

2017-12-10 Thread William Casarin
David Bremner  writes:

> I started looking at William's sorting patches [1], but the
> proliferation of sorting options bugged me a bit. I decided to sketch
> out a new more flexible API.
>
> In the new API, there is is a sort "key", currently mapped one-to-one
> to value slots, but potentially could do more sophisticated things
> like making keys up dynamically (e.g. preprocessing subjects).
>
> The second parameter is a sort "type". Currently this is just
> ascending or descending, but other potential options include
> sort_by_relevance_then_value

This is great, this is what I was thinking about as well. I'll try
refactoring my sorting branch on top of these changes.

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


Re: [PATCH 1/3] cli: add support for --no- prefixed boolean and keyword flag arguments

2017-10-14 Thread William Casarin

Tested ACK 1-3 + id:20171014201836.4486-1-j...@nikula.org
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 1/3] cli: add support for --no- prefixed boolean and keyword flag arguments

2017-10-14 Thread William Casarin
Jani Nikula  writes:

> *blush* I screwed those enums up. Here's a patch that takes care of both
> issues id:20171014201836.4486-1-j...@nikula.org. It's independent of
> this series.

Works, thanks.

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


Re: [bug] [emacs] notmuch-show: names not shown on some mailing lists

2017-10-14 Thread William Casarin
Nevermind, the issue seems to go away on master

Sorry for the noise...
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 1/3] cli: add support for --no- prefixed boolean and keyword flag arguments

2017-10-14 Thread William Casarin

Hey Jani,

Patches look good so far, concept ack for sure.


Jani Nikula  writes:

> For example, you can use --no-exclude instead of --exclude=false in
> notmuch show. If we had keyword flag arguments with some flags
> defaulting to on, say --include=tags in notmuch dump/restore, this
> would allow --no-include=tags to switch that off while not affecting
> other flags.

I've been testing it a bit, I can't seem to make this work in this example:

./notmuch count --no-exclude

After some brief investigation it might be because count is using
EXCLUDE_true(1) and EXCLUDE_false(0) which are not equal to
NOTMUCH_EXCLUDE_TRUE(1) and NOTMUCH_EXCLUDE_FALSE(2), but I'm not sure.

Cheers,
William

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


Re: [bug] [emacs] notmuch-show: names not shown on some mailing lists

2017-10-14 Thread William Casarin
William Casarin <j...@jb55.com> writes:

> Jani Nikula <j...@nikula.org> writes:
>
>> The information comes from the cli. Can you reproduce this using some
>> notmuch show --format=sexp --body=false query, perhaps on just one of
>> the messages?
>
> I get this:
>
>   :From "Person via Mailing list\011<mailingl...@lists.linuxfoundation.org>"

If I wanted to fix this, would I implement it as a wash function?

Thanks,


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


Re: [bug] [emacs] notmuch-show: names not shown on some mailing lists

2017-10-14 Thread William Casarin
Jani Nikula  writes:

> The information comes from the cli. Can you reproduce this using some
> notmuch show --format=sexp --body=false query, perhaps on just one of
> the messages?

I get this:

  :From "Person via Mailing list\011"


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


GitHub + notmuch scripts/hacks

2017-10-13 Thread William Casarin

Hey there,

I've started collecting[1] a bunch of notmuch+GitHub hacks from some of
the discussions @ id:87d16jtsdj@kyleam.com

I've added the ability to comment on/approve/reject pull requests from a
GitHub pull-request email[2].

It can also open a magit-log view of the PR from an email, as shown in
this[3] demo video.

This is still very much a work in progress and is not very user friendly
yet. If you would like to help out and convert my hacky bash script to
elisp that would be great.

Much of this work is due to Kyle Meyer and I have been building off of it.
Thanks Kyle!

Cheers,
William


[1] https://github.com/jb55/notmuch-github
[2] 
https://github.com/jb55/notmuch-github/commit/fb2d80cf9ee9a5967c78ae6ccda866ee98cdd547
[3] https://jb55.com/s/notmuch-github.mp4


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


Re: Washing GitHub emails to include inline patch?

2017-10-13 Thread William Casarin
Kyle Meyer  writes:

> Looking at what I wrote again, I'd change DONT-FETCH to FORCE-FETCH and
> then do something like
>
> (when (or force-fetch
>   (not (magit-ref-exists-p local-ref)))
>   (magit-call-git "fetch" "origin"))
>
> where local-ref is bound to "refs/pull/origin/".  That way, "git
> fetch" is only called if the ref doesn't already exist locally or when a
> prefix argument is given, which would be useful for forced updates.

Oh, good call.

>> -(magit-log (list (concat "master..refs/pull/origin/" pr)
>> +(magit-log (list (concat "origin/master..refs/pull/origin/" pr)
>
> Anyway, it's nice to see that you've been able to modify this into
> something that might be useful to you.

Indeed, thanks again.

The last piece of the puzzle is the origin/master branch isn't always
the base branch it's merging into. I believe the proper way to do this
is like so. First we add another set of refs to fetch in our .git/config:

[remote "origin"]
  fetch = +refs/pull/*/merge:refs/merge/origin/*

Now we can use this to get the base branch for the PR:

refs/merge/origin/100^..refs/pull/origin/100

Which returns the proper set of commits.


Cheers,


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


Re: Washing GitHub emails to include inline patch?

2017-10-12 Thread William Casarin
Kyle Meyer  writes:

> --8<---cut here---start->8---
>
> (defun km/notmuch-github-pr-number ()
>   "Return the PR number for this message."
>   (let (pr)
> (with-current-notmuch-show-message
>  (goto-char (point-min))
>  (if (re-search-forward "https://github\\.com/.*/pull/\\([0-9]+\\)" nil t)
>  (setq pr (match-string-no-properties 1))
>(user-error "Could not find PR number")))
> pr))
>
> ;; This function could be anything that figures out the project based
> ;; on the current notmuch message.  Or, if you use projectile and
> ;; don't mind getting queried each time, it could just read a project
> ;; from `projectile-relevant-known-projects'.
> (defun km/notmuch-repo-from-message ()
>   "Return the repository that this message is associated with."
>   (let ((fname (notmuch-show-get-filename)))
> (or (and fname
>  (string-match-p "magit-list" fname)
>  "~/src/emacs/magit")
> (user-error "Could not determine repo"
>
> (defun km/notmuch-visit-pr-in-magit ( dont-fetch)
>   "Show the Magit log for this message's PR.
> If DONT-FETCH is non-nil, do not fetch first."
>   (interactive "P")
>   (let* ((pr (km/notmuch-github-pr-number))
>  (repo (km/notmuch-repo-from-message))
>  (default-directory repo))
> ;; "origin" is hard-coded below, but it could of course be
> ;; anything.  You could also have an alist that maps repo ->
> ;; remote.
> ;;
> ;; This assumes that you've added
> ;;
> ;;fetch = +refs/pull/*/head:refs/pull/origin/*
> ;;
> ;; to origin's in ".git/config".  You could drop that assumption
> ;; passing a more explicit refspec to the fetch call.
> (unless dont-fetch
>   (magit-call-git "fetch" "origin"))
> (magit-log (list (concat "master..refs/pull/origin/" pr)
> --8<---cut here---end--->8---

This worked pretty well, I've modified it a bit to support a generic
github repo location which is parsed from the subject, and origin/master
instead of master:

--- kyle1.el	2017-10-12 12:22:01.977663605 -0700
+++ kyle2.el	2017-10-12 12:24:49.644673189 -0700
@@ -14,10 +14,12 @@
 ;; from `projectile-relevant-known-projects'.
 (defun km/notmuch-repo-from-message ()
   "Return the repository that this message is associated with."
-  (let ((fname (notmuch-show-get-filename)))
-(or (and fname
- (string-match-p "magit-list" fname)
- "~/src/emacs/magit")
+  (let ((subject (notmuch-show-get-subject))
+(repo))
+(or (and subject
+ (or (and (string-match "\\([^\]]+\\)" subject 1)
+  (setq repo (match-string-no-properties 1 subject))
+  (concat "~/dev/github/" repo
 (user-error "Could not determine repo"
 
 (defun km/notmuch-visit-pr-in-magit ( dont-fetch)
@@ -39,4 +41,4 @@
 ;; passing a more explicit refspec to the fetch call.
 (unless dont-fetch
   (magit-call-git "fetch" "origin"))
-(magit-log (list (concat "master..refs/pull/origin/" pr)
+(magit-log (list (concat "origin/master..refs/pull/origin/" pr)

Cheers,
William

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


  1   2   >