Function: finder-compile-keywords
finder-compile-keywords is a byte-compiled function defined in
finder.el.gz.
Signature
(finder-compile-keywords &rest DIRS)
Documentation
Regenerate list of built-in Emacs packages.
This recomputes package--builtins and finder-keywords-hash,
and prints them into the file generated-finder-keywords-file.
Optional DIRS is a list of Emacs Lisp directories to compile
from; the default is load-path.
Source Code
;; Defined in /usr/src/emacs/lisp/finder.el.gz
(defun finder-compile-keywords (&rest dirs)
"Regenerate list of built-in Emacs packages.
This recomputes `package--builtins' and `finder-keywords-hash',
and prints them into the file `generated-finder-keywords-file'.
Optional DIRS is a list of Emacs Lisp directories to compile
from; the default is `load-path'."
;; Allow compressed files also.
(setq package--builtins nil)
(setq finder-keywords-hash (make-hash-table :test 'eq))
(let* ((el-file-regexp "\\`\\([^=].*\\)\\.el\\(\\.\\(gz\\|Z\\)\\)?\\'")
(file-count 0)
(files (cl-loop for d in (or dirs load-path)
when (file-exists-p (directory-file-name d))
append (mapcar
(lambda (f)
(cons d f))
(directory-files d nil el-file-regexp))))
(progress (make-progress-reporter
(byte-compile-info "Scanning files for finder")
0 (length files)))
base-name summary keywords package version entry desc)
(dolist (elem files)
(let* ((d (car elem))
(f (cdr elem))
(package-override
(intern-soft
(cdr-safe
(assoc (file-name-nondirectory
(directory-file-name d))
finder--builtins-alist)))))
(progress-reporter-update progress (setq file-count (1+ file-count)))
(unless (or (string-match finder-no-scan-regexp f)
(null (setq base-name
(and (string-match el-file-regexp f)
(intern (match-string 1 f))))))
;; (memq base-name processed))
;; There are multiple files in the tree with the same
;; basename. So skipping files based on basename means you
;; randomly (depending on which order the files are
;; traversed in) miss some packages.
;; https://debbugs.gnu.org/14010
;; You might think this could lead to two files providing
;; the same package, but it does not, because the duplicates
;; are (at time of writing) all due to files in cedet, which
;; end up with package-override set. FIXME this is
;; obviously fragile. Make the (eq base-name package) case
;; below issue a warning if package-override is nil?
;; (push base-name processed)
(with-temp-buffer
(insert-file-contents (expand-file-name f d))
(setq keywords (mapcar #'intern (lm-keywords-list))
package (or package-override
(let ((str (lm-header "package")))
(if str (intern str)))
base-name)
summary (or (cdr
(assq package finder--builtins-descriptions))
(lm-synopsis))
version (lm-header "version")))
(when summary
(setq version (or (ignore-errors (version-to-list version))
(alist-get package package--builtin-versions)))
(setq entry (assq package package--builtins))
(cond ((null entry)
(push (cons package
(package-make-builtin version summary))
package--builtins))
;; The idea here is that eg calc.el gets to define
;; the description of the calc package.
;; This does not work for eg nxml-mode.el.
((eq base-name package)
(setq desc (cdr entry))
(aset desc 0 version)
(aset desc 2 summary)))
(dolist (kw keywords)
(puthash kw
(cons package
(delq package
(gethash kw finder-keywords-hash)))
finder-keywords-hash))))))
(progress-reporter-done progress))
(setq package--builtins
(sort package--builtins
(lambda (a b) (string< (symbol-name (car a))
(symbol-name (car b))))))
(with-current-buffer
(find-file-noselect generated-finder-keywords-file)
(setq buffer-undo-list t)
(erase-buffer)
(insert (autoload-rubric generated-finder-keywords-file
"keyword-to-package mapping" t))
(search-backward "")
;; FIXME: Now that we have package--builtin-versions, package--builtins is
;; only needed to get the list of unversioned packages and to get the
;; summary description of each package.
(insert "(setq package--builtins '(\n")
(dolist (package package--builtins)
(insert " ")
(prin1 package (current-buffer))
(insert "\n"))
(insert "))\n\n")
;; Insert hash table.
(insert "(setq finder-keywords-hash\n ")
(prin1 finder-keywords-hash (current-buffer))
(insert ")\n")
(basic-save-buffer)))