]> git.eshelyaron.com Git - emacs.git/commitdiff
Add default sorting and history variable to 'read-library-name'
authorEshel Yaron <me@eshelyaron.com>
Fri, 7 Jun 2024 11:17:14 +0000 (13:17 +0200)
committerEshel Yaron <me@eshelyaron.com>
Fri, 7 Jun 2024 11:17:14 +0000 (13:17 +0200)
lisp/emacs-lisp/find-func.el
lisp/minibuffer.el

index c3a468950699110fa3859d312b8a6802695e0c55..ecf24c5069802cca9d6f5c200eb9c7bce7d77363 100644 (file)
@@ -402,6 +402,9 @@ customizing the candidate completions."
                         'face 'completions-annotations)))))
             libraries)))
 
+(defvar read-library-name-history nil
+  "Minibuffer history for `read-library-name'.")
+
 ;;;###autoload
 (defun read-library-name (&optional prompt)
   "Read and return a library name, defaulting to the one near point.
@@ -413,9 +416,14 @@ if non-nil).
 Optional argument PROMPT is the minibuffer prompt to use, when nil or
 omitted it defaults to \"Library name\"."
   (let* ((prompt (or prompt "Library name"))
-         (files (read-library-name--find-files
-                 (or find-library-source-path load-path)
-                 (find-library-suffixes)))
+         (files (seq-filter
+                 (lambda (library)
+                   ;; Filter out spurious non-libraries.
+                   (not (or (string= library ".dir-locals")
+                            (string-suffix-p "-pkg" library))))
+                 (read-library-name--find-files
+                  (or find-library-source-path load-path)
+                  (find-library-suffixes))))
          (def (thing-at-point 'symbol))
          (def (and (member def files) def)))
     (completing-read (format-prompt prompt def)
@@ -427,7 +435,7 @@ omitted it defaults to \"Library name\"."
                         ,@(when completions-detailed
                             '((affixation-function
                                . read-library-name-affixation)))))
-                     nil t nil nil def)))
+                     nil t nil 'read-library-name-history def)))
 
 (defun read-library-name--find-files (dirs suffixes)
   "Return a list of all files in DIRS that match SUFFIXES."
index d97897b92430db96d70c876c67fac24d358e6a36..b0dff6f5f45177eb8d370f0c37cdd28749506337 100644 (file)
@@ -1175,7 +1175,8 @@ styles for specific categories, such as files, buffers, etc."
     (symbol-help (styles . (basic shorthand substring)))
     (multiple-choice (styles . (basic substring)) (sort-function . identity))
     (calendar-month (sort-function . identity))
-    (keybinding (sort-function . minibuffer-sort-alphabetically)))
+    (keybinding (sort-function . minibuffer-sort-alphabetically))
+    (library (sort-function . minibuffer-sort-alphabetically)))
   "Default settings for specific completion categories.
 
 Each entry has the shape (CATEGORY . ALIST) where ALIST is