aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2011-06-30 23:15:02 -0400
committerStefan Monnier2011-06-30 23:15:02 -0400
commit6a2fb145963ff8242469b41bbe3acd9f6e16dec4 (patch)
tree451b60d64abc5bde3901b2b067b57ac43485a92d
parent3e0b797f616aebf8df59e799261c5d917ef3c5bb (diff)
downloademacs-6a2fb145963ff8242469b41bbe3acd9f6e16dec4.tar.gz
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
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/emacs-lisp/find-func.el21
2 files changed, 27 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 1ce1eb61f14..68a492311fb 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12011-07-01 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * emacs-lisp/find-func.el (find-library--load-name): New fun.
4 (find-library-name): Use it to find relative load names when provided
5 absolute file name (bug#8803).
6
12011-06-30 Lars Magne Ingebrigtsen <larsi@gnus.org> 72011-06-30 Lars Magne Ingebrigtsen <larsi@gnus.org>
2 8
3 * textmodes/flyspell.el (flyspell-word): Consider words that 9 * textmodes/flyspell.el (flyspell-word): Consider words that
@@ -14,7 +20,7 @@
14 20
15 * progmodes/cc-guess.el: New file. 21 * progmodes/cc-guess.el: New file.
16 22
17 * progmodes/cc-langs.el (c-mode-menu): Added "Style..." submenu. 23 * progmodes/cc-langs.el (c-mode-menu): Add "Style..." submenu.
18 24
19 * progmodes/cc-styles.el (cc-choose-style-for-mode): New function 25 * progmodes/cc-styles.el (cc-choose-style-for-mode): New function
20 derived from `c-basic-common-init'. 26 derived from `c-basic-common-init'.
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'."
141 (dolist (suffix (get-load-suffixes) (nreverse suffixes)) 141 (dolist (suffix (get-load-suffixes) (nreverse suffixes))
142 (unless (string-match "elc" suffix) (push suffix suffixes))))) 142 (unless (string-match "elc" suffix) (push suffix suffixes)))))
143 143
144(defun find-library--load-name (library)
145 (let ((name library))
146 (dolist (dir load-path)
147 (let ((rel (file-relative-name library dir)))
148 (if (and (not (string-match "\\`\\.\\./" rel))
149 (< (length rel) (length name)))
150 (setq name rel))))
151 (unless (equal name library) name)))
152
144(defun find-library-name (library) 153(defun find-library-name (library)
145 "Return the absolute file name of the Emacs Lisp source of LIBRARY. 154 "Return the absolute file name of the Emacs Lisp source of LIBRARY.
146LIBRARY should be a string (the name of the library)." 155LIBRARY should be a string (the name of the library)."
@@ -148,13 +157,23 @@ LIBRARY should be a string (the name of the library)."
148 ;; the same name. 157 ;; the same name.
149 (if (string-match "\\.el\\(c\\(\\..*\\)?\\)\\'" library) 158 (if (string-match "\\.el\\(c\\(\\..*\\)?\\)\\'" library)
150 (setq library (replace-match "" t t library))) 159 (setq library (replace-match "" t t library)))
151 (or 160 (or
152 (locate-file library 161 (locate-file library
153 (or find-function-source-path load-path) 162 (or find-function-source-path load-path)
154 (find-library-suffixes)) 163 (find-library-suffixes))
155 (locate-file library 164 (locate-file library
156 (or find-function-source-path load-path) 165 (or find-function-source-path load-path)
157 load-file-rep-suffixes) 166 load-file-rep-suffixes)
167 (when (file-name-absolute-p library)
168 (let ((rel (find-library--load-name library)))
169 (when rel
170 (or
171 (locate-file rel
172 (or find-function-source-path load-path)
173 (find-library-suffixes))
174 (locate-file rel
175 (or find-function-source-path load-path)
176 load-file-rep-suffixes)))))
158 (error "Can't find library %s" library))) 177 (error "Can't find library %s" library)))
159 178
160(defvar find-function-C-source-directory 179(defvar find-function-C-source-directory