]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/emacs-lisp/package.el: Fix use of `find-library-name`
authorStefan Monnier <monnier@iro.umontreal.ca>
Mon, 26 Apr 2021 22:40:09 +0000 (18:40 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Mon, 26 Apr 2021 22:40:09 +0000 (18:40 -0400)
That function caused a warning for a good reason.
Don't just declare it and hope it will be available.

(package--list-of-conflicts): Require `find-func` explicitly before
declaring the function.  Also don't ignore all errors but only
the `file-error`s which will be emitted by `find-library-name`
in normal circumstances.

* lisp/emacs-lisp/find-func.el (find-library-name): Signal a `file-error`
Instead of a generic `error`.

lisp/emacs-lisp/find-func.el
lisp/emacs-lisp/package.el

index a0d859b834df3c074fed342d3ae92bbd6554942a..58876a45e19be5323dbc036f12a8bfce6395e27d 100644 (file)
@@ -208,7 +208,7 @@ LIBRARY should be a string (the name of the library)."
                        (or find-function-source-path load-path)
                        load-file-rep-suffixes)))))
    (find-library--from-load-history library)
-   (error "Can't find library %s" library)))
+   (signal 'file-error (list "Can't find library" library))))
 
 (defun find-library--from-load-history (library)
   ;; In `load-history', the file may be ".elc", ".el", ".el.gz", and
index 1ce2940b2918f7a543270b93602930b77fd5d2f9..503585079e4885cc13b98f7a250053c5beb1d2b1 100644 (file)
@@ -835,8 +835,6 @@ correspond to previously loaded files (those returned by
       ;; Don't return nil.
       t)))
 
-(declare-function find-library-name "find-func" (library))
-
 (defun package--files-load-history ()
   (delq nil
         (mapcar (lambda (x)
@@ -846,20 +844,22 @@ correspond to previously loaded files (those returned by
                 load-history)))
 
 (defun package--list-of-conflicts (dir history)
-   (delq
-    nil
-    (mapcar
-     (lambda (x) (let* ((file (file-relative-name x dir))
-                        ;; Previously loaded file, if any.
-                        (previous
-                         (ignore-errors
-                           (file-name-sans-extension
-                            (file-truename (find-library-name file)))))
-                        (pos (when previous (member previous history))))
-                   ;; Return (RELATIVE-FILENAME . HISTORY-POSITION)
-                   (when pos
-                     (cons (file-name-sans-extension file) (length pos)))))
-     (directory-files-recursively dir "\\`[^\\.].*\\.el\\'"))))
+  (require 'find-func)
+  (declare-function find-library-name "find-func" (library))
+  (delq
+   nil
+   (mapcar
+    (lambda (x) (let* ((file (file-relative-name x dir))
+                  ;; Previously loaded file, if any.
+                  (previous
+                   (ignore-error file-error ;"Can't find library"
+                     (file-name-sans-extension
+                      (file-truename (find-library-name file)))))
+                  (pos (when previous (member previous history))))
+             ;; Return (RELATIVE-FILENAME . HISTORY-POSITION)
+             (when pos
+               (cons (file-name-sans-extension file) (length pos)))))
+    (directory-files-recursively dir "\\`[^\\.].*\\.el\\'"))))
 
 (defun package--list-loaded-files (dir)
   "Recursively list all files in DIR which correspond to loaded features.