[PATCH v3 2/2] notmuch-show.el: handle the case where icalendar-import-buffer returns nil
Tomi Ollila
tomi.ollila at iki.fi
Thu Nov 8 04:08:00 PST 2012
icalendar-import-buffer can fail by an error signal (which have been
witnessed) but according to its docstring it can also return nil
when failing (it returns t when succeeding).
Now that the error is caught by the caller of notmuch-show-inset-part-*
functions in case icalendar-import-buffer returns nil an explicit
error is signaled and unwind-protect takes care of deleting the
temporary file (just in case, it is usually not written to the fs yet).
---
emacs/notmuch-show.el | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index e3977cc..9fb85c5 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -754,12 +754,15 @@ message at DEPTH in the current thread."
(replace-match "\n" nil nil))
(let ((file (make-temp-file "notmuch-ical"))
result)
- (icalendar-import-buffer file t)
- (set-buffer (get-file-buffer file))
- (setq result (buffer-substring (point-min) (point-max)))
- (set-buffer-modified-p nil)
- (kill-buffer (current-buffer))
- (delete-file file)
+ (unwind-protect
+ (progn
+ (unless (icalendar-import-buffer file t)
+ (error "Icalendar import error. See *icalendar-errors* for more information"))
+ (set-buffer (get-file-buffer file))
+ (setq result (buffer-substring (point-min) (point-max)))
+ (set-buffer-modified-p nil)
+ (kill-buffer (current-buffer)))
+ (delete-file file))
result)))
t)
--
1.8.0
More information about the notmuch
mailing list