unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Edmondson <dme@dme.org>
To: notmuch@notmuchmail.org
Subject: [PATCH v1 2/3] emacs: Neaten `notmuch-show-insert-bodypart-internal'.
Date: Tue,  8 Mar 2016 17:12:58 +0000	[thread overview]
Message-ID: <1457457179-4707-3-git-send-email-dme@dme.org> (raw)
In-Reply-To: <1457457179-4707-1-git-send-email-dme@dme.org>

---
 emacs/notmuch-show.el | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 6e268f9..f739987 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -848,21 +848,16 @@ will return nil if the CID is unknown or cannot be retrieved."
 ;; \f
 
 (defun notmuch-show-insert-bodypart-internal (msg part content-type nth depth button)
-  (let ((handlers (notmuch-show-handlers-for content-type)))
-    ;; Run the content handlers until one of them returns a non-nil
-    ;; value.
-    (while (and handlers
-		(not (condition-case err
-			 (funcall (car handlers) msg part content-type nth depth button)
-		       ;; Specifying `debug' here lets the debugger
-		       ;; run if `debug-on-error' is non-nil.
-		       ((debug error)
-			(progn
-				(insert "!!! Bodypart insert error: ")
-				(insert (error-message-string err))
-				(insert " !!!\n") nil)))))
-      (setq handlers (cdr handlers))))
-  t)
+  ;; Run the handlers until one of them succeeds.
+  (loop for handler in (notmuch-show-handlers-for content-type)
+	until (condition-case err
+		  (funcall handler msg part content-type nth depth button)
+		;; Specifying `debug' here lets the debugger run if
+		;; `debug-on-error' is non-nil.
+		((debug error)
+		 (insert "!!! Bodypart handler `" (prin1-to-string handler) "' threw an error:\n"
+			 "!!! " (error-message-string err) "\n")
+		 nil))))
 
 (defun notmuch-show-create-part-overlays (button beg end)
   "Add an overlay to the part between BEG and END"
-- 
2.1.4

  parent reply	other threads:[~2016-03-08 17:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-08 17:12 [PATCH v1 0/3] Improve the acquisition of text parts David Edmondson
2016-03-08 17:12 ` [PATCH v1 1/3] emacs: `notmuch-show-insert-part-multipart/encrypted' should not assume the presence of a button David Edmondson
2016-03-08 17:12 ` David Edmondson [this message]
2016-03-08 17:12 ` [PATCH v1 3/3] emacs: Improve the acquisition of text parts David Edmondson
2016-03-13 15:22 ` [PATCH v1 0/3] " Mark Walters
2016-03-14  8:31   ` David Edmondson
2016-03-14 11:49     ` David Bremner
2016-03-26  9:18       ` Mark Walters
2016-03-27 20:48 ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1457457179-4707-3-git-send-email-dme@dme.org \
    --to=dme@dme.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).