1 ; notmuch.el --- run notmuch within emacs
3 ; Copyright © Carl Worth
5 ; This file is part of Notmuch.
7 ; Notmuch is free software: you can redistribute it and/or modify it
8 ; under the terms of the GNU General Public License as published by
9 ; the Free Software Foundation, either version 3 of the License, or
10 ; (at your option) any later version.
12 ; Notmuch is distributed in the hope that it will be useful, but
13 ; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ; General Public License for more details.
17 ; You should have received a copy of the GNU General Public License
18 ; along with Notmuch. If not, see <http://www.gnu.org/licenses/>.
20 ; Authors: Carl Worth <cworth@cworth.org>
22 ; Much of notmuch.el was written by looking at the implementation of
23 ; compile.el from the emacs distribution source which has the
24 ; following copyright and authorsip (and the identical license as
27 ; Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
28 ; 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
29 ; Free Software Foundation, Inc.
31 ; Authors: Roland McGrath <roland@gnu.org>,
32 ; Daniel Pfeiffer <occitan@esperanto.org>
34 (defvar notmuch-search-mode-map
35 (let ((map (make-sparse-keymap)))
36 (define-key map "n" 'next-line)
37 (define-key map "p" 'previous-line)
39 "Keymap for \"notmuch search\" buffers.")
40 (fset 'notmuch-search-mode-map notmuch-search-mode-map)
43 (defun notmuch-search-mode ()
44 "Major mode for handling the output of notmuch search"
46 (kill-all-local-variables)
47 (use-local-map notmuch-search-mode-map)
48 (setq major-mode 'notmuch-search-mode
49 mode-name "notmuch-search")
50 (setq buffer-read-only t))
52 (defun notmuch-search (query)
53 "Run \"notmuch search\" with the given query string and display results."
54 (interactive "sNotmuch search: ")
55 (let ((buffer (get-buffer-create (concat "*notmuch-search-" query))))
56 (switch-to-buffer buffer)
58 (let ((proc (get-buffer-process (current-buffer)))
59 (inhibit-read-only t))
61 (error "notmuch search process already running for query `%s'" query)
66 (call-process "notmuch" nil t nil "search" query)
71 "Run notmuch to display all mail with tag of 'inbox'"
73 (notmuch-search "tag:inbox"))