summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2019-03-13 18:22:57 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2019-03-13 18:22:57 -0400
commit020e69d992c98fd852e835c9bd707a8d137090f2 (patch)
tree4ec0a3cd13d38dab6d80922a9bea71c65009bbb5 /lisp
parent82b4e9ffacaa8bf3dc30daf5f9f50c72699cc717 (diff)
downloademacs-020e69d992c98fd852e835c9bd707a8d137090f2.tar.gz
* lisp/doc-view.el (doc-view--text-view-mode): Derive from text-mode.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/doc-view.el12
1 files changed, 9 insertions, 3 deletions
diff --git a/lisp/doc-view.el b/lisp/doc-view.el
index 53ae351abd8..a7069072603 100644
--- a/lisp/doc-view.el
+++ b/lisp/doc-view.el
@@ -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)))