1 Return-Path: <too@guru-group.fi>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 01B2E431FAE
\r
6 for <notmuch@notmuchmail.org>; Thu, 8 Nov 2012 04:08:04 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id KyBRWWrGP8oe for <notmuch@notmuchmail.org>;
\r
16 Thu, 8 Nov 2012 04:08:03 -0800 (PST)
\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])
\r
18 by olra.theworths.org (Postfix) with ESMTP id 785D2431FBC
\r
19 for <notmuch@notmuchmail.org>; Thu, 8 Nov 2012 04:08:02 -0800 (PST)
\r
20 Received: by guru.guru-group.fi (Postfix, from userid 501)
\r
21 id 3784F1000C9; Thu, 8 Nov 2012 14:08:03 +0200 (EET)
\r
22 From: Tomi Ollila <tomi.ollila@iki.fi>
\r
23 To: notmuch@notmuchmail.org
\r
24 Subject: [PATCH v3 2/2] notmuch-show.el: handle the case where
\r
25 icalendar-import-buffer returns nil
\r
26 Date: Thu, 8 Nov 2012 14:08:00 +0200
\r
27 Message-Id: <1352376480-29961-3-git-send-email-tomi.ollila@iki.fi>
\r
28 X-Mailer: git-send-email 1.8.0
\r
29 In-Reply-To: <1352376480-29961-1-git-send-email-tomi.ollila@iki.fi>
\r
30 References: <1352376480-29961-1-git-send-email-tomi.ollila@iki.fi>
\r
31 Cc: tomi.ollila@iki.fi
\r
32 X-BeenThere: notmuch@notmuchmail.org
\r
33 X-Mailman-Version: 2.1.13
\r
35 List-Id: "Use and development of the notmuch mail system."
\r
36 <notmuch.notmuchmail.org>
\r
37 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
38 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
39 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
40 List-Post: <mailto:notmuch@notmuchmail.org>
\r
41 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
42 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
43 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
44 X-List-Received-Date: Thu, 08 Nov 2012 12:08:04 -0000
\r
46 icalendar-import-buffer can fail by an error signal (which have been
\r
47 witnessed) but according to its docstring it can also return nil
\r
48 when failing (it returns t when succeeding).
\r
50 Now that the error is caught by the caller of notmuch-show-inset-part-*
\r
51 functions in case icalendar-import-buffer returns nil an explicit
\r
52 error is signaled and unwind-protect takes care of deleting the
\r
53 temporary file (just in case, it is usually not written to the fs yet).
\r
55 emacs/notmuch-show.el | 15 +++++++++------
\r
56 1 file changed, 9 insertions(+), 6 deletions(-)
\r
58 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
59 index e3977cc..9fb85c5 100644
\r
60 --- a/emacs/notmuch-show.el
\r
61 +++ b/emacs/notmuch-show.el
\r
62 @@ -754,12 +754,15 @@ message at DEPTH in the current thread."
\r
63 (replace-match "\n" nil nil))
\r
64 (let ((file (make-temp-file "notmuch-ical"))
\r
66 - (icalendar-import-buffer file t)
\r
67 - (set-buffer (get-file-buffer file))
\r
68 - (setq result (buffer-substring (point-min) (point-max)))
\r
69 - (set-buffer-modified-p nil)
\r
70 - (kill-buffer (current-buffer))
\r
71 - (delete-file file)
\r
74 + (unless (icalendar-import-buffer file t)
\r
75 + (error "Icalendar import error. See *icalendar-errors* for more information"))
\r
76 + (set-buffer (get-file-buffer file))
\r
77 + (setq result (buffer-substring (point-min) (point-max)))
\r
78 + (set-buffer-modified-p nil)
\r
79 + (kill-buffer (current-buffer)))
\r
80 + (delete-file file))
\r