changeset 16064:a9d32637ee38

(locate-library): New arg PATH. Handle autocompression mode.
author Richard M. Stallman <rms@gnu.org>
date Mon, 02 Sep 1996 01:16:42 +0000
parents b4427bbd451e
children 595d0ac6eff6
files lisp/help.el
diffstat 1 files changed, 21 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/help.el	Mon Sep 02 01:05:22 1996 +0000
+++ b/lisp/help.el	Mon Sep 02 01:16:42 1996 +0000
@@ -666,12 +666,15 @@
       (message "%s is not on any key" definition)))
   nil)
 
-(defun locate-library (library &optional nosuffix)
+(defun locate-library (library &optional nosuffix path)
   "Show the precise file name of Emacs library LIBRARY.
 This command searches the directories in `load-path' like `M-x load-library'
 to find the file that `M-x load-library RET LIBRARY RET' would load.
 Optional second arg NOSUFFIX non-nil means don't add suffixes `.elc' or `.el'
-to the specified name LIBRARY."
+to the specified name LIBRARY.
+
+If the optional third arg PATH is specified, that list of directories
+is used instead of `load-path'."
   (interactive "sLocate library: ")
   (catch 'answer
     (mapcar
@@ -684,8 +687,22 @@
 		   (progn
 		     (message "Library is file %s" try)
 		     (throw 'answer try)))))
-	 (if nosuffix '("") '(".elc" ".el" ""))))
-     load-path)
+	 (if nosuffix
+	     '("")
+	   (let ((basic '(".elc" ".el" ""))
+		 (compressed '(".Z" ".gz" "")))
+	     ;; If autocompression mode is on,
+	     ;; consider all combinations of library suffixes
+	     ;; and compression suffixes.
+	     (if (rassq 'jka-compr-handler file-name-handler-alist)
+		 (apply 'nconc
+			(mapcar '(lambda (compelt)
+				   (mapcar '(lambda (baselt)
+					      (concat baselt compelt))
+					   basic))
+				compressed))
+	       basic)))))
+     (or path load-path))
     (message "No library %s in search path" library)
     nil))