From: David Edmondson Date: Tue, 13 May 2014 09:49:10 +0000 (+0100) Subject: Re: [PATCH v3 2/9] emacs/show: Allow the user to decide when part headers should... X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ac5c74277fcfc4fcc242b2aead50bdb4919467ac;p=notmuch-archives.git Re: [PATCH v3 2/9] emacs/show: Allow the user to decide when part headers should be inserted --- diff --git a/05/21524961c8a97212bb6cc0861c17403bae3349 b/05/21524961c8a97212bb6cc0861c17403bae3349 new file mode 100644 index 000000000..81269d56f --- /dev/null +++ b/05/21524961c8a97212bb6cc0861c17403bae3349 @@ -0,0 +1,174 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 452E4429E3B + for ; Tue, 13 May 2014 02:49:33 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id YrrivtFBEK2s for ; + Tue, 13 May 2014 02:49:25 -0700 (PDT) +Received: from mail-wg0-f43.google.com (mail-wg0-f43.google.com + [74.125.82.43]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client + certificate requested) by olra.theworths.org (Postfix) with ESMTPS id + 23F42431FDE for ; Tue, 13 May 2014 02:49:19 -0700 + (PDT) +Received: by mail-wg0-f43.google.com with SMTP id l18so104703wgh.2 + for ; Tue, 13 May 2014 02:49:17 -0700 (PDT) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:to:subject:in-reply-to:references:user-agent + :from:date:message-id:mime-version:content-type; + bh=i4Gs0ziVGXEA0VXTjk7M57aatXErJISgu9FVRnnRP18=; + b=IvqjMce06y9ja0OeFMhxO6VPQkCJ2Cw0unPpE28OGgAP0rdQ+MsX7syKCNzuEG1MM5 + XFEPcdO0v9LnWm5MBgKrTtber0PLSMYzTPb1TkJ9zNuRXo5IBymgxyvJno9U0El01zQL + eqiDPAacJ/buRI4/ypVn/s1mYlO5oybqtk9FyC7JhJbReqUTxXtArm1NhBV2foVQ8MSv + BCShtKJq8MuJFcVBIxoAUzQ8hz9rvzbb97o+sn5ST/qPtubmcz6Ew+DmZh8wKgxHr599 + ZfGyEbMp0qALjpdO8x1QAkLxzjSfkAXhlu2xA6bCJLJBIcso3IFrfT3zpozd0qaJpbWa + nxRg== +X-Gm-Message-State: + ALoCoQnRcZjNFXaqCcsWw8KzN0ENY5fiGozmFETeTRzaZqWacaphiCbX/iL4E6/xBd+FyugDClln +X-Received: by 10.194.62.234 with SMTP id b10mr6974004wjs.48.1399974557884; + Tue, 13 May 2014 02:49:17 -0700 (PDT) +Received: from localhost ([2a01:348:1a2:1:a288:b4ff:fe8a:77d8]) + by mx.google.com with ESMTPSA id bj5sm20999609wib.3.2014.05.13.02.49.16 + for + (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Tue, 13 May 2014 02:49:17 -0700 (PDT) +To: Mark Walters , notmuch@notmuchmail.org +Subject: Re: [PATCH v3 2/9] emacs/show: Allow the user to decide when part + headers should be inserted +In-Reply-To: <87ppjik5jo.fsf@qmul.ac.uk> +References: <87sixdujkv.fsf@qmul.ac.uk> + <1399897769-26809-1-git-send-email-dme@dme.org> + <1399897769-26809-3-git-send-email-dme@dme.org> + <87ppjik5jo.fsf@qmul.ac.uk> +User-Agent: Notmuch/0.18 (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-pc-linux-gnu) +From: David Edmondson +Date: Tue, 13 May 2014 10:49:10 +0100 +Message-ID: +MIME-Version: 1.0 +Content-Type: multipart/signed; boundary="=-=-="; + micalg=pgp-sha1; protocol="application/pgp-signature" +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +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: Tue, 13 May 2014 09:49:33 -0000 + +--=-=-= +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + +On Mon, May 12 2014, Mark Walters wrote: +> On Mon, 12 May 2014, David Edmondson wrote: +>> Make the function that determines whether a part header should be +>> inserted a user controlled, with some example functions. +>> --- +>> emacs/notmuch-show.el | 21 +++++++++++++++++++-- +>> 1 file changed, 19 insertions(+), 2 deletions(-) +>> +>> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +>> index ec99141..f78a0ab 100644 +>> --- a/emacs/notmuch-show.el +>> +++ b/emacs/notmuch-show.el +>> @@ -135,6 +135,17 @@ indentation." +>> :type 'boolean +>> :group 'notmuch-show) +>>=20=20 +>> +(defcustom notmuch-show-insert-header-p-function 'notmuch-show-insert-h= +eader-p-smart +>> + "A function to call to determine whether a MIME part should have a he= +ader button. +>> + +>> +The function is passed one argument, PART - the MIME part in +>> +question." +>> + :type 'function +>> + :group 'notmuch-show +>> + :options '(notmuch-show-insert-header-p-smart +>> + notmuch-show-insert-header-p-always +>> + notmuch-show-insert-header-p-never)) +>> + +> +> I think this is nice as a defcustom for testing/seeing what happens, but = +I am +> not sure we want it exposed longer term: for example never makes it +> nearly impossible to view pdf parts. + +Okay. +> +> Best wishes +> +> Mark +> +> +> +>> (defvar notmuch-show-thread-id nil) +>> (make-variable-buffer-local 'notmuch-show-thread-id) +>> (put 'notmuch-show-thread-id 'permanent-local t) +>> @@ -880,12 +891,18 @@ message at DEPTH in the current thread." +>> "text/x-diff") +>> content-type))) +>>=20=20 +>> -(defun notmuch-show-insert-header-p (part) +>> +(defun notmuch-show-insert-header-p-smart (part) +>> "Return non-NIL if a header button should be inserted for this part." +>> (let ((mime-type (notmuch-show-mime-type part))) +>> (not (and (string=3D mime-type "text/plain") +>> (<=3D (plist-get part :id) 1))))) +>>=20=20 +>> +(defun notmuch-show-insert-header-p-always (part) +>> + t) +>> + +>> +(defun notmuch-show-insert-header-p-never (part) +>> + nil) +>> + +>> (defun notmuch-show-insert-bodypart (msg part depth &optional hide) +>> "Insert the body part PART at depth DEPTH in the current thread. +>>=20=20 +>> @@ -904,7 +921,7 @@ useful for quoting in replies)." +>> ;; We omit the part button for the first (or only) part if +>> ;; this is text/plain, or HIDE is 'no-buttons. +>> (button (when (and (not (equal hide 'no-buttons)) +>> - (notmuch-show-insert-header-p part)) +>> + (funcall notmuch-show-insert-header-p-function part)) +>> (notmuch-show-insert-part-header nth mime-type content-type (plist= +-get part :filename)))) +>> (content-beg (point))) +>>=20=20 +>> --=20 +>> 2.0.0.rc0 +>> +>> _______________________________________________ +>> notmuch mailing list +>> notmuch@notmuchmail.org +>> http://notmuchmail.org/mailman/listinfo/notmuch + +--=-=-= +Content-Type: application/pgp-signature; name="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1 + +iKYEARECAGYFAlNx6pZfFIAAAAAALgAoaXNzdWVyLWZwckBub3RhdGlvbnMub3Bl +bnBncC5maWZ0aGhvcnNlbWFuLm5ldDc1M0Y5NDJDMEExNjc3MDE4OURGMUYyMDY5 +RUNEMEFCRjA0OTY1MTYACgkQaezQq/BJZRYiKgCfc9Jif6Pkeu2q2q43sZ0Ei61Y +Z6AAn0TgH7Ss/7Pu8SF4GuuECgNOFMTq +=aw9J +-----END PGP SIGNATURE----- +--=-=-=--