From: Mark Walters Date: Mon, 12 May 2014 22:15:07 +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=c9eb0f0f4ac2a80cbe0b244f217d7951ed8226fa;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/1f/118e07dae5ac16c4455895fb55331c32174850 b/1f/118e07dae5ac16c4455895fb55331c32174850 new file mode 100644 index 000000000..f76ac8eef --- /dev/null +++ b/1f/118e07dae5ac16c4455895fb55331c32174850 @@ -0,0 +1,146 @@ +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 179F2431FBD + for ; Mon, 12 May 2014 15:15:20 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.201 +X-Spam-Level: +X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, + 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 STwa1VODuvSB for ; + Mon, 12 May 2014 15:15:12 -0700 (PDT) +Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com + [209.85.212.172]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id D7B6B431FAF + for ; Mon, 12 May 2014 15:15:11 -0700 (PDT) +Received: by mail-wi0-f172.google.com with SMTP id hi2so5286048wib.17 + for ; Mon, 12 May 2014 15:15:10 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:subject:in-reply-to:references:user-agent:date:message-id + :mime-version:content-type; + bh=haUlRsl5I4gB0MTYOFj+PVTx0a9xQTYJOYVHMh796IU=; + b=QTpf200px3QRpwAy1Wk3nLNCedXj71i2U+EKZUcxQczuJhCkQ0y8UNSaD/KbsDJnQ6 + 62fGfCbRCaPOV9oMDOSHqcbDuPLZHUWioqN3tKRVTYpi28YHNuHelX0GDwdofFkAx0V5 + CzuVm8MfxJ7HInRDFCkwbLUv2S4n6nFBnOpAhk74PuYgbOw2YqsYtY2AzEfsc3s+CQuR + MFQb+CsrQAUyMeIhPtqsoANCJMJLc96UplsY/Hbv+T/nF3M9/5pakeD/h0IJagjjNpP0 + P5+uyAqofSkmfFZOOAmYQ7s8GvA0CaZET98dthmwBiC5fGQ4N7Wjel8bGdMSEdMPXBY9 + WctA== +X-Received: by 10.180.228.42 with SMTP id sf10mr17399220wic.33.1399932910682; + Mon, 12 May 2014 15:15:10 -0700 (PDT) +Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162]) + by mx.google.com with ESMTPSA id + vm8sm19580727wjc.27.2014.05.12.15.15.09 for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Mon, 12 May 2014 15:15:10 -0700 (PDT) +From: Mark Walters +To: David Edmondson , 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: <1399897769-26809-3-git-send-email-dme@dme.org> +References: <87sixdujkv.fsf@qmul.ac.uk> + <1399897769-26809-1-git-send-email-dme@dme.org> + <1399897769-26809-3-git-send-email-dme@dme.org> +User-Agent: Notmuch/0.15.2+615~g78e3a93 (http://notmuchmail.org) Emacs/23.4.1 + (x86_64-pc-linux-gnu) +Date: Mon, 12 May 2014 23:15:07 +0100 +Message-ID: <87ppjik5jo.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +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: Mon, 12 May 2014 22:15:20 -0000 + +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) +> +> +(defcustom notmuch-show-insert-header-p-function 'notmuch-show-insert-header-p-smart +> + "A function to call to determine whether a MIME part should have a header 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. + +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))) +> +> -(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= mime-type "text/plain") +> (<= (plist-get part :id) 1))))) +> +> +(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. +> +> @@ -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))) +> +> -- +> 2.0.0.rc0 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch