Fix two issues around help-window-select. (Bug#11039) (Bug#19012)
* help.el (help-window-old-frame): New variable. (help-window-select): Default to nil (Bug#11039). Rewrite doc-string. (help-window-setup): When the help window appears on another frame and `help-window-select' is non-nil, give that frame input focus too (Bug#19012). (with-help-window): Store selected frame in help-window-old-frame.
This commit is contained in:
parent
d36439ca66
commit
7b79b1abad
2 changed files with 54 additions and 11 deletions
|
@ -1,3 +1,15 @@
|
|||
2014-11-28 Martin Rudalics <rudalics@gmx.at>
|
||||
|
||||
Fix two issues around help-window-select. (Bug#11039) (Bug#19012)
|
||||
* help.el (help-window-old-frame): New variable.
|
||||
(help-window-select): Default to nil (Bug#11039). Rewrite
|
||||
doc-string.
|
||||
(help-window-setup): When the help window appears on another
|
||||
frame and `help-window-select' is non-nil, give that frame input
|
||||
focus too (Bug#19012).
|
||||
(with-help-window): Store selected frame in
|
||||
help-window-old-frame.
|
||||
|
||||
2014-11-28 Ulf Jasper <ulf.jasper@web.de>
|
||||
|
||||
* net/newst-treeview.el (newsticker--treeview-load): Take care of
|
||||
|
|
53
lisp/help.el
53
lisp/help.el
|
@ -46,6 +46,9 @@
|
|||
(defvar help-window-point-marker (make-marker)
|
||||
"Marker to override default `window-point' in help windows.")
|
||||
|
||||
(defvar help-window-old-frame nil
|
||||
"Frame selected at the time `with-help-window' is invoked.")
|
||||
|
||||
(defvar help-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(define-key map (char-to-string help-char) 'help-for-help)
|
||||
|
@ -1155,17 +1158,27 @@ provided `fit-frame-to-buffer' is non-nil."
|
|||
(fit-window-to-buffer window height nil width))))
|
||||
|
||||
;;; Help windows.
|
||||
(defcustom help-window-select 'other
|
||||
"Non-nil means select help window for viewing.
|
||||
(defcustom help-window-select nil
|
||||
"Non-nil means select help window for viewing.
|
||||
Choices are:
|
||||
|
||||
never (nil) Select help window only if there is no other window
|
||||
on its frame.
|
||||
other Select help window unless the selected window is the
|
||||
only other window on the help window's frame.
|
||||
|
||||
other Select help window if and only if it appears on the
|
||||
previously selected frame, that frame contains at
|
||||
least two other windows and the help window is
|
||||
either new or showed a different buffer before.
|
||||
|
||||
always (t) Always select the help window.
|
||||
|
||||
If this option is non-nil and the help window appears on another
|
||||
frame, then give that frame input focus too. Note also that if
|
||||
the help window appears on another frame, it may get selected and
|
||||
its frame get input focus even if this option is nil.
|
||||
|
||||
This option has effect if and only if the help window was created
|
||||
by `with-help-window'"
|
||||
by `with-help-window'."
|
||||
:type '(choice (const :tag "never (nil)" nil)
|
||||
(const :tag "other" other)
|
||||
(const :tag "always (t)" t))
|
||||
|
@ -1212,7 +1225,9 @@ Return VALUE."
|
|||
(let* ((help-buffer (when (window-live-p window)
|
||||
(window-buffer window)))
|
||||
(help-setup (when (window-live-p window)
|
||||
(car (window-parameter window 'quit-restore)))))
|
||||
(car (window-parameter window 'quit-restore))))
|
||||
(frame (window-frame window)))
|
||||
|
||||
(when help-buffer
|
||||
;; Handle `help-window-point-marker'.
|
||||
(when (eq (marker-buffer help-window-point-marker) help-buffer)
|
||||
|
@ -1220,13 +1235,27 @@ Return VALUE."
|
|||
;; Reset `help-window-point-marker'.
|
||||
(set-marker help-window-point-marker nil))
|
||||
|
||||
;; If the help window appears on another frame, select it if
|
||||
;; `help-window-select' is non-nil and give that frame input focus
|
||||
;; too. See also Bug#19012.
|
||||
(when (and help-window-select
|
||||
(frame-live-p help-window-old-frame)
|
||||
(not (eq frame help-window-old-frame)))
|
||||
(select-window window)
|
||||
(select-frame-set-input-focus frame))
|
||||
|
||||
(cond
|
||||
((or (eq window (selected-window))
|
||||
(and (or (eq help-window-select t)
|
||||
(eq help-setup 'frame)
|
||||
;; If the help window is on the selected frame, select
|
||||
;; it if `help-window-select' is t or `help-window-select'
|
||||
;; is 'other, the frame contains at least three windows, and
|
||||
;; the help window did show another buffer before. See also
|
||||
;; Bug#11039.
|
||||
(and (eq frame (selected-frame))
|
||||
(or (eq help-window-select t)
|
||||
(and (eq help-window-select 'other)
|
||||
(eq (window-frame window) (selected-frame))
|
||||
(> (length (window-list nil 'no-mini)) 2)))
|
||||
(> (length (window-list nil 'no-mini)) 2)
|
||||
(not (eq help-setup 'same))))
|
||||
(select-window window)))
|
||||
;; The help window is or gets selected ...
|
||||
(help-window-display-message
|
||||
|
@ -1235,12 +1264,13 @@ Return VALUE."
|
|||
;; ... and is new, ...
|
||||
"Type \"q\" to delete help window")
|
||||
((eq help-setup 'frame)
|
||||
;; ... on a new frame, ...
|
||||
"Type \"q\" to quit the help frame")
|
||||
((eq help-setup 'other)
|
||||
;; ... or displayed some other buffer before.
|
||||
"Type \"q\" to restore previous buffer"))
|
||||
window t))
|
||||
((and (eq (window-frame window) (selected-frame))
|
||||
((and (eq (window-frame window) help-window-old-frame)
|
||||
(= (length (window-list nil 'no-mini)) 2))
|
||||
;; There are two windows on the help window's frame and the
|
||||
;; other one is the selected one.
|
||||
|
@ -1297,6 +1327,7 @@ the help window if the current value of the user option
|
|||
(cons 'help-mode-setup temp-buffer-window-setup-hook))
|
||||
(temp-buffer-window-show-hook
|
||||
(cons 'help-mode-finish temp-buffer-window-show-hook)))
|
||||
(setq help-window-old-frame (selected-frame))
|
||||
(with-temp-buffer-window
|
||||
,buffer-name nil 'help-window-setup (progn ,@body)))))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue