1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-22 07:09:54 +00:00

* lisp/doc-view.el (doc-view--text-view-mode): Derive from text-mode.

This commit is contained in:
Stefan Monnier 2019-03-13 18:22:57 -04:00
parent 82b4e9ffac
commit 020e69d992

View File

@ -1480,10 +1480,9 @@ For now these keys are useful:
;; can easily distinguish when we want to toggle back because
;; text-mode is a likely candidate for a default major-mode
;; (bug#34451).
(defun doc-view--text-view-mode ()
(define-derived-mode doc-view--text-view-mode text-mode "DV/Text"
"View mode used in DocView's text buffers."
(view-mode)
(setq major-mode 'doc-view--text-view-mode))
(view-mode))
(defun doc-view-open-text ()
"Display the current doc's contents as text."
@ -1496,6 +1495,10 @@ For now these keys are useful:
(buffer-undo-list t)
(dv-bfn doc-view--buffer-file-name))
(erase-buffer)
;; FIXME: Replacing the buffer's PDF content with its txt rendering
;; is pretty risky. We should probably use *another*
;; buffer instead, so there's much less risk of
;; overwriting the PDF file with some text rendering.
(set-buffer-multibyte t)
(insert-file-contents txt)
(doc-view--text-view-mode)
@ -1504,6 +1507,9 @@ For now these keys are useful:
(doc-view-minor-mode)
(add-hook 'write-file-functions
(lambda ()
;; FIXME: If the user changes major mode and then
;; saves the buffer, the PDF file will be clobbered
;; with its txt rendering!
(when (eq major-mode 'doc-view--text-view-mode)
(error "Cannot save text contents of document %s"
buffer-file-name)))