[PATCH v3 2/9] emacs/show: Allow the user to decide when part headers should be inserted

David Edmondson dme at dme.org
Tue May 13 02:49:10 PDT 2014


On Mon, May 12 2014, Mark Walters wrote:
> On Mon, 12 May 2014, David Edmondson <dme at dme.org> 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.

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)))
>>  
>> -(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 at notmuchmail.org
>> http://notmuchmail.org/mailman/listinfo/notmuch
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 310 bytes
Desc: not available
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20140513/afc21d48/attachment.pgp>


More information about the notmuch mailing list