]> git.notmuchmail.org Git - notmuch/blob - emacs/notmuch-lib.el
emacs: Move declare-function from notmuch-lib.el to notmuch-hello.el.
[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 (defun notmuch-version ()
44   "Return a string with the notmuch version number."
45   (let ((long-string
46          ;; Trim off the trailing newline.
47          (substring (shell-command-to-string
48                      (concat notmuch-command " --version"))
49                     0 -1)))
50     (if (string-match "^notmuch\\( version\\)? \\(.*\\)$"
51                       long-string)
52         (match-string 2 long-string)
53       "unknown")))
54
55 ;;
56
57 ;; XXX: This should be a generic function in emacs somewhere, not
58 ;; here.
59 (defun point-invisible-p ()
60   "Return whether the character at point is invisible.
61
62 Here visibility is determined by `buffer-invisibility-spec' and
63 the invisible property of any overlays for point. It doesn't have
64 anything to do with whether point is currently being displayed
65 within the current window."
66   (let ((prop (get-char-property (point) 'invisible)))
67     (if (eq buffer-invisibility-spec t)
68         prop
69       (or (memq prop buffer-invisibility-spec)
70           (assq prop buffer-invisibility-spec)))))
71
72 (provide 'notmuch-lib)