diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2011-06-30 23:15:02 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2011-06-30 23:15:02 -0400 |
commit | 6a2fb145963ff8242469b41bbe3acd9f6e16dec4 (patch) | |
tree | 451b60d64abc5bde3901b2b067b57ac43485a92d /lisp/emacs-lisp | |
parent | 3e0b797f616aebf8df59e799261c5d917ef3c5bb (diff) | |
download | emacs-6a2fb145963ff8242469b41bbe3acd9f6e16dec4.tar.gz emacs-6a2fb145963ff8242469b41bbe3acd9f6e16dec4.tar.bz2 emacs-6a2fb145963ff8242469b41bbe3acd9f6e16dec4.zip |
* lisp/emacs-lisp/find-func.el (find-library--load-name): New fun.
(find-library-name): Use it to find relative load names when provided
absolute file name.
Fixes: debbugs:8803
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/find-func.el | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el index 9c4a3e9832c..0194af2e3a8 100644 --- a/lisp/emacs-lisp/find-func.el +++ b/lisp/emacs-lisp/find-func.el @@ -141,6 +141,15 @@ See the functions `find-function' and `find-variable'." (dolist (suffix (get-load-suffixes) (nreverse suffixes)) (unless (string-match "elc" suffix) (push suffix suffixes))))) +(defun find-library--load-name (library) + (let ((name library)) + (dolist (dir load-path) + (let ((rel (file-relative-name library dir))) + (if (and (not (string-match "\\`\\.\\./" rel)) + (< (length rel) (length name))) + (setq name rel)))) + (unless (equal name library) name))) + (defun find-library-name (library) "Return the absolute file name of the Emacs Lisp source of LIBRARY. LIBRARY should be a string (the name of the library)." @@ -148,13 +157,23 @@ LIBRARY should be a string (the name of the library)." ;; the same name. (if (string-match "\\.el\\(c\\(\\..*\\)?\\)\\'" library) (setq library (replace-match "" t t library))) - (or + (or (locate-file library (or find-function-source-path load-path) (find-library-suffixes)) (locate-file library (or find-function-source-path load-path) load-file-rep-suffixes) + (when (file-name-absolute-p library) + (let ((rel (find-library--load-name library))) + (when rel + (or + (locate-file rel + (or find-function-source-path load-path) + (find-library-suffixes)) + (locate-file rel + (or find-function-source-path load-path) + load-file-rep-suffixes))))) (error "Can't find library %s" library))) (defvar find-function-C-source-directory |