aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authorPhilip Kaludercic2025-09-02 14:51:09 +0200
committerPhilip Kaludercic2025-09-02 14:51:09 +0200
commit055ee29eb43221385b30182643d627512ca99ef7 (patch)
treecdc3021f6f6ad11376140ec15cf1b51bfb4878d4 /admin
parent218eab3f99a53bbb4f4efc8cfa1b78c268238e07 (diff)
parent2a88c6dc3c36f726275554f1b93e32fd726e415c (diff)
downloademacs-055ee29eb43221385b30182643d627512ca99ef7.tar.gz
emacs-055ee29eb43221385b30182643d627512ca99ef7.zip
Merge remote-tracking branch 'origin/feature/package-autosuggest' into scratch/split-package.el
Diffstat (limited to 'admin')
-rw-r--r--admin/scrape-elpa.el81
1 files changed, 81 insertions, 0 deletions
diff --git a/admin/scrape-elpa.el b/admin/scrape-elpa.el
new file mode 100644
index 00000000000..bf3846c0fcb
--- /dev/null
+++ b/admin/scrape-elpa.el
@@ -0,0 +1,81 @@
1;;; scrape-elpa.el --- Collect ELPA package suggestions -*- lexical-binding: t; -*-
2
3;; Copyright (C) 2024 Free Software Foundation, Inc.
4
5;; Author: Philip Kaludercic <philipk@posteo.net>
6;; Keywords: tools
7
8;; This program is free software; you can redistribute it and/or modify
9;; it under the terms of the GNU General Public License as published by
10;; the Free Software Foundation, either version 3 of the License, or
11;; (at your option) any later version.
12
13;; This program is distributed in the hope that it will be useful,
14;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16;; GNU General Public License for more details.
17
18;; You should have received a copy of the GNU General Public License
19;; along with this program. If not, see <https://www.gnu.org/licenses/>.
20
21;;; Commentary:
22
23;; This file defines an administrative command to update the
24;; `package-autosuggest' database.
25
26;;; Code:
27
28(defun scrape-elpa (&rest directories)
29 "Scrape autoload files in DIRECTORIES for package suggestions.
30This file will automatically update \"package-autosuggest.eld\", but not
31save it. You should invoke this command with built GNU ELPA and NonGNU
32ELPA checkouts (i.e. having run \"make autoloads\" in both directories).
33Please review the results before updating the autosuggest database!"
34 (interactive (completing-read-multiple
35 "ELPA directories to scrape: "
36 #'completion-file-name-table
37 #'file-directory-p))
38 (with-current-buffer
39 (find-file (expand-file-name "package-autosuggest.eld" data-directory))
40 (erase-buffer)
41 (lisp-data-mode)
42 (insert ";; The contents of this file are loaded into `package-autosuggest-database'
43;; and were automatically generate by scraping ELPA for auto-loaded
44;; code using the `scrape-elpa' command. Please avoid updating this
45;; file manually!
46
47")
48 (fill-paragraph)
49 (insert "(")
50 (let ((standard-output (current-buffer)))
51 (dolist-with-progress-reporter
52 (file (mapcan
53 (lambda (dir)
54 (directory-files-recursively
55 dir "-autoloads\\.el\\'"))
56 directories))
57 "Scraping files..."
58 (and-let* (((string-match "/\\([^/]+?\\)-autoloads\\.el\\'" file))
59 (pkg (intern (match-string 1 file)))
60 (inhibit-message t))
61 (with-temp-buffer
62 (insert-file-contents file)
63 (condition-case nil
64 (while t
65 (dolist (exp (macroexp-unprogn (read (current-buffer))))
66 (pcase exp
67 (`(add-to-list
68 ',(and (or 'interpreter-mode-alist
69 'magic-mode-alist
70 'auto-mode-alist)
71 variable)
72 '(,(and (pred stringp) regexp) .
73 ,(and (pred symbolp) mode)))
74 (terpri)
75 (prin1 (append (list pkg variable regexp)
76 (and (not (eq pkg mode)) (list mode))))))))
77 (end-of-file nil))))))
78 (insert "\n)\n")))
79
80(provide 'scrape-elpa)
81;;; scrape-elpa.el ends here