emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 7f03ee8: * lisp/emacs-lisp/package.el: Fix use of `find-library-n


From: Stefan Monnier
Subject: master 7f03ee8: * lisp/emacs-lisp/package.el: Fix use of `find-library-name`
Date: Mon, 26 Apr 2021 18:42:24 -0400 (EDT)

branch: master
commit 7f03ee8de15df31e57fd86e193901a1cf70cc49d
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    * lisp/emacs-lisp/package.el: Fix use of `find-library-name`
    
    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 |  2 +-
 lisp/emacs-lisp/package.el   | 32 ++++++++++++++++----------------
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el
index a0d859b..58876a4 100644
--- a/lisp/emacs-lisp/find-func.el
+++ b/lisp/emacs-lisp/find-func.el
@@ -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
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 1ce2940..5035850 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]