]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch.el
notmuch.el: Add 't' binding to filter results to a specific tag.
[notmuch] / notmuch.el
index 0fb6e5f8a8aa59b7c5f4fe705472721f18f2c5f9..989450a697e946cdb2e0f92fb1c8ca1f32fd917f 100644 (file)
 ; along with Notmuch.  If not, see <http://www.gnu.org/licenses/>.
 ;
 ; Authors: Carl Worth <cworth@cworth.org>
-;
-; Much of notmuch.el was written by looking at the implementation of
-; compile.el from the emacs distribution source which has the
-; following copyright and authorsip (and the identical license as
-; above):
-;
-; Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-;   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
-;   Free Software Foundation, Inc.
-
-; Authors: Roland McGrath <roland@gnu.org>,
-;          Daniel Pfeiffer <occitan@esperanto.org>
 
 (defvar notmuch-show-mode-map
   (let ((map (make-sparse-keymap)))
@@ -334,11 +322,13 @@ Does nothing if already on the first message in the buffer."
 (defvar notmuch-search-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map "a" 'notmuch-search-archive-thread)
+    (define-key map "b" 'scroll-down)
     (define-key map "f" 'notmuch-search-filter)
     (define-key map "n" 'next-line)
     (define-key map "p" 'previous-line)
     (define-key map "q" 'kill-this-buffer)
     (define-key map "s" 'notmuch-search)
+    (define-key map "t" 'notmuch-search-filter-by-tag)
     (define-key map "x" 'kill-this-buffer)
     (define-key map "\r" 'notmuch-search-show-thread)
     (define-key map "+" 'notmuch-search-add-tag)
@@ -347,6 +337,8 @@ Does nothing if already on the first message in the buffer."
     (define-key map ">" 'notmuch-search-goto-last-thread)
     (define-key map "=" 'notmuch-search-refresh-view)
     (define-key map "\M->" 'notmuch-search-goto-last-thread)
+    (define-key map " " 'scroll-up)
+    (define-key map (kbd "<DEL>") 'scroll-down)
     map)
   "Keymap for \"notmuch search\" buffers.")
 (fset 'notmuch-search-mode-map notmuch-search-mode-map)
@@ -363,6 +355,8 @@ Does nothing if already on the first message in the buffer."
   (interactive)
   (kill-all-local-variables)
   (make-local-variable 'notmuch-search-query-string)
+  (set (make-local-variable 'scroll-preserve-screen-position) t)
+  (add-to-invisibility-spec 'notmuch-search)
   (use-local-map notmuch-search-mode-map)
   (setq major-mode 'notmuch-search-mode
        mode-name "notmuch-search")
@@ -391,11 +385,15 @@ Does nothing if already on the first message in the buffer."
 
 (defun notmuch-search-hide-thread-ids ()
   (interactive)
-  (add-to-invisibility-spec 'notmuch-search))
+  (add-to-invisibility-spec 'notmuch-search)
+  (force-window-update)
+  (redisplay t))
 
 (defun notmuch-search-show-thread-ids ()
   (interactive)
-  (remove-from-invisibility-spec 'notmuch-search))
+  (remove-from-invisibility-spec 'notmuch-search)
+  (force-window-update)
+  (redisplay t))
 
 (defun notmuch-search-show-thread ()
   (interactive)
@@ -495,14 +493,21 @@ same relative position within the new buffer."
       (goto-char here))))
 
 (defun notmuch-search-filter (query)
-  "Run \"notmuch search\" to refine the current search results.
+  "Filter the current search results based on an additional query string.
 
-A search string will be constructed by appending QUERY to the
-current search string, and the results of \"notmuch search\" for
-the combined query will be displayed."
+Runs a new search matching only messages that match both the
+current search results AND the additional query string provided."
   (interactive "sFilter search: ")
   (notmuch-search (concat notmuch-search-query-string " and " query)))
 
+(defun notmuch-search-filter-by-tag (tag)
+  "Filter the current search results based on a single tag.
+
+Runs a new search matching only messages that match both the
+current search results AND that are tagged with the given tag."
+  (interactive "sFilter by tag: ")
+  (notmuch-search (concat notmuch-search-query-string " and tag:" tag)))
+
 (defun notmuch ()
   "Run notmuch to display all mail with tag of 'inbox'"
   (interactive)