From: Tomi Ollila Date: Thu, 8 Nov 2012 12:08:00 +0000 (+0200) Subject: [PATCH v3 2/2] notmuch-show.el: handle the case where icalendar-import-buffer returns nil X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=2444b412f1ab55c8720efd6319d235a5cfa233dd;p=notmuch-archives.git [PATCH v3 2/2] notmuch-show.el: handle the case where icalendar-import-buffer returns nil --- diff --git a/7e/0ac3ae26f5e32d6c326e995d2287823fb6a740 b/7e/0ac3ae26f5e32d6c326e995d2287823fb6a740 new file mode 100644 index 000000000..49c4927cb --- /dev/null +++ b/7e/0ac3ae26f5e32d6c326e995d2287823fb6a740 @@ -0,0 +1,86 @@ +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 01B2E431FAE + for ; Thu, 8 Nov 2012 04:08:04 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + 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 KyBRWWrGP8oe for ; + Thu, 8 Nov 2012 04:08:03 -0800 (PST) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id 785D2431FBC + for ; Thu, 8 Nov 2012 04:08:02 -0800 (PST) +Received: by guru.guru-group.fi (Postfix, from userid 501) + id 3784F1000C9; Thu, 8 Nov 2012 14:08:03 +0200 (EET) +From: Tomi Ollila +To: notmuch@notmuchmail.org +Subject: [PATCH v3 2/2] notmuch-show.el: handle the case where + icalendar-import-buffer returns nil +Date: Thu, 8 Nov 2012 14:08:00 +0200 +Message-Id: <1352376480-29961-3-git-send-email-tomi.ollila@iki.fi> +X-Mailer: git-send-email 1.8.0 +In-Reply-To: <1352376480-29961-1-git-send-email-tomi.ollila@iki.fi> +References: <1352376480-29961-1-git-send-email-tomi.ollila@iki.fi> +Cc: tomi.ollila@iki.fi +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: Thu, 08 Nov 2012 12:08:04 -0000 + +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 +