comparison lisp/help.el @ 1123:37bdd24225ef

[xemacs-hg @ 2002-11-27 07:15:02 by ben] bug fixes, profiling debugging improvements configure.in: Check for GCC version and only use -Wpacked in v3. .cvsignore: Add .idb, .ilk for MS Windows VC++. cl-macs.el: Document better. cmdloop.el: Removed. Remove nonworking breakpoint-on-error now that debug-on-error works as documented. help.el: Extract out with-displaying-help-buffer into a more general mechanism. lib-complete.el: Support thunks in find-library-source-path. startup.el: Don't catch errors when noninteractive, because that makes stack traces from stack-trace-on-error useless. .cvsignore: Windows shit. alloc.c: Better redisplay-related assert. elhash.c: Comment change. eval.c: Don't generate large warning strings (e.g. backtraces) when they will be discarded. Implement debug-on-error as documented -- it will enter the debugger and crash when an uncaught signal happens noninteractively and we are --debug. Better redisplay-related asserts. frame-msw.c, frame.c, lisp.h, redisplay.c, scrollbar-gtk.c, scrollbar-x.c, signal.c, sysdep.c: Fix up documentation related to QUIT (which CANNOT garbage-collect under any circumstances), and to redisplay critical sections. lread.c: Add load-ignore-out-of-date-elc-files, load-always-display-messages, load-show-full-path-in-messages for more robust package compilation and debugging. profile.c: Overhaul profile code. Change format to include call count and be extensible for further info. Remove call-count-profile-table. Add set-profiling-info. See related profile.el changes (which SHOULD ABSOLUTELY be in the core! Get rid of xemacs-devel and xemacs-base packages *yesterday*!).
author ben
date Wed, 27 Nov 2002 07:15:36 +0000
parents 4bc5bb3ea5ad
children fb556d2c7344
comparison
equal deleted inserted replaced
1122:7abc2b15a990 1123:37bdd24225ef
152 (define-key help-mode-map "c" 'customize-variable) 152 (define-key help-mode-map "c" 'customize-variable)
153 (define-key help-mode-map [tab] 'help-next-symbol) 153 (define-key help-mode-map [tab] 'help-next-symbol)
154 (define-key help-mode-map [(shift tab)] 'help-prev-symbol) 154 (define-key help-mode-map [(shift tab)] 'help-prev-symbol)
155 (define-key help-mode-map "n" 'help-next-section) 155 (define-key help-mode-map "n" 'help-next-section)
156 (define-key help-mode-map "p" 'help-prev-section) 156 (define-key help-mode-map "p" 'help-prev-section)
157
158 (define-derived-mode temp-buffer-mode view-major-mode "Temp"
159 "Major mode for viewing temporary buffers.
160 Exit using \\<temp-buffer-mode-map>\\[help-mode-quit].
161
162 Entry to this mode runs the normal hook `temp-buffer-mode-hook'.
163 Commands:
164 \\{temp-buffer-mode-map}"
165 )
166
167 (define-key temp-buffer-mode-map "q" 'help-mode-quit)
168 (define-key temp-buffer-mode-map "Q" 'help-mode-bury)
157 169
158 (defun describe-function-at-point () 170 (defun describe-function-at-point ()
159 "Describe directly the function at point in the other window." 171 "Describe directly the function at point in the other window."
160 (interactive) 172 (interactive)
161 (let ((symb (function-at-point))) 173 (let ((symb (function-at-point)))
498 ;; for a macro) that uses with-displaying-help-buffer internally. 510 ;; for a macro) that uses with-displaying-help-buffer internally.
499 511
500 (defcustom mode-for-help 'help-mode 512 (defcustom mode-for-help 'help-mode
501 "*Mode that help buffers are put into.") 513 "*Mode that help buffers are put into.")
502 514
515 (defcustom mode-for-temp-buffer 'temp-buffer-mode
516 "*Mode that help buffers are put into.")
517
503 (defvar help-sticky-window nil 518 (defvar help-sticky-window nil
504 ;; Window into which help buffers will be displayed, rather than 519 ;; Window into which help buffers will be displayed, rather than
505 ;; always searching for a new one. This is INTERNAL and liable to 520 ;; always searching for a new one. This is INTERNAL and liable to
506 ;; change its interface and/or name at any moment. It should be 521 ;; change its interface and/or name at any moment. It should be
507 ;; bound, not set. 522 ;; bound, not set.
510 (defvar help-window-config nil) 525 (defvar help-window-config nil)
511 526
512 (make-variable-buffer-local 'help-window-config) 527 (make-variable-buffer-local 'help-window-config)
513 (put 'help-window-config 'permanent-local t) 528 (put 'help-window-config 'permanent-local t)
514 529
515 (defun with-displaying-help-buffer (thunk &optional name) 530 (defmacro with-displaying-temp-buffer (name &rest body)
516 "Form which makes a help buffer with given NAME and evaluates BODY there. 531 "Form which makes a help buffer with given NAME and evaluates BODY there.
517 The actual name of the buffer is generated by the function `help-buffer-name'. 532
518 533 Use this function for displaying information in temporary buffers, where the
519 Use this function for displaying help when C-h something is pressed or 534 user will typically view the information and then exit using
520 in similar situations. Do *not* use it when you are displaying a help 535 \\<temp-buffer-mode-map>\\[help-mode-quit].
521 message and then prompting for input in the minibuffer -- this macro 536
522 usually selects the help buffer, which is not what you want in those 537 The buffer is put into the mode specified in `mode-for-temp-buffer'."
523 situations." 538 `(let* ((winconfig (current-window-configuration))
524 (let* ((winconfig (current-window-configuration)) 539 (was-one-window (one-window-p))
525 (was-one-window (one-window-p)) 540 (buffer-name ,name)
526 (buffer-name (help-buffer-name name)) 541 (help-not-visible
527 (help-not-visible 542 (not (and (windows-of-buffer buffer-name) ;shortcut
528 (not (and (windows-of-buffer buffer-name) ;shortcut 543 (memq (selected-frame)
529 (memq (selected-frame) 544 (mapcar 'window-frame
530 (mapcar 'window-frame 545 (windows-of-buffer buffer-name)))))))
531 (windows-of-buffer buffer-name)))))))
532 (help-register-and-maybe-prune-excess buffer-name) 546 (help-register-and-maybe-prune-excess buffer-name)
533 ;; if help-sticky-window is bogus or deleted, get rid of it. 547 ;; if help-sticky-window is bogus or deleted, get rid of it.
534 (if (and help-sticky-window (or (not (windowp help-sticky-window)) 548 (if (and help-sticky-window (or (not (windowp help-sticky-window))
535 (not (window-live-p help-sticky-window)))) 549 (not (window-live-p help-sticky-window))))
536 (setq help-sticky-window nil)) 550 (setq help-sticky-window nil))
539 (if help-sticky-window 553 (if help-sticky-window
540 #'(lambda (buffer) 554 #'(lambda (buffer)
541 (set-window-buffer help-sticky-window buffer)) 555 (set-window-buffer help-sticky-window buffer))
542 temp-buffer-show-function))) 556 temp-buffer-show-function)))
543 (with-output-to-temp-buffer buffer-name 557 (with-output-to-temp-buffer buffer-name
544 (prog1 (funcall thunk) 558 (prog1 (progn ,@body)
545 (save-excursion 559 (save-excursion
546 (set-buffer standard-output) 560 (set-buffer standard-output)
547 (funcall mode-for-help))))) 561 (funcall mode-for-temp-buffer)))))
548 (let ((helpwin (get-buffer-window buffer-name))) 562 (let ((helpwin (get-buffer-window buffer-name)))
549 (when helpwin 563 (when helpwin
550 ;; If the *Help* buffer is already displayed on this 564 ;; If the temp buffer is already displayed on this
551 ;; frame, don't override the previous configuration 565 ;; frame, don't override the previous configuration
552 (when help-not-visible 566 (when help-not-visible
553 (with-current-buffer (window-buffer helpwin) 567 (with-current-buffer (window-buffer helpwin)
554 (setq help-window-config winconfig))) 568 (setq help-window-config winconfig)))
555 (when help-selects-help-window 569 (when help-selects-help-window
556 (select-window helpwin)) 570 (select-window helpwin))
557 (cond ((eq helpwin (selected-window)) 571 (cond ((eq helpwin (selected-window))
558 (display-message 'command 572 (display-message 'command
559 (substitute-command-keys "Type \\[help-mode-quit] to remove help window, \\[scroll-up] to scroll the help."))) 573 (substitute-command-keys "Type \\[help-mode-quit] to remove window, \\[scroll-up] to scroll the text.")))
560 (was-one-window 574 (was-one-window
561 (display-message 'command 575 (display-message 'command
562 (substitute-command-keys "Type \\[delete-other-windows] to remove help window, \\[scroll-other-window] to scroll the help."))) 576 (substitute-command-keys "Type \\[delete-other-windows] to remove window, \\[scroll-other-window] to scroll the text.")))
563 (t 577 (t
564 (display-message 'command 578 (display-message 'command
565 (substitute-command-keys "Type \\[switch-to-buffer-other-window] to restore the other window, \\[scroll-other-window] to scroll the help."))))))))) 579 (substitute-command-keys "Type \\[switch-to-buffer-other-window] to restore the other window, \\[scroll-other-window] to scroll the text.")))))))))
580
581 (put 'with-displaying-temp-buffer 'lisp-indent-function 1)
582
583 (defun with-displaying-help-buffer (thunk &optional name)
584 "Form which makes a help buffer with given NAME and evaluates BODY there.
585 The actual name of the buffer is generated by the function `help-buffer-name'.
586
587 Use this function for displaying help when C-h something is pressed or
588 in similar situations. Do *not* use it when you are displaying a help
589 message and then prompting for input in the minibuffer -- this macro
590 usually selects the help buffer, which is not what you want in those
591 situations."
592 (let ((mode-for-temp-buffer mode-for-help))
593 (with-displaying-temp-buffer (help-buffer-name name)
594 (funcall thunk))))
566 595
567 (defun describe-key (key) 596 (defun describe-key (key)
568 "Display documentation of the function invoked by KEY. 597 "Display documentation of the function invoked by KEY.
569 KEY is a string, or vector of events. 598 KEY is a string, or vector of events.
570 When called interactively, KEY may also be a menu selection." 599 When called interactively, KEY may also be a menu selection."