]> git.notmuchmail.org Git - notmuch/blob - emacs/notmuch-lib.el
notmuch-hello: Add a 'G' keybinding.
[notmuch] / emacs / notmuch-lib.el
1 ;; notmuch-lib.el --- common variables, functions and function declarations
2 ;;
3 ;; Copyright © Carl Worth
4 ;;
5 ;; This file is part of Notmuch.
6 ;;
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.
11 ;;
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.
16 ;;
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/>.
19 ;;
20 ;; Authors: Carl Worth <cworth@cworth.org>
21
22 ;; This is an part of an emacs-based interface to the notmuch mail system.
23
24 (defvar notmuch-command "notmuch"
25   "Command to run the notmuch binary.")
26
27 (defgroup notmuch nil
28   "Notmuch mail reader for Emacs."
29   :group 'mail)
30
31 (defcustom notmuch-folders '(("inbox" . "tag:inbox") ("unread" . "tag:unread"))
32   "List of searches for the notmuch folder view"
33   :type '(alist :key-type (string) :value-type (string))
34   :group 'notmuch)
35
36 (defcustom notmuch-search-oldest-first t
37   "Show the oldest mail first when searching."
38   :type 'boolean
39   :group 'notmuch)
40
41 ;;
42
43 (declare-function notmuch-poll ())
44
45 (defun notmuch-version ()
46   "Return a string with the notmuch version number."
47   (let ((long-string
48          ;; Trim off the trailing newline.
49          (substring (shell-command-to-string
50                      (concat notmuch-command " --version"))
51                     0 -1)))
52     (if (string-match "^notmuch\\( version\\)? \\(.*\\)$"
53                       long-string)
54         (match-string 2 long-string)
55       "unknown")))
56
57 ;;
58
59 ;; XXX: This should be a generic function in emacs somewhere, not
60 ;; here.
61 (defun point-invisible-p ()
62   "Return whether the character at point is invisible.
63
64 Here visibility is determined by `buffer-invisibility-spec' and
65 the invisible property of any overlays for point. It doesn't have
66 anything to do with whether point is currently being displayed
67 within the current window."
68   (let ((prop (get-char-property (point) 'invisible)))
69     (if (eq buffer-invisibility-spec t)
70         prop
71       (or (memq prop buffer-invisibility-spec)
72           (assq prop buffer-invisibility-spec)))))
73
74 (provide 'notmuch-lib)