Mercurial > emacs
comparison lisp/help-funs.el @ 39847:2f5725430b4f
(locate-library): Use load-suffixes and abbrev filename.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Fri, 12 Oct 2001 20:57:56 +0000 |
parents | 67f0a4191315 |
children | 6748fb350a05 |
comparison
equal
deleted
inserted
replaced
39846:2e4007551cfd | 39847:2f5725430b4f |
---|---|
80 ;;;###autoload | 80 ;;;###autoload |
81 (defun locate-library (library &optional nosuffix path interactive-call) | 81 (defun locate-library (library &optional nosuffix path interactive-call) |
82 "Show the precise file name of Emacs library LIBRARY. | 82 "Show the precise file name of Emacs library LIBRARY. |
83 This command searches the directories in `load-path' like `M-x load-library' | 83 This command searches the directories in `load-path' like `M-x load-library' |
84 to find the file that `M-x load-library RET LIBRARY RET' would load. | 84 to find the file that `M-x load-library RET LIBRARY RET' would load. |
85 Optional second arg NOSUFFIX non-nil means don't add suffixes `.elc' or `.el' | 85 Optional second arg NOSUFFIX non-nil means don't add suffixes `load-suffixes' |
86 to the specified name LIBRARY. | 86 to the specified name LIBRARY. |
87 | 87 |
88 If the optional third arg PATH is specified, that list of directories | 88 If the optional third arg PATH is specified, that list of directories |
89 is used instead of `load-path'. | 89 is used instead of `load-path'. |
90 | 90 |
92 string. When run interactively, the argument INTERACTIVE-CALL is t, | 92 string. When run interactively, the argument INTERACTIVE-CALL is t, |
93 and the file name is displayed in the echo area." | 93 and the file name is displayed in the echo area." |
94 (interactive (list (read-string "Locate library: ") | 94 (interactive (list (read-string "Locate library: ") |
95 nil nil | 95 nil nil |
96 t)) | 96 t)) |
97 (let (result) | 97 (catch 'answer |
98 (catch 'answer | 98 (dolist (dir (or path load-path)) |
99 (mapc | 99 (dolist (suf (append (unless nosuffix load-suffixes) '(""))) |
100 (lambda (dir) | 100 (let ((try (expand-file-name (concat library suf) dir))) |
101 (mapc | 101 (and (file-readable-p try) |
102 (lambda (suf) | 102 (null (file-directory-p try)) |
103 (let ((try (expand-file-name (concat library suf) dir))) | 103 (progn |
104 (and (file-readable-p try) | 104 (if interactive-call |
105 (null (file-directory-p try)) | 105 (message "Library is file %s" (abbreviate-file-name try))) |
106 (progn | 106 (throw 'answer try)))))) |
107 (setq result try) | 107 (if interactive-call |
108 (throw 'answer try))))) | 108 (message "No library %s in search path" library)) |
109 (if nosuffix | 109 nil)) |
110 '("") | |
111 '(".elc" ".el" "") | |
112 (let ((basic '(".elc" ".el" "")) | |
113 (compressed '(".Z" ".gz" ""))) | |
114 ;; If autocompression mode is on, | |
115 ;; consider all combinations of library suffixes | |
116 ;; and compression suffixes. | |
117 (if (rassq 'jka-compr-handler file-name-handler-alist) | |
118 (apply 'nconc | |
119 (mapcar (lambda (compelt) | |
120 (mapcar (lambda (baselt) | |
121 (concat baselt compelt)) | |
122 basic)) | |
123 compressed)) | |
124 basic))))) | |
125 (or path load-path))) | |
126 (and interactive-call | |
127 (if result | |
128 (message "Library is file %s" result) | |
129 (message "No library %s in search path" library))) | |
130 result)) | |
131 | 110 |
132 | 111 |
133 ;; Functions | 112 ;; Functions |
134 | 113 |
135 ;;;###autoload | 114 ;;;###autoload |