]> git.notmuchmail.org Git - notmuch/blob - emacs/notmuch-compat.el
emacs: Remove notmuch-read-char-choice
[notmuch] / emacs / notmuch-compat.el
1 ;;; notmuch-compat.el --- compatibility functions for earlier versions of emacs
2 ;;
3 ;; The functions in this file are copied from more modern versions of
4 ;; emacs and are Copyright (C) 1985-1986, 1992, 1994-1995, 1999-2017
5 ;; Free Software Foundation, Inc.
6 ;;
7 ;; This file is part of Notmuch.
8 ;;
9 ;; Notmuch is free software: you can redistribute it and/or modify it
10 ;; under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
13 ;;
14 ;; Notmuch is distributed in the hope that it will be useful, but
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 ;; General Public License for more details.
18 ;;
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with Notmuch.  If not, see <https://www.gnu.org/licenses/>.
21
22 ;;; Code:
23
24 ;; emacs master has a bugfix for folding long headers when sending
25 ;; messages. Include the fix for earlier versions of emacs. To avoid
26 ;; interfering with gnus we only run the hook when called from
27 ;; notmuch-message-mode.
28
29 (declare-function mail-header-fold-field "mail-parse" nil)
30
31 (defun notmuch-message--fold-long-headers ()
32   (when (eq major-mode 'notmuch-message-mode)
33     (goto-char (point-min))
34     (while (not (eobp))
35       (when (and (looking-at "[^:]+:")
36                  (> (- (line-end-position) (point)) 998))
37         (mail-header-fold-field))
38       (forward-line 1))))
39
40 (unless (fboundp 'message--fold-long-headers)
41   (add-hook 'message-header-hook 'notmuch-message--fold-long-headers))
42
43 ;; End of compatibility functions
44
45 (provide 'notmuch-compat)
46
47 ;;; notmuch-compat.el ends here