From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 008A46DE1BCA for ; Sat, 4 Mar 2017 11:40:01 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.005 X-Spam-Level: X-Spam-Status: No, score=-0.005 tagged_above=-999 required=5 tests=[AWL=0.006, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0Ypw9WTFY7QL for ; Sat, 4 Mar 2017 11:39:59 -0800 (PST) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id 88EA36DE1B83 for ; Sat, 4 Mar 2017 11:39:59 -0800 (PST) Received: from remotemail by fethera.tethera.net with local (Exim 4.84_2) (envelope-from ) id 1ckFWQ-0002Ax-UW; Sat, 04 Mar 2017 14:39:18 -0500 Received: (nullmailer pid 3422 invoked by uid 1000); Sat, 04 Mar 2017 19:39:57 -0000 From: David Bremner To: Mark Walters , notmuch@notmuchmail.org Subject: Re: [PATCH v2 2/2] emacs: compat: backport fix for folding long headers when sending In-Reply-To: <1488649637-19006-3-git-send-email-markwalters1009@gmail.com> References: <1488649637-19006-1-git-send-email-markwalters1009@gmail.com> <1488649637-19006-3-git-send-email-markwalters1009@gmail.com> Date: Sat, 04 Mar 2017 15:39:57 -0400 Message-ID: <8760joal0y.fsf@tethera.net> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Mar 2017 19:40:01 -0000 Mark Walters writes: > 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. > --- > emacs/notmuch-compat.el | 28 ++++++++++++++++++++++++---- > 1 file changed, 24 insertions(+), 4 deletions(-) > > diff --git a/emacs/notmuch-compat.el b/emacs/notmuch-compat.el > index c3d827a..e71e861 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. > + > + > + Seems to be a lot of blank lines. > +;; 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) > + > +(unless (fboundp 'message--fold-long-headers) > + (add-hook 'message-header-hook > + (lambda () > + (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)))))) I'm just parroting what I've read, but it makes it hard for people to manage hooks when you use a lambda instead of a named function. What do you think about defining something notmuch-message--fold-long-headers (using your code above) and adding that to the hook is message--fold-long-headers is unbound? d