[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Showing pdf files with doc-view. Possible?
From: |
Vagn Johansen |
Subject: |
Re: Showing pdf files with doc-view. Possible? |
Date: |
Thu, 22 Apr 2010 19:13:40 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1.91 (gnu/linux) |
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