(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)
(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))
;; 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 .