Re: problems viewing attachments in emacs ui
authorAustin Clements <amdragon@MIT.EDU>
Wed, 31 Jul 2013 14:55:09 +0000 (10:55 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:56:13 +0000 (09:56 -0800)
f4/05bdb79c7c14b0970ec9126e2465f57115c04c [new file with mode: 0644]

diff --git a/f4/05bdb79c7c14b0970ec9126e2465f57115c04c b/f4/05bdb79c7c14b0970ec9126e2465f57115c04c
new file mode 100644 (file)
index 0000000..7ba52b7
--- /dev/null
@@ -0,0 +1,173 @@
+Return-Path: <amdragon@mit.edu>\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 D9F9B431FC0\r
+       for <notmuch@notmuchmail.org>; Wed, 31 Jul 2013 07:55:25 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 At3aS12s-TJh for <notmuch@notmuchmail.org>;\r
+       Wed, 31 Jul 2013 07:55:18 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-3.mit.edu (dmz-mailsec-scanner-3.mit.edu\r
+       [18.9.25.14])\r
+       by olra.theworths.org (Postfix) with ESMTP id 3FEFA431FBF\r
+       for <notmuch@notmuchmail.org>; Wed, 31 Jul 2013 07:55:18 -0700 (PDT)\r
+X-AuditID: 1209190e-b7f988e0000009a7-9a-51f9255362f9\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+       by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id D9.7D.02471.35529F15; Wed, 31 Jul 2013 10:55:15 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+       by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id r6VEtDAd002007; \r
+       Wed, 31 Jul 2013 10:55:14 -0400\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+       (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r6VEtALd029070\r
+       (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
+       Wed, 31 Jul 2013 10:55:12 -0400\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
+       (envelope-from <amdragon@MIT.EDU>)\r
+       id 1V4Xny-000294-5r; Wed, 31 Jul 2013 10:55:10 -0400\r
+Date: Wed, 31 Jul 2013 10:55:09 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Jameson Graef Rollins <jrollins@finestructure.net>\r
+Subject: Re: problems viewing attachments in emacs ui\r
+Message-ID: <20130731145508.GW2214@mit.edu>\r
+References: <87hafe4ox6.fsf@servo.finestructure.net>\r
+       <87ehai4ns3.fsf@servo.finestructure.net>\r
+       <20130731025303.GV2214@mit.edu>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To: <20130731025303.GV2214@mit.edu>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFmpgleLIzCtJLcpLzFFi42IRYrdT1w1W/RlosKSF1WLPPi+L6zdnMjsw\r
+       edw9zeXxbNUt5gCmKC6blNSczLLUIn27BK6MLfcPsxUsVq44PeMtcwPjefEuRk4OCQETiVMr\r
+       VzBD2GISF+6tZ+ti5OIQEtjHKNHypoMFwtnIKPHl0hcmCOc0k0Tbv+PsEM4SRolv984ydjFy\r
+       cLAIqEr82+wKMopNQENi2/7ljCC2iICZRM+XP2A2s4C0xLffzUwgtrCAqcSSxTPZQWxeAW2J\r
+       V5Mfg9UICTQySlz8rgwRF5Q4OfMJC0SvlsSNfy+ZQFaBzFn+jwPE5BTQkVi7wwmkQlRARWLK\r
+       yW1sExiFZiFpnoWkeRZC8wJG5lWMsim5Vbq5iZk5xanJusXJiXl5qUW6xnq5mSV6qSmlmxhB\r
+       Ac0pybeD8etBpUOMAhyMSjy8jhe+BwqxJpYVV+YeYpTkYFIS5bVV+hkoxJeUn1KZkVicEV9U\r
+       mpNafIhRgoNZSYR3DytQjjclsbIqtSgfJiXNwaIkzvvs6dlAIYH0xJLU7NTUgtQimKwMB4eS\r
+       BO9GFaBGwaLU9NSKtMycEoQ0EwcnyHAeoOEFIDW8xQWJucWZ6RD5U4yKUuK8vSAJAZBERmke\r
+       XC8s4bxiFAd6RZh3B0gVDzBZwXW/AhrMBDR4t8o3kMEliQgpqQZG/652XTkz2SSLkiWz1606\r
+       +fJ60aaUo5OW176Tv7zaI+1+SF3Xhn+nDdmcdt4+IH/elfHUp7WLd6m+MVnxueiz2G+pvuUm\r
+       Vre/hln+uJS1+uGmupAHJ51vxrg05PefMD+XMj1wch6nxd65FZwTp6/RM7c/8+nEknWr5hhU\r
+       ttumhZcV7Xind3PvNSWW4oxEQy3mouJEAHvr6YATAwAA\r
+Cc: notmuch@notmuchmail.org\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, 31 Jul 2013 14:55:26 -0000\r
+\r
+Quoth myself on Jul 30 at 10:53 pm:\r
+> Quoth Jameson Graef Rollins on Jul 28 at 10:06 am:\r
+> > On Sun, Jul 28 2013, Jameson Graef Rollins <jrollins@finestructure.net> wrote:\r
+> > > For instance, if I launch notmuch-show-view-part on an html part, my\r
+> > > browser opens pointed at e.g. the following file:\r
+> > >\r
+> > >   file:///home/jrollins/tmp/emm.610040w/mm.6100F_2.htm\r
+> > >\r
+> > > But the browser shows the following error:\r
+> > >\r
+> > >   File not found\r
+> > >   Iceweasel can't find the file at /home/jrollins/tmp/emm.610040w/mm.6100F_2.htm.\r
+> > \r
+> > I'm now realizing that my problem with html parts is probably that\r
+> > browser is attempting to open the temporary file in the background.\r
+> > When the browser call returns, the caller assumes the application is\r
+> > done with the temp file and purges it.  So for this issue at least I\r
+> > need to either convince my browser to not open the file in the\r
+> > background, or tell emacs to cleanup temp files at some later time\r
+> > (session termination, for instance).\r
+> \r
+> As pointed out by David, the root of this problem is in\r
+> mm-display-external in mm-decode.el.  mm-display-external was mostly\r
+> rewritten between Emacs 24.1 and Emacs 24.2 (Emacs commit 1354a694).\r
+> The Emacs 24.1 implementation would wait for the spawned process to\r
+> exit or 30 seconds to elapse, whichever was longer, before deleting\r
+> the file (Emacs 23 was much the same, but waited only 2 seconds).\r
+> Based on the source comments, this appears to be the *intent* of the\r
+> Emacs 24.2 implementation, but what the code actually does is to wait\r
+> for whichever of these events happens *first*.  So, if the spawned\r
+> process exits immediately (like in your situation), the file will be\r
+> deleted immediately, and even if the viewer sticks around, the file\r
+> will be deleted after 30 seconds anyway.\r
+> \r
+> This must be affecting Gnus users the same way, but I haven't found\r
+> any evidence that they're aware of it.  The mm-display-external code\r
+> still has this problem in both the current Emacs master and the\r
+> current Gnus master.\r
+\r
+Try this patch to mm-decode.el.  It should restore the original\r
+behavior and intent of mm-display-external (in a much less gruesome\r
+way than the old 24.1 code).  I simply copied mm-decode.el into my\r
+personal elisp directory (which appears early in my load-path), which\r
+seemed to work just fine for my cursory testing.\r
+\r
+diff --git a/lisp/gnus/mm-decode.el b/lisp/gnus/mm-decode.el\r
+index 98be1c5..c11790c 100644\r
+--- a/lisp/gnus/mm-decode.el\r
++++ b/lisp/gnus/mm-decode.el\r
+@@ -958,26 +958,30 @@ external if displayed external."\r
+                                  shell-command-switch command)\r
+                   (set-process-sentinel\r
+                    (get-buffer-process buffer)\r
+-                   (lexical-let ((outbuf outbuf)\r
+-                                 (file file)\r
+-                                 (buffer buffer)\r
+-                                 (command command)\r
+-                                 (handle handle))\r
++                   (lexical-let* ((outbuf outbuf)\r
++                                    (file file)\r
++                                    (buffer buffer)\r
++                                    (command command)\r
++                                    (handle handle)\r
++                                    (timer-fired nil)\r
++                                    (proc-exited nil)\r
++                                    (maybe-cleanup\r
++                                     (lambda ()\r
++                                       (when (and timer-fired proc-exited)\r
++                                         (ignore-errors\r
++                                           (delete-file file))\r
++                                         (ignore-errors\r
++                                           (delete-directory\r
++                                            (file-name-directory file)))))))\r
+                      (run-at-time\r
+                       30.0 nil\r
+                       (lambda ()\r
+-                        (ignore-errors\r
+-                          (delete-file file))\r
+-                        (ignore-errors\r
+-                          (delete-directory (file-name-directory file)))))\r
++                          (setq timer-fired t)\r
++                          (funcall maybe-cleanup)))\r
+                      (lambda (process state)\r
+                        (when (eq (process-status process) 'exit)\r
+-                         (condition-case nil\r
+-                             (delete-file file)\r
+-                           (error))\r
+-                         (condition-case nil\r
+-                             (delete-directory (file-name-directory file))\r
+-                           (error))\r
++                           (setq proc-exited t)\r
++                           (funcall maybe-cleanup)\r
+                          (when (buffer-live-p outbuf)\r
+                            (with-current-buffer outbuf\r
+                              (let ((buffer-read-only nil)\r