diff options
author | Tassilo Horn <tsdh@gnu.org> | 2019-03-09 22:05:38 +0100 |
---|---|---|
committer | Tassilo Horn <tsdh@gnu.org> | 2019-03-09 22:06:26 +0100 |
commit | affd2a0cee901404251ea1d2ef01bfb618f5213a (patch) | |
tree | 789d4f1a60defde4999d3d54d7c2d6a0c8584d3b /lisp/doc-view.el | |
parent | dfc805532d77a3553a2eb6cb7035a041a8db848d (diff) | |
download | emacs-affd2a0cee901404251ea1d2ef01bfb618f5213a.tar.gz emacs-affd2a0cee901404251ea1d2ef01bfb618f5213a.tar.bz2 emacs-affd2a0cee901404251ea1d2ef01bfb618f5213a.zip |
Make doc-view work with text-mode as default major-mode (bug#34451)
* lisp/doc-view.el (doc-view--text-view-mode): New alias for view-mode.
(doc-view-open-text): Use it.
(doc-view-toggle-display): Use it.
Diffstat (limited to 'lisp/doc-view.el')
-rw-r--r-- | lisp/doc-view.el | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lisp/doc-view.el b/lisp/doc-view.el index 7ae7c6a96cd..53ae351abd8 100644 --- a/lisp/doc-view.el +++ b/lisp/doc-view.el @@ -1476,6 +1476,15 @@ For now these keys are useful: (interactive) (tooltip-show (doc-view-current-info))) +;; We define an own major mode for DocView's text display so that we +;; 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 () + "View mode used in DocView's text buffers." + (view-mode) + (setq major-mode 'doc-view--text-view-mode)) + (defun doc-view-open-text () "Display the current doc's contents as text." (interactive) @@ -1489,13 +1498,13 @@ For now these keys are useful: (erase-buffer) (set-buffer-multibyte t) (insert-file-contents txt) - (text-mode) + (doc-view--text-view-mode) (setq-local doc-view--buffer-file-name dv-bfn) (set-buffer-modified-p nil) (doc-view-minor-mode) (add-hook 'write-file-functions (lambda () - (when (eq major-mode 'text-mode) + (when (eq major-mode 'doc-view--text-view-mode) (error "Cannot save text contents of document %s" buffer-file-name))) nil t)) @@ -1519,7 +1528,7 @@ For now these keys are useful: ;; normal mode. (doc-view-fallback-mode) (doc-view-minor-mode 1)) - ((eq major-mode 'text-mode) + ((eq major-mode 'doc-view--text-view-mode) (let ((buffer-undo-list t)) ;; We're currently viewing the document's text contents, so switch ;; back to . |