comparison lisp/prim/help.el @ 38:1a767b41a199 r19-15b102

Import from CVS: tag r19-15b102
author cvs
date Mon, 13 Aug 2007 08:54:01 +0200
parents c53a95d3c46d
children 8d2a9b52c682
comparison
equal deleted inserted replaced
37:ad40ac360d14 38:1a767b41a199
182 (define-key help-mode-map "q" 'help-mode-quit) 182 (define-key help-mode-map "q" 'help-mode-quit)
183 183
184 (defun help-mode-quit () 184 (defun help-mode-quit ()
185 "Exits from help mode, possibly restoring the previous window configuration." 185 "Exits from help mode, possibly restoring the previous window configuration."
186 (interactive) 186 (interactive)
187 (cond ((local-variable-p 'help-window-config (current-buffer)) 187 (cond ((frame-property (selected-frame) 'help-window-config)
188 (let ((config help-window-config)) 188 (set-window-configuration
189 (kill-local-variable 'help-window-config) 189 (frame-property (selected-frame) 'help-window-config))
190 (bury-buffer) 190 (set-frame-property (selected-frame) 'help-window-config nil))
191 (set-window-configuration config)))
192 ((one-window-p) 191 ((one-window-p)
193 (bury-buffer)) 192 (bury-buffer))
194 (t 193 (t
195 (delete-window)))) 194 (delete-window))))
196 195
346 (defvar help-selects-help-window t 345 (defvar help-selects-help-window t
347 "*If nil, use the \"old Emacs\" behavior for Help buffers. 346 "*If nil, use the \"old Emacs\" behavior for Help buffers.
348 This just displays the buffer in another window, rather than selecting 347 This just displays the buffer in another window, rather than selecting
349 the window.") 348 the window.")
350 349
351 (defvar help-window-config nil)
352 (defvar help-window-max-height .5 350 (defvar help-window-max-height .5
353 "*Proportion of frame to use for help windows.") 351 "*Proportion of frame to use for help windows.")
354 ;; Use this function for displaying help when C-h something is pressed 352 ;; Use this function for displaying help when C-h something is pressed
355 ;; or in similar situations. Do *not* use it when you are displaying 353 ;; or in similar situations. Do *not* use it when you are displaying
356 ;; a help message and then prompting for input in the minibuffer -- 354 ;; a help message and then prompting for input in the minibuffer --
359 357
360 ;;; ### Should really be a macro (as suggested above) to eliminate the 358 ;;; ### Should really be a macro (as suggested above) to eliminate the
361 ;;; requirement of caller to code a lambda form in THUNK -- mrb 359 ;;; requirement of caller to code a lambda form in THUNK -- mrb
362 (defun with-displaying-help-buffer (thunk) 360 (defun with-displaying-help-buffer (thunk)
363 (let ((winconfig (current-window-configuration)) 361 (let ((winconfig (current-window-configuration))
364 (was-one-window (one-window-p))) 362 (was-one-window (one-window-p))
363 (help-not-visible
364 (not (and (windows-of-buffer "*Help*") ;shortcut
365 (member (selected-frame)
366 (mapcar 'window-frame
367 (windows-of-buffer "*Help*")))))))
365 (prog1 (with-output-to-temp-buffer "*Help*" 368 (prog1 (with-output-to-temp-buffer "*Help*"
366 (prog1 (funcall thunk) 369 (prog1 (funcall thunk)
367 (save-excursion 370 (save-excursion
368 (set-buffer standard-output) 371 (set-buffer standard-output)
369 (help-mode)))) 372 (help-mode))))
370 (let ((helpwin (get-buffer-window "*Help*"))) 373 (let ((helpwin (get-buffer-window "*Help*")))
371 (if helpwin 374 (if helpwin
372 (progn 375 (progn
373 (save-excursion 376 (save-excursion
374 (set-buffer (window-buffer helpwin)) 377 (set-buffer (window-buffer helpwin))
375 (set (make-local-variable 'help-window-config) winconfig)) 378 ;;If the *Help* buffer is already displayed on this
379 ;; frame, don't override the previous configuration
380 (if help-not-visible
381 (set-frame-property (selected-frame)
382 'help-window-config winconfig)))
376 (if help-selects-help-window 383 (if help-selects-help-window
377 (select-window helpwin)) 384 (select-window helpwin))
378 (cond ((eq helpwin (selected-window)) 385 (cond ((eq helpwin (selected-window))
379 (message 386 (message
380 (substitute-command-keys "Type \\[help-mode-quit] to remove help window, \\[scroll-up] to scroll the help."))) 387 (substitute-command-keys "Type \\[help-mode-quit] to remove help window, \\[scroll-up] to scroll the help.")))