From xemacs-m  Fri Feb 28 01:28:04 1997
Received: from mecca.spd.louisville.edu (mecca.spd.louisville.edu [136.165.40.148])
	by xemacs.org (8.8.5/8.8.5) with SMTP id BAA23515
	for <xemacs-beta@xemacs.org>; Fri, 28 Feb 1997 01:28:03 -0600 (CST)
Received: (from tjchol01@localhost) by mecca.spd.louisville.edu (950413.SGI.8.6.12/8.6.12) id HAA07066; Fri, 28 Feb 1997 07:28:07 GMT
Date: Fri, 28 Feb 1997 07:28:07 GMT
Message-Id: <199702280728.HAA07066@mecca.spd.louisville.edu>
From: "Tomasz J. Cholewo" <tjchol01@mecca.spd.louisville.edu>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
To: XEmacs-Beta Listserv <xemacs-beta@xemacs.org>
Subject: [patch] load-history in describe-variable and for dumped symbols

Hi,

Prompted by a recent thread on "how to find something in XEmacs sources"
I wrote the following patch (against 20.1-b3).  It adds information
stored in `load-history' to the `describe-variable' output, e.g.:
  
  paren-max-blinks's value is 1500
    -- a variable declared in Lisp (file "paren").
                                  ^^^^^^^^^^^^^^^

It also enables storing of the load-history information for the symbols
dumped during XEmacs build.  This way `describe-{function,variable}' can
help one to find the correct file by displaying the line `-- loads from
"filename"' or `(file "filename")' also for the preloaded symbols.

As this feature uses some extra 25k of purespace (737512 after patch
versus 712944 before; for IRIX) it is enabled only when DEBUG_XEMACS is
defined (default in beta versions).  Another adverse effect is making
the two `describe-' functions somewhat slower.  `unload-feature' is not
a source of problems because it fails on read-only objects when trying
to remove one of the dumped features.

This patch also corrects a small bug in describe-function: `stream'
argument was omitted from calls to princ and terpri in three places.

Tom
==============================================
diff -urd xemacs-20.1-b3/lisp/prim/help.el xemacs-20.1-b3-work/lisp/prim/help.el
--- xemacs-20.1-b3/lisp/prim/help.el	Tue Feb 18 00:05:49 1997
+++ xemacs-20.1-b3-work/lisp/prim/help.el	Fri Feb 28 02:12:43 1997
@@ -737,7 +737,7 @@
   "*If true, then describe-function will show its arglist if the function is
 not an autoload.")
 
-(defun describe-function-find-file (function)
+(defun describe-symbol-find-file (function)
   (and (boundp 'load-history) ; not standardly bound in XEmacs
        (let ((files load-history)
 	     file)
@@ -890,11 +890,11 @@
             (t
              nil)))
     (or file-name
-	(setq file-name (describe-function-find-file function)))
+	(setq file-name (describe-symbol-find-file function)))
     (if file-name
 	(princ (format ".\n  -- loads from \"%s\"" file-name) stream))
-    (princ ".")
-    (terpri)
+    (princ "." stream)
+    (terpri stream)
     (cond (kbd-macro-p
 	   (princ "These characters are executed:\n\n\t" stream)
 	   (princ (key-description def) stream)
@@ -923,7 +923,7 @@
 		 (progn
 		   (princ doc stream)
 		   (or (eq ?\n (aref doc (1- (length doc))))
-		       (terpri)))))))))
+		       (terpri stream)))))))))
 
 
 (defun describe-function-arglist (function)
@@ -1048,6 +1048,9 @@
 	 (terpri)
 	 (princ "  -- ")
 	 (princ (built-in-variable-doc variable))
+         (let ((file-name (describe-symbol-find-file variable)))
+           (if file-name
+               (princ (format " (file \"%s\")" file-name))))
 	 (princ ".")
 	 (terpri)
 	 (cond ((local-variable-p variable (current-buffer))
diff -urd xemacs-20.1-b3/src/alloc.c xemacs-20.1-b3-work/src/alloc.c
--- xemacs-20.1-b3/src/alloc.c	Wed Feb 26 13:26:28 1997
+++ xemacs-20.1-b3-work/src/alloc.c	Fri Feb 28 00:01:15 1997
@@ -3900,7 +3900,9 @@
   Vexec_path = Qnil;
   Vload_path = Qnil;
   /* Vdump_load_path = Qnil; */
+#ifndef DEBUG_XEMACS
   Vload_history = Qnil;
+#endif
   Vshell_file_name = Qnil;
 
   garbage_collect_1 ();
diff -urd xemacs-20.1-b3/src/lread.c xemacs-20.1-b3-work/src/lread.c
--- xemacs-20.1-b3/src/lread.c	Thu Jan 23 00:30:11 1997
+++ xemacs-20.1-b3-work/src/lread.c	Thu Feb 27 23:43:18 1997
@@ -1190,9 +1190,11 @@
   REGISTER Lisp_Object tem, tem2;
   int foundit;
 
+#ifndef DEBUG_XEMACS
   /* Don't bother recording anything for preloaded files.  */
   if (purify_flag)
     return;
+#endif
 
   tail = Vload_history;
   prev = Qnil;
@@ -1245,6 +1247,10 @@
   if (loading || !foundit)
     Vload_history = Fcons (Fnreverse (Vcurrent_load_list),
 			   Vload_history);
+#ifdef DEBUG_XEMACS
+  Vload_history = Fpurecopy (Vload_history);
+#endif
+  
 }
 
 #else /* !LOADHIST */

