diff options
Diffstat (limited to 'lisp/view.el')
-rw-r--r-- | lisp/view.el | 46 |
1 files changed, 15 insertions, 31 deletions
diff --git a/lisp/view.el b/lisp/view.el index 219af1b6e1e..f6698ae5a9f 100644 --- a/lisp/view.el +++ b/lisp/view.el @@ -48,8 +48,7 @@ "Peruse file or buffer without editing." :link '(function-link view-mode) :link '(custom-manual "(emacs)Misc File Ops") - :group 'wp - :group 'editing) + :group 'wp) (defcustom view-highlight-face 'highlight "The face used for highlighting the match found by View mode search." @@ -162,14 +161,6 @@ that use View mode automatically.") "Overlay used to display where a search operation found its match. This is local in each buffer, once it is used.") (make-variable-buffer-local 'view-overlay) - -(unless (assq 'view-mode minor-mode-alist) - (setq minor-mode-alist - (cons (list 'view-mode - (propertize " View" - 'local-map mode-line-minor-mode-keymap - 'help-echo "mouse-3: minor mode menu")) - minor-mode-alist))) ;; Define keymap inside defvar to make it easier to load changes. ;; Some redundant "less"-like key bindings below have been commented out. @@ -231,10 +222,6 @@ This is local in each buffer, once it is used.") (define-key map "?" 'describe-mode) ; Maybe do as less instead? See above. (define-key map "h" 'describe-mode) map)) - -(or (assq 'view-mode minor-mode-map-alist) - (setq minor-mode-map-alist - (cons (cons 'view-mode view-mode-map) minor-mode-map-alist))) ;;; Commands that enter or exit view mode. @@ -263,13 +250,7 @@ This command runs the normal hook `view-mode-hook'." (unless (file-exists-p file) (error "%s does not exist" file)) (let ((had-a-buf (get-file-buffer file)) (buffer (find-file-noselect file))) - (if (eq (with-current-buffer buffer - (get major-mode 'mode-class)) - 'special) - (progn - (switch-to-buffer buffer) - (message "Not using View mode because the major mode is special")) - (view-buffer buffer (and (not had-a-buf) 'kill-buffer-if-not-modified))))) + (view-buffer buffer (and (not had-a-buf) 'kill-buffer-if-not-modified)))) ;;;###autoload (defun view-file-other-window (file) @@ -335,10 +316,16 @@ file: Users may suspend viewing in order to modify the buffer. Exiting View mode will then discard the user's edits. Setting EXIT-ACTION to `kill-buffer-if-not-modified' avoids this." (interactive "bView buffer: ") - (let ((undo-window (list (window-buffer) (window-start) (window-point)))) - (switch-to-buffer buffer) - (view-mode-enter (cons (selected-window) (cons nil undo-window)) - exit-action))) + (if (eq (with-current-buffer buffer + (get major-mode 'mode-class)) + 'special) + (progn + (switch-to-buffer buffer) + (message "Not using View mode because the major mode is special")) + (let ((undo-window (list (window-buffer) (window-start) (window-point)))) + (switch-to-buffer buffer) + (view-mode-enter (cons (selected-window) (cons nil undo-window)) + exit-action)))) ;;;###autoload (defun view-buffer-other-window (buffer &optional not-return exit-action) @@ -394,7 +381,7 @@ this argument instead of explicitly setting `view-exit-action'." exit-action))) ;;;###autoload -(defun view-mode (&optional arg) +(define-minor-mode view-mode ;; In the following documentation string we have to use some explicit key ;; bindings instead of using the \\[] construction. The reason for this ;; is that most commands have more than one key binding. @@ -474,11 +461,8 @@ If view-mode was entered from another buffer, by \\[view-buffer], then \\[View-leave], \\[View-quit] and \\[View-kill-and-leave] will return to that buffer. Entry to view-mode runs the normal hook `view-mode-hook'." - (interactive "P") - (unless (and arg ; Do nothing if already OK. - (if (> (prefix-numeric-value arg) 0) view-mode (not view-mode))) - (if view-mode (view-mode-disable) - (view-mode-enable)))) + :lighter " View" :keymap view-mode-map + (if view-mode (view-mode-enable) (view-mode-disable))) (defun view-mode-enable () "Turn on View mode." |