Make help and view-mode work with new buffer display facilities.
* help.el (help-window): Remove variable. (help-window-point-marker, temp-buffer-max-height) (temp-buffer-resize-mode, help-window-select): Rewrite doc-strings. (help-print-return-message): Don't set help-window. (resize-temp-buffer-window): Rewrite cod eand doc-string. (help-window-setup-finish): Remove. (help-window-display-message, help-window-setup) (with-help-window): Major rewrite based on new display-buffer-window variable. * help-mode.el (help-mode-finish): Remove help-window related code. * view.el (view-exits-all-viewing-windows): Remove reference to view-return-to-alist in doc-string. (view-return-to-alist): Make obsolete. (view-buffer): Call pop-to-buffer-same-window and remove undo-window code. (view-buffer-other-window): Call pop-to-buffer-other-window and simplify code. Ignore second argument. (view-buffer-other-frame): Call pop-to-buffer-other-frame and simplify code. Ignore second argument. (view-return-to-alist-update): Make obsolete. (view-mode-enter): Rename second argument to QUIT-RESTORE. Rewrite using quit-restore window parameters. (view-mode-exit): Rename second argument to EXIT-ONLY. Rewrite using quit-restore-window. (View-exit, View-exit-and-edit, View-leave, View-quit) (View-quit-all, View-kill-and-leave): Call view-mode-exit with appropriate arguments. (view-end-message): Use quit-restore window parameter.
This commit is contained in:
parent
9481c00201
commit
357f93d245
4 changed files with 207 additions and 403 deletions
|
@ -1,5 +1,37 @@
|
||||||
2011-06-13 Martin Rudalics <rudalics@gmx.at>
|
2011-06-13 Martin Rudalics <rudalics@gmx.at>
|
||||||
|
|
||||||
|
* help.el (help-window): Remove variable.
|
||||||
|
(help-window-point-marker, temp-buffer-max-height)
|
||||||
|
(temp-buffer-resize-mode, help-window-select): Rewrite doc-strings.
|
||||||
|
(help-print-return-message): Don't set help-window.
|
||||||
|
(resize-temp-buffer-window): Rewrite cod eand doc-string.
|
||||||
|
(help-window-setup-finish): Remove.
|
||||||
|
(help-window-display-message, help-window-setup)
|
||||||
|
(with-help-window): Major rewrite based on new
|
||||||
|
display-buffer-window variable.
|
||||||
|
|
||||||
|
* help-mode.el (help-mode-finish): Remove help-window related
|
||||||
|
code.
|
||||||
|
|
||||||
|
* view.el (view-exits-all-viewing-windows): Remove reference to
|
||||||
|
view-return-to-alist in doc-string.
|
||||||
|
(view-return-to-alist): Make obsolete.
|
||||||
|
(view-buffer): Call pop-to-buffer-same-window and remove
|
||||||
|
undo-window code.
|
||||||
|
(view-buffer-other-window): Call pop-to-buffer-other-window and
|
||||||
|
simplify code. Ignore second argument.
|
||||||
|
(view-buffer-other-frame): Call pop-to-buffer-other-frame and
|
||||||
|
simplify code. Ignore second argument.
|
||||||
|
(view-return-to-alist-update): Make obsolete.
|
||||||
|
(view-mode-enter): Rename second argument to QUIT-RESTORE.
|
||||||
|
Rewrite using quit-restore window parameters.
|
||||||
|
(view-mode-exit): Rename second argument to EXIT-ONLY. Rewrite
|
||||||
|
using quit-restore-window.
|
||||||
|
(View-exit, View-exit-and-edit, View-leave, View-quit)
|
||||||
|
(View-quit-all, View-kill-and-leave): Call view-mode-exit with
|
||||||
|
appropriate arguments.
|
||||||
|
(view-end-message): Use quit-restore window parameter.
|
||||||
|
|
||||||
* window.el (display-buffer-function): Rewrite doc-string.
|
* window.el (display-buffer-function): Rewrite doc-string.
|
||||||
(display-buffer-window, display-buffer-alist): New variables.
|
(display-buffer-window, display-buffer-alist): New variables.
|
||||||
(display-buffer-split-specifiers)
|
(display-buffer-split-specifiers)
|
||||||
|
|
|
@ -305,23 +305,6 @@ Commands:
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun help-mode-finish ()
|
(defun help-mode-finish ()
|
||||||
(if (eq help-window t)
|
|
||||||
;; If `help-window' is t, `view-return-to-alist' is handled by
|
|
||||||
;; `with-help-window'. In this case set `help-window' to the
|
|
||||||
;; selected window since now is the only moment where we can
|
|
||||||
;; unambiguously identify it.
|
|
||||||
(setq help-window (selected-window))
|
|
||||||
(let ((entry (assq (selected-window) view-return-to-alist)))
|
|
||||||
(if entry
|
|
||||||
;; When entering Help mode from the Help window,
|
|
||||||
;; such as by following a link, preserve the same
|
|
||||||
;; meaning for the q command.
|
|
||||||
;; (setcdr entry (cons (selected-window) help-return-method))
|
|
||||||
nil
|
|
||||||
(setq view-return-to-alist
|
|
||||||
(cons (cons (selected-window) help-return-method)
|
|
||||||
view-return-to-alist)))))
|
|
||||||
|
|
||||||
(when (eq major-mode 'help-mode)
|
(when (eq major-mode 'help-mode)
|
||||||
;; View mode's read-only status of existing *Help* buffer is lost
|
;; View mode's read-only status of existing *Help* buffer is lost
|
||||||
;; by with-output-to-temp-buffer.
|
;; by with-output-to-temp-buffer.
|
||||||
|
|
306
lisp/help.el
306
lisp/help.el
|
@ -55,7 +55,7 @@
|
||||||
;; nowhere before exiting. Currently used by `view-lossage' to assert
|
;; nowhere before exiting. Currently used by `view-lossage' to assert
|
||||||
;; that the last keystrokes are always visible.
|
;; that the last keystrokes are always visible.
|
||||||
(defvar help-window-point-marker (make-marker)
|
(defvar help-window-point-marker (make-marker)
|
||||||
"Marker to override default `window-point' of `help-window'.")
|
"Marker to override default `window-point' in help windows.")
|
||||||
|
|
||||||
(defvar help-map
|
(defvar help-map
|
||||||
(let ((map (make-sparse-keymap)))
|
(let ((map (make-sparse-keymap)))
|
||||||
|
@ -144,8 +144,6 @@ It computes a message, and applies the optional argument FUNCTION to it.
|
||||||
If FUNCTION is nil, it applies `message', thus displaying the message.
|
If FUNCTION is nil, it applies `message', thus displaying the message.
|
||||||
In addition, this function sets up `help-return-method', which see, that
|
In addition, this function sets up `help-return-method', which see, that
|
||||||
specifies what to do when the user exits the help buffer."
|
specifies what to do when the user exits the help buffer."
|
||||||
;; Reset `help-window' here to avoid confusing `help-mode-finish'.
|
|
||||||
(setq help-window nil)
|
|
||||||
(and (not (get-buffer-window standard-output))
|
(and (not (get-buffer-window standard-output))
|
||||||
(let ((first-message
|
(let ((first-message
|
||||||
(cond ((or
|
(cond ((or
|
||||||
|
@ -914,6 +912,7 @@ appeared on the mode-line."
|
||||||
;; In order to list up all minor modes, minor-mode-list
|
;; In order to list up all minor modes, minor-mode-list
|
||||||
;; is used here instead of minor-mode-alist.
|
;; is used here instead of minor-mode-alist.
|
||||||
(delq nil (mapcar 'symbol-name minor-mode-list)))
|
(delq nil (mapcar 'symbol-name minor-mode-list)))
|
||||||
|
|
||||||
(defun describe-minor-mode-from-symbol (symbol)
|
(defun describe-minor-mode-from-symbol (symbol)
|
||||||
"Display documentation of a minor mode given as a symbol, SYMBOL"
|
"Display documentation of a minor mode given as a symbol, SYMBOL"
|
||||||
(interactive (list (intern (completing-read
|
(interactive (list (intern (completing-read
|
||||||
|
@ -937,6 +936,7 @@ appeared on the mode-line."
|
||||||
(t
|
(t
|
||||||
i))))
|
i))))
|
||||||
minor-mode-alist)))
|
minor-mode-alist)))
|
||||||
|
|
||||||
(defun describe-minor-mode-from-indicator (indicator)
|
(defun describe-minor-mode-from-indicator (indicator)
|
||||||
"Display documentation of a minor mode specified by INDICATOR.
|
"Display documentation of a minor mode specified by INDICATOR.
|
||||||
If you call this function interactively, you can give indicator which
|
If you call this function interactively, you can give indicator which
|
||||||
|
@ -972,28 +972,32 @@ is currently activated with completion."
|
||||||
minor-modes nil)
|
minor-modes nil)
|
||||||
(setq minor-modes (cdr minor-modes)))))
|
(setq minor-modes (cdr minor-modes)))))
|
||||||
result))
|
result))
|
||||||
|
|
||||||
|
|
||||||
;;; Automatic resizing of temporary buffers.
|
;;; Automatic resizing of temporary buffers.
|
||||||
|
|
||||||
(defcustom temp-buffer-max-height (lambda (buffer) (/ (- (frame-height) 2) 2))
|
(defcustom temp-buffer-max-height (lambda (buffer) (/ (- (frame-height) 2) 2))
|
||||||
"Maximum height of a window displaying a temporary buffer.
|
"Maximum height of a window displaying a temporary buffer.
|
||||||
This is effective only when Temp Buffer Resize mode is enabled.
|
This is effective only when Temp Buffer Resize mode is enabled.
|
||||||
The value is the maximum height (in lines) which `resize-temp-buffer-window'
|
The value is the maximum height (in lines) which
|
||||||
will give to a window displaying a temporary buffer.
|
`resize-temp-buffer-window' will give to a window displaying a
|
||||||
It can also be a function to be called to choose the height for such a buffer.
|
temporary buffer. It can also be a function to be called to
|
||||||
It gets one argumemt, the buffer, and should return a positive integer."
|
choose the height for such a buffer. It gets one argumemt, the
|
||||||
|
buffer, and should return a positive integer. At the time the
|
||||||
|
function is called, the window to be resized is selected."
|
||||||
:type '(choice integer function)
|
:type '(choice integer function)
|
||||||
:group 'help
|
:group 'help
|
||||||
:version "20.4")
|
:version "20.4")
|
||||||
|
|
||||||
(define-minor-mode temp-buffer-resize-mode
|
(define-minor-mode temp-buffer-resize-mode
|
||||||
"Toggle the mode which makes windows smaller for temporary buffers.
|
"Toggle mode which makes windows smaller for temporary buffers.
|
||||||
With prefix argument ARG, turn the resizing of windows displaying temporary
|
With prefix argument ARG, turn the resizing of windows displaying
|
||||||
buffers on if ARG is positive or off otherwise.
|
temporary buffers on if ARG is positive or off otherwise.
|
||||||
This makes the window the right height for its contents, but never
|
|
||||||
more than `temp-buffer-max-height' nor less than `window-min-height'.
|
This mode makes a window the right height for its contents, but
|
||||||
This applies to `help', `apropos' and `completion' buffers, and some others."
|
never more than `temp-buffer-max-height' nor less than
|
||||||
|
`window-min-height'.
|
||||||
|
|
||||||
|
This mode is used by `help', `apropos' and `completion' buffers,
|
||||||
|
and some others."
|
||||||
:global t :group 'help
|
:global t :group 'help
|
||||||
(if temp-buffer-resize-mode
|
(if temp-buffer-resize-mode
|
||||||
;; `help-make-xrefs' may add a `back' button and thus increase the
|
;; `help-make-xrefs' may add a `back' button and thus increase the
|
||||||
|
@ -1003,29 +1007,26 @@ This applies to `help', `apropos' and `completion' buffers, and some others."
|
||||||
|
|
||||||
(defun resize-temp-buffer-window ()
|
(defun resize-temp-buffer-window ()
|
||||||
"Resize the selected window to fit its contents.
|
"Resize the selected window to fit its contents.
|
||||||
Will not make it higher than `temp-buffer-max-height' nor smaller than
|
Will not make it higher than `temp-buffer-max-height' nor smaller
|
||||||
`window-min-height'. Do nothing if it is the only window on its frame, if it
|
than `window-min-height'. Do nothing if the selected window is
|
||||||
is not as wide as the frame or if some of the window's contents are scrolled
|
not vertically combined or some of its contents are scrolled out
|
||||||
out of view."
|
of view."
|
||||||
(unless (or (one-window-p 'nomini)
|
(when (and (pos-visible-in-window-p (point-min))
|
||||||
(not (pos-visible-in-window-p (point-min)))
|
(window-iso-combined-p))
|
||||||
(not (window-full-width-p)))
|
|
||||||
(fit-window-to-buffer
|
(fit-window-to-buffer
|
||||||
(selected-window)
|
nil
|
||||||
(if (functionp temp-buffer-max-height)
|
(if (functionp temp-buffer-max-height)
|
||||||
(funcall temp-buffer-max-height (current-buffer))
|
(funcall temp-buffer-max-height (window-buffer))
|
||||||
temp-buffer-max-height))))
|
temp-buffer-max-height))))
|
||||||
|
|
||||||
|
;;; Help windows.
|
||||||
;;; help-window
|
|
||||||
|
|
||||||
(defcustom help-window-select 'other
|
(defcustom help-window-select 'other
|
||||||
"Non-nil means select help window for viewing.
|
"Non-nil means select help window for viewing.
|
||||||
Choices are:
|
Choices are:
|
||||||
never (nil) Select help window only if there is no other window
|
never (nil) Select help window only if there is no other window
|
||||||
on its frame.
|
on its frame.
|
||||||
other Select help window unless the selected window is the
|
other Select help window unless the selected window is the
|
||||||
only other window on its frame.
|
only other window on the help window's frame.
|
||||||
always (t) Always select the help window.
|
always (t) Always select the help window.
|
||||||
|
|
||||||
This option has effect if and only if the help window was created
|
This option has effect if and only if the help window was created
|
||||||
|
@ -1036,95 +1037,38 @@ by `with-help-window'"
|
||||||
:group 'help
|
:group 'help
|
||||||
:version "23.1")
|
:version "23.1")
|
||||||
|
|
||||||
(defun help-window-display-message (quit-part window &optional other)
|
(defun help-window-display-message (quit-part window &optional scroll)
|
||||||
"Display message telling how to quit and scroll help window.
|
"Display message telling how to quit and scroll help window.
|
||||||
QUIT-PART is a string telling how to quit the help window WINDOW.
|
QUIT-PART is a string telling how to quit the help window WINDOW.
|
||||||
Optional argument OTHER non-nil means return text telling how to
|
Optional argument SCROLL non-nil means tell how to scroll WINDOW.
|
||||||
scroll the \"other\" window."
|
SCROLL equal `other' means tell how to scroll the \"other\"
|
||||||
|
window."
|
||||||
(let ((scroll-part
|
(let ((scroll-part
|
||||||
(cond
|
(cond
|
||||||
|
;; If we don't have QUIT-PART we probably reuse a window
|
||||||
|
;; showing the same buffer so we don't show any message.
|
||||||
|
((not quit-part) nil)
|
||||||
((pos-visible-in-window-p
|
((pos-visible-in-window-p
|
||||||
(with-current-buffer (window-buffer window)
|
(with-current-buffer (window-buffer window)
|
||||||
(point-max)) window)
|
(point-max)) window t)
|
||||||
;; Buffer end is visible.
|
;; Buffer end is at least partially visible, no need to talk
|
||||||
|
;; about scrolling.
|
||||||
".")
|
".")
|
||||||
(other ", \\[scroll-other-window] to scroll help.")
|
((eq scroll 'other)
|
||||||
(t ", \\[scroll-up] to scroll help."))))
|
", \\[scroll-other-window] to scroll help.")
|
||||||
|
(scroll ", \\[scroll-up] to scroll help."))))
|
||||||
(message "%s"
|
(message "%s"
|
||||||
(substitute-command-keys (concat quit-part scroll-part)))))
|
(substitute-command-keys (concat quit-part scroll-part)))))
|
||||||
|
|
||||||
(defun help-window-setup-finish (window &optional reuse keep-frame)
|
(defun help-window-setup ()
|
||||||
"Finish setting up help window WINDOW.
|
"Set up help window for `with-help-window'.
|
||||||
Select WINDOW according to the value of `help-window-select'.
|
This relies on `display-buffer-window' being correctly set up by
|
||||||
Display message telling how to scroll and eventually quit WINDOW.
|
`display-buffer'."
|
||||||
|
(let* ((help-window (car-safe display-buffer-window))
|
||||||
Optional argument REUSE non-nil means WINDOW has been reused by
|
(help-buffer (when (window-live-p help-window)
|
||||||
`display-buffer'. Optional argument KEEP-FRAME non-nil means
|
(window-buffer help-window)))
|
||||||
that quitting should not delete WINDOW's frame."
|
(help-value (cdr-safe display-buffer-window)))
|
||||||
(let ((number-of-windows
|
(when help-buffer
|
||||||
(length (window-list (window-frame window) 'no-mini window))))
|
|
||||||
(cond
|
|
||||||
((eq window (selected-window))
|
|
||||||
;; The help window is the selected window, probably the
|
|
||||||
;; `pop-up-windows' nil case.
|
|
||||||
(help-window-display-message
|
|
||||||
(if reuse
|
|
||||||
"Type \"q\" to restore this window"
|
|
||||||
;; This should not be taken.
|
|
||||||
"Type \"q\" to quit") window))
|
|
||||||
((= number-of-windows 1)
|
|
||||||
;; The help window is alone on a frame and not the selected
|
|
||||||
;; window, could be the `pop-up-frames' t case.
|
|
||||||
(help-window-display-message
|
|
||||||
(cond
|
|
||||||
(keep-frame "Type \"q\" to delete this window")
|
|
||||||
(reuse "Type \"q\" to restore this window")
|
|
||||||
(view-remove-frame-by-deleting "Type \"q\" to delete this frame")
|
|
||||||
(t "Type \"q\" to iconify this frame"))
|
|
||||||
window))
|
|
||||||
((and (= number-of-windows 2)
|
|
||||||
(eq (window-frame window) (window-frame (selected-window))))
|
|
||||||
;; There are two windows on the help window's frame and the other
|
|
||||||
;; window is the selected one.
|
|
||||||
(if (memq help-window-select '(nil other))
|
|
||||||
;; Do not select the help window.
|
|
||||||
(help-window-display-message
|
|
||||||
(if reuse
|
|
||||||
;; Offer `display-buffer' for consistency with
|
|
||||||
;; `help-print-return-message'. This is hardly TRT when
|
|
||||||
;; the other window and the selected window display the
|
|
||||||
;; same buffer but has been handled this way ever since.
|
|
||||||
"Type \\[display-buffer] RET to restore the other window"
|
|
||||||
;; The classic "two windows" configuration.
|
|
||||||
"Type \\[delete-other-windows] to delete the help window")
|
|
||||||
window t)
|
|
||||||
;; Select help window and tell how to quit.
|
|
||||||
(select-window window)
|
|
||||||
(help-window-display-message
|
|
||||||
(if reuse
|
|
||||||
"Type \"q\" to restore this window"
|
|
||||||
"Type \"q\" to delete this window") window)))
|
|
||||||
(help-window-select
|
|
||||||
;; Issuing a message with 3 or more windows on the same frame
|
|
||||||
;; without selecting the help window doesn't make any sense.
|
|
||||||
(select-window window)
|
|
||||||
(help-window-display-message
|
|
||||||
(if reuse
|
|
||||||
"Type \"q\" to restore this window"
|
|
||||||
"Type \"q\" to delete this window") window)))))
|
|
||||||
|
|
||||||
(defun help-window-setup (list-of-frames list-of-window-tuples)
|
|
||||||
"Set up help window.
|
|
||||||
LIST-OF-FRAMES and LIST-OF-WINDOW-TUPLES are the lists of frames
|
|
||||||
and window quadruples built by `with-help-window'. The help
|
|
||||||
window itself is specified by the variable `help-window'."
|
|
||||||
(let* ((help-buffer (window-buffer help-window))
|
|
||||||
;; `help-buffer' now denotes the help window's buffer.
|
|
||||||
(view-entry
|
|
||||||
(assq help-window
|
|
||||||
(buffer-local-value 'view-return-to-alist help-buffer)))
|
|
||||||
(help-entry (assq help-window list-of-window-tuples)))
|
|
||||||
|
|
||||||
;; Handle `help-window-point-marker'.
|
;; Handle `help-window-point-marker'.
|
||||||
(when (eq (marker-buffer help-window-point-marker) help-buffer)
|
(when (eq (marker-buffer help-window-point-marker) help-buffer)
|
||||||
(set-window-point help-window help-window-point-marker)
|
(set-window-point help-window help-window-point-marker)
|
||||||
|
@ -1132,79 +1076,40 @@ window itself is specified by the variable `help-window'."
|
||||||
(set-marker help-window-point-marker nil))
|
(set-marker help-window-point-marker nil))
|
||||||
|
|
||||||
(cond
|
(cond
|
||||||
(view-entry
|
((or (eq help-window (selected-window))
|
||||||
;; `view-return-to-alist' has an entry for the help window.
|
(and (or (eq help-window-select t)
|
||||||
|
(and (eq help-window-select 'other)
|
||||||
|
(eq (window-frame help-window) (selected-frame))
|
||||||
|
(> (length (window-list nil 'no-mini)) 2)))
|
||||||
|
(select-window help-window)))
|
||||||
|
;; The help window is or gets selected ...
|
||||||
|
(help-window-display-message
|
||||||
(cond
|
(cond
|
||||||
((eq help-window (selected-window))
|
((eq help-value 'new-window)
|
||||||
;; The help window is the selected window, probably because the
|
;; ... and is new, ...
|
||||||
;; user followed a backward/forward button or a cross reference.
|
"Type \"q\" to delete this window")
|
||||||
;; In this case just purge stale entries from
|
((eq help-value 'new-frame)
|
||||||
;; `view-return-to-alist' but leave the entry alone and don't
|
;; ... is on a new frame ...
|
||||||
;; display a message.
|
"Type \"q\" to delete this frame")
|
||||||
(view-return-to-alist-update help-buffer))
|
((eq help-value 'reuse-other-window)
|
||||||
((and help-entry (eq (cadr help-entry) help-buffer))
|
;; ... or displayed some other buffer before.
|
||||||
;; The help window was not selected but displayed the help
|
"Type \"q\" to restore previous buffer"))
|
||||||
;; buffer. In this case reuse existing exit information but try
|
help-window t))
|
||||||
;; to get back to the selected window when quitting. Don't
|
((and (eq (window-frame help-window) (selected-frame))
|
||||||
;; display a message since the user must have seen one before.
|
(= (length (window-list nil 'no-mini)) 2))
|
||||||
(view-return-to-alist-update
|
;; There are two windows on the help window's frame and the
|
||||||
help-buffer (cons help-window
|
;; other one is the selected one.
|
||||||
(cons (selected-window) (cddr view-entry)))))
|
(help-window-display-message
|
||||||
(help-entry
|
(cond
|
||||||
;; The help window was not selected, did display the help buffer
|
((eq help-value 'new-window)
|
||||||
;; earlier, but displayed another buffer when help was invoked.
|
"Type \\[delete-other-windows] to delete the help window")
|
||||||
;; Set up things so that quitting will show that buffer again.
|
((eq help-value 'reuse-other-window)
|
||||||
(view-return-to-alist-update
|
"Type \\[switch-to-prev-buffer] RET to restore previous buffer"))
|
||||||
help-buffer (cons help-window
|
help-window 'other))
|
||||||
(cons (selected-window) (cdr help-entry))))
|
|
||||||
(help-window-setup-finish help-window t))
|
|
||||||
(t
|
(t
|
||||||
;; The help window is new but `view-return-to-alist' had an
|
;; Not much to say here.
|
||||||
;; entry for it. This should never happen.
|
(help-window-display-message
|
||||||
(view-return-to-alist-update
|
"Type \"q\" in help window to quit" help-window))))))
|
||||||
help-buffer (cons help-window
|
|
||||||
(cons (selected-window) 'quit-window)))
|
|
||||||
(help-window-setup-finish help-window t))))
|
|
||||||
(help-entry
|
|
||||||
;; `view-return-to-alist' does not have an entry for help window
|
|
||||||
;; but `list-of-window-tuples' does. Hence `display-buffer' must
|
|
||||||
;; have reused an existing window.
|
|
||||||
(if (eq (cadr help-entry) help-buffer)
|
|
||||||
;; The help window displayed `help-buffer' before but no
|
|
||||||
;; `view-return-to-alist' entry was found probably because the
|
|
||||||
;; user manually switched to the help buffer. Set up things
|
|
||||||
;; for `quit-window' although `view-exit-action' should be
|
|
||||||
;; able to handle this case all by itself.
|
|
||||||
(progn
|
|
||||||
(view-return-to-alist-update
|
|
||||||
help-buffer (cons help-window
|
|
||||||
(cons (selected-window) 'quit-window)))
|
|
||||||
(help-window-setup-finish help-window t))
|
|
||||||
;; The help window displayed another buffer before. Set up
|
|
||||||
;; things in a way that quitting can orderly show that buffer
|
|
||||||
;; again. The window-start and window-point information from
|
|
||||||
;; `list-of-window-tuples' provide the necessary information.
|
|
||||||
(view-return-to-alist-update
|
|
||||||
help-buffer (cons help-window
|
|
||||||
(cons (selected-window) (cdr help-entry))))
|
|
||||||
(help-window-setup-finish help-window t)))
|
|
||||||
((memq (window-frame help-window) list-of-frames)
|
|
||||||
;; The help window is a new window on an existing frame. This
|
|
||||||
;; case must be handled specially by `help-window-setup-finish'
|
|
||||||
;; and `view-mode-exit' to ascertain that quitting does _not_
|
|
||||||
;; inadvertently delete the frame.
|
|
||||||
(view-return-to-alist-update
|
|
||||||
help-buffer (cons help-window
|
|
||||||
(cons (selected-window) 'keep-frame)))
|
|
||||||
(help-window-setup-finish help-window nil t))
|
|
||||||
(t
|
|
||||||
;; The help window is shown on a new frame. In this case quitting
|
|
||||||
;; shall handle both, the help window _and_ its frame. We changed
|
|
||||||
;; the default of `view-remove-frame-by-deleting' to t in order to
|
|
||||||
;; intuitively DTRT here.
|
|
||||||
(view-return-to-alist-update
|
|
||||||
help-buffer (cons help-window (cons (selected-window) t)))
|
|
||||||
(help-window-setup-finish help-window)))))
|
|
||||||
|
|
||||||
;; `with-help-window' is a wrapper for `with-output-to-temp-buffer'
|
;; `with-help-window' is a wrapper for `with-output-to-temp-buffer'
|
||||||
;; providing the following additional twists:
|
;; providing the following additional twists:
|
||||||
|
@ -1212,50 +1117,35 @@ window itself is specified by the variable `help-window'."
|
||||||
;; (1) Issue more accurate messages telling how to scroll and quit the
|
;; (1) Issue more accurate messages telling how to scroll and quit the
|
||||||
;; help window.
|
;; help window.
|
||||||
|
|
||||||
;; (2) Make `view-mode-exit' DTRT in more cases.
|
;; (2) An option (customizable via `help-window-select') to select the
|
||||||
|
|
||||||
;; (3) An option (customizable via `help-window-select') to select the
|
|
||||||
;; help window automatically.
|
;; help window automatically.
|
||||||
|
|
||||||
;; (4) A marker (`help-window-point-marker') to move point in the help
|
;; (3) A marker (`help-window-point-marker') to move point in the help
|
||||||
;; window to an arbitrary buffer position.
|
;; window to an arbitrary buffer position.
|
||||||
|
|
||||||
;; Note: It's usually always wrong to use `help-print-return-message' in
|
;; Note: It's usually always wrong to use `help-print-return-message' in
|
||||||
;; the body of `with-help-window'.
|
;; the body of `with-help-window'.
|
||||||
(defmacro with-help-window (buffer-name &rest body)
|
(defmacro with-help-window (buffer-name &rest body)
|
||||||
"Display buffer BUFFER-NAME in a help window evaluating BODY.
|
"Display buffer with name BUFFER-NAME in a help window evaluating BODY.
|
||||||
Select help window if the actual value of the user option
|
Select help window if the actual value of the user option
|
||||||
`help-window-select' says so. Return last value in BODY."
|
`help-window-select' says so. Return last value in BODY.
|
||||||
|
|
||||||
|
You can specify where and how to show the buffer by binding the
|
||||||
|
variable `temp-buffer-show-specifiers' to an appropriate value."
|
||||||
(declare (indent 1) (debug t))
|
(declare (indent 1) (debug t))
|
||||||
;; Bind list-of-frames to `frame-list' and list-of-window-tuples to a
|
`(progn
|
||||||
;; list of one <window window-buffer window-start window-point> tuple
|
;; Reset `display-buffer-window': `display-buffer' is
|
||||||
;; for each live window.
|
;; supposed to set this to the window displaying the buffer plus
|
||||||
`(let ((list-of-frames (frame-list))
|
;; some additional information.
|
||||||
(list-of-window-tuples
|
(setq display-buffer-window nil)
|
||||||
(let (list)
|
;; Make `help-window-point-marker' point nowhere. The only place
|
||||||
(walk-windows
|
;; where this should be set to a buffer position is within BODY.
|
||||||
(lambda (window)
|
|
||||||
(push (list window (window-buffer window)
|
|
||||||
(window-start window) (window-point window))
|
|
||||||
list))
|
|
||||||
'no-mini t)
|
|
||||||
list)))
|
|
||||||
;; Make `help-window' t to trigger `help-mode-finish' to set
|
|
||||||
;; `help-window' to the actual help window.
|
|
||||||
(setq help-window t)
|
|
||||||
;; Make `help-window-point-marker' point nowhere (the only place
|
|
||||||
;; where this should be set to a buffer position is within BODY).
|
|
||||||
(set-marker help-window-point-marker nil)
|
(set-marker help-window-point-marker nil)
|
||||||
(prog1
|
(prog1
|
||||||
;; Return value returned by `with-output-to-temp-buffer'.
|
;; Return value returned by `with-output-to-temp-buffer'.
|
||||||
(with-output-to-temp-buffer ,buffer-name
|
(with-output-to-temp-buffer ,buffer-name
|
||||||
(progn ,@body))
|
(progn ,@body))
|
||||||
(when (windowp help-window)
|
(when display-buffer-window (help-window-setup)))))
|
||||||
;; Set up help window.
|
|
||||||
(help-window-setup list-of-frames list-of-window-tuples))
|
|
||||||
;; Reset `help-window' to nil to avoid confusing future calls of
|
|
||||||
;; `help-mode-finish' with plain `with-output-to-temp-buffer'.
|
|
||||||
(setq help-window nil))))
|
|
||||||
|
|
||||||
;; Called from C, on encountering `help-char' when reading a char.
|
;; Called from C, on encountering `help-char' when reading a char.
|
||||||
;; Don't print to *Help*; that would clobber Help history.
|
;; Don't print to *Help*; that would clobber Help history.
|
||||||
|
|
237
lisp/view.el
237
lisp/view.el
|
@ -55,10 +55,6 @@
|
||||||
:type 'face
|
:type 'face
|
||||||
:group 'view)
|
:group 'view)
|
||||||
|
|
||||||
;; `view-mode-auto-exit' is replaced by the following option variable which
|
|
||||||
;; only says if scrolling past buffer end should leave view mode or not, it
|
|
||||||
;; doesn't say if leaving view mode should restore windows or not. The latter
|
|
||||||
;; is now controlled by the presence of a value in `view-return-to-alist'.
|
|
||||||
(defcustom view-scroll-auto-exit nil
|
(defcustom view-scroll-auto-exit nil
|
||||||
"Non-nil means scrolling past the end of buffer exits View mode.
|
"Non-nil means scrolling past the end of buffer exits View mode.
|
||||||
A value of nil means attempting to scroll past the end of the buffer,
|
A value of nil means attempting to scroll past the end of the buffer,
|
||||||
|
@ -80,17 +76,14 @@ for all scroll commands in view mode."
|
||||||
If nil, make an icon of the frame. If non-nil, delete the frame."
|
If nil, make an icon of the frame. If non-nil, delete the frame."
|
||||||
:type 'boolean
|
:type 'boolean
|
||||||
:group 'view
|
:group 'view
|
||||||
;; Changed the default of this to t for Emacs 23. Users consider
|
|
||||||
;; frame iconification annoying.
|
|
||||||
:version "23.1")
|
:version "23.1")
|
||||||
|
|
||||||
(defcustom view-exits-all-viewing-windows nil
|
(defcustom view-exits-all-viewing-windows nil
|
||||||
"Non-nil means restore all windows used to view buffer.
|
"Non-nil means restore all windows used to view buffer.
|
||||||
Commands that restore windows when finished viewing a buffer, apply to all
|
Commands that restore windows when finished viewing a buffer,
|
||||||
windows that display the buffer and have restore information in
|
apply to all windows that display the buffer and have restore
|
||||||
`view-return-to-alist'.
|
information. If `view-exits-all-viewing-windows' is nil, only
|
||||||
If `view-exits-all-viewing-windows' is nil, only the selected window is
|
the selected window is considered for restoring."
|
||||||
considered for restoring."
|
|
||||||
:type 'boolean
|
:type 'boolean
|
||||||
:group 'view)
|
:group 'view)
|
||||||
|
|
||||||
|
@ -140,6 +133,8 @@ subtracted from by `view-mode-exit' when finished viewing the buffer.
|
||||||
|
|
||||||
See RETURN-TO-ALIST argument of function `view-mode-exit' for the format of
|
See RETURN-TO-ALIST argument of function `view-mode-exit' for the format of
|
||||||
`view-return-to-alist'.")
|
`view-return-to-alist'.")
|
||||||
|
(make-obsolete-variable
|
||||||
|
'view-return-to-alist "this variable is no more used." "24.1")
|
||||||
(make-variable-buffer-local 'view-return-to-alist)
|
(make-variable-buffer-local 'view-return-to-alist)
|
||||||
(put 'view-return-to-alist 'permanent-local t)
|
(put 'view-return-to-alist 'permanent-local t)
|
||||||
|
|
||||||
|
@ -322,63 +317,48 @@ EXIT-ACTION to `kill-buffer-if-not-modified' avoids this."
|
||||||
(progn
|
(progn
|
||||||
(switch-to-buffer buffer)
|
(switch-to-buffer buffer)
|
||||||
(message "Not using View mode because the major mode is special"))
|
(message "Not using View mode because the major mode is special"))
|
||||||
(let ((undo-window (list (window-buffer) (window-start) (window-point))))
|
(pop-to-buffer-same-window buffer)
|
||||||
(switch-to-buffer buffer)
|
(view-mode-enter nil exit-action)))
|
||||||
(view-mode-enter (cons (selected-window) (cons nil undo-window))
|
|
||||||
exit-action))))
|
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun view-buffer-other-window (buffer &optional not-return exit-action)
|
(defun view-buffer-other-window (buffer &optional not-return exit-action)
|
||||||
"View BUFFER in View mode in another window.
|
"View BUFFER in View mode in another window.
|
||||||
Return to previous buffer when done, unless optional NOT-RETURN is
|
Emacs commands editing the buffer contents are not available;
|
||||||
non-nil. Emacs commands editing the buffer contents are not available;
|
instead, a special set of commands (mostly letters and
|
||||||
instead, a special set of commands (mostly letters and punctuation) are
|
punctuation) are defined for moving around in the buffer.
|
||||||
defined for moving around in the buffer.
|
|
||||||
Space scrolls forward, Delete scrolls backward.
|
Space scrolls forward, Delete scrolls backward.
|
||||||
For a list of all View commands, type H or h while viewing.
|
For a list of all View commands, type H or h while viewing.
|
||||||
|
|
||||||
This command runs the normal hook `view-mode-hook'.
|
This command runs the normal hook `view-mode-hook'.
|
||||||
|
|
||||||
|
Optional argument NOT-RETURN is ignored.
|
||||||
|
|
||||||
Optional argument EXIT-ACTION is either nil or a function with buffer as
|
Optional argument EXIT-ACTION is either nil or a function with buffer as
|
||||||
argument. This function is called when finished viewing buffer. Use
|
argument. This function is called when finished viewing buffer. Use
|
||||||
this argument instead of explicitly setting `view-exit-action'."
|
this argument instead of explicitly setting `view-exit-action'."
|
||||||
(interactive "bIn other window view buffer:\nP")
|
(interactive "bIn other window view buffer:\nP")
|
||||||
(let* ((win ; This window will be selected by
|
(pop-to-buffer-other-window buffer)
|
||||||
(get-lru-window)) ; switch-to-buffer-other-window below.
|
(view-mode-enter nil exit-action))
|
||||||
(return-to
|
|
||||||
(and (not not-return)
|
|
||||||
(cons (selected-window)
|
|
||||||
(if (eq win (selected-window))
|
|
||||||
t ; Has to make new window.
|
|
||||||
(list
|
|
||||||
(window-buffer win) ; Other windows old buffer.
|
|
||||||
(window-start win)
|
|
||||||
(window-point win)))))))
|
|
||||||
(switch-to-buffer-other-window buffer)
|
|
||||||
(view-mode-enter (and return-to (cons (selected-window) return-to))
|
|
||||||
exit-action)))
|
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun view-buffer-other-frame (buffer &optional not-return exit-action)
|
(defun view-buffer-other-frame (buffer &optional not-return exit-action)
|
||||||
"View BUFFER in View mode in another frame.
|
"View BUFFER in View mode in another frame.
|
||||||
Return to previous buffer when done, unless optional NOT-RETURN is
|
Emacs commands editing the buffer contents are not available;
|
||||||
non-nil. Emacs commands editing the buffer contents are not available;
|
instead, a special set of commands (mostly letters and
|
||||||
instead, a special set of commands (mostly letters and punctuation) are
|
punctuation) are defined for moving around in the buffer.
|
||||||
defined for moving around in the buffer.
|
|
||||||
Space scrolls forward, Delete scrolls backward.
|
Space scrolls forward, Delete scrolls backward.
|
||||||
For a list of all View commands, type H or h while viewing.
|
For a list of all View commands, type H or h while viewing.
|
||||||
|
|
||||||
This command runs the normal hook `view-mode-hook'.
|
This command runs the normal hook `view-mode-hook'.
|
||||||
|
|
||||||
|
Optional argument NOT-RETURN is ignored.
|
||||||
|
|
||||||
Optional argument EXIT-ACTION is either nil or a function with buffer as
|
Optional argument EXIT-ACTION is either nil or a function with buffer as
|
||||||
argument. This function is called when finished viewing buffer. Use
|
argument. This function is called when finished viewing buffer. Use
|
||||||
this argument instead of explicitly setting `view-exit-action'."
|
this argument instead of explicitly setting `view-exit-action'."
|
||||||
(interactive "bView buffer in other frame: \nP")
|
(interactive "bView buffer in other frame: \nP")
|
||||||
(let ((return-to
|
(pop-to-buffer-other-frame buffer)
|
||||||
(and (not not-return) (cons (selected-window) t)))) ; Old window.
|
(view-mode-enter nil exit-action))
|
||||||
(switch-to-buffer-other-frame buffer)
|
|
||||||
(view-mode-enter (and return-to (cons (selected-window) return-to))
|
|
||||||
exit-action)))
|
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(define-minor-mode view-mode
|
(define-minor-mode view-mode
|
||||||
|
@ -536,38 +516,27 @@ entry for the selected window, purge that entry from
|
||||||
(when item
|
(when item
|
||||||
(setq view-return-to-alist
|
(setq view-return-to-alist
|
||||||
(cons item view-return-to-alist)))))
|
(cons item view-return-to-alist)))))
|
||||||
|
(make-obsolete 'view-return-to-alist-update "this function has no effect." "24.1")
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun view-mode-enter (&optional return-to exit-action)
|
(defun view-mode-enter (&optional quit-restore exit-action)
|
||||||
"Enter View mode and set up exit from view mode depending on optional arguments.
|
"Enter View mode and set up exit from view mode depending on optional arguments.
|
||||||
RETURN-TO non-nil means add RETURN-TO as an element to the buffer
|
Optional argument QUIT-RESTORE if non-nil must specify a valid
|
||||||
local alist `view-return-to-alist'. Save EXIT-ACTION in buffer
|
entry for quitting and restoring any window showing the current
|
||||||
local variable `view-exit-action'. It should be either nil or a
|
buffer. This entry replaces any parameter installed by
|
||||||
|
`display-buffer' and is used by `view-mode-exit'.
|
||||||
|
|
||||||
|
Optional argument EXIT-ACTION, if non-nil, must specify a
|
||||||
function that takes a buffer as argument. This function will be
|
function that takes a buffer as argument. This function will be
|
||||||
called by `view-mode-exit'.
|
called by `view-mode-exit'.
|
||||||
|
|
||||||
RETURN-TO is either nil, meaning do nothing when exiting view
|
|
||||||
mode, or must have the format (WINDOW OLD-WINDOW . OLD-BUF-INFO).
|
|
||||||
WINDOW is the window used for viewing. OLD-WINDOW is nil or the
|
|
||||||
window to select after viewing. OLD-BUF-INFO tells what to do
|
|
||||||
with WINDOW when exiting. It is one of:
|
|
||||||
1) nil Do nothing.
|
|
||||||
2) t Delete WINDOW or, if it is the only window and
|
|
||||||
`view-remove-frame-by-deleting' is non-nil, its
|
|
||||||
frame.
|
|
||||||
3) (OLD-BUFF START POINT) Display buffer OLD-BUFF with displayed text
|
|
||||||
starting at START and point at POINT in WINDOW.
|
|
||||||
4) quit-window Do `quit-window' in WINDOW.
|
|
||||||
5) keep-frame Like case 2) but do not delete the frame.
|
|
||||||
|
|
||||||
For a list of all View commands, type H or h while viewing.
|
For a list of all View commands, type H or h while viewing.
|
||||||
|
|
||||||
This function runs the normal hook `view-mode-hook'."
|
This function runs the normal hook `view-mode-hook'."
|
||||||
(when return-to
|
(when quit-restore
|
||||||
(let ((entry (assq (car return-to) view-return-to-alist)))
|
(dolist (window (get-buffer-window-list nil nil t))
|
||||||
(if entry
|
(set-window-parameter window 'quit-restore quit-restore)))
|
||||||
(setcdr entry (cdr return-to))
|
|
||||||
(setq view-return-to-alist (cons return-to view-return-to-alist)))))
|
|
||||||
(when exit-action
|
(when exit-action
|
||||||
(setq view-exit-action exit-action))
|
(setq view-exit-action exit-action))
|
||||||
|
|
||||||
|
@ -579,115 +548,45 @@ This function runs the normal hook `view-mode-hook'."
|
||||||
(substitute-command-keys "\
|
(substitute-command-keys "\
|
||||||
View mode: type \\[help-command] for help, \\[describe-mode] for commands, \\[View-quit] to quit.")))))
|
View mode: type \\[help-command] for help, \\[describe-mode] for commands, \\[View-quit] to quit.")))))
|
||||||
|
|
||||||
(defun view-mode-exit (&optional return-to-alist exit-action all-win)
|
;; This is awful because it assumes that the selected window shows the
|
||||||
"Exit View mode in various ways, depending on optional arguments.
|
;; current buffer when this is called.
|
||||||
RETURN-TO-ALIST, EXIT-ACTION and ALL-WIN determine what to do
|
(defun view-mode-exit (&optional exit-only exit-action all-windows)
|
||||||
after exit. EXIT-ACTION is nil or a function that is called with
|
"Exit View mode in various ways.
|
||||||
current buffer as argument.
|
If all arguments are nil, remove the current buffer from the
|
||||||
|
selected window using the `quit-restore' information associated
|
||||||
|
with the selected window. If optional argument ALL-WINDOWS or
|
||||||
|
`view-exits-all-viewing-windows' are non-nil, remove the current
|
||||||
|
buffer from all windows showing it.
|
||||||
|
|
||||||
RETURN-TO-ALIST is an alist that, for some of the windows
|
Optional argument EXIT-ONLY non-nil means just exit `view-mode'
|
||||||
displaying the current buffer, maintains information on what to
|
\(unless `view-no-disable-on-exit' is non-nil) but do not change
|
||||||
do when exiting those windows. If ALL-WIN is non-nil or the
|
the associations of any windows with the current buffer.
|
||||||
variable `view-exits-all-viewing-windows' is non-nil,
|
|
||||||
view-mode-exit attempts to restore all windows showing the
|
|
||||||
current buffer to their old state. Otherwise, only the selected
|
|
||||||
window is affected (provided it is on RETURN-TO-ALIST).
|
|
||||||
|
|
||||||
Elements of RETURN-TO-ALIST must have the format
|
EXIT-ACTION, if non-nil, must specify a function that is called
|
||||||
(WINDOW OLD-WINDOW . OLD-BUF-INFO) where
|
with the current buffer as argument and is called after disabling
|
||||||
|
`view-mode' and removing any associations of windows with the
|
||||||
WINDOW is a window displaying the current buffer and OLD-WINDOW
|
current buffer. "
|
||||||
is either nil or a window to select after viewing. OLD-BUF-INFO
|
(when view-mode
|
||||||
provides information on what to do with WINDOW and may be one of:
|
(let ((buffer (window-buffer)))
|
||||||
1) nil Do nothing.
|
|
||||||
2) t Delete WINDOW and, if it is the only window and
|
|
||||||
`view-remove-frame-by-deleting' is non-nil, its
|
|
||||||
frame.
|
|
||||||
3) (OLD-BUF START POINT) Display buffer OLD-BUF with displayed text
|
|
||||||
starting at START and point at POINT in WINDOW.
|
|
||||||
4) quit-window Do `quit-window' in WINDOW.
|
|
||||||
5) keep-frame Like case 2) but do not delete the frame.
|
|
||||||
|
|
||||||
If one of the WINDOW in RETURN-TO-ALIST is the selected window
|
|
||||||
and the corresponding OLD-WINDOW is a live window, then select
|
|
||||||
OLD-WINDOW."
|
|
||||||
(when view-mode ; Only do something if in view mode.
|
|
||||||
(setq all-win
|
|
||||||
(and return-to-alist
|
|
||||||
(or all-win view-exits-all-viewing-windows)))
|
|
||||||
(let* ((buffer (current-buffer))
|
|
||||||
window notlost
|
|
||||||
(sel-old (assq (selected-window) return-to-alist))
|
|
||||||
(alist (cond
|
|
||||||
(all-win ; Try to restore all windows.
|
|
||||||
(append return-to-alist nil)) ; Copy.
|
|
||||||
(sel-old ; Only selected window.
|
|
||||||
(list sel-old))))
|
|
||||||
(old-window (if sel-old (car (cdr sel-old)))))
|
|
||||||
(if all-win ; Follow chains of old-windows.
|
|
||||||
(let ((c (length alist)) a)
|
|
||||||
(while (and (> c 0) ; Safety if mutually refering windows.
|
|
||||||
(or (not (window-live-p old-window))
|
|
||||||
(eq buffer (window-buffer old-window)))
|
|
||||||
(setq a (assq old-window alist)))
|
|
||||||
(setq c (1- c))
|
|
||||||
(setq old-window (car (cdr a))))
|
|
||||||
(if (or (zerop c) (not (window-live-p old-window)))
|
|
||||||
(setq old-window (selected-window)))))
|
|
||||||
(unless view-no-disable-on-exit
|
(unless view-no-disable-on-exit
|
||||||
(view-mode-disable))
|
(view-mode-disable))
|
||||||
(while alist ; Restore windows with info.
|
|
||||||
(setq notlost nil)
|
(unless exit-only
|
||||||
(when (and (window-live-p (setq window (car (car alist))))
|
|
||||||
(eq buffer (window-buffer window)))
|
|
||||||
(let ((frame (window-frame window))
|
|
||||||
(old-buf-info (cdr (cdr (car alist)))))
|
|
||||||
(if all-win (select-window window))
|
|
||||||
(cond
|
(cond
|
||||||
((consp old-buf-info) ; Case 3.
|
((or all-windows view-exits-all-viewing-windows)
|
||||||
(if (buffer-live-p (car old-buf-info))
|
(dolist (window (get-buffer-window-list))
|
||||||
(progn
|
(quit-restore-window window)))
|
||||||
(set-window-buffer window (car old-buf-info)) ; old-buf
|
((eq (window-buffer) (current-buffer))
|
||||||
(set-window-start window (car (cdr old-buf-info)))
|
(quit-restore-window)))
|
||||||
(set-window-point window (car (cdr (cdr old-buf-info)))))
|
|
||||||
(bury-buffer)))
|
|
||||||
((eq old-buf-info 'quit-window)
|
|
||||||
(quit-window)) ; Case 4.
|
|
||||||
(old-buf-info ; Case 2 or 5.
|
|
||||||
(cond
|
|
||||||
((not (one-window-p t)) ; Not only window.
|
|
||||||
(delete-window))
|
|
||||||
((eq old-buf-info 'keep-frame) ; Case 5.
|
|
||||||
(bury-buffer))
|
|
||||||
((not (eq frame (next-frame))) ; Case 2 and only window.
|
|
||||||
;; Not the only frame, so can safely be removed.
|
|
||||||
(if view-remove-frame-by-deleting
|
|
||||||
(delete-frame frame)
|
|
||||||
(setq notlost t) ; Keep the window. See below.
|
|
||||||
(iconify-frame frame))))))))
|
|
||||||
;; If a frame is removed by iconifying it, the window is not
|
|
||||||
;; really lost. In this case we keep the entry in
|
|
||||||
;; `view-return-to-alist' so that if the user deiconifies the
|
|
||||||
;; frame and then hits q, the frame is iconified again.
|
|
||||||
(unless notlost
|
|
||||||
(with-current-buffer buffer
|
|
||||||
(setq view-return-to-alist
|
|
||||||
(delete (car alist) view-return-to-alist))))
|
|
||||||
(setq alist (cdr alist)))
|
|
||||||
(when (window-live-p old-window)
|
|
||||||
;; old-window is still alive => select it.
|
|
||||||
(select-window old-window))
|
|
||||||
(when exit-action
|
(when exit-action
|
||||||
;; Don't do that: If the user wants to quit the *Help* buffer a
|
|
||||||
;; second time it won't have any effect.
|
|
||||||
;;(setq view-exit-action nil)
|
|
||||||
(funcall exit-action buffer))
|
(funcall exit-action buffer))
|
||||||
(force-mode-line-update))))
|
(force-mode-line-update)))))
|
||||||
|
|
||||||
(defun View-exit ()
|
(defun View-exit ()
|
||||||
"Exit View mode but stay in current buffer."
|
"Exit View mode but stay in current buffer."
|
||||||
(interactive)
|
(interactive)
|
||||||
(view-mode-exit))
|
(view-mode-exit t))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun View-exit-and-edit ()
|
(defun View-exit-and-edit ()
|
||||||
|
@ -695,31 +594,31 @@ OLD-WINDOW."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((view-old-buffer-read-only nil)
|
(let ((view-old-buffer-read-only nil)
|
||||||
(view-no-disable-on-exit nil))
|
(view-no-disable-on-exit nil))
|
||||||
(view-mode-exit)))
|
(view-mode-exit t)))
|
||||||
|
|
||||||
(defun View-leave ()
|
(defun View-leave ()
|
||||||
"Quit View mode and maybe switch buffers, but don't kill this buffer."
|
"Quit View mode and maybe switch buffers, but don't kill this buffer."
|
||||||
(interactive)
|
(interactive)
|
||||||
(view-mode-exit view-return-to-alist))
|
(view-mode-exit))
|
||||||
|
|
||||||
(defun View-quit ()
|
(defun View-quit ()
|
||||||
"Quit View mode, trying to restore window and buffer to previous state.
|
"Quit View mode, trying to restore window and buffer to previous state.
|
||||||
Maybe kill this buffer. Try to restore selected window to previous state
|
Maybe kill this buffer. Try to restore selected window to previous state
|
||||||
and go to previous buffer or window."
|
and go to previous buffer or window."
|
||||||
(interactive)
|
(interactive)
|
||||||
(view-mode-exit view-return-to-alist view-exit-action))
|
(view-mode-exit nil view-exit-action))
|
||||||
|
|
||||||
(defun View-quit-all ()
|
(defun View-quit-all ()
|
||||||
"Quit View mode, trying to restore windows and buffers to previous state.
|
"Quit View mode, trying to restore windows and buffers to previous state.
|
||||||
Maybe kill current buffer. Try to restore all windows viewing buffer to
|
Maybe kill current buffer. Try to restore all windows viewing buffer to
|
||||||
previous state and go to previous buffer or window."
|
previous state and go to previous buffer or window."
|
||||||
(interactive)
|
(interactive)
|
||||||
(view-mode-exit view-return-to-alist view-exit-action t))
|
(view-mode-exit nil view-exit-action t))
|
||||||
|
|
||||||
(defun View-kill-and-leave ()
|
(defun View-kill-and-leave ()
|
||||||
"Quit View mode, kill current buffer and return to previous buffer."
|
"Quit View mode, kill current buffer and return to previous buffer."
|
||||||
(interactive)
|
(interactive)
|
||||||
(view-mode-exit view-return-to-alist (or view-exit-action 'kill-buffer) t))
|
(view-mode-exit nil (or view-exit-action 'kill-buffer) t))
|
||||||
|
|
||||||
|
|
||||||
;;; Some help routines.
|
;;; Some help routines.
|
||||||
|
@ -863,7 +762,7 @@ invocations return to earlier marks."
|
||||||
(defun view-end-message ()
|
(defun view-end-message ()
|
||||||
;; Tell that we are at end of buffer.
|
;; Tell that we are at end of buffer.
|
||||||
(goto-char (point-max))
|
(goto-char (point-max))
|
||||||
(if view-return-to-alist
|
(if (window-parameter nil 'quit-restore)
|
||||||
(message "End of buffer. Type %s to quit viewing."
|
(message "End of buffer. Type %s to quit viewing."
|
||||||
(substitute-command-keys
|
(substitute-command-keys
|
||||||
(if view-scroll-auto-exit "\\[View-scroll-page-forward]"
|
(if view-scroll-auto-exit "\\[View-scroll-page-forward]"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue