aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTassilo Horn2019-03-09 22:05:38 +0100
committerTassilo Horn2019-03-09 22:06:26 +0100
commitaffd2a0cee901404251ea1d2ef01bfb618f5213a (patch)
tree789d4f1a60defde4999d3d54d7c2d6a0c8584d3b
parentdfc805532d77a3553a2eb6cb7035a041a8db848d (diff)
downloademacs-affd2a0cee901404251ea1d2ef01bfb618f5213a.tar.gz
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.
-rw-r--r--lisp/doc-view.el15
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:
1476 (interactive) 1476 (interactive)
1477 (tooltip-show (doc-view-current-info))) 1477 (tooltip-show (doc-view-current-info)))
1478 1478
1479;; We define an own major mode for DocView's text display so that we
1480;; can easily distinguish when we want to toggle back because
1481;; text-mode is a likely candidate for a default major-mode
1482;; (bug#34451).
1483(defun doc-view--text-view-mode ()
1484 "View mode used in DocView's text buffers."
1485 (view-mode)
1486 (setq major-mode 'doc-view--text-view-mode))
1487
1479(defun doc-view-open-text () 1488(defun doc-view-open-text ()
1480 "Display the current doc's contents as text." 1489 "Display the current doc's contents as text."
1481 (interactive) 1490 (interactive)
@@ -1489,13 +1498,13 @@ For now these keys are useful:
1489 (erase-buffer) 1498 (erase-buffer)
1490 (set-buffer-multibyte t) 1499 (set-buffer-multibyte t)
1491 (insert-file-contents txt) 1500 (insert-file-contents txt)
1492 (text-mode) 1501 (doc-view--text-view-mode)
1493 (setq-local doc-view--buffer-file-name dv-bfn) 1502 (setq-local doc-view--buffer-file-name dv-bfn)
1494 (set-buffer-modified-p nil) 1503 (set-buffer-modified-p nil)
1495 (doc-view-minor-mode) 1504 (doc-view-minor-mode)
1496 (add-hook 'write-file-functions 1505 (add-hook 'write-file-functions
1497 (lambda () 1506 (lambda ()
1498 (when (eq major-mode 'text-mode) 1507 (when (eq major-mode 'doc-view--text-view-mode)
1499 (error "Cannot save text contents of document %s" 1508 (error "Cannot save text contents of document %s"
1500 buffer-file-name))) 1509 buffer-file-name)))
1501 nil t)) 1510 nil t))
@@ -1519,7 +1528,7 @@ For now these keys are useful:
1519 ;; normal mode. 1528 ;; normal mode.
1520 (doc-view-fallback-mode) 1529 (doc-view-fallback-mode)
1521 (doc-view-minor-mode 1)) 1530 (doc-view-minor-mode 1))
1522 ((eq major-mode 'text-mode) 1531 ((eq major-mode 'doc-view--text-view-mode)
1523 (let ((buffer-undo-list t)) 1532 (let ((buffer-undo-list t))
1524 ;; We're currently viewing the document's text contents, so switch 1533 ;; We're currently viewing the document's text contents, so switch
1525 ;; back to . 1534 ;; back to .