]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix completion in `read-library-name'
authorLars Ingebrigtsen <larsi@gnus.org>
Tue, 27 Aug 2019 07:46:28 +0000 (09:46 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Tue, 27 Aug 2019 07:46:28 +0000 (09:46 +0200)
* lisp/emacs-lisp/find-func.el (read-library-name): Only list
.el/.el.gz files when completing (bug#36945).

lisp/emacs-lisp/find-func.el

index 9fc7e4a797d3efa526b10dbbdd923107b43df887..142c99edd43d3df1e2dedc45e4628501d576d20a 100644 (file)
@@ -285,10 +285,19 @@ Interactively, prompt for LIBRARY using the one at or near point."
 A library name is the filename of an Emacs Lisp library located
 in a directory under `load-path' (or `find-function-source-path',
 if non-nil)."
-  (let* ((dirs (or find-function-source-path load-path))
-         (suffixes (find-library-suffixes))
-         (table (apply-partially 'locate-file-completion-table
-                                 dirs suffixes))
+  (let* ((suffix-regexp (mapconcat
+                         (lambda (suffix)
+                           (concat (regexp-quote suffix) "\\'"))
+                         (find-library-suffixes)
+                         "\\|"))
+         (table (cl-loop for dir in (or find-function-source-path load-path)
+                         when (file-readable-p dir)
+                         append (mapcar
+                                 (lambda (file)
+                                   (replace-regexp-in-string suffix-regexp
+                                                             "" file))
+                                 (directory-files dir nil
+                                                  suffix-regexp))))
          (def (if (eq (function-called-at-point) 'require)
                   ;; `function-called-at-point' may return 'require
                   ;; with `point' anywhere on this line.  So wrap the