|
David Edmondson |
|
|
---
emacs/notmuch-show.el | 26 ++++++++++++-------------- 1 files changed, 12 insertions(+), 14 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 03c1f6b..f62f8ac 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -286,20 +286,18 @@ message at DEPTH in the current thread." 'face 'message-mml) (defun notmuch-show-insert-part-header (nth content-type declared-type &optional name comment) - (let ((button)) - (setq button - (insert-button - (concat "[ " - (if name (concat name ": ") "") - declared-type - (if (not (string-equal declared-type content-type)) - (concat " (as " content-type ")") - "") - (or comment "") - " ]") - :type 'notmuch-show-part-button-type - :notmuch-part nth - :notmuch-filename name)) + (let ((button (insert-button + (concat "[ " + (if name (concat name ": ") "") + declared-type + (if (not (string-equal declared-type content-type)) + (concat " (as " content-type ")") + "") + (or comment "") + " ]") + :type 'notmuch-show-part-button-type + :notmuch-part nth + :notmuch-filename name))) (insert "\n") ;; return button button)) -- 1.7.8.3 _______________________________________________ notmuch mailing list [hidden email] http://notmuchmail.org/mailman/listinfo/notmuch |
|
David Edmondson |
|
|
Instead, allow the caller to specify some parameters for the
button. Rework `notmuch-show-insert-part-multipart/signed' and `notmuch-show-insert-part-multipart/encrypted' accordingly, moving most of the code into a common `notmuch-show-insert-part-multipart/signed-or-encrypted' to reduce duplication. --- The buttons inserted for encrypted parts are slightly different now - previously the logic was that if a part was encrypted it would have the signature status inserted only if the encryption status was specified. Now the signature status will be inserted even without encryption status. My reading of the documentation says that this is correct, but I'm no expert. Comments? emacs/notmuch-show.el | 88 +++++++++++++++++++++--------------------------- 1 files changed, 39 insertions(+), 49 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index f62f8ac..97e2a15 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -285,22 +285,23 @@ message at DEPTH in the current thread." 'follow-link t 'face 'message-mml) -(defun notmuch-show-insert-part-header (nth content-type declared-type &optional name comment) - (let ((button (insert-button - (concat "[ " - (if name (concat name ": ") "") - declared-type - (if (not (string-equal declared-type content-type)) - (concat " (as " content-type ")") - "") - (or comment "") - " ]") - :type 'notmuch-show-part-button-type - :notmuch-part nth - :notmuch-filename name))) - (insert "\n") - ;; return button - button)) +(defun notmuch-show-insert-part-header (nth content-type declared-type + &optional name comment + &rest button-parameters) + (apply #'insert-button + (concat "[ " + (if name (concat name ": ") "") + declared-type + (if (not (string-equal declared-type content-type)) + (concat " (as " content-type ")") + "") + (or comment "") + " ]") + :type 'notmuch-show-part-button-type + :notmuch-part nth + :notmuch-filename name + button-parameters) + (insert "\n")) ;; Functions handling particular MIME parts. @@ -458,42 +459,31 @@ current buffer, if possible." t) (defun notmuch-show-insert-part-multipart/signed (msg part content-type nth depth declared-type) - (let ((button (notmuch-show-insert-part-header nth declared-type content-type nil))) - (button-put button 'face 'notmuch-crypto-part-header) - ;; add signature status button if sigstatus provided - (if (plist-member part :sigstatus) - (let* ((from (notmuch-show-get-header :From msg)) - (sigstatus (car (plist-get part :sigstatus)))) - (notmuch-crypto-insert-sigstatus-button sigstatus from)) - ;; if we're not adding sigstatus, tell the user how they can get it - (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts."))) - - (let ((inner-parts (plist-get part :content)) - (start (point))) - ;; Show all of the parts. - (mapc (lambda (inner-part) - (notmuch-show-insert-bodypart msg inner-part depth)) - inner-parts) - - (when notmuch-show-indent-multipart - (indent-rigidly start (point) 1))) - t) + (notmuch-show-insert-part-multipart/signed-or-encrypted msg part content-type nth depth declared-type + (plist-get part :sigstatus) + nil)) (defun notmuch-show-insert-part-multipart/encrypted (msg part content-type nth depth declared-type) - (let ((button (notmuch-show-insert-part-header nth declared-type content-type nil))) - (button-put button 'face 'notmuch-crypto-part-header) - ;; add encryption status button if encstatus specified - (if (plist-member part :encstatus) - (let ((encstatus (car (plist-get part :encstatus)))) - (notmuch-crypto-insert-encstatus-button encstatus) - ;; add signature status button if sigstatus specified - (if (plist-member part :sigstatus) - (let* ((from (notmuch-show-get-header :From msg)) - (sigstatus (car (plist-get part :sigstatus)))) - (notmuch-crypto-insert-sigstatus-button sigstatus from)))) - ;; if we're not adding encstatus, tell the user how they can get it - (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts."))) + (notmuch-show-insert-part-multipart/signed-or-encrypted msg part content-type nth depth declared-type + (plist-get part :sigstatus) + (plist-get part :encstatus))) +(defun notmuch-show-insert-part-multipart/signed-or-encrypted (msg part content-type nth depth declared-type sigstatus-tuple encstatus-tuple) + (if (or encstatus-tuple sigstatus-tuple) + (progn + (notmuch-show-insert-part-header nth declared-type content-type + nil nil 'face 'notmuch-crypto-part-header) + (if encstatus-tuple + (notmuch-crypto-insert-encstatus-button (car encstatus-tuple))) + (if sigstatus-tuple + (notmuch-crypto-insert-sigstatus-button (car sigstatus-tuple) + (notmuch-show-get-header :From msg)))) + ;; If we're not adding status buttons, tell the user how they can + ;; enable them. + (notmuch-show-insert-part-header nth declared-type content-type + nil nil 'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts.")) + + ;; Insert the enclosed parts. (let ((inner-parts (plist-get part :content)) (start (point))) ;; Show all of the parts. -- 1.7.8.3 _______________________________________________ notmuch mailing list [hidden email] http://notmuchmail.org/mailman/listinfo/notmuch |
|
David Edmondson |
|
|
In reply to this post by David Edmondson
Add a regexp, `notmuch-show-part-headers-hidden' and if the
content-type of a part matches, don't show the part header. --- emacs/notmuch-show.el | 41 +++++++++++++++++++++++++++-------------- 1 files changed, 27 insertions(+), 14 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 97e2a15..fa826f7 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -110,6 +110,12 @@ indentation." :group 'notmuch :type 'boolean) +(defcustom notmuch-show-part-headers-hidden nil + "Headers for parts whose content-type matches this regexp will +not be shown." + :group 'notmuch + :type 'regexp) + (defmacro with-current-notmuch-show-message (&rest body) "Evaluate body with current buffer set to the text of current message" `(save-excursion @@ -285,23 +291,30 @@ message at DEPTH in the current thread." 'follow-link t 'face 'message-mml) +(defun notmuch-show-hidden-part-header (content-type) + "Return non-nil if a part header should be hidden for +CONTENT-TYPE parts." + (and notmuch-show-part-headers-hidden + (string-match notmuch-show-part-headers-hidden content-type))) + (defun notmuch-show-insert-part-header (nth content-type declared-type &optional name comment &rest button-parameters) - (apply #'insert-button - (concat "[ " - (if name (concat name ": ") "") - declared-type - (if (not (string-equal declared-type content-type)) - (concat " (as " content-type ")") - "") - (or comment "") - " ]") - :type 'notmuch-show-part-button-type - :notmuch-part nth - :notmuch-filename name - button-parameters) - (insert "\n")) + (unless (notmuch-show-hidden-part-header content-type) + (apply #'insert-button + (concat "[ " + (if name (concat name ": ") "") + declared-type + (if (not (string-equal declared-type content-type)) + (concat " (as " content-type ")") + "") + (or comment "") + " ]") + :type 'notmuch-show-part-button-type + :notmuch-part nth + :notmuch-filename name + button-parameters) + (insert "\n"))) ;; Functions handling particular MIME parts. -- 1.7.8.3 _______________________________________________ notmuch mailing list [hidden email] http://notmuchmail.org/mailman/listinfo/notmuch |
|
Jameson Graef Rollins |
|
|
In reply to this post by David Edmondson
On Fri, 20 Jan 2012 09:43:31 +0000, David Edmondson <[hidden email]> wrote:
> The buttons inserted for encrypted parts are slightly different now - > previously the logic was that if a part was encrypted it would have > the signature status inserted only if the encryption status was > specified. Now the signature status will be inserted even without > encryption status. My reading of the documentation says that this is > correct, but I'm no expert. Comments? I need some more time to review this patch, but I don't think this is correct. The signature status of encrypted messages (or even if the message was signed at all) comes from the decryption process. They're not independent. If the decryption fails it's unknown if there was a signature or not. I need to look closer at this, though. Hopefully this weekend. jamie. _______________________________________________ notmuch mailing list [hidden email] http://notmuchmail.org/mailman/listinfo/notmuch |
|
Jameson Graef Rollins |
|
|
In reply to this post by David Edmondson
On Fri, 20 Jan 2012 09:43:31 +0000, David Edmondson <[hidden email]> wrote:
> Instead, allow the caller to specify some parameters for the > button. Rework `notmuch-show-insert-part-multipart/signed' and > `notmuch-show-insert-part-multipart/encrypted' accordingly, moving > most of the code into a common > `notmuch-show-insert-part-multipart/signed-or-encrypted' to reduce > duplication. Hi, David. A couple of issues with this patch: This patch seems to include multiple distinct changes. There is a change to notmuch-show-insert-part-header, but a seemingly unrelated change to the insertion of signed/encrypted part buttons. They should be in separate patches. I'm also not sure I understand why the proposed changes to the signed/encrypted button insertion functions are necessary or desired. Was there a problem with the logic as it was? What is gained by having one function filled with special casing to handle two things, rather than having two distinct functions? Finally, this patch throws out all the changes from the previous patch, making the previous patch superfluous. jamie. _______________________________________________ notmuch mailing list [hidden email] http://notmuchmail.org/mailman/listinfo/notmuch |
|
David Edmondson |
|
|
On Sun, 22 Jan 2012 13:38:09 -0800, Jameson Graef Rollins <[hidden email]> wrote:
> This patch seems to include multiple distinct changes. There is a > change to notmuch-show-insert-part-header, but a seemingly unrelated > change to the insertion of signed/encrypted part buttons. They should > be in separate patches. I can separate them. > I'm also not sure I understand why the proposed changes to the > signed/encrypted button insertion functions are necessary or desired. > Was there a problem with the logic as it was? What is gained by > having one function filled with special casing to handle two things, > rather than having two distinct functions? There was no problem with the logic. The code in the two functions was almost identical, so I'd like to make any future changes in just one place. You didn't actually answer my question - is the logic in the new function correct? > Finally, this patch throws out all the changes from the previous patch, > making the previous patch superfluous. I'll merge the first patch into the later (and presumably get accused of submitting patches which include multiple distinct changes :-)). _______________________________________________ notmuch mailing list [hidden email] http://notmuchmail.org/mailman/listinfo/notmuch |
|
Jameson Graef Rollins |
|
|
On Mon, 23 Jan 2012 08:16:03 +0000, David Edmondson <[hidden email]> wrote:
> There was no problem with the logic. The code in the two functions was > almost identical, so I'd like to make any future changes in just one > place. > > You didn't actually answer my question - is the logic in the new > function correct? Honestly I didn't look too closely yet since I'm not convinced we need the change at all. I would prefer to keep the functions separate. In my opinion, enough special casing would be required that it wouldn't be worth it, and it would make the code less clear. > I'll merge the first patch into the later (and presumably get accused of > submitting patches which include multiple distinct changes :-)). But if you're removing all the code anyway, it's not a distinct change. It's still just a replacement. jamie. _______________________________________________ notmuch mailing list [hidden email] http://notmuchmail.org/mailman/listinfo/notmuch |
|
David Edmondson |
|
|
On Mon, 23 Jan 2012 00:52:26 -0800, Jameson Graef Rollins <[hidden email]> wrote:
> On Mon, 23 Jan 2012 08:16:03 +0000, David Edmondson <[hidden email]> wrote: > > There was no problem with the logic. The code in the two functions was > > almost identical, so I'd like to make any future changes in just one > > place. > > > > You didn't actually answer my question - is the logic in the new > > function correct? > > Honestly I didn't look too closely yet since I'm not convinced we need > the change at all. I would prefer to keep the functions separate. In > my opinion, enough special casing would be required that it wouldn't be > worth it, and it would make the code less clear. _______________________________________________ notmuch mailing list [hidden email] http://notmuchmail.org/mailman/listinfo/notmuch |
|
David Edmondson |
|
|
Instead, allow the caller to specify some parameters for the
button. Rework `notmuch-show-insert-part-multipart/signed' and `notmuch-show-insert-part-multipart/encrypted' accordingly. --- Removed the merge of multipart/signed and multipart/encrypted. emacs/notmuch-show.el | 84 +++++++++++++++++++++++++----------------------- 1 files changed, 44 insertions(+), 40 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 03c1f6b..9144484 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -285,24 +285,23 @@ message at DEPTH in the current thread." 'follow-link t 'face 'message-mml) -(defun notmuch-show-insert-part-header (nth content-type declared-type &optional name comment) - (let ((button)) - (setq button - (insert-button - (concat "[ " - (if name (concat name ": ") "") - declared-type - (if (not (string-equal declared-type content-type)) - (concat " (as " content-type ")") - "") - (or comment "") - " ]") - :type 'notmuch-show-part-button-type - :notmuch-part nth - :notmuch-filename name)) - (insert "\n") - ;; return button - button)) +(defun notmuch-show-insert-part-header (nth content-type declared-type + &optional name comment + &rest button-parameters) + (apply #'insert-button + (concat "[ " + (if name (concat name ": ") "") + declared-type + (if (not (string-equal declared-type content-type)) + (concat " (as " content-type ")") + "") + (or comment "") + " ]") + :type 'notmuch-show-part-button-type + :notmuch-part nth + :notmuch-filename name + button-parameters) + (insert "\n")) ;; Functions handling particular MIME parts. @@ -460,15 +459,18 @@ current buffer, if possible." t) (defun notmuch-show-insert-part-multipart/signed (msg part content-type nth depth declared-type) - (let ((button (notmuch-show-insert-part-header nth declared-type content-type nil))) - (button-put button 'face 'notmuch-crypto-part-header) - ;; add signature status button if sigstatus provided - (if (plist-member part :sigstatus) - (let* ((from (notmuch-show-get-header :From msg)) - (sigstatus (car (plist-get part :sigstatus)))) - (notmuch-crypto-insert-sigstatus-button sigstatus from)) - ;; if we're not adding sigstatus, tell the user how they can get it - (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts."))) + ;; Add signature status button if sigstatus provided. + (if (plist-member part :sigstatus) + (let ((from (notmuch-show-get-header :From msg)) + (sigstatus (car (plist-get part :sigstatus)))) + (notmuch-show-insert-part-header nth declared-type content-type nil nil + 'face 'notmuch-crypto-part-header) + (notmuch-crypto-insert-sigstatus-button sigstatus from)) + + ;; If we're not adding sigstatus, tell the user how to enable it. + (notmuch-show-insert-part-header nth declared-type content-type nil nil + 'face 'notmuch-crypto-part-header + 'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts.")) (let ((inner-parts (plist-get part :content)) (start (point))) @@ -482,19 +484,21 @@ current buffer, if possible." t) (defun notmuch-show-insert-part-multipart/encrypted (msg part content-type nth depth declared-type) - (let ((button (notmuch-show-insert-part-header nth declared-type content-type nil))) - (button-put button 'face 'notmuch-crypto-part-header) - ;; add encryption status button if encstatus specified - (if (plist-member part :encstatus) - (let ((encstatus (car (plist-get part :encstatus)))) - (notmuch-crypto-insert-encstatus-button encstatus) - ;; add signature status button if sigstatus specified - (if (plist-member part :sigstatus) - (let* ((from (notmuch-show-get-header :From msg)) - (sigstatus (car (plist-get part :sigstatus)))) - (notmuch-crypto-insert-sigstatus-button sigstatus from)))) - ;; if we're not adding encstatus, tell the user how they can get it - (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts."))) + ;; Add encryption status button if encstatus provided. + (if (plist-member part :encstatus) + (let ((encstatus (car (plist-get part :encstatus)))) + (notmuch-show-insert-part-header nth declared-type content-type nil nil + 'face 'notmuch-crypto-part-header) + (notmuch-crypto-insert-encstatus-button encstatus) + ;; add signature status button if sigstatus specified + (if (plist-member part :sigstatus) + (let* ((from (notmuch-show-get-header :From msg)) + (sigstatus (car (plist-get part :sigstatus)))) + (notmuch-crypto-insert-sigstatus-button sigstatus from)))) + ;; If we're not adding encstatus, tell the user how to enable it. + (notmuch-show-insert-part-header nth declared-type content-type nil nil + 'face 'notmuch-crypto-part-header + 'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts.")) (let ((inner-parts (plist-get part :content)) (start (point))) -- 1.7.8.3 _______________________________________________ notmuch mailing list [hidden email] http://notmuchmail.org/mailman/listinfo/notmuch |
|
David Edmondson |
|
|
Add a regexp, `notmuch-show-part-headers-hidden' and if the
content-type of a part matches, don't show the part header. --- emacs/notmuch-show.el | 41 +++++++++++++++++++++++++++-------------- 1 files changed, 27 insertions(+), 14 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 9144484..39f35ed 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -110,6 +110,12 @@ indentation." :group 'notmuch :type 'boolean) +(defcustom notmuch-show-part-headers-hidden nil + "Headers for parts whose content-type matches this regexp will +not be shown." + :group 'notmuch + :type 'regexp) + (defmacro with-current-notmuch-show-message (&rest body) "Evaluate body with current buffer set to the text of current message" `(save-excursion @@ -285,23 +291,30 @@ message at DEPTH in the current thread." 'follow-link t 'face 'message-mml) +(defun notmuch-show-hidden-part-header (content-type) + "Return non-nil if a part header should be hidden for +CONTENT-TYPE parts." + (and notmuch-show-part-headers-hidden + (string-match notmuch-show-part-headers-hidden content-type))) + (defun notmuch-show-insert-part-header (nth content-type declared-type &optional name comment &rest button-parameters) - (apply #'insert-button - (concat "[ " - (if name (concat name ": ") "") - declared-type - (if (not (string-equal declared-type content-type)) - (concat " (as " content-type ")") - "") - (or comment "") - " ]") - :type 'notmuch-show-part-button-type - :notmuch-part nth - :notmuch-filename name - button-parameters) - (insert "\n")) + (unless (notmuch-show-hidden-part-header content-type) + (apply #'insert-button + (concat "[ " + (if name (concat name ": ") "") + declared-type + (if (not (string-equal declared-type content-type)) + (concat " (as " content-type ")") + "") + (or comment "") + " ]") + :type 'notmuch-show-part-button-type + :notmuch-part nth + :notmuch-filename name + button-parameters) + (insert "\n"))) ;; Functions handling particular MIME parts. -- 1.7.8.3 _______________________________________________ notmuch mailing list [hidden email] http://notmuchmail.org/mailman/listinfo/notmuch |
|
David Edmondson |
|
|
In reply to this post by David Edmondson
Previously this logic applied only to text/plain. Allow it for other
text/* parts as well. --- This was not included in version 1 of the patch set. emacs/notmuch-show.el | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 39f35ed..55e4e34 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -300,7 +300,9 @@ CONTENT-TYPE parts." (defun notmuch-show-insert-part-header (nth content-type declared-type &optional name comment &rest button-parameters) - (unless (notmuch-show-hidden-part-header content-type) + (unless (or (notmuch-show-hidden-part-header content-type) + (and (= nth 1) + (string-match "text/*" content-type))) (apply #'insert-button (concat "[ " (if name (concat name ": ") "") @@ -561,10 +563,7 @@ current buffer, if possible." (defun notmuch-show-insert-part-text/plain (msg part content-type nth depth declared-type) (let ((start (point))) - ;; If this text/plain part is not the first part in the message, - ;; insert a header to make this clear. - (if (> nth 1) - (notmuch-show-insert-part-header nth declared-type content-type (plist-get part :filename))) + (notmuch-show-insert-part-header nth declared-type content-type (plist-get part :filename)) (insert (notmuch-show-get-bodypart-content msg part nth)) (save-excursion (save-restriction -- 1.7.8.3 _______________________________________________ notmuch mailing list [hidden email] http://notmuchmail.org/mailman/listinfo/notmuch |
|
David Edmondson |
|
|
In reply to this post by David Edmondson
v2 of these patches need to be merged with Mark's part saving
stuff. I've done this, but I'll hold off posting the merged version until this one is reviewed, unless anyone objects. _______________________________________________ notmuch mailing list [hidden email] http://notmuchmail.org/mailman/listinfo/notmuch |
|
David Edmondson |
|
|
In reply to this post by David Edmondson
Rebased on top of the recent button related changes from Mark.
[PATCH 1/3] emacs: Don't return the button from [PATCH 2/3] emacs: Optionally hide some part headers. [PATCH 3/3] emacs: Don't insert a part header if it's the first part _______________________________________________ notmuch mailing list [hidden email] http://notmuchmail.org/mailman/listinfo/notmuch |
|
David Edmondson |
|
|
Instead, allow the caller to specify some parameters for the
button. Rework `notmuch-show-insert-part-multipart/signed' and `notmuch-show-insert-part-multipart/encrypted' accordingly. --- emacs/notmuch-show.el | 86 +++++++++++++++++++++++++----------------------- 1 files changed, 45 insertions(+), 41 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index e6a5b31..d0e0d38 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -355,25 +355,24 @@ message at DEPTH in the current thread." "Submap for button commands") (fset 'notmuch-show-part-button-map notmuch-show-part-button-map) -(defun notmuch-show-insert-part-header (nth content-type declared-type &optional name comment) - (let ((button)) - (setq button - (insert-button - (concat "[ " - (if name (concat name ": ") "") - declared-type - (if (not (string-equal declared-type content-type)) - (concat " (as " content-type ")") - "") - (or comment "") - " ]") - :type 'notmuch-show-part-button-type - :notmuch-part nth - :notmuch-filename name - :notmuch-content-type content-type)) - (insert "\n") - ;; return button - button)) +(defun notmuch-show-insert-part-header (nth content-type declared-type + &optional name comment + &rest button-parameters) + (apply #'insert-button + (concat "[ " + (if name (concat name ": ") "") + declared-type + (if (not (string-equal declared-type content-type)) + (concat " (as " content-type ")") + "") + (or comment "") + " ]") + :type 'notmuch-show-part-button-type + :notmuch-part nth + :notmuch-filename name + :notmuch-content-type content-type + button-parameters) + (insert "\n")) ;; Functions handling particular MIME parts. @@ -559,15 +558,18 @@ current buffer, if possible." t) (defun notmuch-show-insert-part-multipart/signed (msg part content-type nth depth declared-type) - (let ((button (notmuch-show-insert-part-header nth declared-type content-type nil))) - (button-put button 'face 'notmuch-crypto-part-header) - ;; add signature status button if sigstatus provided - (if (plist-member part :sigstatus) - (let* ((from (notmuch-show-get-header :From msg)) - (sigstatus (car (plist-get part :sigstatus)))) - (notmuch-crypto-insert-sigstatus-button sigstatus from)) - ;; if we're not adding sigstatus, tell the user how they can get it - (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts."))) + ;; Add signature status button if sigstatus provided. + (if (plist-member part :sigstatus) + (let ((from (notmuch-show-get-header :From msg)) + (sigstatus (car (plist-get part :sigstatus)))) + (notmuch-show-insert-part-header nth declared-type content-type nil nil + 'face 'notmuch-crypto-part-header) + (notmuch-crypto-insert-sigstatus-button sigstatus from)) + + ;; If we're not adding sigstatus, tell the user how to enable it. + (notmuch-show-insert-part-header nth declared-type content-type nil nil + 'face 'notmuch-crypto-part-header + 'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts.")) (let ((inner-parts (plist-get part :content)) (start (point))) @@ -581,19 +583,21 @@ current buffer, if possible." t) (defun notmuch-show-insert-part-multipart/encrypted (msg part content-type nth depth declared-type) - (let ((button (notmuch-show-insert-part-header nth declared-type content-type nil))) - (button-put button 'face 'notmuch-crypto-part-header) - ;; add encryption status button if encstatus specified - (if (plist-member part :encstatus) - (let ((encstatus (car (plist-get part :encstatus)))) - (notmuch-crypto-insert-encstatus-button encstatus) - ;; add signature status button if sigstatus specified - (if (plist-member part :sigstatus) - (let* ((from (notmuch-show-get-header :From msg)) - (sigstatus (car (plist-get part :sigstatus)))) - (notmuch-crypto-insert-sigstatus-button sigstatus from)))) - ;; if we're not adding encstatus, tell the user how they can get it - (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts."))) + ;; Add encryption status button if encstatus provided. + (if (plist-member part :encstatus) + (let ((encstatus (car (plist-get part :encstatus)))) + (notmuch-show-insert-part-header nth declared-type content-type nil nil + 'face 'notmuch-crypto-part-header) + (notmuch-crypto-insert-encstatus-button encstatus) + ;; add signature status button if sigstatus specified + (if (plist-member part :sigstatus) + (let* ((from (notmuch-show-get-header :From msg)) + (sigstatus (car (plist-get part :sigstatus)))) + (notmuch-crypto-insert-sigstatus-button sigstatus from)))) + ;; If we're not adding encstatus, tell the user how to enable it. + (notmuch-show-insert-part-header nth declared-type content-type nil nil + 'face 'notmuch-crypto-part-header + 'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts.")) (let ((inner-parts (plist-get part :content)) (start (point))) -- 1.7.8.3 _______________________________________________ notmuch mailing list [hidden email] http://notmuchmail.org/mailman/listinfo/notmuch |
|
David Edmondson |
|
|
In reply to this post by David Edmondson
Add a regexp, `notmuch-show-part-headers-hidden' and if the
content-type of a part matches, don't show the part header. --- emacs/notmuch-show.el | 43 ++++++++++++++++++++++++++++--------------- 1 files changed, 28 insertions(+), 15 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index d0e0d38..a0a2873 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -123,6 +123,12 @@ indentation." (const :tag "View interactively" notmuch-show-interactively-view-part))) +(defcustom notmuch-show-part-headers-hidden nil + "Headers for parts whose content-type matches this regexp will +not be shown." + :group 'notmuch + :type 'regexp) + (defmacro with-current-notmuch-show-message (&rest body) "Evaluate body with current buffer set to the text of current message" `(save-excursion @@ -355,24 +361,31 @@ message at DEPTH in the current thread." "Submap for button commands") (fset 'notmuch-show-part-button-map notmuch-show-part-button-map) +(defun notmuch-show-hidden-part-header (content-type) + "Return non-nil if a part header should be hidden for +CONTENT-TYPE parts." + (and notmuch-show-part-headers-hidden + (string-match notmuch-show-part-headers-hidden content-type))) + (defun notmuch-show-insert-part-header (nth content-type declared-type &optional name comment &rest button-parameters) - (apply #'insert-button - (concat "[ " - (if name (concat name ": ") "") - declared-type - (if (not (string-equal declared-type content-type)) - (concat " (as " content-type ")") - "") - (or comment "") - " ]") - :type 'notmuch-show-part-button-type - :notmuch-part nth - :notmuch-filename name - :notmuch-content-type content-type - button-parameters) - (insert "\n")) + (unless (notmuch-show-hidden-part-header content-type) + (apply #'insert-button + (concat "[ " + (if name (concat name ": ") "") + declared-type + (if (not (string-equal declared-type content-type)) + (concat " (as " content-type ")") + "") + (or comment "") + " ]") + :type 'notmuch-show-part-button-type + :notmuch-part nth + :notmuch-filename name + :notmuch-content-type content-type + button-parameters) + (insert "\n"))) ;; Functions handling particular MIME parts. -- 1.7.8.3 _______________________________________________ notmuch mailing list [hidden email] http://notmuchmail.org/mailman/listinfo/notmuch |
|
David Edmondson |
|
|
In reply to this post by David Edmondson
Previously this logic applied only to text/plain. Allow it for other
text/* parts as well. --- emacs/notmuch-show.el | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index a0a2873..23bf1f4 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -370,7 +370,9 @@ CONTENT-TYPE parts." (defun notmuch-show-insert-part-header (nth content-type declared-type &optional name comment &rest button-parameters) - (unless (notmuch-show-hidden-part-header content-type) + (unless (or (notmuch-show-hidden-part-header content-type) + (and (= nth 1) + (string-match "text/*" content-type))) (apply #'insert-button (concat "[ " (if name (concat name ": ") "") @@ -660,10 +662,7 @@ current buffer, if possible." (defun notmuch-show-insert-part-text/plain (msg part content-type nth depth declared-type) (let ((start (point))) - ;; If this text/plain part is not the first part in the message, - ;; insert a header to make this clear. - (if (> nth 1) - (notmuch-show-insert-part-header nth declared-type content-type (plist-get part :filename))) + (notmuch-show-insert-part-header nth declared-type content-type (plist-get part :filename)) (insert (notmuch-show-get-bodypart-content msg part nth)) (save-excursion (save-restriction -- 1.7.8.3 _______________________________________________ notmuch mailing list [hidden email] http://notmuchmail.org/mailman/listinfo/notmuch |
|
Jameson Graef Rollins |
|
|
In reply to this post by David Edmondson
On Tue, 24 Jan 2012 12:53:38 +0000, David Edmondson <[hidden email]> wrote:
> Instead, allow the caller to specify some parameters for the > button. Rework `notmuch-show-insert-part-multipart/signed' and > `notmuch-show-insert-part-multipart/encrypted' accordingly. Hi, David. I was thinking about this, and it seems to me that returning the button itself is useful. I can imagine in the future that it might be useful to be able to modify the button after you've created. Maybe it's inconvenient to specify all button parameters at creation time. Is there a reason it's really necessary to make this change? Can't callers just ignore the returned button if they don't care about it further? I can see that maybe it's nice to be able to specify parameters at creation time, but I'm not sure why that requires throwing out the returned object as well. jamie. _______________________________________________ notmuch mailing list [hidden email] http://notmuchmail.org/mailman/listinfo/notmuch |
|
David Edmondson |
|
|
On Tue, 24 Jan 2012 10:46:57 -0800, Jameson Graef Rollins <[hidden email]> wrote:
> On Tue, 24 Jan 2012 12:53:38 +0000, David Edmondson <[hidden email]> wrote: > > Instead, allow the caller to specify some parameters for the > > button. Rework `notmuch-show-insert-part-multipart/signed' and > > `notmuch-show-insert-part-multipart/encrypted' accordingly. > > Hi, David. I was thinking about this, and it seems to me that returning > the button itself is useful. I can imagine in the future that it might > be useful to be able to modify the button after you've created. Maybe > it's inconvenient to specify all button parameters at creation time. > > Is there a reason it's really necessary to make this change? Can't > callers just ignore the returned button if they don't care about it > further? I can see that maybe it's nice to be able to specify > parameters at creation time, but I'm not sure why that requires throwing > out the returned object as well. inserted. _______________________________________________ notmuch mailing list [hidden email] http://notmuchmail.org/mailman/listinfo/notmuch |
|
Tomi Ollila-2 |
|
|
In reply to this post by David Edmondson
On Tue, 24 Jan 2012 12:53:38 +0000, David Edmondson <[hidden email]> wrote:
> Instead, allow the caller to specify some parameters for the > button. Rework `notmuch-show-insert-part-multipart/signed' and > `notmuch-show-insert-part-multipart/encrypted' accordingly. > --- LGTM. _______________________________________________ notmuch mailing list [hidden email] http://notmuchmail.org/mailman/listinfo/notmuch |
|
Tomi Ollila-2 |
|
|
In reply to this post by David Edmondson
On Tue, 24 Jan 2012 12:53:39 +0000, David Edmondson <[hidden email]> wrote:
> Add a regexp, `notmuch-show-part-headers-hidden' and if the > content-type of a part matches, don't show the part header. > --- LGTM... (I wonder ow easy is it to write regexps in custimization interface) _______________________________________________ notmuch mailing list [hidden email] http://notmuchmail.org/mailman/listinfo/notmuch |
| Powered by Nabble | See how NAML generates this page |