diff 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
line wrap: on
line diff
--- a/lisp/help.el	Tue Nov 26 22:52:59 2002 +0000
+++ b/lisp/help.el	Wed Nov 27 07:15:36 2002 +0000
@@ -155,6 +155,18 @@
 (define-key help-mode-map "n" 'help-next-section)
 (define-key help-mode-map "p" 'help-prev-section)
 
+(define-derived-mode temp-buffer-mode view-major-mode "Temp"
+  "Major mode for viewing temporary buffers.
+Exit using \\<temp-buffer-mode-map>\\[help-mode-quit].
+
+Entry to this mode runs the normal hook `temp-buffer-mode-hook'.
+Commands:
+\\{temp-buffer-mode-map}"
+  )
+
+(define-key temp-buffer-mode-map "q" 'help-mode-quit)
+(define-key temp-buffer-mode-map "Q" 'help-mode-bury)
+
 (defun describe-function-at-point ()
   "Describe directly the function at point in the other window."
   (interactive)
@@ -500,6 +512,9 @@
 (defcustom mode-for-help 'help-mode
   "*Mode that help buffers are put into.")
 
+(defcustom mode-for-temp-buffer 'temp-buffer-mode
+  "*Mode that help buffers are put into.")
+
 (defvar help-sticky-window nil
 ;; Window into which help buffers will be displayed, rather than
 ;; always searching for a new one.  This is INTERNAL and liable to
@@ -512,23 +527,22 @@
 (make-variable-buffer-local 'help-window-config)
 (put 'help-window-config 'permanent-local t)
 
-(defun with-displaying-help-buffer (thunk &optional name)
+(defmacro with-displaying-temp-buffer (name &rest body)
   "Form which makes a help buffer with given NAME and evaluates BODY there.
-The actual name of the buffer is generated by the function `help-buffer-name'.
+
+Use this function for displaying information in temporary buffers, where the
+user will typically view the information and then exit using
+\\<temp-buffer-mode-map>\\[help-mode-quit].
 
-Use this function for displaying help when C-h something is pressed or
-in similar situations.  Do *not* use it when you are displaying a help
-message and then prompting for input in the minibuffer -- this macro
-usually selects the help buffer, which is not what you want in those
-situations."
-  (let* ((winconfig (current-window-configuration))
-	 (was-one-window (one-window-p))
-	 (buffer-name (help-buffer-name name))
-	 (help-not-visible
-	  (not (and (windows-of-buffer buffer-name) ;shortcut
-		    (memq (selected-frame)
-			  (mapcar 'window-frame
-				  (windows-of-buffer buffer-name)))))))
+The buffer is put into the mode specified in `mode-for-temp-buffer'."
+  `(let* ((winconfig (current-window-configuration))
+	  (was-one-window (one-window-p))
+	  (buffer-name ,name)
+	  (help-not-visible
+	   (not (and (windows-of-buffer buffer-name) ;shortcut
+		     (memq (selected-frame)
+			   (mapcar 'window-frame
+				   (windows-of-buffer buffer-name)))))))
     (help-register-and-maybe-prune-excess buffer-name)
     ;; if help-sticky-window is bogus or deleted, get rid of it.
     (if (and help-sticky-window (or (not (windowp help-sticky-window))
@@ -541,13 +555,13 @@
 		       (set-window-buffer help-sticky-window buffer))
 		 temp-buffer-show-function)))
 	  (with-output-to-temp-buffer buffer-name
-	    (prog1 (funcall thunk)
+	    (prog1 (progn ,@body)
 	      (save-excursion
 		(set-buffer standard-output)
-		(funcall mode-for-help)))))
+		(funcall mode-for-temp-buffer)))))
       (let ((helpwin (get-buffer-window buffer-name)))
 	(when helpwin
-	  ;; If the *Help* buffer is already displayed on this
+	  ;; If the temp buffer is already displayed on this
 	  ;; frame, don't override the previous configuration
 	  (when help-not-visible
 	    (with-current-buffer (window-buffer helpwin)
@@ -556,13 +570,28 @@
 	    (select-window helpwin))
 	  (cond ((eq helpwin (selected-window))
 		 (display-message 'command
-		   (substitute-command-keys "Type \\[help-mode-quit] to remove help window, \\[scroll-up] to scroll the help.")))
+		   (substitute-command-keys "Type \\[help-mode-quit] to remove window, \\[scroll-up] to scroll the text.")))
 		(was-one-window
 		 (display-message 'command
-		   (substitute-command-keys "Type \\[delete-other-windows] to remove help window, \\[scroll-other-window] to scroll the help.")))
+		   (substitute-command-keys "Type \\[delete-other-windows] to remove window, \\[scroll-other-window] to scroll the text.")))
 		(t
 		 (display-message 'command
-		   (substitute-command-keys "Type \\[switch-to-buffer-other-window] to restore the other window, \\[scroll-other-window] to scroll the help.")))))))))
+		   (substitute-command-keys "Type \\[switch-to-buffer-other-window] to restore the other window, \\[scroll-other-window] to scroll the text.")))))))))
+
+(put 'with-displaying-temp-buffer 'lisp-indent-function 1)
+
+(defun with-displaying-help-buffer (thunk &optional name)
+  "Form which makes a help buffer with given NAME and evaluates BODY there.
+The actual name of the buffer is generated by the function `help-buffer-name'.
+
+Use this function for displaying help when C-h something is pressed or
+in similar situations.  Do *not* use it when you are displaying a help
+message and then prompting for input in the minibuffer -- this macro
+usually selects the help buffer, which is not what you want in those
+situations."
+  (let ((mode-for-temp-buffer mode-for-help))
+    (with-displaying-temp-buffer (help-buffer-name name)
+      (funcall thunk))))
 
 (defun describe-key (key)
   "Display documentation of the function invoked by KEY.