]> git.notmuchmail.org Git - notmuch/blob - emacs/notmuch-lib.el
emacs: Move ?, q, s, m, =, and G to the common keymap
[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 (require 'mm-view)
25 (require 'mm-decode)
26 (require 'cl)
27
28 (defvar notmuch-command "notmuch"
29   "Command to run the notmuch binary.")
30
31 (defgroup notmuch nil
32   "Notmuch mail reader for Emacs."
33   :group 'mail)
34
35 (defgroup notmuch-hello nil
36   "Overview of saved searches, tags, etc."
37   :group 'notmuch)
38
39 (defgroup notmuch-search nil
40   "Searching and sorting mail."
41   :group 'notmuch)
42
43 (defgroup notmuch-show nil
44   "Showing messages and threads."
45   :group 'notmuch)
46
47 (defgroup notmuch-send nil
48   "Sending messages from Notmuch."
49   :group 'notmuch)
50
51 (custom-add-to-group 'notmuch-send 'message 'custom-group)
52
53 (defgroup notmuch-crypto nil
54   "Processing and display of cryptographic MIME parts."
55   :group 'notmuch)
56
57 (defgroup notmuch-hooks nil
58   "Running custom code on well-defined occasions."
59   :group 'notmuch)
60
61 (defgroup notmuch-external nil
62   "Running external commands from within Notmuch."
63   :group 'notmuch)
64
65 (defgroup notmuch-faces nil
66   "Graphical attributes for displaying text"
67   :group 'notmuch)
68
69 (defcustom notmuch-search-oldest-first t
70   "Show the oldest mail first when searching.
71
72 This variable defines the default sort order for displaying
73 search results. Note that any filtered searches created by
74 `notmuch-search-filter' retain the search order of the parent
75 search."
76   :type 'boolean
77   :group 'notmuch-search)
78
79 (defcustom notmuch-poll-script nil
80   "An external script to incorporate new mail into the notmuch database.
81
82 This variable controls the action invoked by
83 `notmuch-search-poll-and-refresh-view' and
84 `notmuch-hello-poll-and-update' (each have a default keybinding
85 of 'G') to incorporate new mail into the notmuch database.
86
87 If set to nil (the default), new mail is processed by invoking
88 \"notmuch new\". Otherwise, this should be set to a string that
89 gives the name of an external script that processes new mail. If
90 set to the empty string, no command will be run.
91
92 The external script could do any of the following depending on
93 the user's needs:
94
95 1. Invoke a program to transfer mail to the local mail store
96 2. Invoke \"notmuch new\" to incorporate the new mail
97 3. Invoke one or more \"notmuch tag\" commands to classify the mail
98
99 Note that the recommended way of achieving the same is using
100 \"notmuch new\" hooks."
101   :type '(choice (const :tag "notmuch new" nil)
102                  (const :tag "Disabled" "")
103                  (string :tag "Custom script"))
104   :group 'notmuch-external)
105
106 ;;
107
108 (defvar notmuch-search-history nil
109   "Variable to store notmuch searches history.")
110
111 (defcustom notmuch-saved-searches '(("inbox" . "tag:inbox")
112                                     ("unread" . "tag:unread"))
113   "A list of saved searches to display."
114   :type '(alist :key-type string :value-type string)
115   :group 'notmuch-hello)
116
117 (defcustom notmuch-archive-tags '("-inbox")
118   "List of tag changes to apply to a message or a thread when it is archived.
119
120 Tags starting with \"+\" (or not starting with either \"+\" or
121 \"-\") in the list will be added, and tags starting with \"-\"
122 will be removed from the message or thread being archived.
123
124 For example, if you wanted to remove an \"inbox\" tag and add an
125 \"archived\" tag, you would set:
126     (\"-inbox\" \"+archived\")"
127   :type '(repeat string)
128   :group 'notmuch-search
129   :group 'notmuch-show)
130
131 (defvar notmuch-common-keymap
132   (let ((map (make-sparse-keymap)))
133     (define-key map "?" 'notmuch-help)
134     (define-key map "q" 'notmuch-kill-this-buffer)
135     (define-key map "s" 'notmuch-search)
136     (define-key map "m" 'notmuch-mua-new-mail)
137     (define-key map "=" 'notmuch-refresh-this-buffer)
138     (define-key map "G" 'notmuch-poll-and-refresh-this-buffer)
139     map)
140   "Keymap shared by all notmuch modes.")
141
142 ;; By default clicking on a button does not select the window
143 ;; containing the button (as opposed to clicking on a widget which
144 ;; does). This means that the button action is then executed in the
145 ;; current selected window which can cause problems if the button
146 ;; changes the buffer (e.g., id: links) or moves point.
147 ;;
148 ;; This provides a button type which overrides mouse-action so that
149 ;; the button's window is selected before the action is run. Other
150 ;; notmuch buttons can get the same behaviour by inheriting from this
151 ;; button type.
152 (define-button-type 'notmuch-button-type
153   'mouse-action (lambda (button)
154                   (select-window (posn-window (event-start last-input-event)))
155                   (button-activate button)))
156
157 (defun notmuch-command-to-string (&rest args)
158   "Synchronously invoke \"notmuch\" with the given list of arguments.
159
160 If notmuch exits with a non-zero status, output from the process
161 will appear in a buffer named \"*Notmuch errors*\" and an error
162 will be signaled.
163
164 Otherwise the output will be returned"
165   (with-temp-buffer
166     (let* ((status (apply #'call-process notmuch-command nil t nil args))
167            (output (buffer-string)))
168       (notmuch-check-exit-status status (cons notmuch-command args) output)
169       output)))
170
171 (defun notmuch-version ()
172   "Return a string with the notmuch version number."
173   (let ((long-string
174          ;; Trim off the trailing newline.
175          (substring (notmuch-command-to-string "--version") 0 -1)))
176     (if (string-match "^notmuch\\( version\\)? \\(.*\\)$"
177                       long-string)
178         (match-string 2 long-string)
179       "unknown")))
180
181 (defun notmuch-config-get (item)
182   "Return a value from the notmuch configuration."
183   ;; Trim off the trailing newline
184   (substring (notmuch-command-to-string "config" "get" item) 0 -1))
185
186 (defun notmuch-database-path ()
187   "Return the database.path value from the notmuch configuration."
188   (notmuch-config-get "database.path"))
189
190 (defun notmuch-user-name ()
191   "Return the user.name value from the notmuch configuration."
192   (notmuch-config-get "user.name"))
193
194 (defun notmuch-user-primary-email ()
195   "Return the user.primary_email value from the notmuch configuration."
196   (notmuch-config-get "user.primary_email"))
197
198 (defun notmuch-user-other-email ()
199   "Return the user.other_email value (as a list) from the notmuch configuration."
200   (split-string (notmuch-config-get "user.other_email") "\n"))
201
202 (defun notmuch-poll ()
203   "Run \"notmuch new\" or an external script to import mail.
204
205 Invokes `notmuch-poll-script', \"notmuch new\", or does nothing
206 depending on the value of `notmuch-poll-script'."
207   (interactive)
208   (if (stringp notmuch-poll-script)
209       (unless (string= notmuch-poll-script "")
210         (call-process notmuch-poll-script nil nil))
211     (call-process notmuch-command nil nil nil "new")))
212
213 (defun notmuch-kill-this-buffer ()
214   "Kill the current buffer."
215   (interactive)
216   (kill-buffer (current-buffer)))
217
218 (defvar notmuch-buffer-refresh-function nil
219   "Function to call to refresh the current buffer.")
220 (make-variable-buffer-local 'notmuch-buffer-refresh-function)
221
222 (defun notmuch-refresh-this-buffer ()
223   "Refresh the current buffer."
224   (interactive)
225   (when notmuch-buffer-refresh-function
226     (if (commandp notmuch-buffer-refresh-function)
227         ;; Pass prefix argument, etc.
228         (call-interactively notmuch-buffer-refresh-function)
229       (funcall notmuch-buffer-refresh-function))))
230
231 (defun notmuch-poll-and-refresh-this-buffer ()
232   "Invoke `notmuch-poll' to import mail, then refresh the current buffer."
233   (interactive)
234   (notmuch-poll)
235   (notmuch-refresh-this-buffer))
236
237 (defun notmuch-prettify-subject (subject)
238   ;; This function is used by `notmuch-search-process-filter' which
239   ;; requires that we not disrupt its' matching state.
240   (save-match-data
241     (if (and subject
242              (string-match "^[ \t]*$" subject))
243         "[No Subject]"
244       subject)))
245
246 (defun notmuch-escape-boolean-term (term)
247   "Escape a boolean term for use in a query.
248
249 The caller is responsible for prepending the term prefix and a
250 colon.  This performs minimal escaping in order to produce
251 user-friendly queries."
252
253   (save-match-data
254     (if (or (equal term "")
255             (string-match "[ ()]\\|^\"" term))
256         ;; Requires escaping
257         (concat "\"" (replace-regexp-in-string "\"" "\"\"" term t t) "\"")
258       term)))
259
260 (defun notmuch-id-to-query (id)
261   "Return a query that matches the message with id ID."
262   (concat "id:" (notmuch-escape-boolean-term id)))
263
264 ;;
265
266 (defun notmuch-common-do-stash (text)
267   "Common function to stash text in kill ring, and display in minibuffer."
268   (if text
269       (progn
270         (kill-new text)
271         (message "Stashed: %s" text))
272     ;; There is nothing to stash so stash an empty string so the user
273     ;; doesn't accidentally paste something else somewhere.
274     (kill-new "")
275     (message "Nothing to stash!")))
276
277 ;;
278
279 (defun notmuch-remove-if-not (predicate list)
280   "Return a copy of LIST with all items not satisfying PREDICATE removed."
281   (let (out)
282     (while list
283       (when (funcall predicate (car list))
284         (push (car list) out))
285       (setq list (cdr list)))
286     (nreverse out)))
287
288 (defun notmuch-split-content-type (content-type)
289   "Split content/type into 'content' and 'type'"
290   (split-string content-type "/"))
291
292 (defun notmuch-match-content-type (t1 t2)
293   "Return t if t1 and t2 are matching content types, taking wildcards into account"
294   (let ((st1 (notmuch-split-content-type t1))
295         (st2 (notmuch-split-content-type t2)))
296     (if (or (string= (cadr st1) "*")
297             (string= (cadr st2) "*"))
298         ;; Comparison of content types should be case insensitive.
299         (string= (downcase (car st1)) (downcase (car st2)))
300       (string= (downcase t1) (downcase t2)))))
301
302 (defvar notmuch-multipart/alternative-discouraged
303   '(
304     ;; Avoid HTML parts.
305     "text/html"
306     ;; multipart/related usually contain a text/html part and some associated graphics.
307     "multipart/related"
308     ))
309
310 (defun notmuch-multipart/alternative-choose (types)
311   "Return a list of preferred types from the given list of types"
312   ;; Based on `mm-preferred-alternative-precedence'.
313   (let ((seq types))
314     (dolist (pref (reverse notmuch-multipart/alternative-discouraged))
315       (dolist (elem (copy-sequence seq))
316         (when (string-match pref elem)
317           (setq seq (nconc (delete elem seq) (list elem))))))
318     seq))
319
320 (defun notmuch-parts-filter-by-type (parts type)
321   "Given a list of message parts, return a list containing the ones matching
322 the given type."
323   (remove-if-not
324    (lambda (part) (notmuch-match-content-type (plist-get part :content-type) type))
325    parts))
326
327 ;; Helper for parts which are generally not included in the default
328 ;; SEXP output.
329 (defun notmuch-get-bodypart-internal (query part-number process-crypto)
330   (let ((args '("show" "--format=raw"))
331         (part-arg (format "--part=%s" part-number)))
332     (setq args (append args (list part-arg)))
333     (if process-crypto
334         (setq args (append args '("--decrypt"))))
335     (setq args (append args (list query)))
336     (with-temp-buffer
337       (let ((coding-system-for-read 'no-conversion))
338         (progn
339           (apply 'call-process (append (list notmuch-command nil (list t nil) nil) args))
340           (buffer-string))))))
341
342 (defun notmuch-get-bodypart-content (msg part nth process-crypto)
343   (or (plist-get part :content)
344       (notmuch-get-bodypart-internal (notmuch-id-to-query (plist-get msg :id)) nth process-crypto)))
345
346 ;; Workaround: The call to `mm-display-part' below triggers a bug in
347 ;; Emacs 24 if it attempts to use the shr renderer to display an HTML
348 ;; part with images in it (demonstrated in 24.1 and 24.2 on Debian and
349 ;; Fedora 17, though unreproducable in other configurations).
350 ;; `mm-shr' references the variable `gnus-inhibit-images' without
351 ;; first loading gnus-art, which defines it, resulting in a
352 ;; void-variable error.  Hence, we advise `mm-shr' to ensure gnus-art
353 ;; is loaded.
354 (if (>= emacs-major-version 24)
355     (defadvice mm-shr (before load-gnus-arts activate)
356       (require 'gnus-art nil t)
357       (ad-disable-advice 'mm-shr 'before 'load-gnus-arts)))
358
359 (defun notmuch-mm-display-part-inline (msg part nth content-type process-crypto)
360   "Use the mm-decode/mm-view functions to display a part in the
361 current buffer, if possible."
362   (let ((display-buffer (current-buffer)))
363     (with-temp-buffer
364       ;; In case there is :content, the content string is already converted
365       ;; into emacs internal format. `gnus-decoded' is a fake charset,
366       ;; which means no further decoding (to be done by mm- functions).
367       (let* ((charset (if (plist-member part :content)
368                           'gnus-decoded
369                         (plist-get part :content-charset)))
370              (handle (mm-make-handle (current-buffer) `(,content-type (charset . ,charset)))))
371         ;; If the user wants the part inlined, insert the content and
372         ;; test whether we are able to inline it (which includes both
373         ;; capability and suitability tests).
374         (when (mm-inlined-p handle)
375           (insert (notmuch-get-bodypart-content msg part nth process-crypto))
376           (when (mm-inlinable-p handle)
377             (set-buffer display-buffer)
378             (mm-display-part handle)
379             t))))))
380
381 ;; Converts a plist of headers to an alist of headers. The input plist should
382 ;; have symbols of the form :Header as keys, and the resulting alist will have
383 ;; symbols of the form 'Header as keys.
384 (defun notmuch-headers-plist-to-alist (plist)
385   (loop for (key value . rest) on plist by #'cddr
386         collect (cons (intern (substring (symbol-name key) 1)) value)))
387
388 (defun notmuch-face-ensure-list-form (face)
389   "Return FACE in face list form.
390
391 If FACE is already a face list, it will be returned as-is.  If
392 FACE is a face name or face plist, it will be returned as a
393 single element face list."
394   (if (and (listp face) (not (keywordp (car face))))
395       face
396     (list face)))
397
398 (defun notmuch-combine-face-text-property (start end face &optional below object)
399   "Combine FACE into the 'face text property between START and END.
400
401 This function combines FACE with any existing faces between START
402 and END in OBJECT (which defaults to the current buffer).
403 Attributes specified by FACE take precedence over existing
404 attributes unless BELOW is non-nil.  FACE must be a face name (a
405 symbol or string), a property list of face attributes, or a list
406 of these.  For convenience when applied to strings, this returns
407 OBJECT."
408
409   ;; A face property can have three forms: a face name (a string or
410   ;; symbol), a property list, or a list of these two forms.  In the
411   ;; list case, the faces will be combined, with the earlier faces
412   ;; taking precedent.  Here we canonicalize everything to list form
413   ;; to make it easy to combine.
414   (let ((pos start)
415         (face-list (notmuch-face-ensure-list-form face)))
416     (while (< pos end)
417       (let* ((cur (get-text-property pos 'face object))
418              (cur-list (notmuch-face-ensure-list-form cur))
419              (new (cond ((null cur-list) face)
420                         (below (append cur-list face-list))
421                         (t (append face-list cur-list))))
422              (next (next-single-property-change pos 'face object end)))
423         (put-text-property pos next 'face new object)
424         (setq pos next))))
425   object)
426
427 (defun notmuch-combine-face-text-property-string (string face &optional below)
428   (notmuch-combine-face-text-property
429    0
430    (length string)
431    face
432    below
433    string))
434
435 (defun notmuch-map-text-property (start end prop func &optional object)
436   "Transform text property PROP using FUNC.
437
438 Applies FUNC to each distinct value of the text property PROP
439 between START and END of OBJECT, setting PROP to the value
440 returned by FUNC."
441   (while (< start end)
442     (let ((value (get-text-property start prop object))
443           (next (next-single-property-change start prop object end)))
444       (put-text-property start next prop (funcall func value) object)
445       (setq start next))))
446
447 (defun notmuch-logged-error (msg &optional extra)
448   "Log MSG and EXTRA to *Notmuch errors* and signal MSG.
449
450 This logs MSG and EXTRA to the *Notmuch errors* buffer and
451 signals MSG as an error.  If EXTRA is non-nil, text referring the
452 user to the *Notmuch errors* buffer will be appended to the
453 signaled error.  This function does not return."
454
455   (with-current-buffer (get-buffer-create "*Notmuch errors*")
456     (goto-char (point-max))
457     (unless (bobp)
458       (newline))
459     (save-excursion
460       (insert "[" (current-time-string) "]\n" msg)
461       (unless (bolp)
462         (newline))
463       (when extra
464         (insert extra)
465         (unless (bolp)
466           (newline)))))
467   (error "%s" (concat msg (when extra
468                             " (see *Notmuch errors* for more details)"))))
469
470 (defun notmuch-check-async-exit-status (proc msg &optional command err-file)
471   "If PROC exited abnormally, pop up an error buffer and signal an error.
472
473 This is a wrapper around `notmuch-check-exit-status' for
474 asynchronous process sentinels.  PROC and MSG must be the
475 arguments passed to the sentinel.  COMMAND and ERR-FILE, if
476 provided, are passed to `notmuch-check-exit-status'.  If COMMAND
477 is not provided, it is taken from `process-command'."
478   (let ((exit-status
479          (case (process-status proc)
480            ((exit) (process-exit-status proc))
481            ((signal) msg))))
482     (when exit-status
483       (notmuch-check-exit-status exit-status (or command (process-command proc))
484                                  nil err-file))))
485
486 (defun notmuch-check-exit-status (exit-status command &optional output err-file)
487   "If EXIT-STATUS is non-zero, pop up an error buffer and signal an error.
488
489 If EXIT-STATUS is non-zero, pop up a notmuch error buffer
490 describing the error and signal an Elisp error.  EXIT-STATUS must
491 be a number indicating the exit status code of a process or a
492 string describing the signal that terminated the process (such as
493 returned by `call-process').  COMMAND must be a list giving the
494 command and its arguments.  OUTPUT, if provided, is a string
495 giving the output of command.  ERR-FILE, if provided, is the name
496 of a file containing the error output of command.  OUTPUT and the
497 contents of ERR-FILE will be included in the error message."
498
499   (cond
500    ((eq exit-status 0) t)
501    ((eq exit-status 20)
502     (notmuch-logged-error "notmuch CLI version mismatch
503 Emacs requested an older output format than supported by the notmuch CLI.
504 You may need to restart Emacs or upgrade your notmuch Emacs package."))
505    ((eq exit-status 21)
506     (notmuch-logged-error "notmuch CLI version mismatch
507 Emacs requested a newer output format than supported by the notmuch CLI.
508 You may need to restart Emacs or upgrade your notmuch package."))
509    (t
510     (let* ((err (when err-file
511                   (with-temp-buffer
512                     (insert-file-contents err-file)
513                     (unless (eobp)
514                       (buffer-string)))))
515            (extra
516             (concat
517              "command: " (mapconcat #'shell-quote-argument command " ") "\n"
518              (if (integerp exit-status)
519                  (format "exit status: %s\n" exit-status)
520                (format "exit signal: %s\n" exit-status))
521              (when err
522                (concat "stderr:\n" err))
523              (when output
524                (concat "stdout:\n" output)))))
525         (if err
526             ;; We have an error message straight from the CLI.
527             (notmuch-logged-error
528              (replace-regexp-in-string "[ \n\r\t\f]*\\'" "" err) extra)
529           ;; We only have combined output from the CLI; don't inundate
530           ;; the user with it.  Mimic `process-lines'.
531           (notmuch-logged-error (format "%s exited with status %s"
532                                         (car command) exit-status)
533                                 extra))
534         ;; `notmuch-logged-error' does not return.
535         ))))
536
537 (defun notmuch-call-notmuch-sexp (&rest args)
538   "Invoke `notmuch-command' with ARGS and return the parsed S-exp output.
539
540 If notmuch exits with a non-zero status, this will pop up a
541 buffer containing notmuch's output and signal an error."
542
543   (with-temp-buffer
544     (let ((err-file (make-temp-file "nmerr")))
545       (unwind-protect
546           (let ((status (apply #'call-process
547                                notmuch-command nil (list t err-file) nil args)))
548             (notmuch-check-exit-status status (cons notmuch-command args)
549                                        (buffer-string) err-file)
550             (goto-char (point-min))
551             (read (current-buffer)))
552         (delete-file err-file)))))
553
554 (defun notmuch-start-notmuch (name buffer sentinel &rest args)
555   "Start and return an asynchronous notmuch command.
556
557 This starts and returns an asynchronous process running
558 `notmuch-command' with ARGS.  The exit status is checked via
559 `notmuch-check-async-exit-status'.  Output written to stderr is
560 redirected and displayed when the process exits (even if the
561 process exits successfully).  NAME and BUFFER are the same as in
562 `start-process'.  SENTINEL is a process sentinel function to call
563 when the process exits, or nil for none.  The caller must *not*
564 invoke `set-process-sentinel' directly on the returned process,
565 as that will interfere with the handling of stderr and the exit
566 status."
567
568   ;; There is no way (as of Emacs 24.3) to capture stdout and stderr
569   ;; separately for asynchronous processes, or even to redirect stderr
570   ;; to a file, so we use a trivial shell wrapper to send stderr to a
571   ;; temporary file and clean things up in the sentinel.
572   (let* ((err-file (make-temp-file "nmerr"))
573          ;; Use a pipe
574          (process-connection-type nil)
575          ;; Find notmuch using Emacs' `exec-path'
576          (command (or (executable-find notmuch-command)
577                       (error "command not found: %s" notmuch-command)))
578          (proc (apply #'start-process name buffer
579                       "/bin/sh" "-c"
580                       "exec 2>\"$1\"; shift; exec \"$0\" \"$@\""
581                       command err-file args)))
582     (process-put proc 'err-file err-file)
583     (process-put proc 'sub-sentinel sentinel)
584     (process-put proc 'real-command (cons notmuch-command args))
585     (set-process-sentinel proc #'notmuch-start-notmuch-sentinel)
586     proc))
587
588 (defun notmuch-start-notmuch-sentinel (proc event)
589   (let ((err-file (process-get proc 'err-file))
590         (sub-sentinel (process-get proc 'sub-sentinel))
591         (real-command (process-get proc 'real-command)))
592     (condition-case err
593         (progn
594           ;; Invoke the sub-sentinel, if any
595           (when sub-sentinel
596             (funcall sub-sentinel proc event))
597           ;; Check the exit status.  This will signal an error if the
598           ;; exit status is non-zero.  Don't do this if the process
599           ;; buffer is dead since that means Emacs killed the process
600           ;; and there's no point in telling the user that (but we
601           ;; still check for and report stderr output below).
602           (when (buffer-live-p (process-buffer proc))
603             (notmuch-check-async-exit-status proc event real-command err-file))
604           ;; If that didn't signal an error, then any error output was
605           ;; really warning output.  Show warnings, if any.
606           (let ((warnings
607                  (with-temp-buffer
608                    (unless (= (second (insert-file-contents err-file)) 0)
609                      (end-of-line)
610                      ;; Show first line; stuff remaining lines in the
611                      ;; errors buffer.
612                      (let ((l1 (buffer-substring (point-min) (point))))
613                        (skip-chars-forward "\n")
614                        (cons l1 (unless (eobp)
615                                   (buffer-substring (point) (point-max)))))))))
616             (when warnings
617               (notmuch-logged-error (car warnings) (cdr warnings)))))
618       (error
619        ;; Emacs behaves strangely if an error escapes from a sentinel,
620        ;; so turn errors into messages.
621        (message "%s" (error-message-string err))))
622     (ignore-errors (delete-file err-file))))
623
624 ;; This variable is used only buffer local, but it needs to be
625 ;; declared globally first to avoid compiler warnings.
626 (defvar notmuch-show-process-crypto nil)
627 (make-variable-buffer-local 'notmuch-show-process-crypto)
628
629 (provide 'notmuch-lib)
630
631 ;; Local Variables:
632 ;; byte-compile-warnings: (not cl-functions)
633 ;; End: