[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnu-elpa 9ab52ef 2/2: * gnu-elpa-utils.el: New file
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnu-elpa 9ab52ef 2/2: * gnu-elpa-utils.el: New file |
Date: |
Sun, 26 Apr 2020 23:52:18 -0400 (EDT) |
branch: externals/gnu-elpa
commit 9ab52ef1b21997d82dce6e043f5aebe5fe0092f3
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>
* gnu-elpa-utils.el: New file
* gnu-elpa.el: Move `package-archives` setup to it, and generally use it.
* gnu-elpa-maint.el (gnu-elpa--features-for-pkg): First collect autoloads,
then look at the rest. Makes for simpler code.
(gnu-elpa--make-features): Enforce the use of `emacs-internal` encoding.
Mark the generated file a no-byte-compile.
* .gitignore: New file.
* gnu-elpa-features.el: Update.
---
.gitignore | 3 ++
gnu-elpa-features.el | 67 +++++++++++++++++++------
gnu-elpa-maint.el | 135 ++++++++++++++++++++++++++++-----------------------
gnu-elpa-utils.el | 74 ++++++++++++++++++++++++++++
gnu-elpa.el | 28 +++++------
5 files changed, 218 insertions(+), 89 deletions(-)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..327795d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+gnu-elpa-autoloads.el
+gnu-elpa-pkg.el
+*.elc
diff --git a/gnu-elpa-features.el b/gnu-elpa-features.el
index ceff0ca..cf23086 100644
--- a/gnu-elpa-features.el
+++ b/gnu-elpa-features.el
@@ -1,6 +1,8 @@
;;; gnu-elpa-features.el --- Auto-generated autoloads -*- lexical-binding:t
-*-
-;; Copyright (C) 2020 Free Software Foundation, Inc.
+;; ¡¡ This file is auto-generated by `gnu-elpa--make-features', DO NOT EDIT !!
+
+;; Copyright (C) 2020-2020 Free Software Foundation, Inc.
;; Author: gnu-elpa-maint.el
@@ -129,6 +131,31 @@ The lines are shown in a buffer named `*All*'.
Any changes made in that buffer will be propagated to this buffer.
(fn REGEXP &optional NLINES)" t nil)
+ (ampc "Ampc is an asynchronous client for the MPD media player.
+This function is the main entry point for ampc.
+
+HOST and PORT specify the MPD instance to connect to. The values
+default to the ones specified in `ampc-default-server'.
+
+(fn &optional HOST PORT SUSPEND)" t nil)
+ (ampc-on-p "Return non-nil if ampc is connected to the daemon." t
nil)
+ (ampc-suspended-p "Return non-nil if ampc is suspended." t nil)
+ (ampc-tag-files "Start the tagging subsystem.
+FILES should be a list of absolute file names, the files to tag.
+
+(fn FILES)" nil nil)
+ (ampc-tagger-dired "Start the tagging subsystem on dired's marked
files.
+With optional prefix argument ARG, use the next ARG files.
+
+(fn &optional ARG)" t nil)
+ (ampc-tagger-dired-mode "Minor mode that adds a audio file meta
data tagging key binding to dired.
+
+If called interactively, enable Ampc-Tagger-Dired mode if ARG is
+positive, and disable it if ARG is zero or negative. If called from
+Lisp, also enable the mode if ARG is omitted or nil, and toggle it if
+ARG is `toggle'; disable the mode otherwise.
+
+(fn &optional ARG)" t nil)
(arbitools-mode "Major mode for Chess Tournament Management.
(fn)" t nil)
@@ -3064,6 +3091,9 @@ SiSU document structuring, publishing in multiple formats
and search.
URL `http://www.sisudoc.org/'
(fn)" t nil)
+ (sm-c-mode "C editing mode based on SMIE.
+
+(fn)" t nil)
(smalltalk-mode "Major mode for editing Smalltalk code.
Commands:
@@ -4026,45 +4056,54 @@ Argument DIR2 right directory.
(let ((f (car x)))
(unless (fboundp f)
(apply #'autoload f "gnu-elpa" (cdr x)))))
-(defalias 'pcomplete/ack-grep 'pcomplete/ack)
-(defalias 'aggressive-indent-global-mode 'global-aggressive-indent-mode)
+(unless (fboundp 'pcomplete/ack-grep) (defalias 'pcomplete/ack-grep
'pcomplete/ack))
+(unless (fboundp 'aggressive-indent-global-mode) (defalias
'aggressive-indent-global-mode #'global-aggressive-indent-mode))
(add-to-list 'auto-mode-alist '("\\.trf?\\'" . arbitools-mode))
(add-to-list 'auto-mode-alist '("\\.bnf\\'" . bnf-mode))
(add-to-list 'auto-mode-alist '("\\.pgn\\'" . chess-pgn-mode))
-(defalias 'pgn-mode 'chess-pgn-mode)
-(defalias 'chess-session 'chess)
+(unless (fboundp 'pgn-mode) (defalias 'pgn-mode 'chess-pgn-mode))
+(unless (fboundp 'chess-session) (defalias 'chess-session 'chess))
(add-to-list 'auto-mode-alist '("Cakefile" . coffee-mode))
(add-to-list 'auto-mode-alist '("\\.coffee\\'" . coffee-mode))
(add-to-list 'auto-mode-alist '("\\.tsv\\'" . tsv-mode))
(add-to-list 'auto-mode-alist '("\\.[Cc][Ss][Vv]\\'" . csv-mode))
-(defalias 'dictree-create-custom 'make-dictree-custom)
-(defalias 'dictree-create 'make-dictree)
+(unless (fboundp 'dictree-create-custom) (defalias 'dictree-create-custom
'make-dictree-custom))
+(unless (fboundp 'dictree-create) (defalias 'dictree-create 'make-dictree))
(add-to-list 'auto-mode-alist '("\\.djvu\\'" . djvu-dummy-mode))
(add-to-list 'auto-mode-alist '("\\.dtsi?\\'" . dts-mode))
+(unless (fboundp 'easy-mark-sexp) (defalias 'easy-mark-sexp 'easy-mark "Use
`easy-mark' instead. The alias may be removed in future."))
(add-to-list 'auto-mode-alist '("\\.fountain\\'" . fountain-mode))
-(defalias 'gited-list 'gited-list-branches)
+(unless (fboundp 'gited-list) (defalias 'gited-list 'gited-list-branches))
(add-to-list 'auto-mode-alist '("\\.gle\\'" . gle-mode))
-(defalias 'heap-create 'make-heap)
+(unless (fboundp 'heap-create) (defalias 'heap-create 'make-heap))
(add-to-list 'auto-mode-alist '("\\.jgr\\'" . jgraph-mode))
(add-to-list 'auto-mode-alist '("\\.json\\'" . json-mode))
-(defalias 'landmark-repeat 'landmark-test-run)
+(unless (fboundp 'landmark-repeat) (defalias 'landmark-repeat
'landmark-test-run))
(add-to-list 'auto-mode-alist '("\\.elmc\\'" . lmc-asm-mode))
(add-to-list 'auto-mode-alist '("\\.omn\\'" . omn-mode))
(add-to-list 'auto-mode-alist '("\\.pomn\\'" . omn-mode))
-(defalias 'global-on-screen-mode 'on-screen-global-mode)
+(unless (fboundp 'global-on-screen-mode) (defalias 'global-on-screen-mode
'on-screen-global-mode))
(add-to-list 'auto-mode-alist '("\\.rnc\\'" . rnc-mode))
+(add-to-list 'interpreter-mode-alist '("sed" . sed-mode))
(add-to-list 'auto-mode-alist '("\\.sed\\'" . sed-mode))
(add-to-list 'auto-mode-alist '("\\.shen\\'" . shen-mode))
-(defalias 'run-shen 'inferior-shen)
+(unless (fboundp 'run-shen) (defalias 'run-shen 'inferior-shen))
(add-to-list 'auto-mode-alist '("\\.ss[imt]\\'" . sisu-mode))
(add-to-list 'auto-mode-alist '("\\.st\\'" . smalltalk-mode))
(add-to-list 'auto-mode-alist '("\\.grm\\'" . sml-yacc-mode))
(add-to-list 'auto-mode-alist '("\\.cm\\'" . sml-cm-mode))
(add-to-list 'auto-mode-alist '("\\.s\\(ml\\|ig\\)\\'" . sml-mode))
-(defalias 'run-sml 'sml-run)
+(unless (fboundp 'run-sml) (defalias 'run-sml 'sml-run))
(add-to-list 'auto-mode-alist '("\\.[Vv][Cc][Ff]\\'" . vcard-mode))
(add-to-list 'auto-mode-alist (cons (purecopy "\\.vcl\\'") 'vcl-mode))
(add-to-list 'auto-mode-alist '("\\.wy\\'" . wisitoken-grammar-mode))
-(defconst gnu-elpa--autoloads-table (["ace-window" ace-window-display-mode
ace-window ace-maximize-window ace-swap-window ace-delete-window
ace-select-window] ["ack" pcomplete/ag pcomplete/ack ack] ["adaptive-wrap"
adaptive-wrap-prefix-mode] ["adjust-parens" adjust-parens-mode] ["advice-patch"
advice-patch] ["aggressive-indent" global-aggressive-indent-mode
aggressive-indent-mode aggressive-indent-indent-region-and-on
aggressive-indent-indent-defun] ["all" all] ["arbitools" arbitools-mod [...]
+(defconst gnu-elpa--autoloads-table '(["ace-window" ace-window-display-mode
ace-window ace-maximize-window ace-swap-window ace-delete-window
ace-select-window] ["ack" pcomplete/ag pcomplete/ack ack] ["adaptive-wrap"
adaptive-wrap-prefix-mode] ["adjust-parens" adjust-parens-mode] ["advice-patch"
advice-patch] ["aggressive-indent" global-aggressive-indent-mode
aggressive-indent-mode aggressive-indent-indent-region-and-on
aggressive-indent-indent-defun] ["all" all] ["ampc" ampc ampc-on-p am [...]
+
+;; Local Variables:
+;; no-byte-compile: t
+;; version-control: never
+;; no-update-autoloads: t
+;; End:
+
(provide 'gnu-elpa-features)
;;; gnu-elpa-features.el ends here
diff --git a/gnu-elpa-maint.el b/gnu-elpa-maint.el
index 2541526..23d7b2b 100644
--- a/gnu-elpa-maint.el
+++ b/gnu-elpa-maint.el
@@ -58,50 +58,47 @@
(if (file-readable-p f) (insert-file-contents f)))
(goto-char (point-min))
(let ((autoloads ())
- (auto-modes ())
- (aliases ())
(forms ())
(others ()))
(condition-case nil
(while t
(pcase (read (current-buffer))
;; These are the main ones.
- (`(autoload ',f ,_ . ,extra)
- (push (cons f extra) autoloads))
- (`(add-to-list 'auto-mode-alist . ,args) (push args
auto-modes))
- (`(defalias ',f ,(or `',a `#',a)) (push (cons f a) aliases))
- ;; Entries we can just ignore.
- (`(add-to-list 'load-path . ,_) nil)
- ((and `(defvar ,v . ,_)
- (guard (string-match "-mode\\'" (symbol-name v))))
- nil)
- ;; Entries we could conceivably use, but it would take more
- ;; work to make use of them and/or the benefit is unclear.
- (`(if (fboundp 'register-definition-prefixes) . ,_) nil)
- (`(custom-autoload . ,_) nil)
- (`(eieio-defclass-autoload . ,_) nil)
- (`(cl-defstruct . ,_) nil)
- (`(,(or 'put 'function-put) ,_
- ',(or 'interactive-only 'lisp-indent-function
'doc-string-elt)
- . ,_)
- nil)
- ;;
+ (`(autoload ',f ,_ . ,extra) (push (cons f extra) autoloads))
(form (push form others))))
(end-of-file nil))
- ;; Check auto-modes
- (dolist (args auto-modes)
- (push `(add-to-list 'auto-mode-alist ,@args)
- (pcase (car args)
- ((and (or `'(,_ . ,f)
- `(cons ,_ ',f)
- `(cons ,_ #',f))
- (guard (assq f autoloads)))
- forms)
- (_ others))))
- ;; Check aliases.
- (pcase-dolist (`(,f . ,a) aliases)
- (push `(defalias ',f ',a)
- (if (assq a autoloads) forms others)))
+ (dolist (exp (prog1 others (setq others nil)))
+ (pcase exp
+ (`(add-to-list ',(or 'auto-mode-alist 'interpreter-mode-alist)
+ ,(or `'(,_ . ,f)
+ `(cons ,_ ',f)
+ `(cons ,_ #',f))
+ . ,_)
+ (push exp (if (assq f autoloads) forms others)))
+ (`(defalias ',f ,(or `',a `#',a) . ,_)
+ (push `(unless (fboundp ',f) ,exp)
+ (if (assq a autoloads) forms others)))
+ ;; Entries we can just ignore.
+ (`(add-to-list 'load-path . ,_) nil)
+ ((and `(defvar ,v . ,_)
+ (guard (string-match "-mode\\'" (symbol-name v))))
+ nil)
+ ;; Entries we could conceivably use, but it would take more
+ ;; work to make use of them and/or the benefit is unclear.
+ (`(if (fboundp 'register-definition-prefixes) . ,_) nil)
+ (`(custom-autoload . ,_) nil)
+ (`(eieio-defclass-autoload . ,_) nil)
+ (`(cl-defstruct . ,_) nil)
+ (`(,(or 'put 'function-put) ,_
+ ',(or 'interactive-only 'lisp-indent-function 'doc-string-elt)
+ . ,_)
+ nil)
+ ;;
+ (_ (push exp others))))
+ ;; FIXME: We should only autoload a few key entry points per package,
+ ;; so we arbitrarily limit the number of autoloads per package to 10.
+ ;; For packages "larger" than that, we need to figure out a way for
+ ;; the package to specify a subset of its autoloads to use here!
(if (> (length autoloads) 10)
(progn (message "Skipping package %s: too many autoloads (%d)" pkg
(length autoloads))
@@ -138,11 +135,15 @@
)))
(defun gnu-elpa--make-features ()
- (with-temp-file "gnu-elpa-features.el"
- (emacs-lisp-mode)
- (insert ";;; gnu-elpa-features.el --- Auto-generated autoloads -*-
lexical-binding:t -*-
+ (let (;; Make sure we can load this file without load-source-file-function.
+ (coding-system-for-write 'emacs-internal))
+ (with-temp-file "gnu-elpa-features.el"
+ (emacs-lisp-mode)
+ (insert ";;; gnu-elpa-features.el --- Auto-generated autoloads -*-
lexical-binding:t -*-
+
+;; ¡¡ This file is auto-generated by `gnu-elpa--make-features', DO NOT EDIT !!
-;; Copyright (C) 2020 Free Software Foundation, Inc.
+;; Copyright (C) 2020-" (format-time-string "%Y") " Free Software Foundation,
Inc.
;; Author: gnu-elpa-maint.el
@@ -163,32 +164,44 @@
;; Don't edit this file, it's auto-generated by `gnu-elpa--make-features'!
\n")
- (let ((auto-table nil)
- (allforms nil))
- (insert "(dolist (x '(")
- (dolist (pkg (gnu-elpa--pkgs))
- (pcase-let* (((map :autoloads :forms) (gnu-elpa--features-for-pkg
pkg)))
- (when autoloads
- (push (apply #'vector pkg (mapcar #'car autoloads))
- auto-table)
- (setf allforms (append forms allforms))
- (dolist (x autoloads)
- (prin1 x (current-buffer))
- (insert "\n")))))
- (insert "))
+ (let ((auto-table nil)
+ (allforms nil))
+ (insert "(dolist (x '(")
+ (dolist (pkg (gnu-elpa--pkgs))
+ (pcase-let* (((map :autoloads :forms) (gnu-elpa--features-for-pkg
pkg)))
+ (when autoloads
+ (push (apply #'vector pkg (mapcar #'car autoloads))
+ auto-table)
+ (setf allforms (append forms allforms))
+ (dolist (x autoloads)
+ (prin1 x (current-buffer))
+ (insert "\n")))))
+ (insert "))
(let ((f (car x)))
(unless (fboundp f)
(apply #'autoload f \"gnu-elpa\" (cdr x)))))\n")
- (dolist (form (nreverse allforms))
- (prin1 form (current-buffer))
- (insert "\n"))
- (prin1 `(defconst gnu-elpa--autoloads-table ,(nreverse auto-table))
- (current-buffer)))
- (insert "
+ (dolist (form (nreverse allforms))
+ (prin1 form (current-buffer))
+ (insert "\n"))
+ ;; FIXME: Actually `gnu-elpa--autoloads-table' doesn't need to be
+ ;; preloaded from `gnu-elpa-features' so it could be moved to
+ ;; another file!
+ (prin1 `(defconst gnu-elpa--autoloads-table ',(nreverse auto-table))
+ (current-buffer)))
+ ;; Use `\s' instead of a space character, so this code chunk is not
+ ;; mistaken for an actual file-local section of gnu-elpa-maint.el.
+ (insert "
+
+\;;\sLocal\sVariables:
+\;;\sno-byte-compile: t
+\;;\sversion-control: never
+\;;\sno-update-autoloads: t
+\;; End:
+
\(provide 'gnu-elpa-features)
\;;; gnu-elpa-features.el ends here\n")
- (indent-region (point-min) (point-max))
- ))
+ (indent-region (point-min) (point-max))
+ )))
(provide 'gnu-elpa-autoloads-make)
diff --git a/gnu-elpa-utils.el b/gnu-elpa-utils.el
new file mode 100644
index 0000000..6f148b8
--- /dev/null
+++ b/gnu-elpa-utils.el
@@ -0,0 +1,74 @@
+;;; gnu-elpa-utils.el --- Helper functions for `gnu-elpa' -*-
lexical-binding: t; -*-
+
+;; Copyright (C) 2020 Free Software Foundation, Inc.
+
+;; Author: Stefan Monnier <address@hidden>
+;; Keywords:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; Code:
+
+(require 'gnu-elpa-features)
+
+;;;###autoload (eval-after-load 'package
+;;;###autoload '(unless (assoc "gnu" package-archives)
+;;;###autoload (push '("gnu" . "https://elpa.gnu.org/packages/")
+;;;###autoload package-archives)))
+
+;;;###autoload ;; Skip load-source-file-function which would slow us down by
+;;;###autoload ;; a factor 2 (this assumes we were careful to save this file
+;;;###autoload ;; so it doesn't need any decoding).
+;;;###autoload (let ((load-source-file-function nil))
+;;;###autoload (require 'gnu-elpa-features nil 'noerror))
+
+(defun gnu-elpa--autoloaded-function ()
+ (let* ((bt (backtrace-frames))
+ ;; (bt-stash bt)
+ (trigger-function nil))
+ (while bt
+ (pcase-let ((`(\_ ,f . ,_) (pop bt)))
+ (when (and (symbolp f) (autoloadp (indirect-function f)))
+ (setq trigger-function f)
+ (setq bt nil))))
+ (unless trigger-function
+ (error "Can't find the autoload call!"))
+ trigger-function))
+
+(defun gnu-elpa--package (func)
+ "Return the package that provides function FUNC."
+ (let ((pkg nil))
+ (dolist (pkg-desc gnu-elpa--autoloads-table)
+ (mapc (lambda (f) (if (eq f func) (setq pkg (aref pkg-desc 0))))
pkg-desc))
+ pkg))
+
+(defun gnu-elpa--perform-autoload ()
+ "Prompt to install the package that provides the currently autoloaded
function.
+The relevant function is found by walking the stack until we find a function.
+Presumes we're in the process of calling an autoloaded function that's not
+yet loaded."
+ (let* ((f (gnu-elpa--autoloaded-function))
+ (pkg (gnu-elpa--package f)))
+ (unless (yes-or-no-p (format "Install package %s? " pkg))
+ (error "Abort!"))
+ ;; FIXME: These two initializations should be performed by
+ ;; `package-install'!
+ (unless (bound-and-true-p package--initialized) (package-initialize t))
+ (unless package-archive-contents (package-refresh-contents))
+ (package-install (intern pkg))))
+
+(provide 'gnu-elpa-utils)
+;;; gnu-elpa-utils.el ends here
diff --git a/gnu-elpa.el b/gnu-elpa.el
index e9f03c7..76266ff 100644
--- a/gnu-elpa.el
+++ b/gnu-elpa.el
@@ -28,31 +28,31 @@
;;;; FIXME/TODO:
;; - Allow packages more control over what is auto-predefined.
+;; - Don't just silently drop those packages with more than 10 autoloads.
;; - Allow more than `auto-mode-alist' and `autoload's, e.g. allow
;; new menu entries.
;; - Merge with `gnu-elpa-keyring-update'?
;;; Code:
-;;;###autoload (unless (assoc "gnu" package-archives)
-;;;###autoload (push '("gnu" . "https://elpa.gnu.org/packages/")
-;;;###autoload package-archives))
+;; ¡¡ BEWARE !! Don't try to load this file via `load' or `require'!
+;; It's only used as a kind of trigger to find the function that is being
+;; autoloaded.
+
+;; This is done because:
+;; - We want `gnu-elpa' to use `autoload', so that a subsequent call to
+;; `autoload' performed by the actual real package (if/hen it's installed)
+;; will override our pseudo-autoload.
+;; - We don't want to use a separate file for every advertized package,
+;; so we pretend all the functions get "autoloaded" from `gnu-elpa.el'.
;; This file is not meant to be `require'd but to be loaded in response
;; to calling a function (i.e. via autoload) and it will find the package
;; that provides this function and suggest installing the package.
;;(provide 'gnu-elpa)
-(let* ((bt (backtrace-frames))
- (bt-stash bt)
- (trigger-function nil))
- (while bt
- (pcase-let ((`(\_ ,f . ,_) (pop bt)))
- (when (and (symbolp f) (autoloadp (indirect-function f)))
- (setq trigger-function f)
- (setq bt nil))))
- (unless trigger-function
- (error "Can't find the autoload call!"))
- (message "Autoloading %S" trigger-function))
+(require 'gnu-elpa-utils)
+
+(gnu-elpa--perform-autoload)
;;; gnu-elpa.el ends here