mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-30 12:21:25 -08:00
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.
This commit is contained in:
parent
dfc805532d
commit
affd2a0cee
1 changed files with 12 additions and 3 deletions
|
|
@ -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 .
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue