summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Walters <markwalters1009@gmail.com>2017-03-04 20:42:14 +0000
committerDavid Bremner <david@tethera.net>2017-03-04 21:16:42 -0400
commit95e9c137e18a5d7ffe68f70b8835f6b8b779e779 (patch)
treed43d75ac05596ef702a9076d4b7bf9d48c7ee32c
parenta8f91b74e7a52306919452e3593d2a8a1e529bd1 (diff)
emacs: compat: backport fix for folding long headers when sending
This backports the fix from emacs master (commit 77bbca8c82f6e553c42abbfafca28f55fc995d00) to notmuch-emacs to wrap long headers. This fixes the test introduced in the previous changeset.
-rw-r--r--emacs/notmuch-compat.el28
1 files changed, 24 insertions, 4 deletions
diff --git a/emacs/notmuch-compat.el b/emacs/notmuch-compat.el
index c3d827af..2cedd39d 100644
--- a/emacs/notmuch-compat.el
+++ b/emacs/notmuch-compat.el
@@ -1,8 +1,28 @@
-;; Compatibility functions for emacs 23 and 24 pre 24.4
+;; Compatibility functions for earlier versions of emacs
-;; The functions in this file are copied from eamcs 24.4 and are
-;; Copyright (C) 1985-1986, 1992, 1994-1995, 1999-2014 Free Software
-;; Foundation, Inc.
+;; The functions in this file are copied from more modern versions of
+;; emacs and are Copyright (C) 1985-1986, 1992, 1994-1995, 1999-2017
+;; Free Software Foundation, Inc.
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; emacs master has a bugfix for folding long headers when sending
+;; messages. Include the fix for earlier versions of emacs. To avoid
+;; interfering with gnus we only run the hook when called from
+;; notmuch-message-mode.
+
+(declare-function mail-header-fold-field "mail-parse" nil)
+
+(defun notmuch-message--fold-long-headers ()
+ (when (eq major-mode 'notmuch-message-mode)
+ (goto-char (point-min))
+ (while (not (eobp))
+ (when (and (looking-at "[^:]+:")
+ (> (- (line-end-position) (point)) 998))
+ (mail-header-fold-field))
+ (forward-line 1))))
+
+(unless (fboundp 'message--fold-long-headers)
+ (add-hook 'message-header-hook 'notmuch-message--fold-long-headers))
(if (fboundp 'setq-local)
(defalias 'notmuch-setq-local 'setq-local)