unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Edmondson <dme@dme.org>
To: notmuch@notmuchmail.org
Subject: [PATCH 2/5] emacs: Allow `notmuch-show-mode' to display only matching messages.
Date: Tue, 31 Jan 2012 08:46:57 +0000	[thread overview]
Message-ID: <1327999620-14595-3-git-send-email-dme@dme.org> (raw)
In-Reply-To: <1327999620-14595-1-git-send-email-dme@dme.org>

The current behaviour (all messages shown, non-matching collapsed)
is retained as the default. Type '!' to switch to showing only
the matching messages - non-matching messages are not available.
'!' will switch back to showing everything.
---
 emacs/notmuch-show.el |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 35a2809..77ba2dd 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -136,6 +136,10 @@ indentation."
 (make-variable-buffer-local 'notmuch-show-process-crypto)
 (put 'notmuch-show-process-crypto 'permanent-local t)
 
+(defvar notmuch-show-elide-non-matching-messages nil)
+(make-variable-buffer-local 'notmuch-show-elide-non-matching-messages)
+(put 'notmuch-show-elide-non-matching-messages 'permanent-local t)
+
 (defmacro with-current-notmuch-show-message (&rest body)
   "Evaluate body with current buffer set to the text of current message"
   `(save-excursion
@@ -923,11 +927,22 @@ current buffer, if possible."
 	     "Not processing cryptographic MIME parts."))
   (notmuch-show-refresh-view))
 
+(defun notmuch-show-toggle-elide-non-matching ()
+  "Toggle the display of non-matching messages."
+  (interactive)
+  (setq notmuch-show-elide-non-matching-messages (not notmuch-show-elide-non-matching-messages))
+  (message (if notmuch-show-elide-non-matching-messages
+	       "Showing matching messages only."
+	     "Showing all messages."))
+  (notmuch-show-refresh-view))
+
 (defun notmuch-show-insert-tree (tree depth)
   "Insert the message tree TREE at depth DEPTH in the current thread."
   (let ((msg (car tree))
 	(replies (cadr tree)))
-    (notmuch-show-insert-msg msg depth)
+    (if (or (not notmuch-show-elide-non-matching-messages)
+	    (plist-get msg :match))
+	(notmuch-show-insert-msg msg depth))
     (notmuch-show-insert-thread replies (1+ depth))))
 
 (defun notmuch-show-insert-thread (thread depth)
@@ -1081,6 +1096,7 @@ Refreshes the current view, observing changes in cryptographic preferences."
 	(define-key map (kbd "M-RET") 'notmuch-show-open-or-close-all)
 	(define-key map (kbd "RET") 'notmuch-show-toggle-message)
 	(define-key map "#" 'notmuch-show-print-message)
+	(define-key map "!" 'notmuch-show-toggle-elide-non-matching)
 	(define-key map "$" 'notmuch-show-toggle-process-crypto)
 	map)
       "Keymap for \"notmuch show\" buffers.")
-- 
1.7.8.3

  parent reply	other threads:[~2012-01-31  8:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <id:"1327486729-18052-1-git-send-email-dme@dme.org">
2012-01-31  8:46 ` [PATCH 0/5 v4] reworked crypto toggle, plus a few other toggles David Edmondson
2012-01-31  8:46   ` [PATCH 1/5] emacs: Rework crypto switch toggle David Edmondson
2012-01-31  8:46   ` David Edmondson [this message]
2012-01-31  8:46   ` [PATCH 3/5] emacs: Allow the indentation of content to be toggled David Edmondson
2012-01-31 16:15     ` Mark Walters
2012-01-31 16:23       ` David Edmondson
2012-01-31 23:50         ` Mark Walters
2012-02-01  8:52           ` Tomi Ollila
2012-01-31  8:46   ` [PATCH 4/5] emacs: Add a binding (>) to toggle the truncation of long lines David Edmondson
2012-01-31  8:47   ` [PATCH 5/5] emacs: Optionally retain the state of the buffer during `notmuch-show-refresh-view' David Edmondson
2012-01-31  8:55   ` [PATCH 0/5 v4] reworked crypto toggle, plus a few other toggles David Edmondson
2012-01-25 10:18 [PATCH 0/3] reworked crypto toggle, plus a couple of " David Edmondson
2012-01-30 16:30 ` [PATCH 0/5 v3] reworked crypto toggle, plus a few " David Edmondson
2012-01-30 16:31   ` [PATCH 2/5] emacs: Allow `notmuch-show-mode' to display only matching messages David Edmondson

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=1327999620-14595-3-git-send-email-dme@dme.org \
    --to=dme@dme.org \
    --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).