[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: DocView: process ps->pdf changed status to killed.
From: |
Tassilo Horn |
Subject: |
Re: DocView: process ps->pdf changed status to killed. |
Date: |
Wed, 22 Oct 2014 09:16:15 +0200 |
User-agent: |
Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux) |
Tassilo Horn <tsdh@gnu.org> writes:
>> - we change the .txt system so that it displays the text in the
>> original buffer rather than in an auxiliary buffer (and hence we don't
>> switch back to ps-mode).
>
> That's an alternative I've also thought about. I'll see if that's
> feasible...
Ok, here's a patch which does that. `C-c C-t' or saying yes to the
initial "Cannot render; wanna view the text instead?" query replaces the
buffer contents with the text contents of the document and switches to
text-mode + doc-view-minor-mode. The buffer is still read-only so that
you can't modify it because it keeps the file association to the
original file.
With `C-c C-c' you can toggle back to viewing the page images, with
another `C-c C-c' you're back at the original document in its editing
mode (fundamental-mode, ps-mode, or archive-mode for ODF files).
--8<---------------cut here---------------start------------->8---
=== modified file 'lisp/doc-view.el'
--- lisp/doc-view.el 2014-07-28 09:39:09 +0000
+++ lisp/doc-view.el 2014-10-22 07:15:09 +0000
@@ -1396,15 +1396,14 @@
(interactive)
(if doc-view--current-converter-processes
(message "DocView: please wait till conversion finished.")
- (let ((txt (expand-file-name "doc.txt" (doc-view--current-cache-dir)))
- (bname (or buffer-file-name (buffer-name))))
+ (let ((txt (expand-file-name "doc.txt" (doc-view--current-cache-dir))))
(if (file-readable-p txt)
- (let ((name (concat "Text contents of "
- (file-name-nondirectory bname)))
- (dir (or (file-name-directory bname) default-directory)))
- (with-current-buffer (find-file txt)
- (rename-buffer name)
- (setq default-directory dir)))
+ (let ((inhibit-read-only t))
+ (set-buffer-multibyte t)
+ (text-mode)
+ (insert-file-contents txt nil nil nil t)
+ (set-buffer-modified-p nil)
+ (doc-view-minor-mode))
(doc-view-doc->txt txt 'doc-view-open-text)))))
;;;;; Toggle between editing and viewing
@@ -1416,20 +1415,28 @@
(defun doc-view-toggle-display ()
"Toggle between editing a document as text or viewing it."
(interactive)
- (if (eq major-mode 'doc-view-mode)
- ;; Switch to editing mode
- (progn
- (doc-view-kill-proc)
- (setq buffer-read-only nil)
- ;; Switch to the previously used major mode or fall back to
- ;; normal mode.
- (doc-view-fallback-mode)
- (doc-view-minor-mode 1))
+ (cond
+ ((eq major-mode 'doc-view-mode)
+ ;; Switch to editing mode
+ (doc-view-kill-proc)
+ (setq buffer-read-only nil)
+ ;; Switch to the previously used major mode or fall back to
+ ;; normal mode.
+ (doc-view-fallback-mode)
+ (doc-view-minor-mode 1))
+ ((eq major-mode 'text-mode)
+ ;; We're currently viewing the document's text contents, so switch
+ ;; back to doc-view-mode.
+ (setq buffer-read-only nil)
+ (insert-file-contents buffer-file-name nil nil nil t)
+ (doc-view-mode)
+ (set-buffer-modified-p nil))
+ (t
;; Switch to doc-view-mode
(when (and (buffer-modified-p)
(y-or-n-p "The buffer has been modified. Save the changes? "))
(save-buffer))
- (doc-view-mode)))
+ (doc-view-mode))))
;;;; Searching
@@ -1585,11 +1592,11 @@
(concat "No PNG support is available, or some conversion utility for "
(file-name-extension doc-view--buffer-file-name)
" files is missing."))
- (when (and (executable-find doc-view-pdftotext-program)
- (y-or-n-p
- "Unable to render file. View extracted text instead? "))
- (doc-view-open-text))
- (doc-view-toggle-display)))
+ (if (and (executable-find doc-view-pdftotext-program)
+ (y-or-n-p
+ "Unable to render file. View extracted text instead? "))
+ (doc-view-open-text)
+ (doc-view-toggle-display))))
(defvar bookmark-make-record-function)
@@ -1616,7 +1623,7 @@
"Figure out the current document type (`doc-view-doc-type')."
(let ((name-types
(when buffer-file-name
- (cdr (assoc-ignore-case
+ (cdr (assoc-string
(file-name-extension buffer-file-name)
'(
;; DVI
@@ -1634,7 +1641,8 @@
;; Microsoft Office formats (also handled by the odf
;; conversion chain).
("doc" odf) ("docx" odf) ("xls" odf) ("xlsx" odf)
- ("ppt" odf) ("pps" odf) ("pptx" odf))))))
+ ("ppt" odf) ("pps" odf) ("pptx" odf))
+ t))))
(content-types
(save-excursion
(goto-char (point-min))
--8<---------------cut here---------------end--------------->8---
Bye,
Tassilo
- Re: DocView: process ps->pdf changed status to killed., (continued)
- Re: DocView: process ps->pdf changed status to killed., Pierre Lorenzon, 2014/10/18
- Re: DocView: process ps->pdf changed status to killed., Tassilo Horn, 2014/10/19
- Re: DocView: process ps->pdf changed status to killed., Stefan Monnier, 2014/10/19
- Re: DocView: process ps->pdf changed status to killed., Tassilo Horn, 2014/10/21
- Re: DocView: process ps->pdf changed status to killed., Stefan Monnier, 2014/10/21
- Re: DocView: process ps->pdf changed status to killed., Tassilo Horn, 2014/10/21
- Message not available
- Re: DocView: process ps->pdf changed status to killed., Stefan Monnier, 2014/10/21
- Re: DocView: process ps->pdf changed status to killed., Tassilo Horn, 2014/10/21
- Re: DocView: process ps->pdf changed status to killed., Stefan Monnier, 2014/10/21
- Re: DocView: process ps->pdf changed status to killed., Tassilo Horn, 2014/10/22
- Re: DocView: process ps->pdf changed status to killed.,
Tassilo Horn <=
- Re: DocView: process ps->pdf changed status to killed., Stefan Monnier, 2014/10/22
- Re: DocView: process ps->pdf changed status to killed., Tassilo Horn, 2014/10/22
- Re: DocView: process ps->pdf changed status to killed., Pierre Lorenzon, 2014/10/23
- Re: DocView: process ps->pdf changed status to killed., Tassilo Horn, 2014/10/23
- Re: DocView: process ps->pdf changed status to killed., Stefan Monnier, 2014/10/23
- Re: DocView: process ps->pdf changed status to killed., Tassilo Horn, 2014/10/23
- Re: DocView: process ps->pdf changed status to killed., Pierre Lorenzon, 2014/10/24
- Re: DocView: process ps->pdf changed status to killed., Tassilo Horn, 2014/10/24
- Re: DocView: process ps->pdf changed status to killed., Pierre Lorenzon, 2014/10/24
- Re: DocView: process ps->pdf changed status to killed., Pierre Lorenzon, 2014/10/24