[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Progress on merging use-package?

From: Stefan Monnier
Subject: Re: Progress on merging use-package?
Date: Sat, 24 Sep 2022 11:42:12 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

> I still argue that adding it to GNU ELPA would be a good fist step, just

Indeed.  Last I heard, the copyright situation was cleared.  I understand
the desire is to add it to core, but seeing how it hasn't happened,
I'm strongly in favor of adding it to GNU ELPA.

Doing that would not make it harder to move it into core, in any case.

For good measure, I include a patch with my current cosmetic changes to
use-package :-)

diff --git a/.gitignore b/.gitignore
index c0749c9a3b..a406c44fa5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,6 @@
@@ -10,3 +10,5 @@
diff --git a/bind-key.el b/bind-key.el
index 17e161cd72..cdb1cc35b5 100644
--- a/bind-key.el
+++ b/bind-key.el
@@ -109,20 +109,17 @@
 (defcustom bind-key-column-widths '(18 . 40)
   "Width of columns in `describe-personal-keybindings'."
-  :type '(cons integer integer)
-  :group 'bind-key)
+  :type '(cons integer integer))
 (defcustom bind-key-segregation-regexp
   "\\`\\(\\(C-[chx] \\|M-[gso] \\)\\([CM]-\\)?\\|.+-\\)"
   "Regular expression used to divide key sets in the output from
-  :type 'regexp
-  :group 'bind-key)
+  :type 'regexp)
 (defcustom bind-key-describe-special-forms nil
   "If non-nil, extract docstrings from lambdas, closures and keymaps if 
-  :type 'boolean
-  :group 'bind-key)
+  :type 'boolean)
 ;; Create override-global-mode to force key remappings
diff --git a/doc/setup-ox-hugo.el b/doc/setup-ox-hugo.el
index 7b6d521b95..dc2cc827a6 100644
--- a/doc/setup-ox-hugo.el
+++ b/doc/setup-ox-hugo.el
@@ -1,10 +1,13 @@
-  -*- lexical-binding: t; -*-
+;;  -*- lexical-binding: t; -*-
 ;; Time-stamp: <2017-12-19 16:49:24 kmodi>
 ;; Setup to export Org files to Hugo-compatible Markdown using
 ;; `ox-hugo' in an "emacs -Q" environment.
+;; FIXME: Merely loading a file should never have such side effects;
+;; Those settings should be moved to a function.
 ;; Some sane settings
 (setq-default require-final-newline t)
 (setq-default indent-tabs-mode nil)
@@ -166,7 +169,8 @@ Emacs installation.  If Emacs is installed using
 --prefix=\"${PREFIX_DIR}\" this value would typically be
   (when ox-hugo-test-setup-verbose
-    (message "ox-hugo-default-lisp-directory: %S" 
+    (message "ox-hugo-default-lisp-directory: %S"
+             ox-hugo-default-lisp-directory))
   (with-eval-after-load 'package
     ;; Remove Org that ships with Emacs from the `load-path'.
@@ -196,15 +200,14 @@ Emacs installation.  If Emacs is installed using
   ;; Prevent prompts like:
   ;;   Non-existent agenda file
-  (defun org-check-agenda-file (file))
+  (defun org-check-agenda-file (_file) nil)
-  (let (ob-lang-alist)
-    (add-to-list 'ob-lang-alist '(emacs-lisp . t))
-    (add-to-list 'ob-lang-alist '(org . t))
+  (let ((ob-lang-alist '((org . t)
+                         (emacs-lisp . t))))
     (org-babel-do-load-languages 'org-babel-load-languages ob-lang-alist))
   (with-eval-after-load 'ob-core
-    (defun ox-hugo-org-confirm-babel-evaluate-fn (lang body)
+    (defun ox-hugo-org-confirm-babel-evaluate-fn (lang _body)
       "Mark `org' as a safe language for ox-hugo tests and docs."
       (let* ((ob-enabled-langs '("org"))
              (ob-enabled-langs-re (regexp-opt ob-enabled-langs 'words))
diff --git a/use-package-bind-key.el b/use-package-bind-key.el
index 9642f31175..b9a0dde10c 100644
--- a/use-package-bind-key.el
+++ b/use-package-bind-key.el
@@ -120,18 +120,18 @@ deferred until the prefix key sequence is pressed."
 ;;;; :bind, :bind*
-(defalias 'use-package-normalize/:bind 'use-package-normalize-binder)
+(defalias 'use-package-normalize/:bind #'use-package-normalize-binder)
-(defalias 'use-package-normalize/:bind* 'use-package-normalize-binder)
+(defalias 'use-package-normalize/:bind* #'use-package-normalize-binder)
 ;; jww (2017-12-07): This is too simplistic. It will fail to determine
 ;; autoloads in this situation:
 ;;   (use-package foo
 ;;     :bind (:map foo-map (("C-a" . func))))
-(defalias 'use-package-autoloads/:bind 'use-package-autoloads-mode)
+(defalias 'use-package-autoloads/:bind #'use-package-autoloads-mode)
-(defalias 'use-package-autoloads/:bind* 'use-package-autoloads-mode)
+(defalias 'use-package-autoloads/:bind* #'use-package-autoloads-mode)
 (defun use-package-handler/:bind
@@ -150,9 +150,9 @@ deferred until the prefix key sequence is pressed."
 ;;;; :bind-keymap, :bind-keymap*
-(defalias 'use-package-normalize/:bind-keymap 'use-package-normalize-binder)
+(defalias 'use-package-normalize/:bind-keymap #'use-package-normalize-binder)
-(defalias 'use-package-normalize/:bind-keymap* 'use-package-normalize-binder)
+(defalias 'use-package-normalize/:bind-keymap* #'use-package-normalize-binder)
 (defun use-package-handler/:bind-keymap
diff --git a/use-package-chords.el b/use-package-chords.el
index cf390dbe59..d388a92941 100644
--- a/use-package-chords.el
+++ b/use-package-chords.el
@@ -24,10 +24,10 @@
 (require 'bind-chord)
-(defalias 'use-package-autoloads/:chords 'use-package-autoloads-mode)
+(defalias 'use-package-autoloads/:chords #'use-package-autoloads-mode)
-(defalias 'use-package-normalize/:chords 'use-package-normalize-binder)
+(defalias 'use-package-normalize/:chords #'use-package-normalize-binder)
 (defun use-package-handler/:chords (name _keyword arg rest state)
diff --git a/use-package-core.el b/use-package-core.el
index dc9b77bc5b..f5e267c7bd 100644
--- a/use-package-core.el
+++ b/use-package-core.el
@@ -113,8 +113,7 @@ changing where you had inserted a new keyword earlier.
 Note that `:disabled' is special in this list, as it causes
 nothing at all to happen, even if the rest of the use-package
 declaration is incorrect."
-  :type '(repeat symbol)
-  :group 'use-package)
+  :type '(repeat symbol))
 (defcustom use-package-deferring-keywords
@@ -126,22 +125,19 @@ they only imply deferred loading if they reference actual
 function symbols that can be autoloaded from the module; whereas
 the default keywords provided here always defer loading unless
 otherwise requested."
-  :type '(repeat symbol)
-  :group 'use-package)
+  :type '(repeat symbol))
 (defcustom use-package-ignore-unknown-keywords nil
   "If non-nil, issue warning instead of error when unknown
 keyword is encountered. The unknown keyword and its associated
 arguments will be ignored in the `use-package' expansion."
-  :type 'boolean
-  :group 'use-package)
+  :type 'boolean)
 (defcustom use-package-use-theme t
   "If non-nil, use a custom theme to avoid saving :custom
 variables twice (once in the Custom file, once in the use-package
-  :type 'boolean
-  :group 'use-package)
+  :type 'boolean)
 (defcustom use-package-verbose nil
   "Whether to report about loading and configuration details.
@@ -152,26 +148,22 @@ then the expanded macros do their job silently."
   :type '(choice (const :tag "Quiet, without catching errors" errors)
                  (const :tag "Quiet" nil)
                  (const :tag "Verbose" t)
-                 (const :tag "Debug" debug))
-  :group 'use-package)
+                 (const :tag "Debug" debug)))
 (defcustom use-package-check-before-init nil
   "If non-nil, check that package exists before executing its `:init' block.
 This check is performed by calling `locate-library'."
-  :type 'boolean
-  :group 'use-package)
+  :type 'boolean)
 (defcustom use-package-always-defer nil
   "If non-nil, assume `:defer t' unless `:demand' is used.
 See also `use-package-defaults', which uses this value."
-  :type 'boolean
-  :group 'use-package)
+  :type 'boolean)
 (defcustom use-package-always-demand nil
   "If non-nil, assume `:demand t' unless `:defer' is used.
 See also `use-package-defaults', which uses this value."
-  :type 'boolean
-  :group 'use-package)
+  :type 'boolean)
 (defcustom use-package-defaults
   '(;; this '(t) has special meaning; see `use-package-handler/:config'
@@ -214,8 +206,7 @@ attempted."
                         ,@(mapcar #'(lambda (k) (list 'const k))
                 (choice :tag "Default value" sexp function)
-                (choice :tag "Enable if non-nil" sexp function)))
-  :group 'use-package)
+                (choice :tag "Enable if non-nil" sexp function))))
 (defcustom use-package-merge-key-alist
   '((:if    . (lambda (new old) `(and ,new ,old)))
@@ -238,22 +229,19 @@ handler is called only once."
                         ,@(mapcar #'(lambda (k) (list 'const k))
                         (const :tag "Any" t))
-                function))
-  :group 'use-package)
+                function)))
 (defcustom use-package-hook-name-suffix "-hook"
   "Text append to the name of hooks mentioned by :hook.
 Set to nil if you don't want this to happen; it's only a
-  :type '(choice string (const :tag "No suffix" nil))
-  :group 'use-package)
+  :type '(choice string (const :tag "No suffix" nil)))
 (defcustom use-package-minimum-reported-time 0.1
   "Minimal load time that will be reported.
 Note that `use-package-verbose' has to be set to a non-nil value
 for anything to be reported at all."
-  :type 'number
-  :group 'use-package)
+  :type 'number)
 (defcustom use-package-inject-hooks nil
   "If non-nil, add hooks to the `:init' and `:config' sections.
@@ -278,8 +266,7 @@ NOTE: If the `pre-init' hook return a nil value, that 
 user-supplied configuration is not evaluated, so be certain to
 return t if you only wish to add behavior to what the user had
-  :type 'boolean
-  :group 'use-package)
+  :type 'boolean)
 (defcustom use-package-expand-minimally nil
   "If non-nil, make the expanded code as minimal as possible.
@@ -293,8 +280,7 @@ The main advantage to this variable is that, if you know 
 configuration works, it will make the byte-compiled file as
 minimal as possible. It can also help with reading macro-expanded
 definitions, to understand the main intent of what's happening."
-  :type 'boolean
-  :group 'use-package)
+  :type 'boolean)
 (defcustom use-package-form-regexp-eval
   `(concat ,(eval-when-compile
@@ -306,8 +292,7 @@ definitions, to understand the main intent of what's 
   "Sexp providing regexp for finding use-package forms in user files.
 This is used by `use-package-jump-to-package-form' and
-  :type 'sexp
-  :group 'use-package)
+  :type 'sexp)
 (defcustom use-package-enable-imenu-support nil
   "If non-nil, cause imenu to see `use-package' declarations.
@@ -325,8 +310,7 @@ Must be set before loading use-package."
           `(setq lisp-imenu-generic-expression
                  (remove (list "Packages" ,use-package-form-regexp-eval 2)
-      (set-default sym value))
-  :group 'use-package)
+      (set-default sym value)))
 (defconst use-package-font-lock-keywords
   '(("(\\(use-package\\)\\_>[ \t']*\\(\\(?:\\sw\\|\\s_\\)+\\)?"
@@ -341,8 +325,7 @@ View the statistical report using `use-package-report'. 
Note that
 if this option is enabled, you must require `use-package' in your
 user init file at loadup time, or you will see errors concerning
 undefined variables."
-  :type 'boolean
-  :group 'use-package)
+  :type 'boolean)
 (defvar use-package-statistics (make-hash-table))
@@ -382,7 +365,7 @@ convert it to a string and return that."
 (defun use-package-normalize-regex (re)
   "Given some regexp-like thing in RE, resolve to a regular expression."
-   ((and (listp re) (eq (car re) 'rx)) (eval re))
+   ((and (listp re) (eq (car re) 'rx)) (eval re t))
    ((stringp re) re)
    (t (error "Not recognized as regular expression: %s" re))))
@@ -619,13 +602,13 @@ extending any keys already present."
       (when (let ((func (nth 2 spec)))
               (if (and func (functionp func))
                   (funcall func name args)
-                (eval func)))
+                (eval func t)))
         (setq args (use-package-plist-maybe-put
                     args (nth 0 spec)
                     (let ((func (nth 1 spec)))
                       (if (and func (functionp func))
                           (funcall func name args)
-                        (eval func)))))))
+                        (eval func t)))))))
     ;; Determine any autoloads implied by the keywords used.
     (let ((iargs args)
@@ -845,7 +828,7 @@ The argument LABEL is ignored."
    ((and arg (or (use-package-non-nil-symbolp arg) (functionp arg)))
     (let ((value (use-package-normalize-value label arg)))
-      (use-package-normalize-paths label (eval value))))
+      (use-package-normalize-paths label (eval value t))))
    ((stringp arg)
     (let ((path (if (file-name-absolute-p arg)
@@ -853,7 +836,8 @@ The argument LABEL is ignored."
       (list path)))
    ((and (not recursed) (listp arg) (listp (cdr arg)))
     (mapcar #'(lambda (x)
-                (car (use-package-normalize-paths label x t))) arg))
+                (car (use-package-normalize-paths label x t)))
+            arg))
      (concat label " wants a directory path, or list of paths")))))
@@ -1115,17 +1099,17 @@ meaning:
   (use-package-only-one (symbol-name keyword) args
-(defalias 'use-package-normalize/:if 'use-package-normalize-test)
+(defalias 'use-package-normalize/:if #'use-package-normalize-test)
 (defun use-package-handler/:if (name _keyword pred rest state)
   (let ((body (use-package-process-keywords name rest state)))
     `((when ,pred ,@body))))
-(defalias 'use-package-normalize/:when 'use-package-normalize-test)
+(defalias 'use-package-normalize/:when #'use-package-normalize-test)
-(defalias 'use-package-handler/:when 'use-package-handler/:if)
+(defalias 'use-package-handler/:when #'use-package-handler/:if)
-(defalias 'use-package-normalize/:unless 'use-package-normalize-test)
+(defalias 'use-package-normalize/:unless #'use-package-normalize-test)
 (defun use-package-handler/:unless (name _keyword pred rest state)
   (let ((body (use-package-process-keywords name rest state)))
@@ -1133,7 +1117,7 @@ meaning:
 ;;;; :requires
-(defalias 'use-package-normalize/:requires 'use-package-normalize-symlist)
+(defalias 'use-package-normalize/:requires #'use-package-normalize-symlist)
 (defun use-package-handler/:requires (name _keyword requires rest state)
   (let ((body (use-package-process-keywords name rest state)))
@@ -1160,28 +1144,28 @@ meaning:
 ;;;; :no-require
-(defalias 'use-package-normalize/:no-require 'use-package-normalize-predicate)
+(defalias 'use-package-normalize/:no-require #'use-package-normalize-predicate)
 (defun use-package-handler/:no-require (name _keyword _arg rest state)
   (use-package-process-keywords name rest state))
 ;;;; :defines
-(defalias 'use-package-normalize/:defines 'use-package-normalize-symlist)
+(defalias 'use-package-normalize/:defines #'use-package-normalize-symlist)
 (defun use-package-handler/:defines (name _keyword _arg rest state)
   (use-package-process-keywords name rest state))
 ;;;; :functions
-(defalias 'use-package-normalize/:functions 'use-package-normalize-symlist)
+(defalias 'use-package-normalize/:functions #'use-package-normalize-symlist)
 (defun use-package-handler/:functions (name _keyword _arg rest state)
   (use-package-process-keywords name rest state))
 ;;;; :preface
-(defalias 'use-package-normalize/:preface 'use-package-normalize-forms)
+(defalias 'use-package-normalize/:preface #'use-package-normalize-forms)
 (defun use-package-handler/:preface (name _keyword arg rest state)
   (let ((body (use-package-process-keywords name rest state)))
@@ -1245,32 +1229,32 @@ meaning:
 ;;;; :interpreter
-(defalias 'use-package-normalize/:interpreter 'use-package-normalize-mode)
-(defalias 'use-package-autoloads/:interpreter 'use-package-autoloads-mode)
+(defalias 'use-package-normalize/:interpreter #'use-package-normalize-mode)
+(defalias 'use-package-autoloads/:interpreter #'use-package-autoloads-mode)
 (defun use-package-handler/:interpreter (name _keyword arg rest state)
   (use-package-handle-mode name 'interpreter-mode-alist arg rest state))
 ;;;; :mode
-(defalias 'use-package-normalize/:mode 'use-package-normalize-mode)
-(defalias 'use-package-autoloads/:mode 'use-package-autoloads-mode)
+(defalias 'use-package-normalize/:mode #'use-package-normalize-mode)
+(defalias 'use-package-autoloads/:mode #'use-package-autoloads-mode)
 (defun use-package-handler/:mode (name _keyword arg rest state)
   (use-package-handle-mode name 'auto-mode-alist arg rest state))
 ;;;; :magic
-(defalias 'use-package-normalize/:magic 'use-package-normalize-mode)
-(defalias 'use-package-autoloads/:magic 'use-package-autoloads-mode)
+(defalias 'use-package-normalize/:magic #'use-package-normalize-mode)
+(defalias 'use-package-autoloads/:magic #'use-package-autoloads-mode)
 (defun use-package-handler/:magic (name _keyword arg rest state)
   (use-package-handle-mode name 'magic-mode-alist arg rest state))
 ;;;; :magic-fallback
-(defalias 'use-package-normalize/:magic-fallback 'use-package-normalize-mode)
-(defalias 'use-package-autoloads/:magic-fallback 'use-package-autoloads-mode)
+(defalias 'use-package-normalize/:magic-fallback #'use-package-normalize-mode)
+(defalias 'use-package-autoloads/:magic-fallback #'use-package-autoloads-mode)
 (defun use-package-handler/:magic-fallback (name _keyword arg rest state)
   (use-package-handle-mode name 'magic-fallback-mode-alist arg rest state))
@@ -1300,7 +1284,7 @@ meaning:
            (intern (concat (symbol-name name) "-mode")))
          label arg))))
-(defalias 'use-package-autoloads/:hook 'use-package-autoloads-mode)
+(defalias 'use-package-autoloads/:hook #'use-package-autoloads-mode)
 (defun use-package-handler/:hook (name _keyword args rest state)
   "Generate use-package custom keyword code."
@@ -1327,7 +1311,7 @@ meaning:
 ;;;; :commands
-(defalias 'use-package-normalize/:commands 'use-package-normalize-symlist)
+(defalias 'use-package-normalize/:commands #'use-package-normalize-symlist)
 (defun use-package-handler/:commands (name _keyword arg rest state)
@@ -1349,7 +1333,7 @@ meaning:
 ;;;; :defer
-(defalias 'use-package-normalize/:defer 'use-package-normalize-predicate)
+(defalias 'use-package-normalize/:defer #'use-package-normalize-predicate)
 (defun use-package-handler/:defer (name _keyword arg rest state)
   (let ((body (use-package-process-keywords name rest state)))
@@ -1420,7 +1404,7 @@ no keyword implies `:all'."
 ;;;; :demand
-(defalias 'use-package-normalize/:demand 'use-package-normalize-predicate)
+(defalias 'use-package-normalize/:demand #'use-package-normalize-predicate)
 (defun use-package-handler/:demand (name _keyword _arg rest state)
   (use-package-process-keywords name rest state))
@@ -1499,7 +1483,7 @@ no keyword implies `:all'."
 ;;;; :init
-(defalias 'use-package-normalize/:init 'use-package-normalize-forms)
+(defalias 'use-package-normalize/:init #'use-package-normalize-forms)
 (defun use-package-handler/:init (name _keyword arg rest state)
@@ -1534,7 +1518,7 @@ no keyword implies `:all'."
 ;;;; :config
-(defalias 'use-package-normalize/:config 'use-package-normalize-forms)
+(defalias 'use-package-normalize/:config #'use-package-normalize-forms)
 (defun use-package-handler/:config (name _keyword arg rest state)
   (let* ((body (use-package-process-keywords name rest state))
diff --git a/use-package-ensure.el b/use-package-ensure.el
index cb31b4b7dd..4c12ff4346 100644
--- a/use-package-ensure.el
+++ b/use-package-ensure.el
@@ -47,14 +47,12 @@
 (defcustom use-package-always-ensure nil
   "Treat every package as though it had specified using `:ensure SEXP'.
 See also `use-package-defaults', which uses this value."
-  :type 'sexp
-  :group 'use-package-ensure)
+  :type 'sexp)
 (defcustom use-package-always-pin nil
   "Treat every package as though it had specified using `:pin SYM'.
 See also `use-package-defaults', which uses this value."
-  :type 'symbol
-  :group 'use-package-ensure)
+  :type 'symbol)
 (defcustom use-package-ensure-function 'use-package-ensure-elpa
   "Function that ensures a package is installed.
@@ -71,8 +69,7 @@ This function should return non-nil if the package is 
 The default value uses package.el to install the package."
   :type '(choice (const :tag "package.el" use-package-ensure-elpa)
-                 (function :tag "Custom"))
-  :group 'use-package-ensure)
+                 (function :tag "Custom")))
 ;;;; :pin
@@ -124,7 +121,7 @@ manually updated package."
     ;; Pinning should occur just before ensuring
     ;; See `use-package-handler/:ensure'.
     (if (bound-and-true-p byte-compile-current-file)
-        (eval pin-form)              ; Eval when byte-compiling,
+        (eval pin-form t)            ; Eval when byte-compiling,
       (push pin-form body))          ; or else wait until runtime.
diff --git a/use-package-jump.el b/use-package-jump.el
index 4044ad1656..186aeb4e46 100644
--- a/use-package-jump.el
+++ b/use-package-jump.el
@@ -68,7 +68,7 @@ instead."
           (goto-char (point-min))
           (setq location
-                 (format (eval use-package-form-regexp-eval) package) nil t)))
+                 (format (eval use-package-form-regexp-eval t) package) nil 
         (if (null location)
             (message "No use-package form found.")
           (goto-char location)
diff --git a/use-package-lint.el b/use-package-lint.el
index c6e7c3c0ce..dde9b8f7c9 100644
--- a/use-package-lint.el
+++ b/use-package-lint.el
@@ -69,7 +69,7 @@ with the specified `:load-path' the module cannot be found."
     (goto-char (point-min))
-    (let ((re (eval use-package-form-regexp-eval)))
+    (let ((re (eval use-package-form-regexp-eval t)))
       (while (re-search-forward re nil t)
         (goto-char (match-beginning 0))
         (let ((decl (read (current-buffer))))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]