Don't clear out local variables in `with-help-window'
* lisp/help-mode.el (help-mode-setup): Declare obsolete. (help-mode-finish): Ditto. * lisp/help.el (with-help-window): Don't be a wrapper around `with-temp-buffer-window', because that made the macro big and difficult to understand. (help--window-setup): Implement the relevant bits from `with-temp-buffer-window'. Also don't clear out local variables, because that makes things like `text-scale-mode' not work (bug#25979).
This commit is contained in:
parent
9c126cbacb
commit
cd87a5c7a1
2 changed files with 32 additions and 32 deletions
|
@ -422,12 +422,15 @@ Commands:
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun help-mode-setup ()
|
(defun help-mode-setup ()
|
||||||
"Enter Help mode in the current buffer."
|
"Enter Help mode in the current buffer."
|
||||||
(help-mode)
|
(declare (obsolete nil "29.1"))
|
||||||
|
(unless (derived-mode-p 'help-mode)
|
||||||
|
(help-mode))
|
||||||
(setq buffer-read-only nil))
|
(setq buffer-read-only nil))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun help-mode-finish ()
|
(defun help-mode-finish ()
|
||||||
"Finalize Help mode setup in current buffer."
|
"Finalize Help mode setup in current buffer."
|
||||||
|
(declare (obsolete nil "29.1"))
|
||||||
(when (derived-mode-p 'help-mode)
|
(when (derived-mode-p 'help-mode)
|
||||||
(setq buffer-read-only t)
|
(setq buffer-read-only t)
|
||||||
(help-make-xrefs (current-buffer))))
|
(help-make-xrefs (current-buffer))))
|
||||||
|
|
53
lisp/help.el
53
lisp/help.el
|
@ -1938,40 +1938,37 @@ Return VALUE."
|
||||||
;; Return VALUE.
|
;; Return VALUE.
|
||||||
value))
|
value))
|
||||||
|
|
||||||
;; `with-help-window' is a wrapper for `with-temp-buffer-window'
|
|
||||||
;; providing the following additional twists:
|
|
||||||
|
|
||||||
;; (1) It puts the buffer in `help-mode' (via `help-mode-setup') and
|
|
||||||
;; adds cross references (via `help-mode-finish').
|
|
||||||
|
|
||||||
;; (2) It issues a message telling how to scroll and quit the help
|
|
||||||
;; window (via `help-window-setup').
|
|
||||||
|
|
||||||
;; (3) An option (customizable via `help-window-select') to select the
|
|
||||||
;; help window automatically.
|
|
||||||
|
|
||||||
;; (4) A marker (`help-window-point-marker') to move point in the help
|
|
||||||
;; window to an arbitrary buffer position.
|
|
||||||
(defmacro with-help-window (buffer-or-name &rest body)
|
(defmacro with-help-window (buffer-or-name &rest body)
|
||||||
"Evaluate BODY, send output to BUFFER-OR-NAME and show in a help window.
|
"Evaluate BODY, send output to BUFFER-OR-NAME and show in a help window.
|
||||||
This construct is like `with-temp-buffer-window', which see, but unlike
|
The return value from BODY will be returned.
|
||||||
that, it puts the buffer specified by BUFFER-OR-NAME in `help-mode' and
|
|
||||||
displays a message about how to delete the help window when it's no
|
The help window will be selected if `help-window-select' is
|
||||||
longer needed. The help window will be selected if
|
non-nil.
|
||||||
`help-window-select' is non-nil.
|
|
||||||
Most of this is done by `help-window-setup', which see."
|
The `temp-buffer-window-setup-hook' hook is called."
|
||||||
(declare (indent 1) (debug t))
|
(declare (indent 1) (debug t))
|
||||||
`(progn
|
`(help--window-setup ,buffer-or-name (lambda () ,@body)))
|
||||||
|
|
||||||
|
(defun help--window-setup (buffer callback)
|
||||||
;; Make `help-window-point-marker' point nowhere. The only place
|
;; Make `help-window-point-marker' point nowhere. The only place
|
||||||
;; where this should be set to a buffer position is within BODY.
|
;; 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)
|
||||||
(let ((temp-buffer-window-setup-hook
|
(with-current-buffer (get-buffer-create buffer)
|
||||||
(cons 'help-mode-setup temp-buffer-window-setup-hook))
|
(setq buffer-read-only t
|
||||||
(temp-buffer-window-show-hook
|
buffer-file-name nil)
|
||||||
(cons 'help-mode-finish temp-buffer-window-show-hook)))
|
(buffer-disable-undo)
|
||||||
(setq help-window-old-frame (selected-frame))
|
(let ((inhibit-read-only t)
|
||||||
(with-temp-buffer-window
|
(inhibit-modification-hooks t))
|
||||||
,buffer-or-name nil 'help-window-setup (progn ,@body)))))
|
(erase-buffer)
|
||||||
|
(delete-all-overlays)
|
||||||
|
(prog1
|
||||||
|
(let ((standard-output (current-buffer)))
|
||||||
|
(funcall callback)
|
||||||
|
(run-hooks 'temp-buffer-window-setup-hook))
|
||||||
|
(help-window-setup (temp-buffer-window-show (current-buffer)))
|
||||||
|
(unless (derived-mode-p 'help-mode)
|
||||||
|
(help-mode))
|
||||||
|
(help-make-xrefs (current-buffer))))))
|
||||||
|
|
||||||
;; 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.
|
||||||
|
|
Loading…
Add table
Reference in a new issue