From: Alan Schmitt <alan.schmitt@polytechnique.org>
To: help-gnu-emacs@gnu.org
Subject: Re: Cannot open attachments with gnus
Date: Tue, 17 Dec 2013 22:16:05 +0100 [thread overview]
Message-ID: <m2lhzjrxey.fsf@polytechnique.org> (raw)
In-Reply-To: 87zjnzlp41.fsf@flea.lifelogs.com
Hi Ted,
Ted Zlatanov <tzz@lifelogs.com> 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
next prev parent reply other threads:[~2013-12-17 21:16 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-13 13:02 Cannot open attachments with gnus Alan Schmitt
2013-12-13 14:13 ` Eli Zaretskii
2013-12-13 14:55 ` Ted Zlatanov
2013-12-13 17:34 ` Alan Schmitt
2013-12-17 10:59 ` Ted Zlatanov
2013-12-17 21:16 ` Alan Schmitt [this message]
2013-12-18 8:19 ` Alan Schmitt
2013-12-18 19:10 ` Ted Zlatanov
2013-12-18 20:39 ` Alan Schmitt
2013-12-18 21:51 ` Ted Zlatanov
2013-12-19 15:52 ` Ted Zlatanov
2013-12-20 11:20 ` Alan Schmitt
[not found] ` <mailman.9108.1386944000.10748.help-gnu-emacs@gnu.org>
2013-12-13 17:28 ` Alan Schmitt
2013-12-18 3:27 ` Jambunathan K
[not found] ` <mailman.9546.1387337332.10748.help-gnu-emacs@gnu.org>
2013-12-18 8:00 ` Alan Schmitt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2lhzjrxey.fsf@polytechnique.org \
--to=alan.schmitt@polytechnique.org \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.