unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [Patch v4 0/3] Add filter to emacs show mode
@ 2012-04-29  0:06 Mark Walters
  2012-04-29  0:06 ` [Patch v4 1/3] emacs: split notmuch-show-apply-state Mark Walters
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Mark Walters @ 2012-04-29  0:06 UTC (permalink / raw)
  To: notmuch

This is version 4 of the patch set allowing the user to "filter" which
messages are open in emacs show mode. The previous version was at
id:"1335467689-6513-1-git-send-email-markwalters1009@gmail.com"

The change in this version is to keep position in the thread (at least
to the same message). 

The first patch (new in this series) just splits out a sub-function
notmuch-show-goto-msg-id from notmuch-show-apply-state.

The second patch is almost the same as the first patch in the previous
series but uses the new notmuch-show-goto-msg-id function to maintain
position in the thread.

The final patch is identical to the final patch of the previous series
which moves the key-binding for filter in emacs search mode to 'l' to
match the new binding in show-mode.

Best wishes

Mark



Mark Walters (3):
  emacs: split notmuch-show-apply-state
  emacs: add a filter option to show
  emacs: Bind filter in search to 'l'

 emacs/notmuch-show.el |   30 +++++++++++++++++++++++-------
 emacs/notmuch.el      |    4 ++--
 2 files changed, 25 insertions(+), 9 deletions(-)

-- 
1.7.9.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Patch v4 1/3] emacs: split notmuch-show-apply-state
  2012-04-29  0:06 [Patch v4 0/3] Add filter to emacs show mode Mark Walters
@ 2012-04-29  0:06 ` Mark Walters
  2012-04-29  0:57   ` Austin Clements
  2012-04-29  0:06 ` [Patch v4 2/3] emacs: add a filter option to show Mark Walters
  2012-04-29  0:06 ` [Patch v4 3/3] emacs: Bind filter in search to 'l' Mark Walters
  2 siblings, 1 reply; 5+ messages in thread
From: Mark Walters @ 2012-04-29  0:06 UTC (permalink / raw)
  To: notmuch

Separate out a notmuch-show-goto-msg-id sub-function from
notmuch-show-apply-state. There should be no functional change but the
next patch will call the new function.
---
 emacs/notmuch-show.el |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 30b26d1..3bd9a64 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1085,6 +1085,16 @@ This includes:
  - the current message."
   (list (notmuch-show-get-message-id) (notmuch-show-get-message-ids-for-open-messages)))
 
+(defun notmuch-show-goto-message (msg-id)
+  "Go to message with msg-id."
+  (goto-char (point-min))
+  (unless (loop if (string= msg-id (notmuch-show-get-message-id))
+		return t
+		until (not (notmuch-show-goto-message-next)))
+    (goto-char (point-min))
+    (message "Message-id not found."))
+  (notmuch-show-message-adjust))
+
 (defun notmuch-show-apply-state (state)
   "Apply STATE to the current buffer.
 
@@ -1102,13 +1112,7 @@ This includes:
 	  until (not (notmuch-show-goto-message-next)))
 
     ;; Go to the previously open message.
-    (goto-char (point-min))
-    (unless (loop if (string= current (notmuch-show-get-message-id))
-		  return t
-		  until (not (notmuch-show-goto-message-next)))
-      (goto-char (point-min))
-      (message "Previously current message not found."))
-    (notmuch-show-message-adjust)))
+    (notmuch-show-goto-message current)))
 
 (defun notmuch-show-refresh-view (&optional reset-state)
   "Refresh the current view.
-- 
1.7.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Patch v4 2/3] emacs: add a filter option to show
  2012-04-29  0:06 [Patch v4 0/3] Add filter to emacs show mode Mark Walters
  2012-04-29  0:06 ` [Patch v4 1/3] emacs: split notmuch-show-apply-state Mark Walters
@ 2012-04-29  0:06 ` Mark Walters
  2012-04-29  0:06 ` [Patch v4 3/3] emacs: Bind filter in search to 'l' Mark Walters
  2 siblings, 0 replies; 5+ messages in thread
From: Mark Walters @ 2012-04-29  0:06 UTC (permalink / raw)
  To: notmuch

Show the current thread with a different filter (i.e., open messages
in the thread matching the new query).

Bound to 'l' for "limit".

Note that it is not the same as filter in search mode as it replaces
the existing query rather than ANDing with it (but it does keep the
thread-id part of the query).
---
 emacs/notmuch-show.el |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 3bd9a64..f52a96d 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -42,6 +42,7 @@
 (declare-function notmuch-search-next-thread "notmuch" nil)
 (declare-function notmuch-search-show-thread "notmuch" nil)
 (declare-function notmuch-update-tags "notmuch" (current-tags tag-changes))
+(declare-function notmuch-read-query "notmuch" (prompt))
 
 (defcustom notmuch-message-headers '("Subject" "To" "Cc" "Date")
   "Headers that should be shown in a message, in this order.
@@ -1161,6 +1162,7 @@ reset based on the original query."
 	(define-key map "s" 'notmuch-search)
 	(define-key map "m" 'notmuch-mua-new-mail)
 	(define-key map "f" 'notmuch-show-forward-message)
+	(define-key map "l" 'notmuch-show-filter-thread)
 	(define-key map "r" 'notmuch-show-reply-sender)
 	(define-key map "R" 'notmuch-show-reply)
 	(define-key map "|" 'notmuch-show-pipe-message)
@@ -1403,6 +1405,16 @@ current thread."
   "Mark the current message as read."
   (notmuch-show-tag-message "-unread"))
 
+(defun notmuch-show-filter-thread (query)
+  "Filter or LIMIT the current thread based on a new query string.
+
+Reshows the current thread with matches defined by the new query-string."
+  (interactive (list (notmuch-read-query "Filter thread: ")))
+  (let ((msg-id (notmuch-show-get-message-id)))
+    (setq notmuch-show-query-context (if (string= query "") nil query))
+    (notmuch-show-refresh-view t)
+    (notmuch-show-goto-message msg-id)))
+
 ;; Functions for getting attributes of several messages in the current
 ;; thread.
 
-- 
1.7.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Patch v4 3/3] emacs: Bind filter in search to 'l'
  2012-04-29  0:06 [Patch v4 0/3] Add filter to emacs show mode Mark Walters
  2012-04-29  0:06 ` [Patch v4 1/3] emacs: split notmuch-show-apply-state Mark Walters
  2012-04-29  0:06 ` [Patch v4 2/3] emacs: add a filter option to show Mark Walters
@ 2012-04-29  0:06 ` Mark Walters
  2 siblings, 0 replies; 5+ messages in thread
From: Mark Walters @ 2012-04-29  0:06 UTC (permalink / raw)
  To: notmuch

Change the key binding for filter (or "limit") in search-mode. This
gives consistency with the new filter in show-mode, and frees 'f' for
forward-thread in the future.
---
 emacs/notmuch.el |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 736d00f..3df826c 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -286,7 +286,7 @@ For a mouse binding, return nil."
     (define-key map "=" 'notmuch-search-refresh-view)
     (define-key map "G" 'notmuch-search-poll-and-refresh-view)
     (define-key map "t" 'notmuch-search-filter-by-tag)
-    (define-key map "f" 'notmuch-search-filter)
+    (define-key map "l" 'notmuch-search-filter)
     (define-key map [mouse-1] 'notmuch-search-show-thread)
     (define-key map "*" 'notmuch-search-tag-all)
     (define-key map "a" 'notmuch-search-archive-thread)
@@ -1095,7 +1095,7 @@ search."
   (notmuch-search-refresh-view))
 
 (defun notmuch-search-filter (query)
-  "Filter the current search results based on an additional query string.
+  "Filter or LIMIT the current search results based on an additional query string.
 
 Runs a new search matching only messages that match both the
 current search results AND the additional query string provided."
-- 
1.7.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Patch v4 1/3] emacs: split notmuch-show-apply-state
  2012-04-29  0:06 ` [Patch v4 1/3] emacs: split notmuch-show-apply-state Mark Walters
@ 2012-04-29  0:57   ` Austin Clements
  0 siblings, 0 replies; 5+ messages in thread
From: Austin Clements @ 2012-04-29  0:57 UTC (permalink / raw)
  To: Mark Walters; +Cc: notmuch

Hmm.  I think this will wind up spuriously marking messages read.  If
notmuch-show-refresh-view is called with reset-state set to t, it will
mark the first open message read, before you move to the previously
current message.

IMO, notmuch-show-refresh-view should not be marking messages read at
all, but I tried to separate out that functionality before and failed.
Perhaps you can find a good way to do it.  A more incremental but
slightly lame approach could be to pass some symbol for reset-state
that indicates it should reset the open state, but not the
position... and not mark anything read.  Ugh.

Quoth Mark Walters on Apr 29 at  1:06 am:
> Separate out a notmuch-show-goto-msg-id sub-function from
> notmuch-show-apply-state. There should be no functional change but the
> next patch will call the new function.
> ---
>  emacs/notmuch-show.el |   18 +++++++++++-------
>  1 files changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 30b26d1..3bd9a64 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -1085,6 +1085,16 @@ This includes:
>   - the current message."
>    (list (notmuch-show-get-message-id) (notmuch-show-get-message-ids-for-open-messages)))
>  
> +(defun notmuch-show-goto-message (msg-id)
> +  "Go to message with msg-id."
> +  (goto-char (point-min))
> +  (unless (loop if (string= msg-id (notmuch-show-get-message-id))
> +		return t
> +		until (not (notmuch-show-goto-message-next)))
> +    (goto-char (point-min))
> +    (message "Message-id not found."))
> +  (notmuch-show-message-adjust))
> +
>  (defun notmuch-show-apply-state (state)
>    "Apply STATE to the current buffer.
>  
> @@ -1102,13 +1112,7 @@ This includes:
>  	  until (not (notmuch-show-goto-message-next)))
>  
>      ;; Go to the previously open message.
> -    (goto-char (point-min))
> -    (unless (loop if (string= current (notmuch-show-get-message-id))
> -		  return t
> -		  until (not (notmuch-show-goto-message-next)))
> -      (goto-char (point-min))
> -      (message "Previously current message not found."))
> -    (notmuch-show-message-adjust)))
> +    (notmuch-show-goto-message current)))
>  
>  (defun notmuch-show-refresh-view (&optional reset-state)
>    "Refresh the current view.

-- 
Austin Clements                                      MIT/'06/PhD/CSAIL
amdragon@mit.edu                           http://web.mit.edu/amdragon
       Somewhere in the dream we call reality you will find me,
              searching for the reality we call dreams.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-04-29  0:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-29  0:06 [Patch v4 0/3] Add filter to emacs show mode Mark Walters
2012-04-29  0:06 ` [Patch v4 1/3] emacs: split notmuch-show-apply-state Mark Walters
2012-04-29  0:57   ` Austin Clements
2012-04-29  0:06 ` [Patch v4 2/3] emacs: add a filter option to show Mark Walters
2012-04-29  0:06 ` [Patch v4 3/3] emacs: Bind filter in search to 'l' Mark Walters

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).