unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Mark Walters <markwalters1009@gmail.com>
To: notmuch@notmuchmail.org
Subject: [PATCH v5 2/3] emacs: add a filter option to show
Date: Sat, 13 Jun 2015 09:08:09 +0100	[thread overview]
Message-ID: <1434182890-8047-3-git-send-email-markwalters1009@gmail.com> (raw)
In-Reply-To: <1434182890-8047-1-git-send-email-markwalters1009@gmail.com>

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 file changed, 12 insertions(+)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index a978d3c..4dee34b 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -47,6 +47,7 @@
 (declare-function notmuch-tree "notmuch-tree"
 		  (&optional query query-context target buffer-name open-target))
 (declare-function notmuch-tree-get-message-properties "notmuch-tree" nil)
+(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.
@@ -1372,6 +1373,7 @@ (defvar notmuch-show-mode-map
     (define-key map (kbd "<backtab>") 'notmuch-show-previous-button)
     (define-key map (kbd "TAB") 'notmuch-show-next-button)
     (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)
@@ -1660,6 +1662,16 @@ (defun notmuch-show-command-hook ()
     (save-excursion
       (funcall notmuch-show-mark-read-function (window-start) (window-end)))))
 
+(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.
 
-- 
2.1.4

  parent reply	other threads:[~2015-06-13  8:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-13  8:08 [PATCH v5 0/3] Add filter to emacs show mode Mark Walters
2015-06-13  8:08 ` [PATCH v5 1/3] emacs: split notmuch-show-apply-state Mark Walters
2015-06-13  8:08 ` Mark Walters [this message]
2015-08-04  7:19   ` [PATCH v5 2/3] emacs: add a filter option to show David Bremner
2015-06-13  8:08 ` [PATCH v5 3/3] emacs: Bind filter in search to 'l' Mark Walters
2015-09-07  6:19   ` Tomi Ollila
2016-02-09 20:24   ` David Edmondson
2016-02-09 21:04     ` Mark Walters
2016-02-10  8:17       ` Tomi Ollila
2016-02-17 22:44       ` Daniel Kahn Gillmor
2016-02-18  0:24         ` David Bremner
2016-02-18  7:54         ` David Edmondson
2016-02-13 16:45   ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1434182890-8047-3-git-send-email-markwalters1009@gmail.com \
    --to=markwalters1009@gmail.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).