From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Schmitt Newsgroups: gmane.emacs.help Subject: Re: Cannot open attachments with gnus Date: Tue, 17 Dec 2013 22:16:05 +0100 Organization: IRISA, INRIA Rennes (FR) Message-ID: References: <87vbysol5y.fsf@flea.lifelogs.com> <87zjnzlp41.fsf@flea.lifelogs.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1387316420 12516 80.91.229.3 (17 Dec 2013 21:40:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 17 Dec 2013 21:40:20 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Dec 17 22:40:26 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Vt2NO-0002Gc-FE for geh-help-gnu-emacs@m.gmane.org; Tue, 17 Dec 2013 22:40:26 +0100 Original-Received: from localhost ([::1]:35865 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vt2NN-0006LI-Rl for geh-help-gnu-emacs@m.gmane.org; Tue, 17 Dec 2013 16:40:26 -0500 X-FeedAbuse: http://nntpfeed.proxad.net/abuse.pl feeded by 78.192.65.63 Original-Path: usenet.stanford.edu!news.kjsl.com!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!proxad.net!feeder1-2.proxad.net!nntpfeed.proxad.net!news.muarf.org!news.ecp.fr!news-rocq.inria.fr!news.irisa.fr!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 84 Original-NNTP-Posting-Host: cbg35-2-78-242-14-140.fbx.proxad.net Original-X-Trace: news-v3.irisa.fr 1387314966 16412 78.242.14.140 (17 Dec 2013 21:16:06 GMT) Original-X-Complaints-To: abuse@irisa.fr Original-NNTP-Posting-Date: Tue, 17 Dec 2013 21:16:06 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) Cancel-Lock: sha1:Gq9ucEw6SEynmXmm991bw65MJDk= Original-Xref: usenet.stanford.edu gnu.emacs.help:202797 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:95066 Archived-At: Hi Ted, Ted Zlatanov writes: > I think so. My system doesn't have `open' so I don't know if it has an > option to run synchronously, but you could either write a wrapper script > or set up the MIME handling to call the PDF viewer directly. I tried to change my .mailcap, but the change did not seem to have taken. I'll have to try restarting emacs to see if it matters. What kind of wrapper script should I write? Something that first copies the file somewhere where emacs won't delete it? Is it common practice for asynchronous viewers? > AS> If so, is there a way to tell gnus not to clean up after opening an > AS> attachment? (The /tmp files will eventually be deleted.) > > I don't think there's built-in functionality for this, but it can > probably be written. I tried to look at the code, and I found it lives in function `mm-display-external' in mm-decode.el. The code that matters is at the end, but I'm not sure I'm reading it correctly. The way I read it: the process is launched, and whatever happens, after 30 seconds the file is going to be deleted (I guess this is what the "run-at-time" part does). Even though the command says deletion "should be postponed for some wrappers", I could not find a way where it is done. I'd gladly take any suggestion. #+begin_src emacs-lisp ;; Deleting the temp file should be postponed for some wrappers, ;; shell scripts, and so on, which might exit right after having ;; started a viewer command as a background job. (let ((command (mm-mailcap-command method file (mm-handle-type handle)))) (unwind-protect (progn (start-process "*display*" (setq buffer (generate-new-buffer " *mm*")) shell-file-name shell-command-switch command) (set-process-sentinel (get-buffer-process buffer) (lexical-let ((outbuf outbuf) (file file) (buffer buffer) (command command) (handle handle)) (run-at-time 30.0 nil (lambda () (ignore-errors (delete-file file)) (ignore-errors (delete-directory (file-name-directory file))))) (lambda (process state) (when (eq (process-status process) 'exit) (condition-case nil (delete-file file) (error)) (condition-case nil (delete-directory (file-name-directory file)) (error)) (when (buffer-live-p outbuf) (with-current-buffer outbuf (let ((buffer-read-only nil) (point (point))) (forward-line 2) (mm-insert-inline handle (with-current-buffer buffer (buffer-string))) (goto-char point)))) (when (buffer-live-p buffer) (kill-buffer buffer))) (message "Displaying %s...done" command))))) ...)) #+end_src Thanks a lot, Alan