Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* Showing pdf files with doc-view. Possible?
@ 2010-04-19  7:15 Vagn Johansen
  2010-04-22 15:37 ` Tassilo Horn
  0 siblings, 1 reply; 3+ messages in thread
From: Vagn Johansen @ 2010-04-19  7:15 UTC (permalink / raw)
  To: info-gnus-english


Does anyone know if it is possible to use doc-view(*) mode with gnus?

I have some situations where I get images sent as pdf files! It would
be nice to be able to inline these with doc-view.

In general it would be cool to have setting which inlined a pdf file
if it had fewer than n pages.



*) http://www.emacswiki.org/emacs/DocViewMode

-- 
Vagn Johansen

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Showing pdf files with doc-view. Possible?
  2010-04-19  7:15 Showing pdf files with doc-view. Possible? Vagn Johansen
@ 2010-04-22 15:37 ` Tassilo Horn
  2010-04-22 17:13   ` Vagn Johansen
  0 siblings, 1 reply; 3+ messages in thread
From: Tassilo Horn @ 2010-04-22 15:37 UTC (permalink / raw)
  To: info-gnus-english

Vagn Johansen <gonz808@hotmail.com> writes:

Hi Vagn,

> Does anyone know if it is possible to use doc-view(*) mode with gnus?

I know that! ;-)

It's not possible to inline the PDF images, but as a workaround you
could write your own command that saves the pdf part in a temp file and
opens that with emacs.

This is not tested, but might work:

--8<---------------cut here---------------start------------->8---
(defun th-gnus-mime-view-internally ()
  (interactive)
  (gnus-article-check-buffer)
  (let ((data (get-text-property (point) 'gnus-data)))
    (when data
      (let ((f (make-temp-file "mime-part" nil ".pdf")))
        (mm-save-part-to-file data f)
        (find-file f)))))
--8<---------------cut here---------------end--------------->8---

Bind it to some nice key in `gnus-article-mode-map' and have fun.

Bye,
Tassilo

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Showing pdf files with doc-view. Possible?
  2010-04-22 15:37 ` Tassilo Horn
@ 2010-04-22 17:13   ` Vagn Johansen
  0 siblings, 0 replies; 3+ messages in thread
From: Vagn Johansen @ 2010-04-22 17:13 UTC (permalink / raw)
  To: info-gnus-english

Tassilo Horn <tassilo@member.fsf.org> writes:

> Vagn Johansen <gonz808@hotmail.com> writes:
>
> Hi Vagn,
>
>> Does anyone know if it is possible to use doc-view(*) mode with gnus?
>
> I know that! ;-)
>
> It's not possible to inline the PDF images, but as a workaround you
> could write your own command that saves the pdf part in a temp file and
> opens that with emacs.
>
> This is not tested, but might work:
>
>
> (defun th-gnus-mime-view-internally ()
>   (interactive)
>   (gnus-article-check-buffer)
>   (let ((data (get-text-property (point) 'gnus-data)))
>     (when data
>       (let ((f (make-temp-file "mime-part" nil ".pdf")))
>         (mm-save-part-to-file data f)
>         (find-file f)))))


Cool. It works!

>
> Bind it to some nice key in `gnus-article-mode-map' and have fun.
>

I prefer "doing stuff" to attachments via the K prefix in
gnus-summary-mode.

Here are my improvements and generalisations to your code (with some
inspiration from gnus-sum.el and gnus-art.el).

Usage: 

  (define-key gnus-summary-mode-map [?K ?f]
    'gnus-article-view-part-via-find-file)

Code:


(defun gnus-mime-view-part-via-find-file (&optional handle)
  (interactive)
  (gnus-article-check-buffer)
  (let ((handle (or handle  (get-text-property (point) 'gnus-data))))
    (when handle
      (let* ((gnus-data (mm-handle-type (get-text-property (point)
                                          'gnus-data)))
              (ext (file-name-extension
                     (or (mail-content-type-get gnus-data 'name)
                       "dummy.txt")))
              (suffix (concat "." ext ))
              (f (make-temp-file "mime-part" nil suffix)))
        (mm-save-part-to-file handle f)
        (find-file f)))))

(defun gnus-article-view-part-via-find-file (n)
  "View MIME part N via find-file, which is the numerical prefix."
  (interactive "P")
  (gnus-article-part-wrapper n 'gnus-mime-view-part-via-find-file))


-- 
Vagn Johansen
Evalesco A/S

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-04-22 17:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-19  7:15 Showing pdf files with doc-view. Possible? Vagn Johansen
2010-04-22 15:37 ` Tassilo Horn
2010-04-22 17:13   ` Vagn Johansen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).