GNU bug report logs - #8803
23.3; backtrace should use find-function-source-path to find source

Previous Next

Package: emacs;

Reported by: Ivan Kanis <gnu <at> kanis.fr>

Date: Sun, 5 Jun 2011 18:21:01 UTC

Severity: minor

Found in version 23.3

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 8803 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Ivan Kanis <gnu <at> kanis.fr>
Cc: 8803 <at> debbugs.gnu.org
Subject: Re: bug#8803: 23.3;
	backtrace should use find-function-source-path to find source
Date: Mon, 20 Jun 2011 16:57:24 -0400
> 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





This bug report was last modified 14 years and 24 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.