config

Personal configuration.
git clone git://code.dwrz.net/config
Log | Files | Refs

notmuch-compat.el (2223B)


      1 ;;; notmuch-compat.el --- compatibility functions for earlier versions of emacs  -*- lexical-binding: t -*-
      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 ;; Before Emacs 26.1 lines that are longer than 998 octets were not.
     25 ;; folded. Commit 77bbca8c82f6e553c42abbfafca28f55fc995d00 fixed
     26 ;; that. Until we drop support for Emacs 25 we have to backport that
     27 ;; fix. To avoid interfering with Gnus we only run the hook when
     28 ;; called from notmuch-message-mode.
     29 
     30 (declare-function mail-header-fold-field "mail-parse" nil)
     31 
     32 (defun notmuch-message--fold-long-headers ()
     33   (when (eq major-mode 'notmuch-message-mode)
     34     (goto-char (point-min))
     35     (while (not (eobp))
     36       (when (and (looking-at "[^:]+:")
     37 		 (> (- (line-end-position) (point)) 998))
     38 	(mail-header-fold-field))
     39       (forward-line 1))))
     40 
     41 (unless (fboundp 'message--fold-long-headers)
     42   (add-hook 'message-header-hook 'notmuch-message--fold-long-headers))
     43 
     44 ;; `dlet' isn't available until Emacs 28.1.  Below is a copy, with the
     45 ;; addition of `with-no-warnings'.
     46 (defmacro notmuch-dlet (binders &rest body)
     47   "Like `let*' but using dynamic scoping."
     48   (declare (indent 1) (debug let))
     49   `(let (_)
     50      (with-no-warnings  ; Quiet "lacks a prefix" warning.
     51        ,@(mapcar (lambda (binder)
     52 		   `(defvar ,(if (consp binder) (car binder) binder)))
     53 		 binders))
     54      (let* ,binders ,@body)))
     55 
     56 (provide 'notmuch-compat)
     57 
     58 ;;; notmuch-compat.el ends here