[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#8803: 23.3; backtrace should use find-function-source-path to find s
From: |
Stefan Monnier |
Subject: |
bug#8803: 23.3; backtrace should use find-function-source-path to find source |
Date: |
Mon, 20 Jun 2011 16:57:24 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
> find-library-name: Can't find library /home/ubuntu/compile/foo.el
> I expect emacs to load foo.el since find-function-source-path is
> defined.
The problem here is that we use an absolute file name, rather than
a relative one.
> @@ -156,6 +156,9 @@
> (locate-file library
> (or find-function-source-path load-path)
> load-file-rep-suffixes)
> + (locate-file (file-name-sans-extension (file-name-nondirectory library))
> + (or find-function-source-path load-path)
> + (find-library-suffixes))
> (error "Can't find library %s" library)))
But this will still fail for files such as Semantic's which are placed
in subdirectories (e.g. loaded with (require 'foo/bar)).
We really need to record both the absolute file name and the relative
file name so that find-library-name can try both.
In the mean time, does the patch below work for you?
Stefan
=== modified file 'lisp/emacs-lisp/find-func.el'
--- lisp/emacs-lisp/find-func.el 2011-01-25 04:08:28 +0000
+++ lisp/emacs-lisp/find-func.el 2011-06-20 20:55:50 +0000
@@ -141,6 +141,15 @@
(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)."
@@ -155,6 +164,16 @@
(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