Re: bug related to ical
authorTomi Ollila <tomi.ollila@iki.fi>
Wed, 3 Oct 2012 13:30:12 +0000 (16:30 +0300)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:49:42 +0000 (09:49 -0800)
5e/25b41b612d0b5e4c87407ad5ec7b65a86fc35c [new file with mode: 0644]

diff --git a/5e/25b41b612d0b5e4c87407ad5ec7b65a86fc35c b/5e/25b41b612d0b5e4c87407ad5ec7b65a86fc35c
new file mode 100644 (file)
index 0000000..00f3b67
--- /dev/null
@@ -0,0 +1,166 @@
+Return-Path: <tomi.ollila@iki.fi>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 31584431FAF\r
+       for <notmuch@notmuchmail.org>; Wed,  3 Oct 2012 06:30:11 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id oIBhgL2VRcmM for <notmuch@notmuchmail.org>;\r
+       Wed,  3 Oct 2012 06:30:10 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+       by olra.theworths.org (Postfix) with ESMTP id D4F89431FAE\r
+       for <notmuch@notmuchmail.org>; Wed,  3 Oct 2012 06:30:09 -0700 (PDT)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+       by guru.guru-group.fi (Postfix) with ESMTP id 179C3100150;\r
+       Wed,  3 Oct 2012 16:30:13 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Aaron Ecay <aaronecay@gmail.com>, Robert Horn <rjhorn@alum.mit.edu>,\r
+       notmuch@notmuchmail.org\r
+Subject: Re: bug related to ical\r
+In-Reply-To: <87d319b899.fsf@gmail.com>\r
+References: <m31ul3qo4w.fsf@quad.robs.office> <87d319b899.fsf@gmail.com>\r
+User-Agent: Notmuch/0.14+51~g62cd13b (http://notmuchmail.org) Emacs/24.2.1\r
+       (x86_64-unknown-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+       $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+       !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Wed, 03 Oct 2012 16:30:12 +0300\r
+Message-ID: <m2obkjlm3f.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Transfer-Encoding: quoted-printable\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 03 Oct 2012 13:30:11 -0000\r
+\r
+On Wed, Sep 26 2012, Aaron Ecay wrote:\r
+\r
+> The problem is in the =E2=80=98notmuch-show-insert-part-text/calendar=E2=\r
+=80=99\r
+> function.  The call to =E2=80=98icalendar--convert-ical-to-diary=E2=80=99=\r
+ does not\r
+> create a buffer visiting the temp file, so the call to =E2=80=98set-buffe=\r
+r=E2=80=99\r
+> fails.  The following patch fixes the problem.\r
+>\r
+> The ical->diary conversion also doesn=E2=80=99t seem to work =E2=80=93 th=\r
+e calendar\r
+> attachment shows up as an empty part =E2=80=93 but I guess that=E2=80=99s=\r
+ a separate\r
+> issue (and not addressed by the patch).\r
+>\r
+> I guess that part insertion handlers should be called inside a\r
+> =E2=80=98condition-case=E2=80=99, so that an error inside of one can be r=\r
+ecovered from,\r
+> and doesn=E2=80=99t entirely derail the insertion of the messages in the =\r
+buffer.\r
+> (I actually made this patch because I was so annoyed that Olivier=E2=80=\r
+=99s\r
+> buggy test attachment made it impossible for me to read Tomi=E2=80=99s re=\r
+ply.)\r
+>\r
+> ----- cut here -----\r
+>\r
+> diff --git i/emacs/notmuch-show.el w/emacs/notmuch-show.el\r
+> index ce5ea6f..4c89d7e 100644\r
+> --- i/emacs/notmuch-show.el\r
+> +++ w/emacs/notmuch-show.el\r
+> @@ -746,7 +746,7 @@ message at DEPTH in the current thread."\r
+>            (icalendar--convert-ical-to-diary\r
+>             (icalendar--read-element nil nil)\r
+>             file t)\r
+> -          (set-buffer (get-file-buffer file))\r
+> +          (set-buffer (find-file-noselect file))\r
+>            (setq result (buffer-substring (point-min) (point-max)))\r
+>            (set-buffer-modified-p nil)\r
+>            (kill-buffer (current-buffer))\r
+>\r
+> ----- cut here -----\r
+\r
+The problem seems to be carriage returns in the attachment -- which goes\r
+unnotified when converting from octet-stream content.\r
+\r
+I've got the example in question to "work" with the following patch_\r
+\r
+--8<----8<----8<-- cut here  --8<----8<----8<--\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 86130ce..f7c08ee 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -747,17 +747,21 @@ message at DEPTH in the current thread."\r
+   (notmuch-show-insert-part-header nth declared-type content-type (plist-g=\r
+et part :filename))\r
+   (insert (with-temp-buffer\r
+           (insert (notmuch-get-bodypart-content msg part nth notmuch-show-proce=\r
+ss-crypto))\r
+-          (goto-char (point-min))\r
+           (let ((file (make-temp-file "notmuch-ical"))\r
+                 result)\r
++            (set-buffer (icalendar--get-unfolded-buffer (current-buffer)))\r
++            (beginning-of-buffer)\r
++            (replace-string "" "")\r
++            (beginning-of-buffer)\r
+             (icalendar--convert-ical-to-diary\r
+              (icalendar--read-element nil nil)\r
+              file t)\r
++            (kill-buffer (current-buffer))\r
+             (set-buffer (get-file-buffer file))\r
+             (setq result (buffer-substring (point-min) (point-max)))\r
+             (set-buffer-modified-p nil)\r
+             (kill-buffer (current-buffer))\r
+-            (delete-file file)\r
++            ;;;(delete-file file)\r
+             result)))\r
+   t)\r
+=20\r
+--8<----8<----8<-- cut here  --8<----8<----8<--\r
+\r
+In our case the icalendar--get-unfolded-buffer doesn't seem\r
+to do any conversions (the docstring mentions some LF/CR/BLANK\r
+replacements) -- I just copied that line from icalendar-import-buffer\r
+which I tried first.\r
+\r
+The interesting thing is that the notmuch-icalXXXXXX file is\r
+still empty ... hmm, the buffer is just not saved (would /dev/null work ;))\r
+\r
+To do:\r
+Check why icalendar--get-unfolded-buffer did not do what it advertised;\r
+the code seems to support the replacements mentioned -- or maybe I failed ;/\r
+\r
+The problem with failing to icalendar--convert-ical-to-diary is that\r
+the buffer is not created. The find-file-noselect shields about that\r
+problem here but not elsewhere (and why that failure is so "fatal" ???)\r
+Some shielding in higher level should be implemented (i.e. the\r
+"condition-case" suggestion Aaron mentioned or something :)\r
+\r
+\r
+self to remember:  M-x debug-on-entry and keys 'd', 'u' and 'c' in debugger=\r
+ :)\r
+\r
+Tomi\r
+\r
+>\r
+> --=20\r
+> Aaron Ecay\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r