From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 27 16:19:47 2025 Received: (at submit) by debbugs.gnu.org; 27 Jul 2025 20:19:47 +0000 Received: from localhost ([127.0.0.1]:52000 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ug7qS-00081x-WF for submit@debbugs.gnu.org; Sun, 27 Jul 2025 16:19:47 -0400 Received: from lists.gnu.org ([2001:470:142::17]:56098) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ug7qP-000811-2a for submit@debbugs.gnu.org; Sun, 27 Jul 2025 16:19:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ug7ps-0006yc-8w for bug-gnu-emacs@gnu.org; Sun, 27 Jul 2025 16:19:10 -0400 Received: from mail-oo1-xc44.google.com ([2607:f8b0:4864:20::c44]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ug7po-00023t-5M for bug-gnu-emacs@gnu.org; Sun, 27 Jul 2025 16:19:08 -0400 Received: by mail-oo1-xc44.google.com with SMTP id 006d021491bc7-615950642d9so2086704eaf.1 for ; Sun, 27 Jul 2025 13:19:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753647541; x=1754252341; darn=gnu.org; h=mime-version:message-id:date:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=8f/tEx1e+pTO6nGqlb4mfg0oYP8QntSIgP5q4dY/KhY=; b=RyRJD4iqfBwnhCyXwDjF20C3aWYtvMY/aG4kqXBeQrvKHbdYRf27DtcVL3YDXescZf PycJCnTcUwvxjjcANH7v9GWqulei7v8jJVLS8ze4EeeDgzikC9AqrLCfN/YvflZ65M// jRUib9xpB/7r+p2JlhtgmI0AU84adABklm/ckSN8GTkLoIdib7YwWY99n9dJM57cj7N+ mLfBD+XPZAvyj3wkUwqQKgm+CWNNdJZvbTCOSSKZ60GkeViibW4k4NXhLVKc5EM8gp6T VJnc9ZKHFR/hOFVYN3dJky84Yfge6agdrwjPKLToAutXdZqNYRdy2/wB3qxhmtg4EWwj rQRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753647541; x=1754252341; h=mime-version:message-id:date:subject:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=8f/tEx1e+pTO6nGqlb4mfg0oYP8QntSIgP5q4dY/KhY=; b=uyC9DWAS12Kloz2QXKnFcSbL0i4wP6Odv+G5rMbbS+/hDrT9QfumZJjqeNpFqE93rb jLfrl9bTn/c+p9Obwlkzu5ojYY08DXEATyNASIXpEWIabU1v65HQTn2q3d/HkCqyLxI7 dPhOW5WX3yB/sdJrOjyZz78dCqWFqx6okqQ3N9p3pHeaOSH8SVoD77HcKT6akjCakMi8 uSkYN8Uoj/XHjgLoI00aixYBiaIp8yXBSvLSB1iKwrxQb+oGKHFQ9RL4GxGofLAPsM20 shPV2v8zLCLSzLZ8gFOHpny0E1vaNCJqGi5NBchVTHJdLVk97Jf26EmxcdrmwSfNTTrQ HB4Q== X-Gm-Message-State: AOJu0Yx9eY+7mcElk8Z5ma8kVizrHbQsIyYVf3dPWBW3mBzqrtMF7dBp JImoKLmrXRdzCZwdhjzu4CK3EN3ErvNmSyi3m5cubJiYNtn362XyWqxbCX57VhjN X-Gm-Gg: ASbGncviIrZQYl4O3BtnGaafk9TX9s0y2RP+eaS6vn3Ada5sBmnQVZMxtQH7frkvxi1 FKUwxWCeYZzdnkId8vgLrPrdBTrHSegQgkjnoarul+cxyqt41OfHbFRVrodiZmm9J0PijEkkwDD VzmCMJZS6BAcueRZSsZkqFO0zPEICqDDFiufBwoFagnWM7fUG69oTBEIxa4vSxG4xG1KPH1I9wa ieC3fopArezYzGtuVyMdl7/BjWfprnCFFoxxNsaT/4gqFbaELqUB6ac3UrRyA4IKPjI35UILMC3 VNPQ8j0wHrHkbC5brNuoBjFPOMSQC4DMTddLObHzvzLsq0KDST7dUaQ1WJJSPYkQQ6HQ5Wz+tb5 4B73dV/29U19Rc5M= X-Google-Smtp-Source: AGHT+IG8YAE/E1lB+LdVUpFFPu8n6wjk51hMtczA/1LqKwHM09OR+h30aAEjqKT9zyEcTXyLJeMwcg== X-Received: by 2002:a05:6871:9d87:b0:2cc:3e39:7352 with SMTP id 586e51a60fabf-30701ace85dmr6149078fac.18.1753647540607; Sun, 27 Jul 2025 13:19:00 -0700 (PDT) Received: from fedora ([189.215.162.117]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-74147f4afacsm846033a34.10.2025.07.27.13.18.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 13:18:59 -0700 (PDT) From: =?utf-8?Q?Elijah_Gabe_P=C3=A9rez?= To: bug-gnu-emacs@gnu.org Subject: [PATCH] Add new optional keywords to use-package X-Debbugs-Cc: John Wiegley , Eli Zaretskii Date: Sun, 27 Jul 2025 14:18:57 -0600 Message-ID: <87wm7te6a6.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::c44; envelope-from=eg642616@gmail.com; helo=mail-oo1-xc44.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.2 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Tags: patch As discussed in https://lists.gnu.org/archive/html/emacs-devel/2025-07/msg00354.html This patch add new optional keywords to use-package, most of them are inspired by suggestions from use-package bug-tracker on github Content analysis details: (1.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2001:470:142:0:0:0:0:17 listed in] [list.dnswl.org] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (eg642616[at]gmail.com) -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (eg642616[at]gmail.com) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.2 (/) --=-=-= Content-Type: text/plain Tags: patch As discussed in https://lists.gnu.org/archive/html/emacs-devel/2025-07/msg00354.html This patch add new optional keywords to use-package, most of them are inspired by suggestions from use-package bug-tracker on github This includes following keywords: * :advice Add or remove function advices. * :custom-face* Like :custom-face but override the face specs. This closes bug#77928 dilemma. * :defvar-keymap Define a new keymap or override an existent one. * :doc Document the use-package declaration instead using comments. * :tag Like :doc, but for categorizing. (This and :doc does nothing) * :emacs<, :emacs<=, :emacs=, :emacs>, :emacs>=, shorthand for `:if (version...)` * :hook-suffix Changes `use-package-hook-name-suffix' value only in the current use-package declaration. * :hook+ Like default :hook, but allows to set the hook depth and set multiple functions in the hook (or for each hook). Although I tried to make it compatible with :hook, there may be some things I missed, so I decided to put it separately instead of merging it with :hook. In addition, its syntax is more complex compared to :hook. * :local-set Bind variables locally when entering to a mode or to a hook(s). An alternative to `:hook (hook . (lambda () (setq-local ...)))` * :setopt Like :custom, but can also bind plain variables. This uses the `setopt` function for bind the variables. * :which-key-replacement A simple way to set which-key replacements. --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Add-new-optional-keywords-to-use-package.patch >From 356eef67922b2a4339ccde858e0bc1ede9947f54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?El=C3=ADas=20Gabriel=20P=C3=A9rez?= Date: Sat, 26 Jul 2025 22:43:38 -0600 Subject: [PATCH] Add new optional keywords to use-package This includes new optional keywords to use-packages, most of them are intended to be used for a more advanced customization, thus they are not loaded. (bug#) * lisp/use-package/use-package-core.el: Add new keywords to keywords list. * lisp/use-package/use-package-x/use-package-x-advice.el: * lisp/use-package/use-package-x/use-package-x-custom-face*.el: * lisp/use-package/use-package-x/use-package-x-defvar-keymap.el: * lisp/use-package/use-package-x/use-package-x-docs.el: * lisp/use-package/use-package-x/use-package-x-emacs-versions.el: * lisp/use-package/use-package-x/use-package-x-hook+.el: * lisp/use-package/use-package-x/use-package-x-local-set.el: * lisp/use-package/use-package-x/use-package-x-setopt.el: * lisp/use-package/use-package-x/use-package-x-which-key-replacement.el: New files. --- lisp/use-package/use-package-core.el | 16 ++ .../use-package-x/use-package-x-advice.el | 78 +++++++ .../use-package-x-custom-face*.el | 56 +++++ .../use-package-x-defvar-keymap.el | 77 +++++++ .../use-package-x/use-package-x-docs.el | 66 ++++++ .../use-package-x-emacs-versions.el | 100 +++++++++ .../use-package-x/use-package-x-hook+.el | 211 ++++++++++++++++++ .../use-package-x/use-package-x-local-set.el | 91 ++++++++ .../use-package-x/use-package-x-setopt.el | 72 ++++++ .../use-package-x-which-key-replacement.el | 126 +++++++++++ 10 files changed, 893 insertions(+) create mode 100644 lisp/use-package/use-package-x/use-package-x-advice.el create mode 100644 lisp/use-package/use-package-x/use-package-x-custom-face*.el create mode 100644 lisp/use-package/use-package-x/use-package-x-defvar-keymap.el create mode 100644 lisp/use-package/use-package-x/use-package-x-docs.el create mode 100644 lisp/use-package/use-package-x/use-package-x-emacs-versions.el create mode 100644 lisp/use-package/use-package-x/use-package-x-hook+.el create mode 100644 lisp/use-package/use-package-x/use-package-x-local-set.el create mode 100644 lisp/use-package/use-package-x/use-package-x-setopt.el create mode 100644 lisp/use-package/use-package-x/use-package-x-which-key-replacement.el diff --git a/lisp/use-package/use-package-core.el b/lisp/use-package/use-package-core.el index 65b9485b4e3..b0e2d699507 100644 --- a/lisp/use-package/use-package-core.el +++ b/lisp/use-package/use-package-core.el @@ -77,22 +77,33 @@ use-package-keywords :defines :functions :preface + :hook-suffix :if :when :unless + :emacs< :emacs<= :emacs= + :emacs> :emacs>= :vc :no-require :catch :after + :setopt + :local-set :custom :custom-face + :custom-face* :bind :bind* :bind-keymap :bind-keymap* + :defvar-keymap + :which-key-replacement + :advice :interpreter :mode :magic :magic-fallback :hook + :hook+ + :doc :tag ;; Any other keyword that also declares commands to be autoloaded (such as ;; :bind) must appear before this keyword. :commands @@ -236,6 +247,11 @@ use-package-defaults (defcustom use-package-merge-key-alist '((:if . (lambda (new old) `(and ,new ,old))) + (:emacs< . (lambda (new old) `(and ,new ,old))) + (:emacs<= . (lambda (new old) `(and ,new ,old))) + (:emacs= . (lambda (new old) `(and ,new ,old))) + (:emacs> . (lambda (new old) `(and ,new ,old))) + (:emacs>= . (lambda (new old) `(and ,new ,old))) (:after . (lambda (new old) `(:all ,new ,old))) (:defer . (lambda (new old) old)) (:bind . (lambda (new old) (append new (list :break) old)))) diff --git a/lisp/use-package/use-package-x/use-package-x-advice.el b/lisp/use-package/use-package-x/use-package-x-advice.el new file mode 100644 index 00000000000..46605934f65 --- /dev/null +++ b/lisp/use-package/use-package-x/use-package-x-advice.el @@ -0,0 +1,78 @@ +;;; use-package-x-advice.el --- :advice keyword definitions -*- lexical-binding: t; -*- + +;; Copyright (C) 2025 Free Software Foundation, Inc. + +;; Author: Elias G. Perez + +;; 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 . + +;;; Commentary: +;; +;; This file provides the following extra keyword for +;; `use-package': +;; +;; * :advice +;; Add or remove function advices. +;; This is a shorthand for ":init (advice-[add|remove] ...)" +;; +;; :advice +;; (:add my-function other-function) +;; (:remove other-function my-function) +;; +;; To use it load this library in your init file: +;; +;; (require 'use-package-x-advice) + +;;; Code: + +;;; Requires +(require 'cl-lib) +(require 'use-package) + + + +;;; Functions + +;;;###autoload +(defun use-package-normalize/:advice (_name keyword args) + (mapcar + (lambda (elt) + (use-package-as-one (symbol-name keyword) (list elt) + (lambda (label arg) + (unless (and (consp arg) (memq (car arg) '(:add :remove))) + (use-package-error + (concat label + " must be a (:add )" + " or (:remove )" + " or list of these" label))) + arg))) + args)) + +;;;###autoload +(defun use-package-handler/:advice (name _keyword args rest state) + (use-package-concat + (mapcar + (lambda (elt) + (if (eq (car elt) :add) + (let ((fn (nth 1 elt)) + (how (nth 2 elt)) + (fn2 (nth 3 elt))) + `(advice-add (function ,fn) ,how (function ,fn2))) + `(advice-remove (function ,(nth 1 elt)) (function ,(nth 2 elt))))) + args) + (use-package-process-keywords name rest state))) + + +(provide 'use-package-x-advice) +;;; use-package-x-advice.el ends here diff --git a/lisp/use-package/use-package-x/use-package-x-custom-face*.el b/lisp/use-package/use-package-x/use-package-x-custom-face*.el new file mode 100644 index 00000000000..ec43abe508c --- /dev/null +++ b/lisp/use-package/use-package-x/use-package-x-custom-face*.el @@ -0,0 +1,56 @@ +;;; use-package-x-custom-face*.el --- :custom-face* keyword definition -*- lexical-binding: t; -*- + +;; Copyright (C) 2025 Free Software Foundation, Inc. + +;; Author: Elias G. Perez + +;; 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 . + +;;; Commentary: + +;; This file provides the following extra keyword for +;; `use-package': +;; +;; * :custom-face* +;; Like :custom-face but override the face specs. +;; +;; To use it load this library in your init file: +;; +;; (require 'use-package-x-custom-face*) + +;;; Code: + +;;; Requires +(require 'cl-lib) +(require 'use-package) + + + +;;; Functions +;;;###autoload +(defalias 'use-package-normalize/:custom-face* 'use-package-normalize/:custom-face) + +;;;###autoload +(defun use-package-handler/:custom-face* (name _keyword args rest state) + (use-package-concat + (mapcar #'(lambda (def) + `(progn + (apply #'face-spec-set (backquote ,def)) + (put ',(car def) 'face-modified t))) + args) + (use-package-process-keywords name rest state))) + + +(provide 'use-package-x-custom-face*) +;;; use-package-x-custom-face*.el ends here diff --git a/lisp/use-package/use-package-x/use-package-x-defvar-keymap.el b/lisp/use-package/use-package-x/use-package-x-defvar-keymap.el new file mode 100644 index 00000000000..30a5a0979c0 --- /dev/null +++ b/lisp/use-package/use-package-x/use-package-x-defvar-keymap.el @@ -0,0 +1,77 @@ +;;; use-package-x-defvar-keymap.el --- :defvar-keymap keyword definition -*- lexical-binding: t; -*- + +;; Copyright (C) 2025 Free Software Foundation, Inc. + +;; Author: Elias G. Perez + +;; 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 . + +;;; Commentary: + +;; This file provides the following extra keyword for +;; `use-package': +;; +;; * :defvar-keymap +;; Define a new keymap or override an existent one. +;; The form is similar to `defvar-keymap' arguments, which see. +;; +;; :defvar-keymap +;; (:map my-mode-map +;; "C-x foo" #'bar +;; "C-x foo2" #'bar2 +;; ... you can define multiple in the same list +;; :map another-mode-map +;; "C-c foo" #'bar +;; "C-c foo2" #'bar2) +;; +;; To use it load this library in your init file: +;; +;; (require 'use-package-x-defvar-keymap) + +;;; Code: + +;;; Requires +(require 'cl-lib) +(require 'use-package) + + + +;;; Functions + +;;;###autoload +(defun use-package-normalize/:defvar-keymap (_name keyword args) + (use-package-as-one (symbol-name keyword) args + (lambda (label arg) + (unless (eq (car arg) :map) + (use-package-error + (concat label + " value must be (:map #' ...)" + " ensure `:map ' is in the list."))) + ;; For some reason this is returned as + ;; (nil (...)) + ;; so, only return the list we want. + (cdr (use-package-split-list-at-keys :map arg))))) + +;;;###autoload +(defun use-package-handler/:defvar-keymap (name _keyword args rest state) + (use-package-concat + (mapcar + (lambda (elt) + `(defvar-keymap ,(car elt) + ,@(cdr elt))) + args) + (use-package-process-keywords name rest state))) + +(provide 'use-package-x-defvar-keymap) +;;; use-package-x-defvar-keymap.el ends here diff --git a/lisp/use-package/use-package-x/use-package-x-docs.el b/lisp/use-package/use-package-x/use-package-x-docs.el new file mode 100644 index 00000000000..9ff30c79b1e --- /dev/null +++ b/lisp/use-package/use-package-x/use-package-x-docs.el @@ -0,0 +1,66 @@ +;;; use-package-x-docs.el --- :doc :tags keywords definitions -*- lexical-binding: t; -*- + +;; Copyright (C) 2025 Free Software Foundation, Inc. + +;; Author: Elias G. Perez + +;; 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 . + +;;; Commentary: +;; This file provides the following extra keywords for +;; `use-package': +;; +;; * :doc +;; Document your use-package declaration instead using comments. +;; +;; :doc +;; +;; * :tag +;; +;; Categorize your use-package declaration, this doesn't have any +;; effect. +;; +;; :tag +;; +;; To use it load this library in your init file: +;; +;; (require 'use-package-x-docs) + +;;; Code: + +;;; Requires +(require 'cl-lib) +(require 'use-package) + + + +;;; Functions +(defun use-package-x-handle-always (name _keyword _args rest state) + "Ignore ARGS, do nothing, and process the next `use-package' keyword." + (use-package-concat (use-package-process-keywords name rest state))) + +;;; :doc +;;;###autoload +(defalias 'use-package-normalize/:doc 'always) +;;;###autoload +(defalias 'use-package-handler/:doc 'use-package-x-handle-always) + +;;; :tag +;;;###autoload +(defalias 'use-package-normalize/:tag 'always) +;;;###autoload +(defalias 'use-package-handler/:tag 'use-package-x-handle-always) + +(provide 'use-package-x-docs) +;;; use-package-x-docs.el ends here diff --git a/lisp/use-package/use-package-x/use-package-x-emacs-versions.el b/lisp/use-package/use-package-x/use-package-x-emacs-versions.el new file mode 100644 index 00000000000..53b138d9c49 --- /dev/null +++ b/lisp/use-package/use-package-x/use-package-x-emacs-versions.el @@ -0,0 +1,100 @@ +;;; use-package-x-emacs-versions.el --- :emacs< :emacs<= :emacs= :emacs> :emacs>= definitions -*- lexical-binding: t; -*- + +;; Copyright (C) 2025 Free Software Foundation, Inc. + +;; Author: Elias G. Perez + +;; 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 . + +;;; Commentary: + +;; This file provides the following extra keywords for +;; `use-package': +;; +;; * :emacs< +;; Shorthand for :if (version< emacs-version ) +;; +;; * :emacs<= +;; Shorthand for :if (version<= emacs-version ) +;; +;; * :emacs= +;; Shorthand for :if (version= emacs-version ) +;; +;; * :emacs> +;; Shorthand for :if (version< emacs-version) +;; +;; * :emacs>= +;; Shorthand for :if (version<= emacs-version) +;; +;; To use them load this library in your init file: +;; +;; (require 'use-package-x-emacs-versions) + +;;; Code: + +;;; Requires +(require 'cl-lib) +(require 'use-package) + + + +;;; Functions +(defun use-package-x-normalize-version (_name keyword args) + "Normalize version in ARGS. +If version is a number, convert it to a string." + (use-package-only-one (symbol-name keyword) args + (lambda (_label version) + (let ((version (if (numberp version) (number-to-string version) version))) + (pcase keyword + (:emacs< `(version< emacs-version ,version)) + (:emacs<= `(version<= emacs-version ,version)) + (:emacs= `(version= emacs-version ,version)) + (:emacs> `(version< ,version emacs-version)) + (:emacs>= `(version<= ,version emacs-version))))))) + +;;; :emacs< + +;;;###autoload +(defalias 'use-package-normalize/:emacs< 'use-package-x-normalize-version) +;;;###autoload +(defalias 'use-package-handler/:emacs< 'use-package-handler/:if) + +;;; :emacs<= +;;;###autoload +(defalias 'use-package-normalize/:emacs<= 'use-package-x-normalize-version) +;;;###autoload +(defalias 'use-package-handler/:emacs<= 'use-package-handler/:if) + +;;; :emacs= +;;;###autoload +(defalias 'use-package-normalize/:emacs= 'use-package-x-normalize-version) +;;;###autoload +(defalias 'use-package-handler/:emacs= 'use-package-handler/:if) + +;;; :emacs> + +;;;###autoload +(defalias 'use-package-normalize/:emacs> 'use-package-x-normalize-version) +;;;###autoload +(defalias 'use-package-handler/:emacs> 'use-package-handler/:if) + +;;; :emacs>= + +;;;###autoload +(defalias 'use-package-normalize/:emacs>= 'use-package-x-normalize-version) +;;;###autoload +(defalias 'use-package-handler/:emacs>= 'use-package-handler/:if) + +(provide 'use-package-x-emacs-versions) +;;; use-package-x-emacs-versions.el ends here diff --git a/lisp/use-package/use-package-x/use-package-x-hook+.el b/lisp/use-package/use-package-x/use-package-x-hook+.el new file mode 100644 index 00000000000..398bfb016bd --- /dev/null +++ b/lisp/use-package/use-package-x/use-package-x-hook+.el @@ -0,0 +1,211 @@ +;;; use-package-x-hook+.el --- :hook+ keyword definition -*- lexical-binding: t; -*- + +;; Copyright (C) 2025 Free Software Foundation, Inc. + +;; Author: Elias G. Perez + +;; 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 . + +;;; Commentary: + +;; This file provides the following extra keywords for +;; `use-package': +;; +;; * :hook-suffix +;; Change `use-package-hook-name-suffix' value to only the current +;; use-package declaration. +;; +;; * :hook+ +;; An enchanted :hook which supports hooks depths and +;; set multiple functions. +;; +;; The hook depth is provided using the sub-keyword :depth +;; e.g. +;; :hook+ +;; (:depth 10 +;; (major-mode . my-func)) +;; +;; To set multiple functions (including lambdas) to the +;; hook or list of hooks you can use the :multi keyword: +;; +;; :hook (my-hook-or-list-of-hooks +;; . (:multi fn1 fn2 (lambda () ..) ...)) +;; +;; This also supports the :hook valid forms: +;; +;; :hook+ +;; (:depth 10 +;; (major-mode . my-func-or-lambda) +;; (mode mode2 mode3) +;; single-mode) +;; ((hook1 hook2) . (:multi fn1 fn2 fn3)) +;; ...and also use it as a normal :hook... +;; (major-mode . my-func-or-lambda) +;; (mode mode2 mode3) +;; single-mode +;; +;; To use it load this library in your init file: +;; +;; (require 'use-package-x-hook+) + +;;; Code: + +;;; Requires +(require 'cl-lib) +(require 'use-package) + + + +;;; Functions + +;;; :hook-suffix +;;;###autoload +(defun use-package-normalize/:hook-suffix (_name keyword args) + "Normalize :hook-prefix, ensure it's a string or nil." + (use-package-only-one (symbol-name keyword) args + (lambda (label arg) + (unless (or (stringp arg) (null arg)) + (use-package-error + (concat label " must be nil or a string"))) + arg))) + +;;;###autoload +(defun use-package-handler/:hook-suffix (name _keyword arg rest state) + "Normalize :hook-prefix. +Set `use-package-hook-name-suffix' to ARG only in the current +`use-package' declaration." + (dlet ((use-package-hook-name-suffix arg)) + (use-package-process-keywords name rest state))) + + + +;;; :hook+ +(defun use-package-x--normalize-pairs (list label name) + "Normalize all the pairs in the LIST." + (if (ignore-errors (eq (cadar list) :multi)) + ;; FIXME: There is not a better way to include this into the + ;; loop (below), so just return the LIST without normalizing. + list + (use-package-normalize-pairs + (lambda (k) + (or (use-package-non-nil-symbolp k) + (and k (let ((every t)) + (while (and every k) + (if (and (consp k) + (use-package-non-nil-symbolp (car k))) + (setq k (cdr k)) + (setq every nil))) + every)))) + #'use-package-recognize-function + (if (string-suffix-p "-mode" (symbol-name name)) + name + (intern (concat (symbol-name name) "-mode"))) + label list))) + +;;;###autoload +(defun use-package-normalize/:hook+ (name keyword args) + "Normalize :hook+ keyword. +Return the proper list or ARGS for `use-package-autoloads/:hook+' +and `use-package-handler/:hook+'." + (use-package-as-one (symbol-name keyword) args + (lambda (label arg) + (unless (or (use-package-non-nil-symbolp arg) (consp arg)) + (use-package-error + (concat label + " must be" + " a or a list or these" + " or ( . )" + " or ( . (:multi ...))" + " or (:depth ...)"))) + ;; Check if :depth is defined and return ( + ;; ) for the handler function, otherwise just + ;; return the normal list + (mapcan + (lambda (elt) + (if (eq (car-safe elt) :depth) + (mapcar (lambda (pairs) + (cons (nth 1 elt) (list pairs))) + (use-package-x--normalize-pairs (cddr elt) label name)) + (use-package-x--normalize-pairs (list elt) label name))) + args)))) + +(defun use-package-x--normalize-commands (list) + "Like `use-package-normalize-commands' but for supporting the :depth keyword." + (mapcar (lambda (x) + (cond ((numberp (car x)) + (cons (car x) (use-package-normalize-commands (cdr x)))) + ((consp x) + (cons (car x) (use-package-normalize-function (cdr x)))) + (t x))) + list)) + +(defun use-package-autoloads/:hook+ (_name _keyword args) + "Like `use-package-autoloads-mode' but supports the :depth and :multi keywords." + (setq args + (mapcar + (lambda (list) + (cond + ;; return the list without the depth number + ((integerp (car list)) (cadr list)) + (t list))) + args)) + + (cl-loop for x in args + for multi = (ignore-errors (eq (cadr x) :multi)) + when (and (consp x) (or (use-package-non-nil-symbolp (cdr x)) multi)) + if multi append + (cl-loop for cm in (cddr x) + if (use-package-non-nil-symbolp cm) + collect (cons cm 'command)) + else collect (cons (cdr x) 'command))) + +(defun use-package-x--create-hook (sym fun depth) + "Return the proper `add-hook' for mode SYM with FUN and DEPTH (if there is)." + (let ((symname (symbol-name sym))) + (if (and (boundp sym) + (not (string-suffix-p "-mode" symname))) + `(add-hook (quote ,sym) (function ,fun) ,depth) + `(add-hook + (quote ,(intern + (concat symname use-package-hook-name-suffix))) + (function ,fun) + ,depth)))) + +;;;###autoload +(defun use-package-handler/:hook+ (name _keyword args rest state) + "Hadle :hook+ keyword. +Add the proper `add-hook' to use-package expanded form, +compared to normal :hook, this handle hook depths and multiple +functions." + (use-package-concat + (use-package-process-keywords name rest state) + (cl-mapcan + (lambda (def) + (let* ((car (car def)) + (depth (if (integerp car) car)) + (syms (if depth (caadr def) car)) + (fun (if depth (cdadr def) (cdr def))) + (multi-p (and (listp fun) (eq (car fun) :multi)))) + (when fun + (cl-loop + for mode in (use-package-hook-handler-normalize-mode-symbols syms) + if multi-p append ; For `:multi' + (cl-loop for fn in (cdr fun) collect + (use-package-x--create-hook mode fn depth)) + else + collect (use-package-x--create-hook mode fun depth))))) + (use-package-x--normalize-commands args)))) + +(provide 'use-package-x-hook+) +;;; use-package-x-hook+.el ends here diff --git a/lisp/use-package/use-package-x/use-package-x-local-set.el b/lisp/use-package/use-package-x/use-package-x-local-set.el new file mode 100644 index 00000000000..69f6dbd75a9 --- /dev/null +++ b/lisp/use-package/use-package-x/use-package-x-local-set.el @@ -0,0 +1,91 @@ +;;; use-package-x-local-set.el --- :local-set keyword definition -*- lexical-binding: t; -*- + +;; Copyright (C) 2025 Free Software Foundation, Inc. + +;; Author: Elias G. Perez + +;; 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 . + +;;; Commentary: + +;; This file provides the following extra keyword for +;; `use-package': +;; +;; * :local-set +;; +;; Set variables locally when entering to a mode. +;; +;; :local-set +;; ( ...) <- Automatically set to package mode hook +;; --or-- +;; (:hook <- Set it only to hook(s), +;; compared to :hook and :hook+ +;; ...) you need to add the full hook name +;; +;; To use it load this library in your init file: +;; +;; (require 'use-package-x-local-set) + +;;; Code: + +;;; Requires +(require 'cl-lib) +(require 'use-package) + + + +;;;###autoload +(defun use-package-normalize/:local-set (_name keyword args) + "Normalize :local-set keyword, ensure ARGS are valid." + (use-package-as-one (symbol-name keyword) args + (lambda (label arg) + (let ((arg-car (car arg))) + (unless (or (eq arg-car :hook) (consp arg-car) (use-package-non-nil-symbolp arg-car)) + (use-package-error + (concat label + " can be ( ...)" + " or (:hook ...)"))) + args)))) + +(defun use-package-x-create-hook (hook values) + `(add-hook (quote ,hook) + (lambda (&rest _) + (setq-local ,@values)))) + +;;;###autoload +(defun use-package-handler/:local-set (name _keyword args rest state) + (use-package-concat + (mapcan + (lambda (elt) + (if (eq (car elt) :hook) + ;; :hook + (if-let* ((hook (nth 1 elt)) + ((listp hook))) + (mapcar + (lambda (x) (use-package-x-create-hook x (cddr elt))) + hook) + (list (use-package-x-create-hook hook (cddr elt)))) + ;; plain variables + (let* ((sym-name (symbol-name name)) + (hook (intern (concat + sym-name + (if (string-suffix-p "-mode" sym-name) + "-hook" + "-mode-hook"))))) + (list (use-package-x-create-hook hook elt))))) + args) + (use-package-process-keywords name rest state))) + +(provide 'use-package-x-local-set) +;;; use-package-x-local-set.el ends here diff --git a/lisp/use-package/use-package-x/use-package-x-setopt.el b/lisp/use-package/use-package-x/use-package-x-setopt.el new file mode 100644 index 00000000000..1dac29034eb --- /dev/null +++ b/lisp/use-package/use-package-x/use-package-x-setopt.el @@ -0,0 +1,72 @@ +;;; use-package-x-setopt.el --- :setopt keyword definition -*- lexical-binding: t; -*- + +;; Copyright (C) 2025 Free Software Foundation, Inc. + +;; Author: Elias G. Perez + +;; 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 . + +;;; Commentary: + +;; This file provides the following extra keyword for +;; `use-package': +;; +;; * :setopt +;; Similar to :custom, but can also bind plain variables. +;; This uses the `setopt' function, for bind the variables. +;; +;; :setopt ( ) ... +;; +;; VALUE is optional, if omitted, VARIABLE will be set to nil. +;; +;; To use it load this library in your init file: +;; +;; (require 'use-package-x-setopt) + +;;; Code: + +;;; Requires +(require 'cl-lib) +(require 'use-package) + + + +;;; Functions + +;;;###autoload +(defun use-package-normalize/:setopt (_name keyword args) + "Normalize :setopt keyword, ensure the values in ARGS are valid." + (mapcar + (lambda (elt) + (use-package-as-one (symbol-name keyword) (list elt) + (lambda (label arg) + (unless (and (consp arg) (use-package-non-nil-symbolp (car arg))) + (use-package-error + (concat label + " must be a ( [])" + " or a list of these"))) + arg))) + args)) + +;;;###autoload +(defun use-package-handler/:setopt (name _keyword args rest state) + (use-package-concat + `((setopt + ,@(mapcan + (lambda (list) (list (car list) (nth 1 list))) + args))) + (use-package-process-keywords name rest state))) + +(provide 'use-package-x-setopt) +;;; use-package-x-setopt.el ends here diff --git a/lisp/use-package/use-package-x/use-package-x-which-key-replacement.el b/lisp/use-package/use-package-x/use-package-x-which-key-replacement.el new file mode 100644 index 00000000000..04ec914a515 --- /dev/null +++ b/lisp/use-package/use-package-x/use-package-x-which-key-replacement.el @@ -0,0 +1,126 @@ +;;; use-package-x-which-key-replacement.el --- :which-key-replacement keyword definitions -*- lexical-binding: t; -*- + +;; Copyright (C) 2025 Free Software Foundation, Inc. + +;; Author: Elias G. Perez + +;; 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 . + +;;; Commentary: + +;; This file provides the following extra keyword for +;; `use-package': +;; +;; * :which-key-replacement +;; A simple way to set your which-key replacement keybindings. +;; +;; The form can be a any of these options: +;; +;; A cons-cell which will be passed as arguments for +;; which-key-add-key-based-replacements +;; +;; :which-key-replacement +;; ("C-c d" . "foo") +;; ("C-x 8" . '("unicode" . "Unicode keys")) +;; ... +;; +;; A list which specifies a keymap, passed as arguments for +;; which-key-add-keymap-based-replacements +;; +;; :which-key-replacement +;; (:keymap global-map +;; ("C-x a" "pretty name" command-name) +;; -- To add a prefix command, enclose it into a list-- +;; ("C-c a" "prefix" (prefix-map)) +;; ...) +;; +;; Or a list which specifies a major mode, passed as arguments for +;; which-key-add-major-mode-key-based-replacements +;; +;; :which-key-replacement +;; (:mode major-mode +;; ("C-c f" . "foo") +;; ("C-c e" . '("prefix" . "Pretty name")) +;; ...) +;; +;; To use it load this library in your init file: +;; +;; (require 'use-package-x-which-key-replacement) + +;;; Code: + +;;; Requires +(require 'cl-lib) +(require 'use-package) + + + +;;; Functions + +;;;###autoload +(defun use-package-normalize/:which-key-replacement (_name keyword args) + (let ((arg args) + args*) + (while arg + (let ((x (car arg))) + (cond + ;; CONS-CELL + ((and (consp x) + (stringp (car x))) + (setq args* (nconc args* (list x))) + (setq arg (cdr arg))) + ;; KEYWORDS: + ;; :map KEYMAP + ;; :mode MAJOR-MODE + ((and (memq (car x) '(:keymap :mode)) + (symbolp (cadr x))) + (setq args* (nconc args* `(,x))) + (setq arg (cdr arg))) + (t + ;; Error! + (use-package-error + (concat (symbol-name keyword) + " values must be a ( . )" + " or (:keymap ( " + " ) ...)" + " or (:mode ( . ))")))))) + args*)) + +;;;###autoload +(defun use-package-handler/:which-key-replacement (name _keyword args rest state) + (use-package-concat + (use-package-process-keywords name rest state) + (mapcar + #'(lambda (elt) + (let ((car (car elt))) + (cond ((stringp car) + `(which-key-add-key-based-replacements ,car ,(cdr elt))) + ((eq :keymap car) + `(which-key-add-keymap-based-replacements ,(nth 1 elt) + ,@(cl-loop for (key string command) in (cddr elt) + append `(,key + (quote + ,(cons string + ;; For keymaps or functions + (if (consp command) + (symbol-value (car command)) + command))))))) + ((eq :mode car) + `(which-key-add-major-mode-key-based-replacements ,(nth 1 elt) + ,@(cl-loop for (key . replacement) in (cddr elt) + append `(,key ,replacement))))))) + args))) + +(provide 'use-package-x-which-key-replacement) +;;; use-package-x-which-key-replacement.el ends here -- 2.50.1 --=-=-= Content-Type: text/plain -- - E.G via Gnus and Org. --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 28 15:23:01 2025 Received: (at 79106) by debbugs.gnu.org; 28 Jul 2025 19:23:01 +0000 Received: from localhost ([127.0.0.1]:57398 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ugTR6-0002AQ-Tc for submit@debbugs.gnu.org; Mon, 28 Jul 2025 15:23:01 -0400 Received: from mout01.posteo.de ([185.67.36.65]:46687) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ugTR3-00029q-5Y for 79106@debbugs.gnu.org; Mon, 28 Jul 2025 15:22:59 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 3AA83240027 for <79106@debbugs.gnu.org>; Mon, 28 Jul 2025 21:22:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=posteo.net; s=1984.ea087b; t=1753730571; bh=lsQPDHVysd2BYEKIRVWOeuAj9HktigsLQTTxk7zRgCo=; h=From:To:Cc:Subject:Autocrypt:OpenPGP:Date:Message-ID:MIME-Version: Content-Type:Content-Transfer-Encoding:From; b=EsuFoaa/tjRRDGbR/jdNhjU/wDr7Ie2pMbh3/B0x4/Kh0I9t6yg2hEqhk5LbFpcJI ZHx0lPiB/hHzvXHXCsLWs91nvKBZwEsAg31+dom23LmDEDqk85Yoi/84TZ738/48Nq bCcKXf7IhqmCwE5kM3QKSVPf7Vh4YDuO7ElDj7IgQx0HlCZJRpVzPWLU4/sBuIgQ9V ipHcLbcrcMX1zdUiXVXoXRIpK6swyid9jW7z74uhZGpD3P53wbmc7Ee9d8e1MFDK8d c9fh0nBPfx/FotMT4UmE9lh4MEcwaWnUNgZ30dBuYkcMcI0SdqwrQz0rSOAeSWc52s t5/gj4kK+6U+1z99Lon9WUi3nWLdsBcmy7wsnec37Blw+bvFCE7xzkJq325fsXINtD rBjbYY4xvwTfv2Gofk/Noz7vqaM6zwnZeFdMpQR+fWeR31gLb2OhS8dY/pMMo1Lxyk 8AbLDKTVCOR991PexYLJulLUvyk7xAGYzKvSsZbDXVP6vZ+ahFx Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4brSzs6bfRz6txl; Mon, 28 Jul 2025 21:22:49 +0200 (CEST) From: Philip Kaludercic To: Elijah Gabe =?utf-8?Q?P=C3=A9rez?= Subject: Re: bug#79106: [PATCH] Add new optional keywords to use-package In-Reply-To: <87wm7te6a6.fsf@gmail.com> References: <87wm7te6a6.fsf@gmail.com> Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM OpenPGP: id=7126E1DE2F0CE35C770BED01F2C3CC513DB89F66; url="https://keys.openpgp.org/vks/v1/by-fingerprint/7126E1DE2F0CE35C770BED01F2C3CC513DB89F66"; preference=signencrypt Date: Mon, 28 Jul 2025 19:22:50 +0000 Message-ID: <871pq03yt7.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79106 Cc: John Wiegley , Eli Zaretskii , 79106@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Elijah Gabe P=C3=A9rez writes: I guess it would be good to discuss the content of the patch now that we are considering to merge it. > Tags: patch > > As discussed in > https://lists.gnu.org/archive/html/emacs-devel/2025-07/msg00354.html > > This patch add new optional keywords to use-package, most of them are > inspired by suggestions from use-package bug-tracker on github > > This includes following keywords: > > * :advice Add or remove function advices. I did not understand how this uses :advice to create something use-package specific that has an advantage over `define-advice'. > * :custom-face* Like :custom-face but override the face specs. > This closes bug#77928 dilemma. > > * :defvar-keymap Define a new keymap or override an existent one. Why is this something that a user would be interested in when configuring a package? > * :doc Document the use-package declaration instead using comments. > > * :tag Like :doc, but for categorizing. > (This and :doc does nothing) Can you explain what these tags are good for? > * :emacs<, :emacs<=3D, :emacs=3D, :emacs>, :emacs>=3D, shorthand for > `:if (version...)` > > * :hook-suffix Changes `use-package-hook-name-suffix' value only in the > current use-package declaration. > > * :hook+ Like default :hook, but allows to set the hook depth and set > multiple functions in the hook (or for each hook). > > Although I tried to make it compatible with :hook, there may be some > things I missed, so I decided to put it separately instead of merging > it with :hook. In addition, its syntax is more complex compared to > :hook. I can imagine that the name is confusing to beginners, and also question if it might be cleaner to just advise users to use `add-hook' if they want to do something specific and more technical. > * :local-set Bind variables locally when entering to a mode or to a hook(= s). > An alternative to `:hook (hook . (lambda () (setq-local ...)))` > > * :setopt Like :custom, but can also bind plain variables. > This uses the `setopt` function for bind the variables. Would it make sense to re-use :custom but modify the behaviour with a user-option? > * :which-key-replacement A simple way to set which-key replacements. Wrt. the patch, I would still merge the files into one, instead of having each keyword in a separate file. From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 29 02:33:57 2025 Received: (at 79106) by debbugs.gnu.org; 29 Jul 2025 06:33:57 +0000 Received: from localhost ([127.0.0.1]:59814 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ugduM-0000gc-Sh for submit@debbugs.gnu.org; Tue, 29 Jul 2025 02:33:57 -0400 Received: from mail-ot1-x343.google.com ([2607:f8b0:4864:20::343]:61949) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1ugduI-0000fw-1r for 79106@debbugs.gnu.org; Tue, 29 Jul 2025 02:33:53 -0400 Received: by mail-ot1-x343.google.com with SMTP id 46e09a7af769-73e88bc38bbso3161243a34.3 for <79106@debbugs.gnu.org>; Mon, 28 Jul 2025 23:33:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753770824; x=1754375624; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=5DulJMiHN6zBmZCSKaKv7p4moldcz/rFh3mlXOXO++8=; b=bVcVrhKHcsyw4P0AR0vimZxqcpkPJPy2x3+wvEV2ZVzNlazlQMR3jKJl9niYqQRXwt wrbd5Vb4WHTKV1Wcm7m58F1idSGYm5KhPrHXe9YQdCNQwZPEi6UeBmgQN1iLxkgv+iWd T9b/efFIDplZ3sASou96tdeSsqZxRslvmYl/cTpkLZjbOltL5BNEDzSXBjbRrobBGMCW kI/nTDlnMLsHnS+JEuzzeMMj7ZpON9nvRlUU7lTZY6S7XRR67LBzntyufpwJXOzlNwoL sDUFVaAVyvVmI4KqOhds/9z0H/UQAtFbT9ySb8zvgWLd4pBaussINT+icaXm1XQuza58 f+6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753770824; x=1754375624; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=5DulJMiHN6zBmZCSKaKv7p4moldcz/rFh3mlXOXO++8=; b=OpEbeIi6Tqzphl91q1iHK9QeTlfBRImFxvW9bRqNf37GEdSKS622Ddl/vJFI2aCnmK bHXk3aBAlTszLKUyJVCODGzufQsYP1yB3OmaFcb5EBr9fNyHz5t67MHvX3MkNtNEvdET kTbCejwAhhBl5d/IECUPCouC5V1G3jExZUyK76c8M+6uz6QDMpzOdTUW0umBS0/f/mJd pHrGMCQVQyNsySNURmhllBAhfCLzRbG0qCngnVKIKmk6CAwwFbwnw+P4YCivD9K6yd3y N1BhQkwHy9IqtbypQ2cxMHNMFIqsd2OFXakqBlIN7VyMkI2jbZCUvhY+1jKG1vKJPRM4 NPHg== X-Forwarded-Encrypted: i=1; AJvYcCWdY3f+/L1sIPY/z2+tcpEFrRjTRloSkOIJLcIzHFCDTMJhfH6Dkq4VrYrkKvLNMQq/we0GDA==@debbugs.gnu.org X-Gm-Message-State: AOJu0YxeN5OtQ6utJrH+B5HsfXq6XEi2Y4knaJZ1xxMXWDmKbW5EFY3p WbogNXPmJtMBZMthm9dTgI7lbUA5cfAxFkdwD6P1nibNk0vvKQfASLuOc1+eW7m2 X-Gm-Gg: ASbGncspoV7YWRdFMLWmSpAENQQojq52bzzW9hp/VTMiwIkPkaaeH5NtuYmMs/IN0zU upmR3ndfUH1i6+qEyETEbVFyF17xubUyXnzbM2Es0UgToP97kSPV/+zOkWW4+UWWWHldwwWHY03 MKeXwKB5DwTwTUWZxxZpMIWcYCuLkleiu/MVs2B9y6iSIwAauMhHnGkuVwGk4m4mXHoVxIc75+a DQKIs1GZuEbSFZ6NHksYoqhdpF1dr2RnTcrr0mofTVNy9AgKth/JTJKbsmEdE/PL6aCeN9lUQ7X XQGR93cB10DU8lWbIYX+xjPYdyEeM2ltuyRpbpxc63gTmBg+oV21nFu7+LUad50Sss+3k2Va0kf ne+XbP/GF8aLamDU= X-Google-Smtp-Source: AGHT+IEJojQTueYJI+max77FY1wzeKo7HUrlW/tU9mBjdmTII6dpqE376x1WJz1B3GSx/fZiSmyIgw== X-Received: by 2002:a05:6830:448b:b0:73e:9cc6:718c with SMTP id 46e09a7af769-7413dd22552mr9220410a34.1.1753770823551; Mon, 28 Jul 2025 23:33:43 -0700 (PDT) Received: from fedora ([189.215.162.117]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-74147f4c6c8sm1398840a34.4.2025.07.28.23.33.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Jul 2025 23:33:42 -0700 (PDT) From: =?utf-8?Q?Elijah_Gabe_P=C3=A9rez?= To: Philip Kaludercic Subject: Re: bug#79106: [PATCH] Add new optional keywords to use-package In-Reply-To: <871pq03yt7.fsf@posteo.net> References: <87wm7te6a6.fsf@gmail.com> <871pq03yt7.fsf@posteo.net> Date: Tue, 29 Jul 2025 00:33:36 -0600 Message-ID: <87a54nfqv3.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 79106 Cc: John Wiegley , Eli Zaretskii , 79106@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Philip Kaludercic writes: > Elijah Gabe P=C3=A9rez writes: > > I guess it would be good to discuss the content of the patch now that we > are considering to merge it. Sure. >> Tags: patch >> >> As discussed in >> https://lists.gnu.org/archive/html/emacs-devel/2025-07/msg00354.html >> >> This patch add new optional keywords to use-package, most of them are >> inspired by suggestions from use-package bug-tracker on github >> >> This includes following keywords: >> >> * :advice Add or remove function advices. > > I did not understand how this uses :advice to create something > use-package specific that has an advantage over `define-advice'. This acts more to `advice-add` than `define-advice`. It is intended to add advices from some packages, such as consult, which has the `consult-register-window` function, that is intended to override `register-preview`. This is also inspired by leaf.el which have `:advice` and `:advice-remove`. >> * :defvar-keymap Define a new keymap or override an existent one. > > Why is this something that a user would be interested in when > configuring a package? :defvar-keymap is meant for people that wants to use their own keybindings in a mode (such as cua-mode) instead mode keybindings. In my case it's useful when i want to use a few keybindings from a mode, not all. >> * :doc Document the use-package declaration instead using comments. >> >> * :tag Like :doc, but for categorizing. >> (This and :doc does nothing) > > Can you explain what these tags are good for? At this moment, both :tag (and :doc) are useless, the only use I can see for it would be as an identifier for when someone wants to export their configuration as a web page. I decided include them because I've seen some configurations that use them (either from leaf.el or a personal extension). Perhaps in the future they can be modified to give a better use, but at this moment I can't think of any. >> * :hook+ Like default :hook, but allows to set the hook depth and set >> multiple functions in the hook (or for each hook). >> >> Although I tried to make it compatible with :hook, there may be some >> things I missed, so I decided to put it separately instead of merging >> it with :hook. In addition, its syntax is more complex compared to >> :hook. > > I can imagine that the name is confusing to beginners, and also question > if it might be cleaner to just advise users to use `add-hook' if they > want to do something specific and more technical. Yeah, but :hook+ already covers most of the basics for add-hook. It can put the same depth for all the hooks in a region: (:depth -10 (prog-mode . whitespace-mode) ; <- -10 (xml-mode . electric-pair-mode)) ; <- -10 >> * :setopt Like :custom, but can also bind plain variables. >> This uses the `setopt` function for bind the variables. > > Would it make sense to re-use :custom but modify the behaviour with a > user-option? I didn't quite understand this, did you mean to modify :custom for handle this instead? In that case, it would better to ask to John. > Wrt. the patch, I would still merge the files into one, instead of > having each keyword in a separate file. This is inconvenient, since if someone wants to use only one of these keywords, they would have to load the entire file. Keeping them separate prevents this and is also easier to maintain and move them to ELPA (if it is decided in the future). Also I'm sending a fixed patch, I'm not sure if the additional keywords should be documented in the manual. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-new-optional-keywords-to-use-package.patch >From 0f66925a9028c74402ec1797925f8d6b3053552d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?El=C3=ADas=20Gabriel=20P=C3=A9rez?= Date: Sat, 26 Jul 2025 22:43:38 -0600 Subject: [PATCH] Add new optional keywords to use-package This includes new optional keywords to use-packages, most of them are intended to be used for a more advanced customization, thus they are not loaded. (bug#) * etc/NEWS: Announce changes. * lisp/use-package/use-package-core.el: Add new keywords to keywords list. * lisp/use-package/use-package-x/use-package-x-advice.el: * lisp/use-package/use-package-x/use-package-x-custom-face*.el: * lisp/use-package/use-package-x/use-package-x-defvar-keymap.el: * lisp/use-package/use-package-x/use-package-x-docs.el: * lisp/use-package/use-package-x/use-package-x-emacs-versions.el: * lisp/use-package/use-package-x/use-package-x-hook+.el: * lisp/use-package/use-package-x/use-package-x-local-set.el: * lisp/use-package/use-package-x/use-package-x-setopt.el: * lisp/use-package/use-package-x/use-package-x-which-key-replacement.el: New files. --- etc/NEWS | 46 ++++ lisp/use-package/use-package-core.el | 11 + .../use-package-x/use-package-x-advice.el | 77 +++++++ .../use-package-x-custom-face*.el | 55 +++++ .../use-package-x-defvar-keymap.el | 71 ++++++ .../use-package-x/use-package-x-docs.el | 65 ++++++ .../use-package-x-emacs-versions.el | 99 +++++++++ .../use-package-x/use-package-x-hook+.el | 210 ++++++++++++++++++ .../use-package-x/use-package-x-local-set.el | 90 ++++++++ .../use-package-x/use-package-x-setopt.el | 70 ++++++ .../use-package-x-which-key-replacement.el | 111 +++++++++ 11 files changed, 905 insertions(+) create mode 100644 lisp/use-package/use-package-x/use-package-x-advice.el create mode 100644 lisp/use-package/use-package-x/use-package-x-custom-face*.el create mode 100644 lisp/use-package/use-package-x/use-package-x-defvar-keymap.el create mode 100644 lisp/use-package/use-package-x/use-package-x-docs.el create mode 100644 lisp/use-package/use-package-x/use-package-x-emacs-versions.el create mode 100644 lisp/use-package/use-package-x/use-package-x-hook+.el create mode 100644 lisp/use-package/use-package-x/use-package-x-local-set.el create mode 100644 lisp/use-package/use-package-x/use-package-x-setopt.el create mode 100644 lisp/use-package/use-package-x/use-package-x-which-key-replacement.el diff --git a/etc/NEWS b/etc/NEWS index a81d1105443..345e2116d93 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2419,6 +2419,52 @@ A major mode based on the tree-sitter library for editing "go.work" files. If tree-sitter is properly set-up by the user, it can be enabled for files named "go.work". +** New packages for additional keywords for 'use-package' +The following includes additional and optional keywords for +'use-package': + +*** New package use-package-x-advice +This package includes the ':advice' keyword, which allows to add or +remove function advices. + +*** New package use-package-x-custom-face* +This package includes the ':custom-face*' keyword, which acts like +':custom-face', but overrides the face specs. + +*** New package use-package-x-defvar-keymap +This package includes the ':defvar-keymap' keyword, which allows to +define a new keymap or override an existent one. + +*** New package use-package-x-docs +This package includes the ':doc' and ':tag' keywords, which allows to +document or tag the use-package declaration instead of using comments. + +*** New package use-package-x-emacs-versions +This package includes the ':emacs<', ':emacs<=', ':emacs=', ':emacs>' +and ':emacs>=' keywords, which initialize the use-package declaration +only for an Emacs version or versions. + +*** New package use-package-x-hook+ +This package includes the following keywords: + +':hook-suffix', that allows to change the 'use-package-hook-name-suffix' +value to only the use-package declaration. + +':hook+', which acts like ':hook' but also supports hooks depths and set +multiple functions. + +*** New package use-package-x-local-set +This package includes the ':local-set' keyword, that allows to bind +variables locally to a hook. + +*** New package use-package-x-setopt +This package includes the ':setopt' keyword, which acts like ':custom' +but can also bind plain variables. + +*** New package use-package-x-which-key-replacement +This package includes the ':which-key-replacement' keyword, which allows +to define and replace key descriptions. + * Incompatible Lisp Changes in Emacs 31.1 diff --git a/lisp/use-package/use-package-core.el b/lisp/use-package/use-package-core.el index 65b9485b4e3..e38280d670c 100644 --- a/lisp/use-package/use-package-core.el +++ b/lisp/use-package/use-package-core.el @@ -77,22 +77,33 @@ use-package-keywords :defines :functions :preface + :hook-suffix :if :when :unless + :emacs< :emacs<= :emacs= + :emacs> :emacs>= :vc :no-require :catch :after + :setopt + :local-set :custom :custom-face + :custom-face* :bind :bind* :bind-keymap :bind-keymap* + :defvar-keymap + :which-key-replacement + :advice :interpreter :mode :magic :magic-fallback :hook + :hook+ + :doc :tag ;; Any other keyword that also declares commands to be autoloaded (such as ;; :bind) must appear before this keyword. :commands diff --git a/lisp/use-package/use-package-x/use-package-x-advice.el b/lisp/use-package/use-package-x/use-package-x-advice.el new file mode 100644 index 00000000000..b9839953950 --- /dev/null +++ b/lisp/use-package/use-package-x/use-package-x-advice.el @@ -0,0 +1,77 @@ +;;; use-package-x-advice.el --- :advice keyword definition -*- lexical-binding: t; -*- + +;; Copyright (C) 2025 Free Software Foundation, Inc. + +;; Author: Elias G. Perez + +;; 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 . + +;;; Commentary: +;; +;; This file provides the following extra keyword for +;; `use-package': +;; +;; * :advice +;; Add or remove function advices. +;; This is a shorthand for ":init (advice-[add|remove] ...)" +;; +;; :advice +;; (:add my-function other-function) +;; (:remove other-function my-function) +;; +;; To use it load this library in your init file: +;; +;; (require 'use-package-x-advice) + +;;; Code: + +;;; Requires +(require 'use-package-core) + + + +;;; Functions + +;;;###autoload +(defun use-package-normalize/:advice (_name keyword args) + (mapcar + (lambda (elt) + (use-package-as-one (symbol-name keyword) (list elt) + (lambda (label arg) + (unless (and (consp arg) (memq (car arg) '(:add :remove))) + (use-package-error + (concat label + " must be a (:add )" + " or (:remove )" + " or list of these" label))) + arg))) + args)) + +;;;###autoload +(defun use-package-handler/:advice (name _keyword args rest state) + (use-package-concat + (mapcar + (lambda (elt) + (if (eq (car elt) :add) + (let ((fn (nth 1 elt)) + (how (nth 2 elt)) + (fn2 (nth 3 elt))) + `(advice-add (function ,fn) ,how (function ,fn2))) + `(advice-remove (function ,(nth 1 elt)) (function ,(nth 2 elt))))) + args) + (use-package-process-keywords name rest state))) + + +(provide 'use-package-x-advice) +;;; use-package-x-advice.el ends here diff --git a/lisp/use-package/use-package-x/use-package-x-custom-face*.el b/lisp/use-package/use-package-x/use-package-x-custom-face*.el new file mode 100644 index 00000000000..7d482ba3737 --- /dev/null +++ b/lisp/use-package/use-package-x/use-package-x-custom-face*.el @@ -0,0 +1,55 @@ +;;; use-package-x-custom-face*.el --- :custom-face* keyword definition -*- lexical-binding: t; -*- + +;; Copyright (C) 2025 Free Software Foundation, Inc. + +;; Author: Elias G. Perez + +;; 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 . + +;;; Commentary: + +;; This file provides the following extra keyword for +;; `use-package': +;; +;; * :custom-face* +;; Like :custom-face but override the face specs. +;; +;; To use it load this library in your init file: +;; +;; (require 'use-package-x-custom-face*) + +;;; Code: + +;;; Requires +(require 'use-package-core) + + + +;;; Functions +;;;###autoload +(defalias 'use-package-normalize/:custom-face* 'use-package-normalize/:custom-face) + +;;;###autoload +(defun use-package-handler/:custom-face* (name _keyword args rest state) + (use-package-concat + (mapcar #'(lambda (def) + `(progn + (apply #'face-spec-set (backquote ,def)) + (put ',(car def) 'face-modified t))) + args) + (use-package-process-keywords name rest state))) + + +(provide 'use-package-x-custom-face*) +;;; use-package-x-custom-face*.el ends here diff --git a/lisp/use-package/use-package-x/use-package-x-defvar-keymap.el b/lisp/use-package/use-package-x/use-package-x-defvar-keymap.el new file mode 100644 index 00000000000..4253f5a02aa --- /dev/null +++ b/lisp/use-package/use-package-x/use-package-x-defvar-keymap.el @@ -0,0 +1,71 @@ +;;; use-package-x-defvar-keymap.el --- :defvar-keymap keyword definition -*- lexical-binding: t; -*- + +;; Copyright (C) 2025 Free Software Foundation, Inc. + +;; Author: Elias G. Perez + +;; 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 . + +;;; Commentary: + +;; This file provides the following extra keyword for +;; `use-package': +;; +;; * :defvar-keymap +;; Define a new keymap or override an existent one. +;; The form is similar to `defvar-keymap' arguments, which see. +;; +;; :defvar-keymap +;; (:map my-mode-map +;; "C-x foo" #'bar +;; "C-x foo2" #'bar2) +;; +;; To use it load this library in your init file: +;; +;; (require 'use-package-x-defvar-keymap) + +;;; Code: + +;;; Requires +(require 'use-package-core) + + + +;;; Functions + +;;;###autoload +(defun use-package-normalize/:defvar-keymap (_name keyword args) + (use-package-as-one (symbol-name keyword) args + (lambda (label arg) + (unless (or (eq (car arg) :map) (listp arg)) + (use-package-error + (concat label + " value must be" + " (:map #' ...)"))) + (if (eq (car arg) :map) + (list arg) + arg)))) + +;;;###autoload +(defun use-package-handler/:defvar-keymap (name _keyword args rest state) + (use-package-concat + (mapcar + (lambda (elt) + `(defvar-keymap ,(cadr elt) + ,@(cddr elt))) + args) + (use-package-process-keywords name rest state))) + +(provide 'use-package-x-defvar-keymap) +;;; use-package-x-defvar-keymap.el ends here diff --git a/lisp/use-package/use-package-x/use-package-x-docs.el b/lisp/use-package/use-package-x/use-package-x-docs.el new file mode 100644 index 00000000000..2c586ffd340 --- /dev/null +++ b/lisp/use-package/use-package-x/use-package-x-docs.el @@ -0,0 +1,65 @@ +;;; use-package-x-docs.el --- :doc :tag keywords definitions -*- lexical-binding: t; -*- + +;; Copyright (C) 2025 Free Software Foundation, Inc. + +;; Author: Elias G. Perez + +;; 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 . + +;;; Commentary: +;; This file provides the following extra keywords for +;; `use-package': +;; +;; * :doc +;; Document your use-package declaration instead of using comments. +;; +;; :doc ... +;; +;; * :tag +;; +;; Categorize your use-package declaration, this doesn't have any +;; effect. +;; +;; :tag ... +;; +;; To use it load this library in your init file: +;; +;; (require 'use-package-x-docs) + +;;; Code: + +;;; Requires +(require 'use-package-core) + + + +;;; Functions +(defun use-package-x-handle-always (name _keyword _args rest state) + "Ignore ARGS, do nothing, and process the next `use-package' keyword." + (use-package-concat (use-package-process-keywords name rest state))) + +;;; :doc +;;;###autoload +(defalias 'use-package-normalize/:doc 'always) +;;;###autoload +(defalias 'use-package-handler/:doc 'use-package-x-handle-always) + +;;; :tag +;;;###autoload +(defalias 'use-package-normalize/:tag 'always) +;;;###autoload +(defalias 'use-package-handler/:tag 'use-package-x-handle-always) + +(provide 'use-package-x-docs) +;;; use-package-x-docs.el ends here diff --git a/lisp/use-package/use-package-x/use-package-x-emacs-versions.el b/lisp/use-package/use-package-x/use-package-x-emacs-versions.el new file mode 100644 index 00000000000..08d4185569a --- /dev/null +++ b/lisp/use-package/use-package-x/use-package-x-emacs-versions.el @@ -0,0 +1,99 @@ +;;; use-package-x-emacs-versions.el --- :emacs< :emacs<= :emacs= :emacs> :emacs>= definitions -*- lexical-binding: t; -*- + +;; Copyright (C) 2025 Free Software Foundation, Inc. + +;; Author: Elias G. Perez + +;; 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 . + +;;; Commentary: + +;; This file provides the following extra keywords for +;; `use-package': +;; +;; * :emacs< +;; Shorthand for :if (version< emacs-version ) +;; +;; * :emacs<= +;; Shorthand for :if (version<= emacs-version ) +;; +;; * :emacs= +;; Shorthand for :if (version= emacs-version ) +;; +;; * :emacs> +;; Shorthand for :if (version< emacs-version) +;; +;; * :emacs>= +;; Shorthand for :if (version<= emacs-version) +;; +;; To use them load this library in your init file: +;; +;; (require 'use-package-x-emacs-versions) + +;;; Code: + +;;; Requires +(require 'use-package-core) + + + +;;; Functions +(defun use-package-x-normalize-version (_name keyword args) + "Normalize version in ARGS. +If version is a number, convert it to a string." + (use-package-only-one (symbol-name keyword) args + (lambda (_label version) + (let ((version (if (numberp version) (number-to-string version) version))) + (pcase keyword + (:emacs< `(version< emacs-version ,version)) + (:emacs<= `(version<= emacs-version ,version)) + (:emacs= `(version= emacs-version ,version)) + (:emacs> `(version< ,version emacs-version)) + (:emacs>= `(version<= ,version emacs-version))))))) + +;;; :emacs< + +;;;###autoload +(defalias 'use-package-normalize/:emacs< 'use-package-x-normalize-version) +;;;###autoload +(defalias 'use-package-handler/:emacs< 'use-package-handler/:if) + +;;; :emacs<= +;;;###autoload +(defalias 'use-package-normalize/:emacs<= 'use-package-x-normalize-version) +;;;###autoload +(defalias 'use-package-handler/:emacs<= 'use-package-handler/:if) + +;;; :emacs= +;;;###autoload +(defalias 'use-package-normalize/:emacs= 'use-package-x-normalize-version) +;;;###autoload +(defalias 'use-package-handler/:emacs= 'use-package-handler/:if) + +;;; :emacs> + +;;;###autoload +(defalias 'use-package-normalize/:emacs> 'use-package-x-normalize-version) +;;;###autoload +(defalias 'use-package-handler/:emacs> 'use-package-handler/:if) + +;;; :emacs>= + +;;;###autoload +(defalias 'use-package-normalize/:emacs>= 'use-package-x-normalize-version) +;;;###autoload +(defalias 'use-package-handler/:emacs>= 'use-package-handler/:if) + +(provide 'use-package-x-emacs-versions) +;;; use-package-x-emacs-versions.el ends here diff --git a/lisp/use-package/use-package-x/use-package-x-hook+.el b/lisp/use-package/use-package-x/use-package-x-hook+.el new file mode 100644 index 00000000000..e9e32230881 --- /dev/null +++ b/lisp/use-package/use-package-x/use-package-x-hook+.el @@ -0,0 +1,210 @@ +;;; use-package-x-hook+.el --- :hook+ :hook-suffix keywords definitions -*- lexical-binding: t; -*- + +;; Copyright (C) 2025 Free Software Foundation, Inc. + +;; Author: Elias G. Perez + +;; 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 . + +;;; Commentary: + +;; This file provides the following extra keywords for +;; `use-package': +;; +;; * :hook-suffix +;; Change `use-package-hook-name-suffix' value to only the use-package +;; declaration. +;; +;; * :hook+ +;; An enchanted :hook which supports hooks depths and +;; set multiple functions. +;; +;; The hook depth is provided using the sub-keyword :depth +;; e.g. +;; :hook+ +;; (:depth 10 +;; (major-mode . my-func)) +;; +;; To set multiple functions (including lambdas) to the +;; hook or list of hooks you can use the :multi keyword: +;; +;; :hook (my-hook-or-list-of-hooks +;; . (:multi fn1 fn2 (lambda () ..) ...)) +;; +;; This also supports the :hook valid forms: +;; +;; :hook+ +;; (:depth 10 +;; (major-mode . my-func-or-lambda) +;; (mode mode2 mode3) +;; single-mode) +;; ((hook1 hook2) . (:multi fn1 fn2 fn3)) +;; ...and also use it as a normal :hook... +;; (major-mode . my-func-or-lambda) +;; (mode mode2 mode3) +;; single-mode +;; +;; To use it load this library in your init file: +;; +;; (require 'use-package-x-hook+) + +;;; Code: + +;;; Requires +(require 'use-package-core) + + + +;;; Functions + +;;; :hook-suffix +;;;###autoload +(defun use-package-normalize/:hook-suffix (_name keyword args) + "Normalize :hook-prefix, ensure it's a string or nil." + (use-package-only-one (symbol-name keyword) args + (lambda (label arg) + (unless (or (stringp arg) (null arg)) + (use-package-error + (concat label " must be nil or a string"))) + arg))) + +;;;###autoload +(defun use-package-handler/:hook-suffix (name _keyword arg rest state) + "Normalize :hook-prefix. +Set `use-package-hook-name-suffix' to ARG only in the current +`use-package' declaration." + (dlet ((use-package-hook-name-suffix arg)) + (use-package-process-keywords name rest state))) + + + +;;; :hook+ +(defun use-package-x--normalize-pairs (list label name) + "Normalize all the pairs in the LIST." + (if (ignore-errors (eq (cadar list) :multi)) + ;; FIXME: There is not a better way to include this into the + ;; loop (below), so just return the LIST without normalizing. + list + (use-package-normalize-pairs + (lambda (k) + (or (use-package-non-nil-symbolp k) + (and k (let ((every t)) + (while (and every k) + (if (and (consp k) + (use-package-non-nil-symbolp (car k))) + (setq k (cdr k)) + (setq every nil))) + every)))) + #'use-package-recognize-function + (if (string-suffix-p "-mode" (symbol-name name)) + name + (intern (concat (symbol-name name) "-mode"))) + label list))) + +;;;###autoload +(defun use-package-normalize/:hook+ (name keyword args) + "Normalize :hook+ keyword. +Return the proper list or ARGS for `use-package-autoloads/:hook+' +and `use-package-handler/:hook+'." + (use-package-as-one (symbol-name keyword) args + (lambda (label arg) + (unless (or (use-package-non-nil-symbolp arg) (consp arg)) + (use-package-error + (concat label + " must be" + " a or a list or these" + " or ( . )" + " or ( . (:multi ...))" + " or (:depth ...)"))) + ;; Check if :depth is defined and return ( + ;; ) for the handler function, otherwise just + ;; return the normal list + (mapcan + (lambda (elt) + (if (eq (car-safe elt) :depth) + (mapcar (lambda (pairs) + (cons (nth 1 elt) (list pairs))) + (use-package-x--normalize-pairs (cddr elt) label name)) + (use-package-x--normalize-pairs (list elt) label name))) + args)))) + +(defun use-package-x--normalize-commands (list) + "Like `use-package-normalize-commands' but for supporting the :depth keyword." + (mapcar (lambda (x) + (cond ((numberp (car x)) + (cons (car x) (use-package-normalize-commands (cdr x)))) + ((consp x) + (cons (car x) (use-package-normalize-function (cdr x)))) + (t x))) + list)) + +(defun use-package-autoloads/:hook+ (_name _keyword args) + "Like `use-package-autoloads-mode' but supports the :depth and :multi keywords." + (setq args + (mapcar + (lambda (list) + (cond + ;; return the list without the depth number + ((integerp (car list)) (cadr list)) + (t list))) + args)) + + (cl-loop for x in args + for multi = (ignore-errors (eq (cadr x) :multi)) + when (and (consp x) (or (use-package-non-nil-symbolp (cdr x)) multi)) + if multi append + (cl-loop for cm in (cddr x) + if (use-package-non-nil-symbolp cm) + collect (cons cm 'command)) + else collect (cons (cdr x) 'command))) + +(defun use-package-x--create-hook (sym fun depth) + "Return the proper `add-hook' for mode SYM with FUN and DEPTH (if there is)." + (let ((symname (symbol-name sym))) + (if (and (boundp sym) + (not (string-suffix-p "-mode" symname))) + `(add-hook (quote ,sym) (function ,fun) ,depth) + `(add-hook + (quote ,(intern + (concat symname use-package-hook-name-suffix))) + (function ,fun) + ,depth)))) + +;;;###autoload +(defun use-package-handler/:hook+ (name _keyword args rest state) + "Hadle :hook+ keyword. +Add the proper `add-hook' to use-package expanded form, +compared to normal :hook, this handle hook depths and multiple +functions." + (use-package-concat + (use-package-process-keywords name rest state) + (cl-mapcan + (lambda (def) + (let* ((car (car def)) + (depth (if (integerp car) car)) + (syms (if depth (caadr def) car)) + (fun (if depth (cdadr def) (cdr def))) + (multi-p (and (listp fun) (eq (car fun) :multi)))) + (when fun + (cl-loop + for mode in (use-package-hook-handler-normalize-mode-symbols syms) + if multi-p append ; For `:multi' + (cl-loop for fn in (cdr fun) collect + (use-package-x--create-hook mode fn depth)) + else + collect (use-package-x--create-hook mode fun depth))))) + (use-package-x--normalize-commands args)))) + +(provide 'use-package-x-hook+) +;;; use-package-x-hook+.el ends here diff --git a/lisp/use-package/use-package-x/use-package-x-local-set.el b/lisp/use-package/use-package-x/use-package-x-local-set.el new file mode 100644 index 00000000000..0074ecd3718 --- /dev/null +++ b/lisp/use-package/use-package-x/use-package-x-local-set.el @@ -0,0 +1,90 @@ +;;; use-package-x-local-set.el --- :local-set keyword definition -*- lexical-binding: t; -*- + +;; Copyright (C) 2025 Free Software Foundation, Inc. + +;; Author: Elias G. Perez + +;; 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 . + +;;; Commentary: + +;; This file provides the following extra keyword for +;; `use-package': +;; +;; * :local-set +;; +;; Set variables locally when entering to a mode. +;; +;; :local-set +;; ( ...) <- Automatically set to package mode hook +;; --or-- +;; (:hook <- Set it only to hook(s), +;; compared to :hook and :hook+ +;; ...) you need to add the full hook name +;; +;; To use it load this library in your init file: +;; +;; (require 'use-package-x-local-set) + +;;; Code: + +;;; Requires +(require 'use-package) + + + +;;;###autoload +(defun use-package-normalize/:local-set (_name keyword args) + "Normalize :local-set keyword, ensure ARGS are valid." + (use-package-as-one (symbol-name keyword) args + (lambda (label arg) + (let ((arg-car (car arg))) + (unless (or (eq arg-car :hook) (consp arg-car) (use-package-non-nil-symbolp arg-car)) + (use-package-error + (concat label + " can be ( ...)" + " or (:hook ...)"))) + args)))) + +(defun use-package-x--local-hook (hook values) + `(add-hook (quote ,hook) + (lambda (&rest _) + (setq-local ,@values)))) + +;;;###autoload +(defun use-package-handler/:local-set (name _keyword args rest state) + (use-package-concat + (mapcan + (lambda (elt) + (if (eq (car elt) :hook) + ;; :hook + (if-let* ((hook (nth 1 elt)) + ((listp hook))) + (mapcar + (lambda (x) (use-package-x--local-hook x (cddr elt))) + hook) + (list (use-package-x--local-hook hook (cddr elt)))) + ;; plain variables + (let* ((sym-name (symbol-name name)) + (hook (intern (concat + sym-name + (if (string-suffix-p "-mode" sym-name) + "-hook" + "-mode-hook"))))) + (list (use-package-x--local-hook hook elt))))) + args) + (use-package-process-keywords name rest state))) + +(provide 'use-package-x-local-set) +;;; use-package-x-local-set.el ends here diff --git a/lisp/use-package/use-package-x/use-package-x-setopt.el b/lisp/use-package/use-package-x/use-package-x-setopt.el new file mode 100644 index 00000000000..df63448b4f8 --- /dev/null +++ b/lisp/use-package/use-package-x/use-package-x-setopt.el @@ -0,0 +1,70 @@ +;;; use-package-x-setopt.el --- :setopt keyword definition -*- lexical-binding: t; -*- + +;; Copyright (C) 2025 Free Software Foundation, Inc. + +;; Author: Elias G. Perez + +;; 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 . + +;;; Commentary: + +;; This file provides the following extra keyword for +;; `use-package': +;; +;; * :setopt +;; Similar to :custom, but can also bind plain variables. +;; This uses the `setopt' function, for bind the variables. +;; +;; :setopt ( [value]) ... +;; +;; VALUE is optional, if omitted, VARIABLE will be set to nil. +;; +;; To use it load this library in your init file: +;; +;; (require 'use-package-x-setopt) + +;;; Code: + +;;; Requires +(require 'use-package) + + + +;;; Functions + +;;;###autoload +(defun use-package-normalize/:setopt (_name keyword args) + "Normalize :setopt keyword, ensure the values in ARGS are valid." + (use-package-as-one (symbol-name keyword) args + (lambda (label arg) + (unless (listp arg) + (use-package-error + (concat label + " must be a ( [value])" + " or a list of these"))) + (if (use-package-non-nil-symbolp (car arg)) + (list arg) + arg)))) + +;;;###autoload +(defun use-package-handler/:setopt (name _keyword args rest state) + (use-package-concat + `((setopt + ,@(mapcan + (lambda (list) (list (car list) (nth 1 list))) + args))) + (use-package-process-keywords name rest state))) + +(provide 'use-package-x-setopt) +;;; use-package-x-setopt.el ends here diff --git a/lisp/use-package/use-package-x/use-package-x-which-key-replacement.el b/lisp/use-package/use-package-x/use-package-x-which-key-replacement.el new file mode 100644 index 00000000000..186cf20bc7b --- /dev/null +++ b/lisp/use-package/use-package-x/use-package-x-which-key-replacement.el @@ -0,0 +1,111 @@ +;;; use-package-x-which-key-replacement.el --- :which-key-replacement keyword definition -*- lexical-binding: t; -*- + +;; Copyright (C) 2025 Free Software Foundation, Inc. + +;; Author: Elias G. Perez + +;; 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 . + +;;; Commentary: + +;; This file provides the following extra keyword for +;; `use-package': +;; +;; * :which-key-replacement +;; A simple way to set your which-key replacement keybindings. +;; +;; The form can be a any of these options: +;; +;; A cons-cell which will be passed as arguments for +;; which-key-add-key-based-replacements +;; +;; :which-key-replacement +;; ("C-c d" . "foo") +;; ("C-x 8" . '("unicode" . "Unicode keys")) +;; ... +;; +;; A list which specifies a keymap, passed as arguments for +;; which-key-add-keymap-based-replacements +;; +;; :which-key-replacement +;; (:keymap global-map +;; ("C-x a" "pretty name" command-name) +;; -- To add a prefix command, enclose it into a list-- +;; ("C-c a" "prefix" (prefix-map)) +;; ...) +;; +;; Or a list which specifies a major mode, passed as arguments for +;; which-key-add-major-mode-key-based-replacements +;; +;; :which-key-replacement +;; (:mode major-mode +;; ("C-c f" . "foo") +;; ("C-c e" . '("prefix" . "Pretty name")) +;; ...) +;; +;; To use it load this library in your init file: +;; +;; (require 'use-package-x-which-key-replacement) + +;;; Code: + +;;; Requires +(require 'use-package-core) + + + +;;; Functions + +;;;###autoload +(defun use-package-normalize/:which-key-replacement (_name keyword args) + "Normalize :which-key-replacement keyword." + (dolist (arg args) + (let ((x (car-safe arg))) + (unless (or x + (and (consp arg) (stringp x)) + (and (memq x '(:keymap :mode)) (symbolp (cadr arg)))) + (use-package-error + (concat (symbol-name keyword) + " values must be ( . )" + " or (:keymap ( ) ...)" + " or (:mode ( . ))"))))) + args) + +;;;###autoload +(defun use-package-handler/:which-key-replacement (name _keyword args rest state) + (use-package-concat + (use-package-process-keywords name rest state) + (mapcar + (lambda (elt) + (let ((car (car elt))) + (cond ((stringp car) + `(which-key-add-key-based-replacements ,car ,(cdr elt))) + ((eq :keymap car) + `(which-key-add-keymap-based-replacements ,(nth 1 elt) + ,@(cl-loop for (key string command) in (cddr elt) + append `(,key + (quote + ,(cons string + ;; For keymaps or functions + (if (consp command) + (symbol-value (car command)) + command))))))) + ((eq :mode car) + `(which-key-add-major-mode-key-based-replacements ,(nth 1 elt) + ,@(cl-loop for (key . replacement) in (cddr elt) + append `(,key ,replacement))))))) + args))) + +(provide 'use-package-x-which-key-replacement) +;;; use-package-x-which-key-replacement.el ends here -- 2.50.1 --=-=-= Content-Type: text/plain -- - E.G via Gnus and Org. --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 30 02:58:18 2025 Received: (at 79106) by debbugs.gnu.org; 30 Jul 2025 06:58:18 +0000 Received: from localhost ([127.0.0.1]:38782 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uh0lW-0006GD-0D for submit@debbugs.gnu.org; Wed, 30 Jul 2025 02:58:18 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]:46123) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uh0lT-0006Fd-8N for 79106@debbugs.gnu.org; Wed, 30 Jul 2025 02:58:16 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-24009eeb2a7so29432885ad.0 for <79106@debbugs.gnu.org>; Tue, 29 Jul 2025 23:58:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753858689; x=1754463489; darn=debbugs.gnu.org; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=NZ28YFPVKKpFnDBqqPrNF56M9ZcoeZslnAFZ35iArx0=; b=Fui2XLmfO55oz6Qi2g6LCK3Vo4Afyt6Qud/TxCPP0/IUFo4YwXLZNQ7h2wRJ1WuZxY BE9VVN3aVOoq17UQ539qnXAQxAomRG9j06F4BGNgPmwdMs8bkO14xPYM/pixY0FU85sy Pi+pzmJ6APEnkX0pUcIKq1HRGpOr62iN0Rw5e1GnqMvLIQaJHG9pOG38i3miIWzlJbzx nBXE/XKGrx6EidlP9rnWr4ZF+YMcEQHr8wGruw5lGqRk6sREsIhFnPrC8HodYWtAOTrP WgyHSvE1syCdJao/cFhWA4TOfQoP9gAEuql1KlfRmGoQd+ewgwQsLpyJxboj5UUA+oVL vH6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753858689; x=1754463489; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NZ28YFPVKKpFnDBqqPrNF56M9ZcoeZslnAFZ35iArx0=; b=JhKeM/yceqV6F6jPzWqTve7CV/RsmoOFxSit4MvBLu7LK4nfNpAJ4FKNPTmXg8XD1b kIc4YG9X6UE6UOCCZf5bbyNLXLiwAkpHtBydKim8xyIQsJFolWdsk4R4Tfvr28Dc+T7u oFIO/Av3gkTPjgmlDsyWGZxFkSRwTDscwfHAlHUN6ezAlZtjM6tUfggONjqHUeE53Wvv EkYPyNuj5YN7QzRaUQYAf8GTRcFZwEKtI9UvbMSiFC+a7CKmzj8uTcTxF1mDGk5gr4h3 FFTdEwfwZjAIETx2DrFu1+eYO8KM1rXb1FeAKT1l3zUHtHZmGZR5tAdta/PK1ySUCK+l jD3w== X-Forwarded-Encrypted: i=1; AJvYcCWbZvDKWe73YtuLV6jo2tkKzW/dMf6WDmVmvYkUDASTZHaodlg4myJYEoGSjOGzhwTRXXfo6w==@debbugs.gnu.org X-Gm-Message-State: AOJu0Yyel/vJ17l0862ItmTaEMrNJqNqTp3ns0eCFqtNFBda7hj9ZNSB E1Wyk2hDa+wWKODlCZOk9wdF4DAQhUGlwYniC7HM0UIqE3vxsd5yaUci X-Gm-Gg: ASbGncvJTNmXtqkIL95LuKDokPy5UTVnADVri1YUE1MJ8kRzAxBdakhTXAhMTVNQ/ER P3zglyFDiPrkpBJHRIBWMkiTHhMwgPT9y9GBp6mIyyPbLNOc2xQhCJCNMY+Zr+Ng5I/2Nm4gMP1 /Pulu95fz06s3uwaj9CWBbqrYH+ZglSqSWMX1novm81sNMICfE8Byyf3P5SqtAAEvWceM6EQn/C ycsjJK8HggyheuhN9o7BMMNtN7rD6FTDRdty+89hD7LWe/zAYSbipPV0bxAIYA3p2xtKnfwNWO8 lZEdqhR8nKFjdcRgsqEw0ZJFsnXIga3ZxRaeAQBV6bUr7VDXVVVv3JQ4z1y4y81Vhk6UB2ryozt ldBBW/Rl1HB66cmJ35FHgD75HnUN4p4xivAg8eT6JEZZtTfPsHYsH1W8Abudtw/LpZMrkIME= X-Google-Smtp-Source: AGHT+IFjGtnBM4pddWSjCEIZq3q6eK2Ransig9ZnRdzyZ9GK6oJKTMufLA7/872JK4WlsYy8vKVwlA== X-Received: by 2002:a17:903:986:b0:240:3584:6174 with SMTP id d9443c01a7336-24096a9da9bmr38939155ad.21.1753858689046; Tue, 29 Jul 2025 23:58:09 -0700 (PDT) Received: from localhost (c-98-207-111-199.hsd1.ca.comcast.net. [98.207.111.199]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-24007d98b25sm72633795ad.97.2025.07.29.23.58.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Jul 2025 23:58:08 -0700 (PDT) From: Karthik Chikmagalur To: Elijah Gabe =?utf-8?Q?P=C3=A9rez?= Subject: Re: bug#79106: [PATCH] Add new optional keywords to use-package In-Reply-To: <87a54nfqv3.fsf@gmail.com> ("Elijah Gabe =?utf-8?Q?P=C3=A9rez?= =?utf-8?Q?=22's?= message of "Tue, 29 Jul 2025 00:33:36 -0600") References: <87wm7te6a6.fsf@gmail.com> <871pq03yt7.fsf@posteo.net> <87a54nfqv3.fsf@gmail.com> Date: Tue, 29 Jul 2025 23:58:07 -0700 Message-ID: <87ms8mupvk.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 79106 Cc: John Wiegley , Philip Kaludercic , 79106@debbugs.gnu.org, Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) My general feedback is that most of these keywords are adding complexity without providing much benefit over the more explicit form of placing code in :init, :preface or :config. >>> This includes following keywords: >>> >>> * :advice Add or remove function advices. >> >> I did not understand how this uses :advice to create something >> use-package specific that has an advantage over `define-advice'. > > This acts more to `advice-add` than `define-advice`. It is intended to > add advices from some packages, such as consult, which has the > `consult-register-window` function, that is intended to override > `register-preview`. > > This is also inspired by leaf.el which have `:advice` and `:advice-remove`. It seems better to me to use :init followed by advice-add. Version in the patch: (use-package test :advice (:add my-function :override other-function) (:add my-other-function :around (lambda (...) ...))) Current approach: (use-package test :init (advice-add 'other-function :override 'my-function) (advice-add 'my-other-function :around (lambda (...) ...))) The current approach seems superior to introducing a new keyword -- it does not require learning new syntax, and the advice statements under :init can be independently evaluated (with eval-last-sexp) if required. It's also not saving the user any typing, as far as I can tell? >>> * :defvar-keymap Define a new keymap or override an existent one. I have the same thought here -- it's not any more work to write a defvar-keymap statement in :init, and it can specify all aspects of the keymap (such as repeat states, keymap sparsity etc), which this cannot do. >>> * :hook+ Like default :hook, but allows to set the hook depth and set >>> multiple functions in the hook (or for each hook). >>> >>> Although I tried to make it compatible with :hook, there may be some >>> things I missed, so I decided to put it separately instead of merging >>> it with :hook. In addition, its syntax is more complex compared to >>> :hook. I think :hook can be generalized a bit, and that might be better than introducing :hook+. In the following example: (use-package test :hook+ ((text-mode prog-mode) . (:multi auto-fill-mode show-paren-mode)) (org-mode . (:multi (lambda () something) org-indent-mode)) (:depth -4 (outline-mode . (:multi (lambda () (print "-4 depth!")) outline-hide-body)))) The price of "magic" syntax like :multi and :depth here is paid by the user who might use them infrequently (compared to add-hook) and have to relearn it every time. But once there is public code out there that uses :hook+, the price will also be paid by all parties when sharing code. New Emacs users often copy code blocks and tweak them without understanding it. It is much easier for them to try to understand a series of add-hook statements in :init than something like the above. There is nothing they can run describe-symbol on, for example. >> I can imagine that the name is confusing to beginners, and also question >> if it might be cleaner to just advise users to use `add-hook' if they >> want to do something specific and more technical. I agree with Philip here. >> Wrt. the patch, I would still merge the files into one, instead of >> having each keyword in a separate file. > > This is inconvenient, since if someone wants to use only one of these > keywords, they would have to load the entire file. > > Keeping them separate prevents this and is also easier to maintain and > move them to ELPA (if it is decided in the future). Here I agree with Elijah, although the Emacs maintainers know best. Karthik From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 30 06:21:55 2025 Received: (at 79106) by debbugs.gnu.org; 30 Jul 2025 10:21:55 +0000 Received: from localhost ([127.0.0.1]:39614 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uh3wZ-000358-0j for submit@debbugs.gnu.org; Wed, 30 Jul 2025 06:21:55 -0400 Received: from mout01.posteo.de ([185.67.36.65]:47733) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uh3wV-00034o-S2 for 79106@debbugs.gnu.org; Wed, 30 Jul 2025 06:21:52 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 9A1F3240027 for <79106@debbugs.gnu.org>; Wed, 30 Jul 2025 12:21:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=posteo.net; s=1984.ea087b; t=1753870904; bh=Rb2ljGZviYURMUBFbmoEQOq/S2B7HFuTgIIdBTzW1mk=; h=From:To:Cc:Subject:Autocrypt:OpenPGP:Date:Message-ID:MIME-Version: Content-Type:From; b=FLiN+pvWgmG2ksOa+NuIl1qcwe/6zzF2C6iwk2E5YGxQ/mc9CjiYjd22pBja9KGLr gGn2uzstOMqF6QeSLqS7xV/cEOhG7TIktIK1iQNSr8gff+EshdfjVs1Tm8mTwWPtsf JVvNK4TQMt0DeNWHj4UdI0Z424L8ip/PACw6fNlrHLoLBcjrjU5f15teUQ7j8294ho CK27Q8vtcSnHRZcDxqgSz4rMvPKbMDjL13pg13g5rfoGQpDUXYaGsEP+UpnHuXVL6W qLOBdY4Ta3kaOJc5MfNfkMjyIaDHwKXGvoBrQMq8M/McM5ZEvOrefWGUcDiZPtOPWU ba8OhRJWdQb+BcdEmD8a+Mnit1n+VPRph3905egFiQ5BK/uqzyUOsOx+XmfBKUfnu5 kE2UwATslkizWNeopeUlVjSmR09L6f/mGf8ZaSzo8rUu35x7sU4AUjzNLaH6dnoDPo iKPxsGxPilay4mOw6gjOPLgYMvvVAObgbYlVPfr2hV2gijaZBXL Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4bsStb4m91z9rxN; Wed, 30 Jul 2025 12:21:43 +0200 (CEST) From: Philip Kaludercic To: Karthik Chikmagalur Subject: Re: bug#79106: [PATCH] Add new optional keywords to use-package In-Reply-To: <87ms8mupvk.fsf@gmail.com> References: <87wm7te6a6.fsf@gmail.com> <871pq03yt7.fsf@posteo.net> <87a54nfqv3.fsf@gmail.com> <87ms8mupvk.fsf@gmail.com> Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM OpenPGP: id=7126E1DE2F0CE35C770BED01F2C3CC513DB89F66; url="https://keys.openpgp.org/vks/v1/by-fingerprint/7126E1DE2F0CE35C770BED01F2C3CC513DB89F66"; preference=signencrypt Date: Wed, 30 Jul 2025 10:21:44 +0000 Message-ID: <87jz3q2d3d.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79106 Cc: John Wiegley , Elijah Gabe =?utf-8?Q?P=C3=A9rez?= , 79106@debbugs.gnu.org, Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Karthik Chikmagalur writes: > My general feedback is that most of these keywords are adding complexity > without providing much benefit over the more explicit form of placing > code in :init, :preface or :config. I should clarify, that I don't use `use-package', so I don't know what users are looking for. I can just say, that in my configuration macro `setup' the guiding principle for adding a local macro (which roughly corresponds to a keyword in use-package) is that there is some local context that can be exploited to avoid duplication. For instance, (setup texinfo (:hook reftex-mode) (:unbind "RET")) expands to (progn (add-hook 'texinfo-mode-hook (function reftex-mode)) (eval-after-load 'texinfo (function (lambda nil (define-key texinfo-mode-map "." nil))))) where the fact that texinfo is being configured is used to determine what hook to add the function to, what feature to wait for until it has been loaded and what map to modify thereafter. I have macros like :option (that correspond to use-package's `:custom', but I don't advise using them and never wanted to add more like these, because they do not do anything more than just `setopt' (though to be fair, setopt is newer than :option)). Perhaps this is also an interesting heuristic to decide what new keywords are interesting for use-package as well -- unless we want to say that the ideal should be to be able to express everything in non-evaluated code -- i.e. that :init and :config are in some sense bad style that distract from the declarative nature of use-package, and just exist to plug the holes of configuration patterns that don't yet have keywords. >>>> This includes following keywords: >>>> >>>> * :advice Add or remove function advices. >>> >>> I did not understand how this uses :advice to create something >>> use-package specific that has an advantage over `define-advice'. >> >> This acts more to `advice-add` than `define-advice`. It is intended to >> add advices from some packages, such as consult, which has the >> `consult-register-window` function, that is intended to override >> `register-preview`. >> >> This is also inspired by leaf.el which have `:advice` and `:advice-remove`. > > It seems better to me to use :init followed by advice-add. Version in > the patch: a> > (use-package test > :advice > (:add my-function :override other-function) > (:add my-other-function :around (lambda (...) ...))) > > Current approach: > > (use-package test > :init > (advice-add 'other-function :override 'my-function) > (advice-add 'my-other-function :around (lambda (...) ...))) > > The current approach seems superior to introducing a new keyword -- it > does not require learning new syntax, and the advice statements under > :init can be independently evaluated (with eval-last-sexp) if required. > It's also not saving the user any typing, as far as I can tell? Right, this was what I was getting at. Functionally, the new keyword doesn't exploit the fact that we are configuring the package `test'. But as I said, if the goal is to have a consistent syntax for everything, then this might be desirable. >>>> * :defvar-keymap Define a new keymap or override an existent one. > > I have the same thought here -- it's not any more work to write a > defvar-keymap statement in :init, and it can specify all aspects of the > keymap (such as repeat states, keymap sparsity etc), which this cannot > do. > >>>> * :hook+ Like default :hook, but allows to set the hook depth and set >>>> multiple functions in the hook (or for each hook). >>>> >>>> Although I tried to make it compatible with :hook, there may be some >>>> things I missed, so I decided to put it separately instead of merging >>>> it with :hook. In addition, its syntax is more complex compared to >>>> :hook. > > I think :hook can be generalized a bit, and that might be better than > introducing :hook+. > > In the following example: > > (use-package test > :hook+ > ((text-mode prog-mode) > . (:multi auto-fill-mode > show-paren-mode)) > (org-mode > . (:multi (lambda () something) > org-indent-mode)) > (:depth -4 > (outline-mode > . (:multi (lambda () (print "-4 depth!")) > outline-hide-body)))) > > The price of "magic" syntax like :multi and :depth here is paid by the > user who might use them infrequently (compared to add-hook) and have to > relearn it every time. > > But once there is public code out there that uses :hook+, the price will > also be paid by all parties when sharing code. New Emacs users often > copy code blocks and tweak them without understanding it. It is much > easier for them to try to understand a series of add-hook statements in > :init than something like the above. There is nothing they can run > describe-symbol on, for example. > >>> I can imagine that the name is confusing to beginners, and also question >>> if it might be cleaner to just advise users to use `add-hook' if they >>> want to do something specific and more technical. > > I agree with Philip here. > >>> Wrt. the patch, I would still merge the files into one, instead of >>> having each keyword in a separate file. >> >> This is inconvenient, since if someone wants to use only one of these >> keywords, they would have to load the entire file. IIRC correctly, the overhead of loading just a few files would probably exceed the time saved from having to only parse the necessary ones. We can benchmark this in more details if we want to be sure, but there is a reason that we have options like `package-quickstart'. >> Keeping them separate prevents this and is also easier to maintain and >> move them to ELPA (if it is decided in the future). That shouldn't be our concern here, as if we add the features to the core, the danger of moving it out to ELPA are very slim -- and even if, it would take a long time of deprecation where we would be free to change and split up the files again. And for my suggestions, having a use-package-x.el file, it wouldn't be make much of a difference in effort to move that or a larger number of files out to ELPA. > Here I agree with Elijah, although the Emacs maintainers know best. > > Karthik From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 30 11:25:37 2025 Received: (at 79106) by debbugs.gnu.org; 30 Jul 2025 15:25:37 +0000 Received: from localhost ([127.0.0.1]:41971 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uh8gS-0000W0-12 for submit@debbugs.gnu.org; Wed, 30 Jul 2025 11:25:36 -0400 Received: from mail-ua1-x92f.google.com ([2607:f8b0:4864:20::92f]:52415) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uh8gP-0000VZ-1J for 79106@debbugs.gnu.org; Wed, 30 Jul 2025 11:25:34 -0400 Received: by mail-ua1-x92f.google.com with SMTP id a1e0cc1a2514c-88bc56adaa4so400681241.0 for <79106@debbugs.gnu.org>; Wed, 30 Jul 2025 08:25:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753889127; x=1754493927; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=8PryJl33XNGu8kBV+TJ1k37i2MzITv8P1YyohhM9MBw=; b=fAlyudw5xiUAo7tbJhHd1XkCpuVu6ZWNxydmaeBUU0X3tQZ/AflpSIJtJsioZtXOZ4 1PIes/0NFnVsRl+Qpq78Yb/QZeaH2QSUlZbbdCesv8KQ5dKogceEeGpRpB8rUBqVczIF wwabhn93twUm1gaUkpIl6trWrh9ROXJ/JEQ23f8x7qGwCrtLiso1PkXDFvAEMPfblKte gDqHEG1QpWJE9WFLlYyobHwsnktjQjWLirVOvrxE9fKwou5UQk72G4bdWXp8GDP2i2gd RqlSDP5saOrDaSy1Wy8bVtWVX07cli/k56tVX/imJ7LQIqN2GuMJ2sE7MhvrmEuipblt 2KoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753889127; x=1754493927; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8PryJl33XNGu8kBV+TJ1k37i2MzITv8P1YyohhM9MBw=; b=KCvxtWHVBiUAVwk3Z0qSZ9pjQRb8yql5/H/mqVlbnXHVy4t8sNLmGlTqXByUs6Nm97 QQub4607/wggeG1jAsZOqtnHMPeDRtEmR6I6Ar8FWEdy6fe2bL4Ix0PQ8JG2PDWTqy0J k5E3DMAO6oix57HZH3VUJ8XTOzTkUJeUSsJ1ladyIYb+faODnWMBXoFPmq+UuL2LxwGu k/3KN11D1Q8zwgH9qeC5RAcCeLrEcrNdfHNsKT84gEp0AbZqlG/ei0j4IxnC+8CXPagg oNkiwalAnXCZyFUu2uCOeHbjgFULeivN0yV9MmHn3OB+6xri5xd4HkpqF6AGXL9g2Qsx x1NA== X-Forwarded-Encrypted: i=1; AJvYcCUVmeITMgsiyudIRPbzAVVr6dOyvoKG1l6UeHl58VwLvctDcgASbJGnv6PbsPcd07ELuisXJg==@debbugs.gnu.org X-Gm-Message-State: AOJu0YzjvuofBYKQAMgV1VW+Kj4mcqf+pLZzP/KnSED7fOqxUDAbT/vH I3l2tF7/A7Erf0kAthzNSxI8C7FsX5q6yS5QPEBC5kHLCyFlUru/Gb3uAuKz3FWkE6B4b6scNsj YmitCl3fJPoC01hktWpMLZwVsQjC73YN1JA== X-Gm-Gg: ASbGncvIc83L949ytraezCS5k9PGQkXVZXg1whPZYsUeO4HWPe0KlRqB3wDnIMnZRp1 OMQtFi32tQLQ8GuFm0yWSAR3DO8CuBlvzFJCiY2b3fhsy6CYg3341AycS4ESXqzRPq7Q627hHUj kNc6QZ+Y+BKmd99eKfOhOQIX+MxXrSqj+9HQID1IIj+kQ1jL5GJXTH3CqeeIdirNVulKkZ/otFn tDat+MNtA== X-Google-Smtp-Source: AGHT+IGaEsELFB6s5jJaN/LlssZF3FcCpJV1YgFueSVnKgkeUUIeb9Ta3n0EpNpymbIUsdcseoprUyHvEgjhv6oNtfY= X-Received: by 2002:a05:6102:2ad1:b0:4e9:9281:85aa with SMTP id ada2fe7eead31-4fbe7efb074mr2194878137.1.1753889126849; Wed, 30 Jul 2025 08:25:26 -0700 (PDT) MIME-Version: 1.0 References: <87wm7te6a6.fsf@gmail.com> <871pq03yt7.fsf@posteo.net> <87a54nfqv3.fsf@gmail.com> <87ms8mupvk.fsf@gmail.com> In-Reply-To: <87ms8mupvk.fsf@gmail.com> From: =?UTF-8?Q?St=C3=A9phane_Marks?= Date: Wed, 30 Jul 2025 11:25:15 -0400 X-Gm-Features: Ac12FXz2VvJEfhxZSD-vOeC7upX9Kkjbm-f9WaCn-7G21gfffqIdPPnDUuEYHfw Message-ID: Subject: Re: bug#79106: [PATCH] Add new optional keywords to use-package To: Karthik Chikmagalur Content-Type: multipart/alternative; boundary="00000000000061b074063b2722ef" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 79106 Cc: John Wiegley , =?UTF-8?Q?Elijah_Gabe_P=C3=A9rez?= , 79106@debbugs.gnu.org, Philip Kaludercic , Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --00000000000061b074063b2722ef Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jul 30, 2025 at 3:03=E2=80=AFAM Karthik Chikmagalur < karthikchikmagalur@gmail.com> wrote: > My general feedback is that most of these keywords are adding complexity > without providing much benefit over the more explicit form of placing > code in :init, :preface or :config. > > >>> This includes following keywords: > >>> > >>> * :advice Add or remove function advices. > >> > >> I did not understand how this uses :advice to create something > >> use-package specific that has an advantage over `define-advice'. > > > > This acts more to `advice-add` than `define-advice`. It is intended to > > add advices from some packages, such as consult, which has the > > `consult-register-window` function, that is intended to override > > `register-preview`. > > > > This is also inspired by leaf.el which have `:advice` and > `:advice-remove`. > > It seems better to me to use :init followed by advice-add. Version in > the patch: > > (use-package test > :advice > (:add my-function :override other-function) > (:add my-other-function :around (lambda (...) ...))) > > Current approach: > > (use-package test > :init > (advice-add 'other-function :override 'my-function) > (advice-add 'my-other-function :around (lambda (...) ...))) > > The current approach seems superior to introducing a new keyword -- it > does not require learning new syntax, and the advice statements under > :init can be independently evaluated (with eval-last-sexp) if required. > It's also not saving the user any typing, as far as I can tell? > > >>> * :defvar-keymap Define a new keymap or override an existent one. > > I have the same thought here -- it's not any more work to write a > defvar-keymap statement in :init, and it can specify all aspects of the > keymap (such as repeat states, keymap sparsity etc), which this cannot > do. > > >>> * :hook+ Like default :hook, but allows to set the hook depth and set > >>> multiple functions in the hook (or for each hook). > >>> > >>> Although I tried to make it compatible with :hook, there may be som= e > >>> things I missed, so I decided to put it separately instead of mergi= ng > >>> it with :hook. In addition, its syntax is more complex compared to > >>> :hook. > > I think :hook can be generalized a bit, and that might be better than > introducing :hook+. > > In the following example: > > (use-package test > :hook+ > ((text-mode prog-mode) > . (:multi auto-fill-mode > show-paren-mode)) > (org-mode > . (:multi (lambda () something) > org-indent-mode)) > (:depth -4 > (outline-mode > . (:multi (lambda () (print "-4 depth!")) > outline-hide-body)))) > > The price of "magic" syntax like :multi and :depth here is paid by the > user who might use them infrequently (compared to add-hook) and have to > relearn it every time. > > But once there is public code out there that uses :hook+, the price will > also be paid by all parties when sharing code. New Emacs users often > copy code blocks and tweak them without understanding it. It is much > easier for them to try to understand a series of add-hook statements in > :init than something like the above. There is nothing they can run > describe-symbol on, for example. > > >> I can imagine that the name is confusing to beginners, and also questi= on > >> if it might be cleaner to just advise users to use `add-hook' if they > >> want to do something specific and more technical. > > I agree with Philip here. > > >> Wrt. the patch, I would still merge the files into one, instead of > >> having each keyword in a separate file. > > > > This is inconvenient, since if someone wants to use only one of these > > keywords, they would have to load the entire file. > > > > Keeping them separate prevents this and is also easier to maintain and > > move them to ELPA (if it is decided in the future). > > Here I agree with Elijah, although the Emacs maintainers know best. > I tend to agree with Karthik, and would not use any of the new keywords in my configuration. I suspect it will encourage lack of understanding, and increase support burden. e.g., for sufficiently sophisticated users that need to specify hook depth, they're likely also providing their own functions and those have to be defined somewhere (and lambdas are discouraged in hooks, right?). In my configuration, I tend to pair `remove-hook` and `advice-remove` calls, which I comment out, to facilitate testing and comparison of results from unadvised functions, and to make it easy to remove a named hook also for the same reasons. These keywords will discourage learning Elisp programming, which even the most minor of function advices requires to foster a mental model. Are these syntactic sugar keywords truly necessary if the evidence of requests on the core Emacs mailing lists has been very limited? I'm not sure using Github issues is as valuable as core discussions tend to be. -St=C3=A9phane --00000000000061b074063b2722ef Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
My general feedback is that= most of these keywords are adding complexity
without providing much benefit over the more explicit form of placing
code in :init, :preface or :config.

>>> This includes following keywords:
>>>
>>> * :advice Add or remove function advices.
>>
>> I did not understand how this uses :advice to create something
>> use-package specific that has an advantage over `define-advice'= ;.
>
> This acts more to `advice-add` than `define-advice`.=C2=A0 It is inten= ded to
> add advices from some packages, such as consult, which has the
> `consult-register-window` function, that is intended to override
> `register-preview`.
>
> This is also inspired by leaf.el which have `:advice` and `:advice-rem= ove`.

It seems better to me to use :init followed by advice-add.=C2=A0 Version in=
the patch:

(use-package test
=C2=A0 :advice
=C2=A0 (:add my-function :override other-function)
=C2=A0 (:add my-other-function :around (lambda (...) ...)))

Current approach:

(use-package test
=C2=A0 :init
=C2=A0 (advice-add 'other-function :override 'my-function)
=C2=A0 (advice-add 'my-other-function :around (lambda (...) ...)))

The current approach seems superior to introducing a new keyword -- it
does not require learning new syntax, and the advice statements under
:init can be independently evaluated (with eval-last-sexp) if required.
It's also not saving the user any typing, as far as I can tell?

>>> * :defvar-keymap Define a new keymap or override an existent o= ne.

I have the same thought here -- it's not any more work to write a
defvar-keymap statement in :init, and it can specify all aspects of the
keymap (such as repeat states, keymap sparsity etc), which this cannot
do.

>>> * :hook+ Like default :hook, but allows to set the hook depth = and set
>>>=C2=A0 =C2=A0multiple functions in the hook (or for each hook).=
>>>
>>>=C2=A0 =C2=A0Although I tried to make it compatible with :hook,= there may be some
>>>=C2=A0 =C2=A0things I missed, so I decided to put it separately= instead of merging
>>>=C2=A0 =C2=A0it with :hook.=C2=A0 In addition, its syntax is mo= re complex compared to
>>>=C2=A0 =C2=A0:hook.

I think :hook can be generalized a bit, and that might be better than
introducing :hook+.

In the following example:

(use-package test
=C2=A0 :hook+
=C2=A0 ((text-mode prog-mode)
=C2=A0 =C2=A0. (:multi auto-fill-mode
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0show-paren-mode))
=C2=A0 (org-mode
=C2=A0 =C2=A0. (:multi (lambda () something)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0org-indent-mode))
=C2=A0 (:depth -4
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (outline-mode
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0. (:multi (lambda () (print "= -4 depth!"))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0outline-hide-body))))

The price of "magic" syntax like :multi and :depth here is paid b= y the
user who might use them infrequently (compared to add-hook) and have to
relearn it every time.

But once there is public code out there that uses :hook+, the price will also be paid by all parties when sharing code.=C2=A0 New Emacs users often<= br> copy code blocks and tweak them without understanding it.=C2=A0 It is much<= br> easier for them to try to understand a series of add-hook statements in
:init than something like the above.=C2=A0 There is nothing they can run describe-symbol on, for example.

>> I can imagine that the name is confusing to beginners, and also qu= estion
>> if it might be cleaner to just advise users to use `add-hook' = if they
>> want to do something specific and more technical.

I agree with Philip here.

>> Wrt. the patch, I would still merge the files into one, instead of=
>> having each keyword in a separate file.
>
> This is inconvenient, since if someone wants to use only one of these<= br> > keywords, they would have to load the entire file.
>
> Keeping them separate prevents this and is also easier to maintain and=
> move them to ELPA (if it is decided in the future).

Here I agree with Elijah, although the Emacs maintainers know best.

I tend to agree with Karthik, and would not use any of the new ke= ywords in my configuration.=C2=A0 I suspect it will encourage lack of under= standing, and increase support burden.=C2=A0 e.g., for sufficiently sophist= icated users that need to specify hook depth, they're likely also provi= ding their own functions and those have to be defined somewhere (and lambda= s are discouraged in hooks, right?).=C2=A0 In my configuration, I tend to p= air `remove-hook` and `advice-remove` calls, which I comment out, to facili= tate testing and comparison of results from unadvised functions, and to mak= e it easy to remove a named hook also for the same reasons.=C2=A0 These key= words will discourage learning Elisp programming, which even the most minor= of function advices requires to foster a mental model.

Are these syntactic sugar keywor= ds truly necessary if the evidence of requests on the core Emacs mailing li= sts has been very limited?=C2=A0 I'm not sure using Github issues is as= valuable as core discussions tend to be.

-St=C3=A9phane
--00000000000061b074063b2722ef-- From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 30 14:07:56 2025 Received: (at 79106) by debbugs.gnu.org; 30 Jul 2025 18:07:56 +0000 Received: from localhost ([127.0.0.1]:42641 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uhBDX-00026i-Mv for submit@debbugs.gnu.org; Wed, 30 Jul 2025 14:07:56 -0400 Received: from fhigh-b4-smtp.messagingengine.com ([202.12.124.155]:36395) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uhBDV-00026D-8N for 79106@debbugs.gnu.org; Wed, 30 Jul 2025 14:07:53 -0400 Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfhigh.stl.internal (Postfix) with ESMTP id 674CD7A011A; Wed, 30 Jul 2025 14:07:47 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Wed, 30 Jul 2025 14:07:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newartisans.com; h=cc:cc:content-transfer-encoding:content-type:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=fm2; t=1753898867; x=1753985267; bh=85BJrP0hjjHzf4LObBsYzdpTN8s98CKj UZ3fsD1uV0M=; b=dEips1+BcGmkLADzarTfHRsCSSfx/GHhG/GIwtEHxivoNAbj tIkPRjqe9mNqZumL3/6nYuU9twuPYhtPl95db80FEyH+wISOvQCcWE6aJ1Q6dKx1 7+u+BtRTRc5NZKAYB4qRIU1rGteVp084FFpdJe29Bgv/BvFT1BBm2C50SRrjgNFg bS07ncFNJ7awlj1bP0BYnZ92OZcS0FBnhDPKF3KPPIIeR0vVmO+TZTqtflEKZDB6 CcWkAPON52/8aTXzCl4WVvDCY3vq1GgnSi8BqvgoH8p6KcLftjU2pWZr451QfRZU iDu6cqsfzQX+6lni7Ych6YbtO0Ij8gGlgdTGmQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1753898867; x= 1753985267; bh=85BJrP0hjjHzf4LObBsYzdpTN8s98CKjUZ3fsD1uV0M=; b=D y7YBih2H6Mpes5Le7m76fMNW++nzAW+gW1T1OkTYuEdmKbb2ol5JJjSX2N/OlHOI TxMvLUgiYDg2jVhmn0kgeasgBsZw3b/FIjxdqLPh00kYOO37CuKOQ/OVYUfqMvbn dzufF8ZHP1fkdkFAdiRyHj/VAlmYHLVpPBYYjRKKnsM6uopRCKyoGbmAUV7fT5+Y SzdAFfulOIC8mbbwpf6C84N5PHrsgN91UYIIQ+c1y05Fj6afdVZMaXBfLErFTG1u ot7aC6MqT9E0QljEME1HJdcZO1pZ36+XgSz32HWBQce9YACzfYclRdJuH7uTrlQw LMxZjNpMoI+jxTZfk/Mvw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdelkeeiudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefhvfevufgjohhffffkfgggtgfgsehtqhertddtreejnecuhfhrohhmpeflohhhnhcu hghivghglhgvhicuoehjohhhnhifsehnvgifrghrthhishgrnhhsrdgtohhmqeenucggtf frrghtthgvrhhnpedvvdefteelvdeugfdvffduudejjeelueeugfdtueekhfdtvdeijeef ffdthffgteenucffohhmrghinhepnhgvfigrrhhtihhsrghnshdrtghomhdpghhithhhuh gsrdgtohhmpdhprghtrhgvohhnrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfr rghrrghmpehmrghilhhfrhhomhepjhhohhhnfiesnhgvfigrrhhtihhsrghnshdrtghomh dpnhgspghrtghpthhtohepiedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepvghl ihiisehgnhhurdhorhhgpdhrtghpthhtohepjeeluddtieesuggvsggsuhhgshdrghhnuh drohhrghdprhgtphhtthhopehphhhilhhiphhksehpohhsthgvohdrnhgvthdprhgtphht thhopegvgheigedvieduieesghhmrghilhdrtghomhdprhgtphhtthhopehkrghrthhhih hktghhihhkmhgrghgrlhhurhesghhmrghilhdrtghomhdprhgtphhtthhopehshhhiphhm ihhnthhssehgmhgrihhlrdgtohhm X-ME-Proxy: Feedback-ID: i4e0145b7:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 30 Jul 2025 14:07:45 -0400 (EDT) From: John Wiegley To: =?utf-8?Q?St=C3=A9phane?= Marks Subject: Re: bug#79106: [PATCH] Add new optional keywords to use-package In-Reply-To: (=?utf-8?Q?=22St=C3=A9phane?= Marks"'s message of "Wed, 30 Jul 2025 11:25:15 -0400") Organization: New Artisans LLC References: <87wm7te6a6.fsf@gmail.com> <871pq03yt7.fsf@posteo.net> <87a54nfqv3.fsf@gmail.com> <87ms8mupvk.fsf@gmail.com> Date: Wed, 30 Jul 2025 11:07:44 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 79106 Cc: Karthik Chikmagalur , Elijah Gabe =?utf-8?Q?P=C3=A9rez?= , 79106@debbugs.gnu.org, Philip Kaludercic , Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) >>>>> St=C3=A9phane Marks writes: > I tend to agree with Karthik, and would not use any of the new > keywords in my configuration.=C2=A0 I suspect it will encourage lack of > understanding, and increase support burden.=C2=A0 e.g., for sufficiently > sophisticated users that need to specify hook depth, they're likely > also providing their own functions and those have to be defined > somewhere (and lambdas are discouraged in hooks, right?).=C2=A0 In my > configuration, I tend to pair `remove-hook` and `advice-remove` > calls, which I comment out, to facilitate testing and comparison of > results from unadvised functions, and to make it easy to remove a > named hook also for the same reasons.=C2=A0 These keywords will discourage > learning Elisp programming, which even the most minor of function > advices requires to foster a mental model. I must say that I respectfully disagree with Karthik=E2=80=99s reasoning he= re. I don=E2=80=99t think it=E2=80=99s a good design principle to remove functionality from the= hands of everyone, only for the sake of those who would not fully understand it =E2= =80=94 and thus, who probably wouldn=E2=80=99t have used it in the first place. If we take this logic to the extreme, there would be no reason for use-pack= age at all, because in the end it=E2=80=99s just Elisp that you can write yours= elf. The main reason I created it is to codify best practices that I didn=E2=80=99t = want to have to repeat. Take :hook for example. It codifies this pattern: If :demand is being used (or is implied), it=E2=80=99s just add-hook with= the tiny syntactic convenience of not needed to put `-hook` at the end of the symb= ol name, or the ability to just say `SYM` and have the hook name inferred. If :demand is not being used (or is not implied), then it additionally declares an autoload for the function being added to the hook. This autol= oad is probably already being defined by the package, so doubtful it=E2=80=99= s needed. Is it really better to say: (use-package foo :hook bar) Than just: (add-hook 'bar-hook #'foo-mode) Probably not really. The former hides a bit of logic =E2=80=94 and thus, op= ens the door to confusion =E2=80=94 while the second always works as intended and c= an be separately evaluated, etc. But the point is: *the first form is what I want= to write, as an Emacs user who does understand what=E2=80=99s going on*. Adding :hook+ would allow me to additionally specify depth, which at the moment I cannot do, requiring me to undo the declarative form and use the procedural form in order to pass a depth argument. Lastly, use-package-x (and family?) is *opt-in*. If people want to post the= ir use of it online, and others want to copy&paste it, that=E2=80=99s on them.= I wouldn=E2=80=99t try to prevent them from having easy access to those features simply because some third party might try to join in the fun and not fully understand what= =E2=80=99s going on. -- John Wiegley GPG fingerprint =3D 4710 CF98 AF9B 327B B80F http://newartisans.com 60E1 46C4 BD1A 7AC1 4BA2 Sponsor my open source on github.com/sponsors/jwiegley or patreon.com/jwieg= ley From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 30 19:08:45 2025 Received: (at 79106) by debbugs.gnu.org; 30 Jul 2025 23:08:45 +0000 Received: from localhost ([127.0.0.1]:43479 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uhFue-0003VC-IS for submit@debbugs.gnu.org; Wed, 30 Jul 2025 19:08:45 -0400 Received: from mail-oa1-x44.google.com ([2001:4860:4864:20::44]:47273) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uhFub-0003Uq-My for 79106@debbugs.gnu.org; Wed, 30 Jul 2025 19:08:42 -0400 Received: by mail-oa1-x44.google.com with SMTP id 586e51a60fabf-2edec6c5511so173644fac.2 for <79106@debbugs.gnu.org>; Wed, 30 Jul 2025 16:08:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753916915; x=1754521715; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=8NKnV97Y7s80fV9W5kQY4Q1hrOxyHx7WahkIrqrQWmQ=; b=HY34BkamrUFi7BEyGZ1ewovTFInvUYFdc13yVavI+bH91YPi2T4j9z7eoJbIXFeryj xe0H7pqcNSXXzapXpK6qDubry54TgC3EvOfOraNpNFYhR0LgQSrX5CPwzPf5e3owEAOn 7/SGfVWjYtl1GWEv29W/oHrqNAajR80UK4AHd7FerQayoo8SeF/MygoMli6bnxMinFlt VjZrBgHh1K8zSZaL1sbFjY4Za3Y/KPg9Jq/hNmzLqU/GNYPSmv4T7PVv+L01N7Ds4rpU U6x5xubVtJ94iIsG6w8zSS/Z5qpn1aUc3ZINm8+zqj0LEz5tusaMoxSNVeAi7B5lHXfz e9UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753916915; x=1754521715; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=8NKnV97Y7s80fV9W5kQY4Q1hrOxyHx7WahkIrqrQWmQ=; b=qdamPpxgBFA0G/MmI4+HeToTDia5PBSADKKYVURO8Lgbem9N8c+Gbt23YUFQA89S32 YpbbgJC1EfMcis5r3Mh3VUWqF+yM1mAz3bdrlooN/a9fKLU0E5pNcLkgQQ8bSh4p5rzl E5chpfKGhesVBjiIGQkMP3OUaTeVQ0K7J/CQEH/6vcmKDYCXqS7QM+9NSHWdd0pNdXG5 fssp+EzIzDd8jispUxZ0lWtaG9O5KeD9Fiycs0oMdcIv41Ohtvtw++MvHKcw55a8ECvp NY6fhQ0YVdDJPDnyij9riodXtFBWhOFj0zSOhd81cwGs5BvWKmg4rHu44gg9T8TyjMre bQ5A== X-Forwarded-Encrypted: i=1; AJvYcCWVpnOT81XmYLQc5usr0s18ZcS9sNaAkFLbo9c2h9U5ySRD+KbtC7JatnDG2vmqJuQ2jCXQVQ==@debbugs.gnu.org X-Gm-Message-State: AOJu0YwiBymFmzKTXbz2+nTtnPhGFkpYMfkiBNNdzcCH9PHOUOZTSPZf 05JnMahXhEd22GSQwOLSmnCsRsVZ51OirusltT8OU58iZzpYEB/0oI07 X-Gm-Gg: ASbGncu4o/PeS34bEXp4AirRf4hUGMGkxnVSaKO9oV5UN6xUWFX6wTXRKu45DBGri6v Us5moVJ1bUagvfEfaYcxa3qfpSsAbRpza3jA1L0TSH51zul8wmxLlrOKvVACh0EbphpTUB38Vj2 /dP9uSUpG3JeuH+O512CQt+MYNq2YD/eFAEiD2kfpgoo+5xQfJPtG40U66tt5Bvb515+O9DZVYo 2WVerc0/mUMd9Hm+YdTab96YOzVU2FHG1VUUYKXgaPp6AwH2rYCQmydUw/DQrQdlKSgE9BWTfSV apjY0+dR68y99ieZCTgblHdFu2V942T5TB7XRL/O6OgQdqyFidlfAh/n4qPwmawofl+UxvJ8YMc LXKxttAcgzgjLZcOxCjftiF3wMg== X-Google-Smtp-Source: AGHT+IGc/XceL+ggg3P1WI1hT/eUo1jJI5/Kh+Wf67Cqfv8fhUYx1Iz+qsGKEerAjVtrSIyuYsjoWw== X-Received: by 2002:a05:6870:4e94:b0:2d6:103e:e43d with SMTP id 586e51a60fabf-30785c8b7c9mr2980735fac.20.1753916915436; Wed, 30 Jul 2025 16:08:35 -0700 (PDT) Received: from fedora ([189.215.162.117]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-307a740ae10sm82765fac.25.2025.07.30.16.08.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jul 2025 16:08:35 -0700 (PDT) From: =?utf-8?Q?Elijah_Gabe_P=C3=A9rez?= To: Philip Kaludercic , Eli Zaretskii Subject: Re: bug#79106: [PATCH] Add new optional keywords to use-package In-Reply-To: References: <87wm7te6a6.fsf@gmail.com> <871pq03yt7.fsf@posteo.net> <87a54nfqv3.fsf@gmail.com> <87ms8mupvk.fsf@gmail.com> Date: Wed, 30 Jul 2025 17:08:32 -0600 Message-ID: <87wm7pnuof.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 79106 Cc: Karthik Chikmagalur , 79106@debbugs.gnu.org, =?utf-8?Q?St=C3=A9phane?= Marks , John Wiegley X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Since this discussion (and the emacs-devel discussion) doesn't seem to be leading to any solution (besides the divided opinions), my solution i can think of would be to make the keywords that may be considered useful (I'm not sure which ones) part of use-package, and leave the rest in ELPA (or in NonGNU) in a single package. Of course, this package was not intended to be part of use-package, just an **optional** thing that i wanted to have. -- - E.G via Gnus and Org. From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 02 10:38:57 2025 Received: (at 79106) by debbugs.gnu.org; 2 Aug 2025 14:38:57 +0000 Received: from localhost ([127.0.0.1]:36970 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uiDNx-0004op-1B for submit@debbugs.gnu.org; Sat, 02 Aug 2025 10:38:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50362) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uiDNv-0004oV-Be for 79106@debbugs.gnu.org; Sat, 02 Aug 2025 10:38:55 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uiDNo-0003hR-MH; Sat, 02 Aug 2025 10:38:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=hiNxdlheQktWPk/M1DduG8vHiCmS/kxD6S68rCFrcWM=; b=pUdOeqhYfVgODd0kMGvx xQrzErPHXClROPNZj9SSYRrSvxhFsGbZ0PWekM59/GNPDvVdO2ta9n6LJnf6o+H2fZS4Nt68LneBv rmWHer+sYWpR4iDIu2rhDJuZIaBJ/XyRLFBFcOEPG+Ddd6/ha3A4YqnGeNH5KUFv14ffFEzc46oNr TC1Ff0Ei/QF8QiplDsEMJD2gxuG+zM8O/mo+u75vDCMPzWdMoeCTacHLdBhkdf7uT0DPrIGgdlHa3 iwwEmUm2RCZAlArTEsF+LsBU+3TumMmXsVCr42jBpBOIqHF3r92wWSblEhlyNtVYOhq0EGZdxkJ+7 WQM+8MhnzSRS0Q==; Date: Sat, 02 Aug 2025 17:38:42 +0300 Message-Id: <86ecttrdot.fsf@gnu.org> From: Eli Zaretskii To: Elijah Gabe =?iso-8859-1?Q?P=E9rez?= In-Reply-To: <87wm7pnuof.fsf@gmail.com> (message from Elijah Gabe =?iso-8859-1?Q?P=E9rez?= on Wed, 30 Jul 2025 17:08:32 -0600) Subject: Re: bug#79106: [PATCH] Add new optional keywords to use-package References: <87wm7te6a6.fsf@gmail.com> <871pq03yt7.fsf@posteo.net> <87a54nfqv3.fsf@gmail.com> <87ms8mupvk.fsf@gmail.com> <87wm7pnuof.fsf@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79106 Cc: karthikchikmagalur@gmail.com, philipk@posteo.net, 79106@debbugs.gnu.org, shipmints@gmail.com, johnw@newartisans.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Elijah Gabe Pérez > Cc: Stéphane Marks , Karthik > Chikmagalur > , 79106@debbugs.gnu.org, John Wiegley > > Date: Wed, 30 Jul 2025 17:08:32 -0600 > > Since this discussion (and the emacs-devel discussion) doesn't seem to > be leading to any solution (besides the divided opinions), my solution i > can think of would be to make the keywords that may be considered useful > (I'm not sure which ones) part of use-package, and leave the rest in > ELPA (or in NonGNU) in a single package. > > Of course, this package was not intended to be part of use-package, just > an **optional** thing that i wanted to have. >From my POV, we can install these changes in core, assuming that you can post a patch that incorporates the relevant parts of the discussions. Please also rename the new files such that they don't include the "-x-" part. That is, instead of, e.g., use-package-x-advice.el add a file use-package-advice.el. Also, please put them inside lisp/use-package/, not in its subdirectory. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 02 16:39:23 2025 Received: (at 79106) by debbugs.gnu.org; 2 Aug 2025 20:39:23 +0000 Received: from localhost ([127.0.0.1]:38117 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uiJ0j-00048Q-Pd for submit@debbugs.gnu.org; Sat, 02 Aug 2025 16:39:22 -0400 Received: from mail-oi1-x243.google.com ([2607:f8b0:4864:20::243]:52246) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uiJ0h-00047z-0d for 79106@debbugs.gnu.org; Sat, 02 Aug 2025 16:39:20 -0400 Received: by mail-oi1-x243.google.com with SMTP id 5614622812f47-40a4de175a3so1934639b6e.0 for <79106@debbugs.gnu.org>; Sat, 02 Aug 2025 13:39:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754167153; x=1754771953; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=mT0u8kHfDU2HrNPhhs9FV7ga5uYtIHSw+TmCFJBqYZ8=; b=LY4MOXw6lC3t3rde2g/V6bnY61ink/6Ita6Sfo7lxcGo5sDsrk7KzrCkt8bxA7kpRh WIbLz3bOwYK3JRJRQYnNc+KXS5oICDTxvFi98vkqpf84VR5fDZx5eLFD0wTasKQq+rn5 7oqnxDaXgPjqG4f/Jf07MJW1aA92C8JgaxCWCZvqtCJeV83YrLcJzeGKLZzbatyKZgnx 0ghFkdl5hE6fT2Dp+FNsPVJEymFmJt88YXm0sRHNXmqK9kgg7Q6UwXY7A2BLUb2D0+Sr NWsIN4wWnNqcUJWzUvHU6esHoRjtz5jE4AlVS1GaKekbs1s9jejM5oEfnQ/W0+ge8rb0 f8yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754167153; x=1754771953; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=mT0u8kHfDU2HrNPhhs9FV7ga5uYtIHSw+TmCFJBqYZ8=; b=f2113h1EDb1diciTq17yfCbxkObBlWYLY9bvCFLinjMDHKpXRkMBdVKdxq9wtJRYEG htGP7yaiHhxPAvBe2xmiPJDbpdogmcS22d5QxpAUZszcGHkgqf+5xkO6kxfaMqFzmjKq 0XAXBSGpJXOl8JVt5ucI1FASc5RO14CXbAF1qV2staSgD5oDFnIM5kvo+mD/jnoxZZ6z 4eoGk1WpaVaZ0i5SRQQC6YbL5EOmLOOdLPeuvf+8mVHajVIkSd/7LtMP2trmgerIihyl LrUhgHNBodMwI7huEOTwQyHxmSQPybOQP7IC3/wnnTZ3I0zxWKWL8SvpXzYs7RtemcCn 6E6w== X-Forwarded-Encrypted: i=1; AJvYcCWSpiS9oY9AapPUxmOBmNy7HbBirw/nFPdw3dxV96V7booeHxVi7NNCTGIM8MUtI7JD554ACw==@debbugs.gnu.org X-Gm-Message-State: AOJu0YweBfRxqhuuDFueNiP8vDWrM22knR/MOdbhjtdgoSPQRUDSaO2h R/Wpv5n7cSrI/wlcRuQTddEQScD+mwK4UCPTmXNR9gpB7X462lWfHyOP X-Gm-Gg: ASbGncvMNYnXM7p0M1uo/UH+iyHsDWFNZNdxqDCwQVMUH8ThQnQ0AX78AQiat1O4IOf wJswQvGsUlbizT30/U9lK1b+YmaaZAn9NzjUmytp56xciKR/LUBGOZ9TDJxrpVK55AWsHD/xsnI srAmMAimDQVlI777mxbZ72qG4N/rHjuki0yJMgsabqYxBvEi/Q2cTbFfMBV7TMm28RipbBK9Xx6 k6xrUYYWhOGkFsQe1OduuIszD8SkC7cReDARl6Pkgqn5jhV1EereqYg2Y/mmPd1MyrejAe/krwB AfYFAW0qgNcHZbP2Wmxbdgey34B9i4AYhf0Bq25cJDq/nix1CLx9rki+um564n/rpZOIG+v9Cqg QJSK/MRvrJXvVGI+c2qztqh5v6w== X-Google-Smtp-Source: AGHT+IGaXMPZBsc11nUCshdPGzwaa6mmSwbR5BsHgNVZ4Qe6iDVd90CFpGtkQOf0jtcQBmDA98JW8Q== X-Received: by 2002:a05:6808:50a5:b0:424:b3f9:cd12 with SMTP id 5614622812f47-433f02fe9b7mr2376480b6e.20.1754167152864; Sat, 02 Aug 2025 13:39:12 -0700 (PDT) Received: from fedora ([189.215.162.117]) by smtp.gmail.com with ESMTPSA id 5614622812f47-43358d8687asm1398593b6e.26.2025.08.02.13.39.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 13:39:12 -0700 (PDT) From: =?utf-8?Q?Elijah_Gabe_P=C3=A9rez?= To: Eli Zaretskii Subject: Re: bug#79106: [PATCH] Add new optional keywords to use-package In-Reply-To: <86ecttrdot.fsf@gnu.org> References: <87wm7te6a6.fsf@gmail.com> <871pq03yt7.fsf@posteo.net> <87a54nfqv3.fsf@gmail.com> <87ms8mupvk.fsf@gmail.com> <87wm7pnuof.fsf@gmail.com> <86ecttrdot.fsf@gnu.org> Date: Sat, 02 Aug 2025 14:39:09 -0600 Message-ID: <87jz3lbgr6.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 79106 Cc: karthikchikmagalur@gmail.com, philipk@posteo.net, 79106@debbugs.gnu.org, shipmints@gmail.com, johnw@newartisans.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Eli Zaretskii writes: >> From: Elijah Gabe P=C3=A9rez >> Cc: St=C3=A9phane Marks , Karthik >> Chikmagalur >> , 79106@debbugs.gnu.org, John Wiegley >> >> Date: Wed, 30 Jul 2025 17:08:32 -0600 >>=20 >> Since this discussion (and the emacs-devel discussion) doesn't seem to >> be leading to any solution (besides the divided opinions), my solution i >> can think of would be to make the keywords that may be considered useful >> (I'm not sure which ones) part of use-package, and leave the rest in >> ELPA (or in NonGNU) in a single package. >>=20 >> Of course, this package was not intended to be part of use-package, just >> an **optional** thing that i wanted to have. > > From my POV, we can install these changes in core, assuming that you > can post a patch that incorporates the relevant parts of the > discussions. Sounds good to me, I've updated the patch for include *only* the keywords that people may find useful. The rest can be kept in my use-package-x repository. > Please also rename the new files such that they don't include the > "-x-" part. That is, instead of, e.g., use-package-x-advice.el add a > file use-package-advice.el. Also, please put them inside > lisp/use-package/, not in its subdirectory. Done: --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-new-optional-keywords-to-use-package.-Bug-79106.patch >From 574b5b00b5138646c0d030100321743cea79225a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?El=C3=ADas=20Gabriel=20P=C3=A9rez?= Date: Sat, 26 Jul 2025 22:43:38 -0600 Subject: [PATCH] Add new optional keywords to use-package. (Bug#79106) * etc/NEWS: Announce changes. * lisp/use-package/use-package-core.el (use-package-keywords): Add new keywords to keywords list. (use-package-normalize/:custom-face*) (use-package-handler/:custom-face*): New functions. * lisp/use-package/use-package-hook.el: * lisp/use-package/use-package-local-set.el: * lisp/use-package/use-package-set.el: New files. --- etc/NEWS | 27 +++ lisp/use-package/use-package-core.el | 20 +++ lisp/use-package/use-package-hook.el | 209 ++++++++++++++++++++++ lisp/use-package/use-package-local-set.el | 89 +++++++++ lisp/use-package/use-package-set.el | 69 +++++++ 5 files changed, 414 insertions(+) create mode 100644 lisp/use-package/use-package-hook.el create mode 100644 lisp/use-package/use-package-local-set.el create mode 100644 lisp/use-package/use-package-set.el diff --git a/etc/NEWS b/etc/NEWS index a81d1105443..beb788d3a72 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -955,6 +955,33 @@ units that 'elisp-eldoc-funcall-with-docstring' and 'elisp-eldoc-var-docstring-with-value' will show. By default, it is set to 1000 characters. +** Use package + ++++ +*** New ':hook-suffix' keyword. +This keyword enables the user to change the +'use-package-hook-name-suffix' to the use-package declaration where this +is used. + ++++ +*** New ':set' keyword. +This keyword enables the user to bind plain variables. + ++++ +*** New ':local-set' keyword. +This keyword is similar to ':set', but bind the variables locally to the +package hook or to a list of hooks. + ++++ +*** New ':custom-face*' keyword. +This keyword is similar to ':custom-face*', but overrides the face +specs. + ++++ +*** New ':hook+' keyword. +This keyword is similar to ':hook', but supports hook depths and set +multiple function into a hook or for each hook. + ** Buffer Menu --- diff --git a/lisp/use-package/use-package-core.el b/lisp/use-package/use-package-core.el index 65b9485b4e3..2dae6e0c83d 100644 --- a/lisp/use-package/use-package-core.el +++ b/lisp/use-package/use-package-core.el @@ -77,13 +77,17 @@ use-package-keywords :defines :functions :preface + :hook-suffix :if :when :unless :vc :no-require :catch :after + :set + :local-set :custom :custom-face + :custom-face* :bind :bind* :bind-keymap @@ -93,6 +97,7 @@ use-package-keywords :magic :magic-fallback :hook + :hook+ ;; Any other keyword that also declares commands to be autoloaded (such as ;; :bind) must appear before this keyword. :commands @@ -1630,6 +1635,21 @@ use-package-handler/:custom-face args) (use-package-process-keywords name rest state))) +;;;; :custom-face* +;; see: bug#77928 + +(defalias 'use-package-normalize/:custom-face* 'use-package-normalize/:custom-face) + +(defun use-package-handler/:custom-face* (name _keyword args rest state) + "Like :custom-face*, but override the face specs." + (use-package-concat + (mapcar #'(lambda (def) + `(progn + (apply #'face-spec-set (backquote ,def)) + (put ',(car def) 'face-modified t))) + args) + (use-package-process-keywords name rest state))) + ;;;; :init (defalias 'use-package-normalize/:init 'use-package-normalize-forms) diff --git a/lisp/use-package/use-package-hook.el b/lisp/use-package/use-package-hook.el new file mode 100644 index 00000000000..10c04e17d89 --- /dev/null +++ b/lisp/use-package/use-package-hook.el @@ -0,0 +1,209 @@ +;;; use-package-hook.el --- :hook+ :hook-suffix keywords definitions -*- lexical-binding: t; -*- + +;; Copyright (C) 2025 Free Software Foundation, Inc. + +;; Author: Elias G. Perez +;; Keywords: convenience, tools, extensions +;; Package-Requires: ((use-package "2.1")) + +;; 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 . + +;;; Commentary: + +;; This file provides the following extra keywords for +;; `use-package': +;; +;; * :hook-suffix +;; Change `use-package-hook-name-suffix' value to only the use-package +;; declaration. +;; +;; * :hook+ +;; An enchanted :hook which supports hooks depths and +;; set multiple functions. +;; +;; The hook depth is provided using the sub-keyword :depth +;; e.g. +;; :hook+ +;; (:depth 10 +;; (major-mode . my-func)) +;; +;; To set multiple functions (including lambdas) to the +;; hook or list of hooks you can use the :multi keyword: +;; +;; :hook (my-hook-or-list-of-hooks +;; . (:multi fn1 fn2 (lambda () ..) ...)) +;; +;; This also supports the :hook valid forms: +;; +;; :hook+ +;; (:depth 10 +;; (major-mode . my-func-or-lambda) +;; (mode mode2 mode3) +;; single-mode) +;; ((hook1 hook2) . (:multi fn1 fn2 fn3)) +;; ...and also use it as a normal :hook... +;; (major-mode . my-func-or-lambda) +;; (mode mode2 mode3) +;; single-mode +;; + +;;; Code: + +;;; Requires +(require 'use-package-core) + + + +;;; Functions + +;;; :hook-suffix +;;;###autoload +(defun use-package-normalize/:hook-suffix (_name keyword args) + "Normalize :hook-prefix, ensure it's a string or nil." + (use-package-only-one (symbol-name keyword) args + (lambda (label arg) + (unless (or (stringp arg) (null arg)) + (use-package-error + (concat label " must be nil or a string"))) + arg))) + +;;;###autoload +(defun use-package-handler/:hook-suffix (name _keyword arg rest state) + "Normalize :hook-prefix. +Set `use-package-hook-name-suffix' to ARG only in the current +`use-package' declaration." + (dlet ((use-package-hook-name-suffix arg)) + (use-package-process-keywords name rest state))) + + + +;;; :hook+ +(defun use-package-hook--normalize-pairs (list label name) + "Normalize all the pairs in the LIST." + (if (ignore-errors (eq (cadar list) :multi)) + ;; FIXME: There is not a better way to include this into the + ;; loop (below), so just return the LIST without normalizing. + list + (use-package-normalize-pairs + (lambda (k) + (or (use-package-non-nil-symbolp k) + (and k (let ((every t)) + (while (and every k) + (if (and (consp k) + (use-package-non-nil-symbolp (car k))) + (setq k (cdr k)) + (setq every nil))) + every)))) + #'use-package-recognize-function + (if (string-suffix-p "-mode" (symbol-name name)) + name + (intern (concat (symbol-name name) "-mode"))) + label list))) + +;;;###autoload +(defun use-package-normalize/:hook+ (name keyword args) + "Normalize :hook+ keyword. +Return the proper list or ARGS for `use-package-autoloads/:hook+' +and `use-package-handler/:hook+'." + (use-package-as-one (symbol-name keyword) args + (lambda (label arg) + (unless (or (use-package-non-nil-symbolp arg) (consp arg)) + (use-package-error + (concat label + " must be" + " a or a list or these" + " or ( . )" + " or ( . (:multi ...))" + " or (:depth ...)"))) + ;; Check if :depth is defined and return ( + ;; ) for the handler function, otherwise just + ;; return the normal list + (mapcan + (lambda (elt) + (if (eq (car-safe elt) :depth) + (mapcar (lambda (pairs) + (cons (nth 1 elt) (list pairs))) + (use-package-hook--normalize-pairs (cddr elt) label name)) + (use-package-hook--normalize-pairs (list elt) label name))) + args)))) + +(defun use-package-hook--normalize-commands (list) + "Like `use-package-normalize-commands' but for supporting the :depth keyword." + (mapcar (lambda (x) + (cond ((numberp (car x)) + (cons (car x) (use-package-normalize-commands (cdr x)))) + ((consp x) + (cons (car x) (use-package-normalize-function (cdr x)))) + (t x))) + list)) + +(defun use-package-autoloads/:hook+ (_name _keyword args) + "Like `use-package-autoloads-mode' but supports the :depth and :multi keywords." + (setq args + (mapcar + (lambda (list) + (cond + ;; return the list without the depth number + ((integerp (car list)) (cadr list)) + (t list))) + args)) + + (cl-loop for x in args + for multi = (ignore-errors (eq (cadr x) :multi)) + when (and (consp x) (or (use-package-non-nil-symbolp (cdr x)) multi)) + if multi append + (cl-loop for cm in (cddr x) + if (use-package-non-nil-symbolp cm) + collect (cons cm 'command)) + else collect (cons (cdr x) 'command))) + +(defun use-package-hook--create-hook (sym fun depth) + "Return the proper `add-hook' for mode SYM with FUN and DEPTH (if there is)." + (let ((symname (symbol-name sym))) + (if (and (boundp sym) + (not (string-suffix-p "-mode" symname))) + `(add-hook (quote ,sym) (function ,fun) ,depth) + `(add-hook + (quote ,(intern + (concat symname use-package-hook-name-suffix))) + (function ,fun) + ,depth)))) + +;;;###autoload +(defun use-package-handler/:hook+ (name _keyword args rest state) + "Hadle :hook+ keyword. +Add the proper `add-hook' to use-package expanded form, +compared to normal :hook, this handle hook depths and multiple +functions." + (use-package-concat + (use-package-process-keywords name rest state) + (cl-mapcan + (lambda (def) + (let* ((car (car def)) + (depth (if (integerp car) car)) + (syms (if depth (caadr def) car)) + (fun (if depth (cdadr def) (cdr def))) + (multi-p (and (listp fun) (eq (car fun) :multi)))) + (when fun + (cl-loop + for mode in (use-package-hook-handler-normalize-mode-symbols syms) + if multi-p append ; For `:multi' + (cl-loop for fn in (cdr fun) collect + (use-package-hook--create-hook mode fn depth)) + else + collect (use-package-hook--create-hook mode fun depth))))) + (use-package-hook--normalize-commands args)))) + +(provide 'use-package-hook) +;;; use-package-hook.el ends here diff --git a/lisp/use-package/use-package-local-set.el b/lisp/use-package/use-package-local-set.el new file mode 100644 index 00000000000..dfdbb7d876c --- /dev/null +++ b/lisp/use-package/use-package-local-set.el @@ -0,0 +1,89 @@ +;;; use-package-local-set.el --- :local-set keyword definition -*- lexical-binding: t; -*- + +;; Copyright (C) 2025 Free Software Foundation, Inc. + +;; Author: Elias G. Perez +;; Keywords: convenience, tools, extensions +;; Package-Requires: ((use-package "2.1")) + +;; 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 . + +;;; Commentary: + +;; This file provides the following extra keyword for +;; `use-package': +;; +;; * :local-set +;; +;; Set variables locally when entering to a mode. +;; +;; :local-set +;; ( ...) <- Automatically set to package mode hook +;; --or-- +;; (:hook <- Set it only to hook(s), +;; compared to :hook and :hook+ +;; ...) you need to add the full hook name +;; + +;;; Code: + +;;; Requires +(require 'use-package-core) + + + +;;;###autoload +(defun use-package-normalize/:local-set (_name keyword args) + "Normalize :local-set keyword, ensure ARGS are valid." + (use-package-as-one (symbol-name keyword) args + (lambda (label arg) + (let ((arg-car (car arg))) + (unless (or (eq arg-car :hook) (consp arg-car) (use-package-non-nil-symbolp arg-car)) + (use-package-error + (concat label + " can be ( ...)" + " or (:hook ...)"))) + args)))) + +(defun use-package-local-set--local-hook (hook values) + `(add-hook (quote ,hook) + (lambda (&rest _) + (setq-local ,@values)))) + +;;;###autoload +(defun use-package-handler/:local-set (name _keyword args rest state) + (use-package-concat + (mapcan + (lambda (elt) + (if (eq (car elt) :hook) + ;; :hook + (if-let* ((hook (nth 1 elt)) + ((listp hook))) + (mapcar + (lambda (x) (use-package-local-set--local-hook x (cddr elt))) + hook) + (list (use-package-local-set--local-hook hook (cddr elt)))) + ;; plain variables + (let* ((sym-name (symbol-name name)) + (hook (intern (concat + sym-name + (if (string-suffix-p "-mode" sym-name) + "-hook" + "-mode-hook"))))) + (list (use-package-local-set--local-hook hook elt))))) + args) + (use-package-process-keywords name rest state))) + +(provide 'use-package-local-set) +;;; use-package-local-set.el ends here diff --git a/lisp/use-package/use-package-set.el b/lisp/use-package/use-package-set.el new file mode 100644 index 00000000000..b86544d311a --- /dev/null +++ b/lisp/use-package/use-package-set.el @@ -0,0 +1,69 @@ +;;; use-package-set.el --- :set keyword definition -*- lexical-binding: t; -*- + +;; Copyright (C) 2025 Free Software Foundation, Inc. + +;; Author: Elias G. Perez +;; Keywords: convenience, tools, extensions +;; Package-Requires: ((use-package "2.1")) + +;; 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 . + +;;; Commentary: + +;; This file provides the following extra keyword for +;; `use-package': +;; +;; * :set +;; Similar to :custom, but is meant to bind plain variables. +;; This uses setq-default for bind the variables. +;; +;; :set ( [value]) ... +;; +;; VALUE is optional, if omitted, VARIABLE will be set to nil. +;; + +;;; Code: + +;;; Requires +(require 'use-package) + + + +;;; Functions + +;;;###autoload +(defun use-package-normalize/:set (_name keyword args) + "Normalize :setopt keyword, ensure the values in ARGS are valid." + (use-package-as-one (symbol-name keyword) args + (lambda (label arg) + (unless (listp arg) + (use-package-error + (concat label + " must be a ( [value])" + " or a list of these"))) + (if (use-package-non-nil-symbolp (car arg)) + (list arg) + arg)))) + +;;;###autoload +(defun use-package-handler/:set (name _keyword args rest state) + (use-package-concat + `((setq-default + ,@(mapcan + (lambda (list) (list (car list) (nth 1 list))) + args))) + (use-package-process-keywords name rest state))) + +(provide 'use-package-set) +;;; use-package-set.el ends here -- 2.50.1 --=-=-= Content-Type: text/plain NOTE: The patch does not yet include the corresponding change in the use-package manual, I am waiting for feedback first. -- - E.G via Gnus and Org. --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 02 19:04:05 2025 Received: (at 79106) by debbugs.gnu.org; 2 Aug 2025 23:04:06 +0000 Received: from localhost ([127.0.0.1]:38926 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uiLGn-0005sI-GP for submit@debbugs.gnu.org; Sat, 02 Aug 2025 19:04:05 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:54304) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uiLGk-0005rW-2g for 79106@debbugs.gnu.org; Sat, 02 Aug 2025 19:04:02 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-76bd6e84eddso3103038b3a.0 for <79106@debbugs.gnu.org>; Sat, 02 Aug 2025 16:04:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754175836; x=1754780636; darn=debbugs.gnu.org; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=Q67Dl4++dcx5O3Jlz0HqdIHTcnQWa05IrByEzvlMqlk=; b=HqPQnOcpDXvXEqWYKGKjimpc1T9BeeKz9dUB1xvx2nVL5p/S/zJAIgs0AuyLBkoUCI /rpxXaHnO5ytlAa2hTFL5RyM0EQzJ1gtdiNyFxNKrHv7XVTl1Oau65meE7KnwlVT1m2a eCMLsflbJURappKb0s5bgkBM/zuAf3SyCiuzApGqbwu+4/zJrIHRbe3pck9PWSqkz9GP 8eJM62bgmB68AubGaQLQbfxjSoeKaZpPbvDkX7CcTWOt/10eRwpZOWCnGGfnXe6Lja8S WKEzYx53WIH2oLq4IhqBUgRoKHHV7P3Pa/AM1bnPq1yvtGtsHiCy8+60+zGgbtpWLbBo 4gGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754175836; x=1754780636; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Q67Dl4++dcx5O3Jlz0HqdIHTcnQWa05IrByEzvlMqlk=; b=ua9z0gQV3GSg1CxaUYzaZcbWrAlXJ3URj2qYewBNB6+AMq1FXMC+F+KbVRV9CI7PuT FhghdS6/XvEv0b28WefnjlDC0EZ6OXpcdEFPBGAWkhWqoZuRiB2NGO97neNC/BoolbBG CEDkPsMaQ8GHUwZhCigIWpytf2NWfJyZyM8sHnXJhTs6i44ROvclq5+B7mQvLVao25dF GpOVfZLG3irYr/2pzGxjK1z9R4bgoCIobi1iEFFawnMp17Aug1dutVb7GYDjxF0JLXCS XVTmoHgN5ftwDV2p3xN3BLJY6bgpJH1/TCDlSWi0ZOEGWwZGhKqF6cYnMO9Ab1Kqt0PK PBjg== X-Forwarded-Encrypted: i=1; AJvYcCX7TP2aJ7yBURRPgTcSY9t46tHtmr3XIOjNr3wmCBqsMTvWDPfHNnjHt83p4xQPPRvT6TxSig==@debbugs.gnu.org X-Gm-Message-State: AOJu0YyMNglPJr8XLi/2qT8Q9rssbp4iXpQMem1OBZQ9eBALxr2FkUm8 LwCqHnQrnvkJJ5O160I+bWJZrCn9Pk8a9v7bcpCqyz/iUcTcyTPwflF/ X-Gm-Gg: ASbGncuxO8EardYRlXS+4ZHoeGK4ZGq/B1TpX9QFmWbo8T+1vGyPkpBQwzKNPFYcGG6 k7hUupHWYO4YlUx5b6pCR7cn86mTZP40F57a/i1MbUixW3DTuCvRg+CsjNQfizeVgZ1JN8i8QXK BYJRQIfMollfK2F8CrR3FsdG4nm7CRo8+Y730ncmhp3f1PoDrHP5OmxmKM/33KtKgLfnlmf7cuo D5qWthGmryS9Ez8Sfl+oNLcl3fSbEiEsYny8KA7HBJ4R67VWFi2sepQyuCpAdH2KjciAWTDGqcL imTsaiKZdRoc+7P9UEiAzjdAnfJfCg4us7eaB3oyzys+bBwzHymgT1blLhfN9JoCZqILfj6GmD5 FWapFXB79i4V4pAPKrM+au4JNe1p3RhoKNHuIVLsvVe0+bziFEkBpxMgpa7mDHZyjk3vDcTI= X-Google-Smtp-Source: AGHT+IEHRSJGgzdmoyrHJuT4ko0bUCQbz8mOkRdbSX5EYaboB7lhzClzZXkJ+gNSeMAE0onKIzwsYg== X-Received: by 2002:a05:6a00:9a4:b0:736:2a73:6756 with SMTP id d2e1a72fcca58-76bec4f4d6emr5725761b3a.21.1754175835885; Sat, 02 Aug 2025 16:03:55 -0700 (PDT) Received: from localhost (c-98-207-111-199.hsd1.ca.comcast.net. [98.207.111.199]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-76bccfbcee7sm7168565b3a.66.2025.08.02.16.03.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 16:03:55 -0700 (PDT) From: Karthik Chikmagalur To: Elijah Gabe =?utf-8?Q?P=C3=A9rez?= , Eli Zaretskii Subject: Re: bug#79106: [PATCH] Add new optional keywords to use-package In-Reply-To: <87jz3lbgr6.fsf@gmail.com> References: <87wm7te6a6.fsf@gmail.com> <871pq03yt7.fsf@posteo.net> <87a54nfqv3.fsf@gmail.com> <87ms8mupvk.fsf@gmail.com> <87wm7pnuof.fsf@gmail.com> <86ecttrdot.fsf@gnu.org> <87jz3lbgr6.fsf@gmail.com> Date: Sat, 02 Aug 2025 16:03:54 -0700 Message-ID: <877bzl5ns5.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 79106 Cc: johnw@newartisans.com, philipk@posteo.net, 79106@debbugs.gnu.org, shipmints@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) >> From my POV, we can install these changes in core, assuming that you >> can post a patch that incorporates the relevant parts of the >> discussions. > > Sounds good to me, I've updated the patch for include *only* the > keywords that people may find useful. > > The rest can be kept in my use-package-x repository. Since support for :hook+ is being added, I have a suggestion to make its syntax more in-line with add-hook, so the user does not have to learn new syntax. This might not be possible (or lead to ambiguous parsing), so feel free to ignore it if this is the case. add-hook takes the arguments (HOOK FUNCTION DEPTH LOCAL), so perhaps :hook+ can do the same? ------------------------------------- Suggestion 1: allow many hooks to be specified in a list :hook+ (foo-mode . (bar baz quux)) adds functions bar, baz and quux to foo-mode-hook. (To disambiguate between a list of hook functions and a lambda, you can look at the car of the list maybe?) Suggestion 2: allow many hooks to be added to. (:hook already does this) :hook+ ((foo-mode cor-mode) . (bar baz quux)) Adds the three functions to both foo-mode-hook and cor-mode-hook. Suggestion 3: Allow DEPTH and LOCAL to be optionally specified with the functions, in the same order as add-hook. :hook+ (foo-mode . ((bar 90 t) baz (quux -30) (cor nil t)) will install - bar at depth 90, to be run buffer-locally when foo-mode-hook runs - baz without special accommodations, and - quux at depth -30. - cor buffer-locally with default depth To distinguish between (bar 90 t) and (lambda () ...), you could again examine the car of the list. ------------------------------------- Again, there might be ambiguities in parsing that I'm not aware of, but if this is possible I think this is an improvement over both :hook and the currently proposed :hook+ syntax. Karthik From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 02 21:42:42 2025 Received: (at 79106) by debbugs.gnu.org; 3 Aug 2025 01:42:42 +0000 Received: from localhost ([127.0.0.1]:39868 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uiNkH-0008RR-VY for submit@debbugs.gnu.org; Sat, 02 Aug 2025 21:42:42 -0400 Received: from mail-ot1-x344.google.com ([2607:f8b0:4864:20::344]:47474) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uiNkB-0008Qr-0O for 79106@debbugs.gnu.org; Sat, 02 Aug 2025 21:42:39 -0400 Received: by mail-ot1-x344.google.com with SMTP id 46e09a7af769-741518e14d4so956506a34.3 for <79106@debbugs.gnu.org>; Sat, 02 Aug 2025 18:42:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754185349; x=1754790149; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=lVD0pXAzWYiMDW98wZiX58EE5QML3Yielu1NzzVBmS0=; b=Hbg+OLCyJP1/7H9/MwS4LcP6ve7WADgk2feFpqTm2AfXlLWNdvxuFhOOQMVVpzMLre rIQyuIM8tNA5xNBnmCqdgsKYuEnr+EYRefHI3zaMlQJTWQgwvbNAgqzsEwrGXIbGGr/V Pkb/IB/sKrlKpb3ScQzZfkHKoEz5ZRlT67iYiGLF+7+ZD5iLO/qkbjDBUpWlGRIhpe4S HGy8c4+xMQ81Jh5oSKuNekb73EnGFeSu5rCIrdEvpwbuA2DqwN9T34t/wxEb7B40uZqB a3RVYaWIzpeQyNpeH5Fz3OdS1nAheG2qBPKzyrc6njtD1jdv5RH3QUfnchZsXCKCD0ag JTQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754185349; x=1754790149; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=lVD0pXAzWYiMDW98wZiX58EE5QML3Yielu1NzzVBmS0=; b=WfKMbpR4aKW16OX70Kk9js2DyGrvPr1rB4sB51JLlT2gYP9+iy7w8tuS79n9R9+FMs abA2Num0ffcQ+gdOp2gx1jbdm0EbAXyyJAcN1LRBm06Vm3VtpUdD8bqI7bSgdedm6exc dj2UjhpyRLoXv6F+KmhaffbMbVfu6JCH7i8c7a+M8Sh34/cENFANilbsLNNKuuUpHK7O lxaC+qP4hdid/fz2Iji/rBtcV5J7rnCy9WKEONgY6G1ZagjVrmLutQBPZf29pE3LktTK 1dWesgBodw5IJ6KZeNIPaXyDovueO+3KnPdjKcxCNGwpNu6QWsYwSa5hZXXg6cE2Syi1 m3RA== X-Forwarded-Encrypted: i=1; AJvYcCX0BbhHN8OD4vdRurwfzxLHoT6BJWzL4mwJNh3Eu7NCAKqEcJYgNlZ/BhPec6mgHLSDDL7E9g==@debbugs.gnu.org X-Gm-Message-State: AOJu0YyjTncCHDq17VhJaGwDM0tqjmFkxG7ErZQQxtRp6gYnIA1DT0ax 8AiqSMpcTNQpzLWlqvp+w+XdXgQWQUNt4xdH0zfgEWmyhVp3nZDOcOc4 X-Gm-Gg: ASbGncu8LUfIjDIV0okY+hleIiy570oZ82nk4PcmC3iJs/19jh+hn0RFye5/A5AxyTS +cSfvFjSMj7Psqts49B3Zct2c1VzSkVkRK0qh1FMrJIA8n8KtP5RaWqLmw72f+uLRCS1rAvRr9h JAkIgng2N/XLTZo14an3B8KPoZMrEC0OjPIaHrKxClBTfBHmEI1dUwqmJ+gL2JEfxFmdKHXG/Jx Zs6B7l84bc7pXffNaxQtJaNKezBZZMhUFF6brrOH7f6ihD4gA3KcKLdF4BIhYmYLF0lAXdHXwFO ykBCza4m/PbdwUx/q0WrdMmQ2dW09GbzRBS1CSKgqgal/ircpGyDqgAbmz5y696MVUpL87J3e5z hHq60iKTj4hb7FLE= X-Google-Smtp-Source: AGHT+IGyGNLKkI5ZDK6GP383ggcK2Z/S5gL1tHDIS84TYSUgeDKNKdxudpEHiLvlmSRNS6Ms0CKD7A== X-Received: by 2002:a05:6830:258a:b0:73c:c494:a032 with SMTP id 46e09a7af769-7419d09421fmr2539702a34.2.1754185348862; Sat, 02 Aug 2025 18:42:28 -0700 (PDT) Received: from fedora ([189.215.162.117]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-74186dd26a9sm1530093a34.57.2025.08.02.18.42.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 18:42:28 -0700 (PDT) From: =?utf-8?Q?Elijah_Gabe_P=C3=A9rez?= To: Karthik Chikmagalur Subject: Re: bug#79106: [PATCH] Add new optional keywords to use-package In-Reply-To: <877bzl5ns5.fsf@gmail.com> References: <87wm7te6a6.fsf@gmail.com> <871pq03yt7.fsf@posteo.net> <87a54nfqv3.fsf@gmail.com> <87ms8mupvk.fsf@gmail.com> <87wm7pnuof.fsf@gmail.com> <86ecttrdot.fsf@gnu.org> <87jz3lbgr6.fsf@gmail.com> <877bzl5ns5.fsf@gmail.com> Date: Sat, 02 Aug 2025 19:42:24 -0600 Message-ID: <87a54hgozj.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 79106 Cc: johnw@newartisans.com, Eli Zaretskii , 79106@debbugs.gnu.org, philipk@posteo.net, shipmints@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Karthik Chikmagalur writes: >>> From my POV, we can install these changes in core, assuming that >>> you >>> can post a patch that incorporates the relevant parts of the >>> discussions. >> >> Sounds good to me, I've updated the patch for include *only* the >> keywords that people may find useful. >> >> The rest can be kept in my use-package-x repository. > > Since support for :hook+ is being added, I have a suggestion to make > its > syntax more in-line with add-hook, so the user does not have to learn > new syntax. This might not be possible (or lead to ambiguous > parsing), > so feel free to ignore it if this is the case. > > add-hook takes the arguments (HOOK FUNCTION DEPTH LOCAL), so perhaps > :hook+ can do the same? > > ------------------------------------- > > Suggestion 1: allow many hooks to be specified in a list > > :hook+ (foo-mode . (bar baz quux)) > > adds functions bar, baz and quux to foo-mode-hook. (To disambiguate > between a list of hook functions and a lambda, you can look at the car > of the list maybe?) It is not possible because (foo-mode . (bar baz quux)) is expanded as (foo-mode bar baz quux), and this can be misinterpreted by :hook+ as a list of hooks. The only workaround i found is making a kind of separator (:multi), which tells :hook+ the cdr is a list of functions, not part of a list of hooks. I know that :multi can look weird (even i was thinking in rename it [1] or use a better separator), but it was the only solution i found and worked. > Suggestion 2: allow many hooks to be added to. (:hook already does > this) > > :hook+ ((foo-mode cor-mode) . (bar baz quux)) > > Adds the three functions to both foo-mode-hook and cor-mode-hook. Similar problem as previous. > Suggestion 3: Allow DEPTH and LOCAL to be optionally specified with > the functions, > in the same order as add-hook. > > :hook+ (foo-mode . ((bar 90 t) > baz > (quux -30) > (cor nil t)) > > will install > - bar at depth 90, to be run buffer-locally when foo-mode-hook runs > - baz without special accommodations, and > - quux at depth -30. > - cor buffer-locally with default depth I like this, i think i can implement only the "local" part. But of course, only part of :multi. If i can get rid of `:multi` i can implement this, but it will look somewhat ugly: :hook+ (foo-mode . '((bar 90 t))) [1] Some of my alternatives were using `quote` or `list` instead of `:multi`, and another was using `'(fn fn2 fn3)`, or even use a list instead of a cons-cell, these actually work, but I didn't know which of them to use. -- - E.G via Gnus and Org. From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 07 09:56:35 2025 Received: (at 79106) by debbugs.gnu.org; 7 Aug 2025 13:56:35 +0000 Received: from localhost ([127.0.0.1]:35330 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uk16h-00017L-8d for submit@debbugs.gnu.org; Thu, 07 Aug 2025 09:56:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51958) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uk16e-00017D-6L for 79106@debbugs.gnu.org; Thu, 07 Aug 2025 09:56:33 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uk16Y-00016g-Fa; Thu, 07 Aug 2025 09:56:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=6gKuXbTuZuEstSDIt3ah56qIh+KJALAMkF7cQtYtn2Q=; b=VoOj3qq+HK/JTUfzJXv8 YtuEkLzc+SMha//ZLK8zsm1J+gj0gXno9U0GptT7j7qEbiT8iEIZWzwSQsYm2GXfrFURkDqiFdBB9 MRrlDZ7FZCOuu9w/sQjVlogNLeql9rD/6f5Gg7Kkd6H/ad2KBvla/hhdg2e57+UZC7BQEd/rNDd/r Wkc8NcHZhW7HG0YsphYn5KepPO/Np2oqBdWKndJ27/CQdCdn9227kJpBi9g77VebcZOijdVrlD8oL RmdSm1Tqnpf6zYao5gPhJ0MEbYhYPkI8YvePLVCSS0jqVDlWIINRlG9QesJEKvtCG72Iof/apvAsp /0HU3LDKABWLWA==; Date: Thu, 07 Aug 2025 16:56:23 +0300 Message-Id: <861ppnqlq0.fsf@gnu.org> From: Eli Zaretskii To: Elijah Gabe =?iso-8859-1?Q?P=E9rez?= In-Reply-To: <87a54hgozj.fsf@gmail.com> (message from Elijah Gabe =?iso-8859-1?Q?P=E9rez?= on Sat, 02 Aug 2025 19:42:24 -0600) Subject: Re: bug#79106: [PATCH] Add new optional keywords to use-package References: <87wm7te6a6.fsf@gmail.com> <871pq03yt7.fsf@posteo.net> <87a54nfqv3.fsf@gmail.com> <87ms8mupvk.fsf@gmail.com> <87wm7pnuof.fsf@gmail.com> <86ecttrdot.fsf@gnu.org> <87jz3lbgr6.fsf@gmail.com> <877bzl5ns5.fsf@gmail.com> <87a54hgozj.fsf@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79106 Cc: karthikchikmagalur@gmail.com, philipk@posteo.net, 79106@debbugs.gnu.org, shipmints@gmail.com, johnw@newartisans.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Elijah Gabe Pérez > Cc: Eli Zaretskii , johnw@newartisans.com, > philipk@posteo.net, 79106@debbugs.gnu.org, shipmints@gmail.com > Date: Sat, 02 Aug 2025 19:42:24 -0600 > > Karthik Chikmagalur writes: > > >>> From my POV, we can install these changes in core, assuming that > >>> you > >>> can post a patch that incorporates the relevant parts of the > >>> discussions. > >> > >> Sounds good to me, I've updated the patch for include *only* the > >> keywords that people may find useful. > >> > >> The rest can be kept in my use-package-x repository. > > > > Since support for :hook+ is being added, I have a suggestion to make > > its > > syntax more in-line with add-hook, so the user does not have to learn > > new syntax. This might not be possible (or lead to ambiguous > > parsing), > > so feel free to ignore it if this is the case. > > > > add-hook takes the arguments (HOOK FUNCTION DEPTH LOCAL), so perhaps > > :hook+ can do the same? > > > > ------------------------------------- > > > > Suggestion 1: allow many hooks to be specified in a list > > > > :hook+ (foo-mode . (bar baz quux)) > > > > adds functions bar, baz and quux to foo-mode-hook. (To disambiguate > > between a list of hook functions and a lambda, you can look at the car > > of the list maybe?) > > It is not possible because (foo-mode . (bar baz quux)) is expanded as > (foo-mode bar baz quux), and this can be misinterpreted by :hook+ as a > list of hooks. > > The only workaround i found is making a kind of separator (:multi), > which tells :hook+ the cdr is a list of functions, not part of a list of > hooks. > > I know that :multi can look weird (even i was thinking in rename it [1] > or use a better separator), but it was the only solution i found and > worked. > > > Suggestion 2: allow many hooks to be added to. (:hook already does > > this) > > > > :hook+ ((foo-mode cor-mode) . (bar baz quux)) > > > > Adds the three functions to both foo-mode-hook and cor-mode-hook. > > Similar problem as previous. > > > Suggestion 3: Allow DEPTH and LOCAL to be optionally specified with > > the functions, > > in the same order as add-hook. > > > > :hook+ (foo-mode . ((bar 90 t) > > baz > > (quux -30) > > (cor nil t)) > > > > will install > > - bar at depth 90, to be run buffer-locally when foo-mode-hook runs > > - baz without special accommodations, and > > - quux at depth -30. > > - cor buffer-locally with default depth > > I like this, i think i can implement only the "local" part. > But of course, only part of :multi. > > If i can get rid of `:multi` i can implement this, but it will look > somewhat ugly: > > :hook+ (foo-mode . '((bar 90 t))) So what is the outcome of this discussion? Are you working on an updated patch, or should I install the last one you posted? From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 07 10:27:05 2025 Received: (at 79106) by debbugs.gnu.org; 7 Aug 2025 14:27:05 +0000 Received: from localhost ([127.0.0.1]:35397 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uk1aC-0002bj-Ba for submit@debbugs.gnu.org; Thu, 07 Aug 2025 10:27:05 -0400 Received: from mout02.posteo.de ([185.67.36.66]:42951) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uk1a9-0002bC-4Q for 79106@debbugs.gnu.org; Thu, 07 Aug 2025 10:27:02 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 8A085240101 for <79106@debbugs.gnu.org>; Thu, 7 Aug 2025 16:26:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=posteo.net; s=1984.ea087b; t=1754576814; bh=nshnXcVIEggqCPdDvYQKclRnPEOYPo4KoFfiucpt2SU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: Content-Transfer-Encoding:From; b=SIz0PBAZygmA2HnsCiGXbx7Q+9LRTnVT8blEIi734RtjR6UIF6OGj8Ptfyc4XSKkl /EbZ77rQgpSPdmLaE1EuL2UYbO6sgZos9I0rK02ObnvongIOUhQwLPzTGZ0xb0r76n U9p2FwnQNbpUY4qmnv/52Dn5ot7jo0phUw3j8eu+EXb93Tsj7nEBZ3DygGgkYdKSbN j8K222cofX/gyUzmjMCmyCMXOa2yjKwbhOlDWbsBxA5rRWenb5K6hRDbghg6QDTdrA F0fP0EOYDgOW+hbXDG/ADh9g77vLDjEBSG/gMr/ZZl8SndhD1u8bnnVtbJ9sp5EHJ0 NoSA9WYrk/eNWEmIxdg6UoJRadwprzWVKqsELaxFh3HHcfShnnyDr/jKLXcwj8Y+VH o0K/eFxzKRLJ3nMUODY1qiJZFl7aBQPGhDGncY0C7SMkQfkrRoPtSEGUqiUQu56HF5 f7Xo55o80FAa2tnY5hLPfH48HtWPuYxtr9AhLYt9kAvVCLDks55 Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4byTxn1W93z6twc; Thu, 7 Aug 2025 16:26:53 +0200 (CEST) From: Philip Kaludercic To: Eli Zaretskii Subject: Re: bug#79106: [PATCH] Add new optional keywords to use-package In-Reply-To: <861ppnqlq0.fsf@gnu.org> References: <87wm7te6a6.fsf@gmail.com> <871pq03yt7.fsf@posteo.net> <87a54nfqv3.fsf@gmail.com> <87ms8mupvk.fsf@gmail.com> <87wm7pnuof.fsf@gmail.com> <86ecttrdot.fsf@gnu.org> <87jz3lbgr6.fsf@gmail.com> <877bzl5ns5.fsf@gmail.com> <87a54hgozj.fsf@gmail.com> <861ppnqlq0.fsf@gnu.org> Date: Thu, 07 Aug 2025 14:26:53 +0000 Message-ID: <87fre32onn.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79106 Cc: karthikchikmagalur@gmail.com, Elijah Gabe =?utf-8?Q?P=C3=A9rez?= , 79106@debbugs.gnu.org, shipmints@gmail.com, johnw@newartisans.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Eli Zaretskii writes: >> From: Elijah Gabe P=C3=A9rez >> Cc: Eli Zaretskii , johnw@newartisans.com, >> philipk@posteo.net, 79106@debbugs.gnu.org, shipmints@gmail.com >> Date: Sat, 02 Aug 2025 19:42:24 -0600 >>=20 >> Karthik Chikmagalur writes: >>=20 >> >>> From my POV, we can install these changes in core, assuming that >> >>> you >> >>> can post a patch that incorporates the relevant parts of the >> >>> discussions. >> >> >> >> Sounds good to me, I've updated the patch for include *only* the >> >> keywords that people may find useful. >> >> >> >> The rest can be kept in my use-package-x repository. >> > >> > Since support for :hook+ is being added, I have a suggestion to make >> > its >> > syntax more in-line with add-hook, so the user does not have to learn >> > new syntax. This might not be possible (or lead to ambiguous >> > parsing), >> > so feel free to ignore it if this is the case. >> > >> > add-hook takes the arguments (HOOK FUNCTION DEPTH LOCAL), so perhaps >> > :hook+ can do the same? >> > >> > ------------------------------------- >> > >> > Suggestion 1: allow many hooks to be specified in a list >> > >> > :hook+ (foo-mode . (bar baz quux)) >> > >> > adds functions bar, baz and quux to foo-mode-hook. (To disambiguate >> > between a list of hook functions and a lambda, you can look at the car >> > of the list maybe?) >>=20 >> It is not possible because (foo-mode . (bar baz quux)) is expanded as >> (foo-mode bar baz quux), and this can be misinterpreted by :hook+ as a >> list of hooks. >>=20 >> The only workaround i found is making a kind of separator (:multi), >> which tells :hook+ the cdr is a list of functions, not part of a list of >> hooks. >>=20 >> I know that :multi can look weird (even i was thinking in rename it [1] >> or use a better separator), but it was the only solution i found and >> worked. >>=20 >> > Suggestion 2: allow many hooks to be added to. (:hook already does >> > this) >> > >> > :hook+ ((foo-mode cor-mode) . (bar baz quux)) >> > >> > Adds the three functions to both foo-mode-hook and cor-mode-hook. >>=20 >> Similar problem as previous. >>=20 >> > Suggestion 3: Allow DEPTH and LOCAL to be optionally specified with >> > the functions, >> > in the same order as add-hook. >> > >> > :hook+ (foo-mode . ((bar 90 t) >> > baz >> > (quux -30) >> > (cor nil t)) >> > >> > will install=20 >> > - bar at depth 90, to be run buffer-locally when foo-mode-hook runs >> > - baz without special accommodations, and >> > - quux at depth -30. >> > - cor buffer-locally with default depth >>=20 >> I like this, i think i can implement only the "local" part. >> But of course, only part of :multi. >>=20 >> If i can get rid of `:multi` i can implement this, but it will look >> somewhat ugly: >>=20 >> :hook+ (foo-mode . '((bar 90 t))) > > So what is the outcome of this discussion? Are you working on an > updated patch, or should I install the last one you posted? I believe there was a reasonable doubt whether we need some of the keywords at all from the initial patch. So my vote would be to hold back from that option for now, and figure out what would make sense to add to the core. --=20 Philip Kaludercic From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 07 10:52:29 2025 Received: (at 79106) by debbugs.gnu.org; 7 Aug 2025 14:52:29 +0000 Received: from localhost ([127.0.0.1]:35466 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uk1ym-0003ri-Hs for submit@debbugs.gnu.org; Thu, 07 Aug 2025 10:52:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55332) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uk1yk-0003rU-LK for 79106@debbugs.gnu.org; Thu, 07 Aug 2025 10:52:27 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uk1yf-0003JC-6H; Thu, 07 Aug 2025 10:52:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=+jtX/uRQ1Kqqfi2upEkTZVosvXqoSNqKbmwxPOZrJdA=; b=oibGd7aY25AMIFJbqwQ+ RMtrPXvtc1lwJebJnwVOFmGBUmnZ4AUwHq9rYHJE/Llq6ydgD8IYsPFKN1P9UNOJBRammx7UsOIa5 j6Tw+6ryIzhYGg+q/p6Qgo38UZByLOHpKnsGQNaUL4b3sAnKLOhpZyz9tcV84N3ODU6uThk5P7Y0Z VdnN61Io3QRv+7+nZE92SDgmpHXtSZ1oOMT0TPUGm7XmSgqPzA2GRBMUTdgA4fFWxt/agzfjD4pse 0+ysz+V/03LadBurnn3SE1CyJtn3amIvQjiEc95zAeBUMwxbc3RuIBRnE3Otf05HU6W7RT9uCBMcs 7/A15jxxQGb0hg==; Date: Thu, 07 Aug 2025 17:52:12 +0300 Message-Id: <86ldnvp4kj.fsf@gnu.org> From: Eli Zaretskii To: Philip Kaludercic In-Reply-To: <87fre32onn.fsf@posteo.net> (message from Philip Kaludercic on Thu, 07 Aug 2025 14:26:53 +0000) Subject: Re: bug#79106: [PATCH] Add new optional keywords to use-package References: <87wm7te6a6.fsf@gmail.com> <871pq03yt7.fsf@posteo.net> <87a54nfqv3.fsf@gmail.com> <87ms8mupvk.fsf@gmail.com> <87wm7pnuof.fsf@gmail.com> <86ecttrdot.fsf@gnu.org> <87jz3lbgr6.fsf@gmail.com> <877bzl5ns5.fsf@gmail.com> <87a54hgozj.fsf@gmail.com> <861ppnqlq0.fsf@gnu.org> <87fre32onn.fsf@posteo.net> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79106 Cc: karthikchikmagalur@gmail.com, eg642616@gmail.com, 79106@debbugs.gnu.org, shipmints@gmail.com, johnw@newartisans.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Philip Kaludercic > Cc: Elijah Gabe PĆ©rez , > karthikchikmagalur@gmail.com, > johnw@newartisans.com, 79106@debbugs.gnu.org, shipmints@gmail.com > Date: Thu, 07 Aug 2025 14:26:53 +0000 > > Eli Zaretskii writes: > > >> > Suggestion 1: allow many hooks to be specified in a list > >> > > >> > :hook+ (foo-mode . (bar baz quux)) > >> > > >> > adds functions bar, baz and quux to foo-mode-hook. (To disambiguate > >> > between a list of hook functions and a lambda, you can look at the car > >> > of the list maybe?) > >> > >> It is not possible because (foo-mode . (bar baz quux)) is expanded as > >> (foo-mode bar baz quux), and this can be misinterpreted by :hook+ as a > >> list of hooks. > >> > >> The only workaround i found is making a kind of separator (:multi), > >> which tells :hook+ the cdr is a list of functions, not part of a list of > >> hooks. > >> > >> I know that :multi can look weird (even i was thinking in rename it [1] > >> or use a better separator), but it was the only solution i found and > >> worked. > >> > >> > Suggestion 2: allow many hooks to be added to. (:hook already does > >> > this) > >> > > >> > :hook+ ((foo-mode cor-mode) . (bar baz quux)) > >> > > >> > Adds the three functions to both foo-mode-hook and cor-mode-hook. > >> > >> Similar problem as previous. > >> > >> > Suggestion 3: Allow DEPTH and LOCAL to be optionally specified with > >> > the functions, > >> > in the same order as add-hook. > >> > > >> > :hook+ (foo-mode . ((bar 90 t) > >> > baz > >> > (quux -30) > >> > (cor nil t)) > >> > > >> > will install > >> > - bar at depth 90, to be run buffer-locally when foo-mode-hook runs > >> > - baz without special accommodations, and > >> > - quux at depth -30. > >> > - cor buffer-locally with default depth > >> > >> I like this, i think i can implement only the "local" part. > >> But of course, only part of :multi. > >> > >> If i can get rid of `:multi` i can implement this, but it will look > >> somewhat ugly: > >> > >> :hook+ (foo-mode . '((bar 90 t))) > > > > So what is the outcome of this discussion? Are you working on an > > updated patch, or should I install the last one you posted? > > I believe there was a reasonable doubt whether we need some of the > keywords at all from the initial patch. So my vote would be to hold > back from that option for now, and figure out what would make sense to > add to the core. Figure out how? AFAIU, the latest round of comments just brought up an issue with :hook+, and the rest didn't cause any objections? Why not install them? From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 07 11:44:59 2025 Received: (at 79106) by debbugs.gnu.org; 7 Aug 2025 15:45:00 +0000 Received: from localhost ([127.0.0.1]:35583 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uk2nb-0006Ug-8W for submit@debbugs.gnu.org; Thu, 07 Aug 2025 11:44:59 -0400 Received: from mail-ot1-x341.google.com ([2607:f8b0:4864:20::341]:50314) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uk2nZ-0006UR-2N for 79106@debbugs.gnu.org; Thu, 07 Aug 2025 11:44:57 -0400 Received: by mail-ot1-x341.google.com with SMTP id 46e09a7af769-741b49e4b28so245112a34.0 for <79106@debbugs.gnu.org>; Thu, 07 Aug 2025 08:44:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754581491; x=1755186291; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YlFSPcHrw+Eyy0MuMi1XFga+sO05gGjgBX2XdCQTnAw=; b=k1HTEzJ480KZb2B+xuKupvXBjwEpjlTf5T6yPvXtE4Rg6ba+tf63nvY1PiyAQJgwja 4yRxGe+oaz3Qapefj2t7gs9bDNMzRNzgm3nSyoXaEeedo7n5utuG+1XrH/fAMDtMDU6f U2ohb/wWYY/HbEwyX6P72icGl9cbY/lYxkUIpNLSxfW8Mq5JxwQrekVQmDWT6C4G9EHT UL56v9ygrBK7G9HFByKRuajt7QdspyRwWGoDbMiAv6qYpq+Fu1JRyNFRp7XgERAWNM4z 2hpJuVgIulZAakR1OgWLjou6MB2+YcP3fL15QNx/AIzNM2dnCh8fy5RnUHnSep1RlAqr rMBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754581491; x=1755186291; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=YlFSPcHrw+Eyy0MuMi1XFga+sO05gGjgBX2XdCQTnAw=; b=oTtQcsfKkHsTcxyG1cVk1hlyG0/MlZw/ZbaaHMcHhn3G+2e+/0RKYi0QZEbSnAqbNF 1PYPehV/UsNQEYLiEEo1m/ZPvFlf5iYpSjLuUSQe+ho5NHi80iFW1DrYxwBxQlb4BbBP E45nr9v1irA0HxvTF85mlGfYqEFVuws8PHxq58SK/hQ2eJqFnx1l3LYbkh7+XUBsIJPU VHVm9rWnEGejoDh6dKkl8EjWepXlv78cROsUNB1hu2u7gw5mGFehptFzcoIXZ78oFhXP 46kmFqrRNGsT5WLD2SMmYTF1KcLKRNznPslvKYCR9ORswFVj86jmKi5wwHGfsDfYmeVb iEzw== X-Forwarded-Encrypted: i=1; AJvYcCXdyF2gQxL34Ybu2pSh+xwiDfxFFpGr95gSSRurUBKaye0B5wlOYTKNFvJeejtv7LQMUDXV+g==@debbugs.gnu.org X-Gm-Message-State: AOJu0YyNw1eiqLL9NtAp8aE6KAbkufBItHx7Ons/ZTU99UQcLba4CcVx 67hzoQEhVDem9WqUe1LfJDCHf+ewwCEf1v1FBPghnzxWbZRvK8CT8t4d X-Gm-Gg: ASbGncvyCxrtMPtARRWd9EQmkH7xyZy3rKf6Y+9qaWunPigrWsp+p8dxBgGbI7rJdjK snigzubS6Unbcu4LXwUB8Dtaczb5mH2zXM1pED8Zg7ZWF5drWCn5Jykwcz8bWUHn5/wrZHE9o+F rzOYou1a/y82ojfMAS2l3+t89BJTeKVfLA9T4kKXiVILJR8/koubB0CB4Mt1PdGRBL/pAiiI7NM 7nQAP/gHk5bq80ajGR8VPmNSf82yWgCqKmD2c4gJNpOiGJRNdCO1B1TKHslr+le87TBAitIBkyO dRXJrtT1/Y6nzeNLIqB6GVkHfsRbINPGo6jrs3n6MJ07oP5kCQ4nYtftGS8aLPiZgIHbLgN66FX HE9cFfZgkuPTFQub8UQ== X-Google-Smtp-Source: AGHT+IG58Q/ES0KV/NOO8k1QPuSYV+SgUtsiVMZlqOeJsT+7D6YpahKB3Lq0hPrEI+ufIG/U7b5CJg== X-Received: by 2002:a05:6871:6217:b0:30b:4a87:bb96 with SMTP id 586e51a60fabf-30be2bd6053mr4468470fac.18.1754581490917; Thu, 07 Aug 2025 08:44:50 -0700 (PDT) Received: from localhost ([189.215.161.127]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-741c21c8015sm2121745a34.11.2025.08.07.08.44.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Aug 2025 08:44:50 -0700 (PDT) From: "Elijah G." To: Eli Zaretskii , Philip Kaludercic Subject: Re: bug#79106: [PATCH] Add new optional keywords to use-package In-Reply-To: <86ldnvp4kj.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 07 Aug 2025 17:52:12 +0300") References: <87wm7te6a6.fsf@gmail.com> <871pq03yt7.fsf@posteo.net> <87a54nfqv3.fsf@gmail.com> <87ms8mupvk.fsf@gmail.com> <87wm7pnuof.fsf@gmail.com> <86ecttrdot.fsf@gnu.org> <87jz3lbgr6.fsf@gmail.com> <877bzl5ns5.fsf@gmail.com> <87a54hgozj.fsf@gmail.com> <861ppnqlq0.fsf@gnu.org> <87fre32onn.fsf@posteo.net> <86ldnvp4kj.fsf@gnu.org> Date: Thu, 07 Aug 2025 09:44:46 -0600 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.93 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Eli Zaretskii writes: >> From: Philip Kaludercic >> Cc: Elijah Gabe PĆ©rez , >> karthikchikmagalur@gmail.com, >> johnw@newartisans.com, 79106@debbugs.gnu.org, shipmints@gmail.com >> Date: Thu, 07 Aug 2025 14:26:53 +0000 [...] Content analysis details: (1.3 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (eg642616[at]gmail.com) 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (eg642616[at]gmail.com) -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:341 listed in] [list.dnswl.org] 1.0 FREEMAIL_REPLY From and body contain different freemails X-Debbugs-Envelope-To: 79106 Cc: karthikchikmagalur@gmail.com, 79106@debbugs.gnu.org, shipmints@gmail.com, johnw@newartisans.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Eli Zaretskii writes: >> From: Philip Kaludercic >> Cc: Elijah Gabe P=C3=A9rez , >> karthikchikmagalur@gmail.com, >> johnw@newartisans.com, 79106@debbugs.gnu.org, shipmints@gmail.com >> Date: Thu, 07 Aug 2025 14:26:53 +0000 >>=20 >> Eli Zaretskii writes: >>=20 >> >> > Suggestion 1: allow many hooks to be specified in a list >> >> > >> >> > :hook+ (foo-mode . (bar baz quux)) >> >> > >> >> > adds functions bar, baz and quux to foo-mode-hook. (To >> >> > disambiguate >> >> > between a list of hook functions and a lambda, you can look at >> >> > the car >> >> > of the list maybe?) >> >>=20 >> >> It is not possible because (foo-mode . (bar baz quux)) is >> >> expanded as >> >> (foo-mode bar baz quux), and this can be misinterpreted by :hook+ >> >> as a >> >> list of hooks. >> >>=20 >> >> The only workaround i found is making a kind of separator >> >> (:multi), >> >> which tells :hook+ the cdr is a list of functions, not part of a >> >> list of >> >> hooks. >> >>=20 >> >> I know that :multi can look weird (even i was thinking in rename >> >> it [1] >> >> or use a better separator), but it was the only solution i found >> >> and >> >> worked. >> >>=20 >> >> > Suggestion 2: allow many hooks to be added to. (:hook already >> >> > does >> >> > this) >> >> > >> >> > :hook+ ((foo-mode cor-mode) . (bar baz quux)) >> >> > >> >> > Adds the three functions to both foo-mode-hook and >> >> > cor-mode-hook. >> >>=20 >> >> Similar problem as previous. >> >>=20 >> >> > Suggestion 3: Allow DEPTH and LOCAL to be optionally specified >> >> > with >> >> > the functions, >> >> > in the same order as add-hook. >> >> > >> >> > :hook+ (foo-mode . ((bar 90 t) >> >> > baz >> >> > (quux -30) >> >> > (cor nil t)) >> >> > >> >> > will install=20 >> >> > - bar at depth 90, to be run buffer-locally when foo-mode-hook >> >> > runs >> >> > - baz without special accommodations, and >> >> > - quux at depth -30. >> >> > - cor buffer-locally with default depth >> >>=20 >> >> I like this, i think i can implement only the "local" part. >> >> But of course, only part of :multi. >> >>=20 >> >> If i can get rid of `:multi` i can implement this, but it will >> >> look >> >> somewhat ugly: >> >>=20 >> >> :hook+ (foo-mode . '((bar 90 t))) >> > >> > So what is the outcome of this discussion? Are you working on an >> > updated patch, or should I install the last one you posted? >>=20 >> I believe there was a reasonable doubt whether we need some of the >> keywords at all from the initial patch. So my vote would be to hold >> back from that option for now, and figure out what would make sense >> to >> add to the core. > > Figure out how? > > AFAIU, the latest round of comments just brought up an issue with > :hook+, and the rest didn't cause any objections? Why not install > them? AFAIU, the keywords are considered useless and perhaps unnecessary, and actually, they are, most of them can be useless and redundant or confusing, but to remember, most of these keywords are ideas and concepts that people asked for in use-package and could not be implemented due to lack of time or had to be eliminated. Based on the comments here and in emacs-devel, the only keyword i think should be in core would be :hook+. And this is based on a recent comment in use-package bug tracker on github: --- I myself have a wrapper around use-package for various reasons and I'll be adding support for this as I don't like having things like: :config ;; TODO: neo/use-package could support dept in :hook (add-hook 'after-init-hook 'neo/desktop-restore 99) ; :hook doesn't sup= port depth but if it were supported by use-package it could benefit more people. --- Currently, I'm trying to rewrite :hook+ to make it more familar to add-hook (and see if it's possible to merge it with :hook). So, I'll be sending a better patch when I have something. --=20 - E.G via GNU Emacs Android port. From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 07 12:19:30 2025 Received: (at 79106) by debbugs.gnu.org; 7 Aug 2025 16:19:30 +0000 Received: from localhost ([127.0.0.1]:35666 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uk3Kz-0008Ee-9N for submit@debbugs.gnu.org; Thu, 07 Aug 2025 12:19:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39346) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uk3Kv-0008EK-4P for 79106@debbugs.gnu.org; Thu, 07 Aug 2025 12:19:26 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uk3Kp-0003zu-2G; Thu, 07 Aug 2025 12:19:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=UYnu2tWP/+Nwp3euYJG68umGuf2bN7WkNof0CKI1UFo=; b=o2KROsv+08wBdxC545p+ iHBP1bEp5iSYn+2Ac7AXCBxrQiOtnR7XYgZTIisNb4ZSAn6ji6fJw9b2BZ1IrCiGOsQ65HZQhn19f kqkFuW4L3RERZDuEvImPV2BgsKhO6Fv2wqUZJHdR3f13MnmMX0JFx8f8soB7uOMn1jhePGuzcGdnf wT00FC/C9lcgBXP8ijbWmyDWaRLI38Qhymmsq42UznvlTa8lUA3jpVHKG39Xp/LzkCol2mmkDbJrg HZZhS1RBb4HmrsC+vs0j54Mbj9eLfqXhxvU8Y+PJQBa9A49Sex81UoJo0KlBI2y1sELadpQqs4p3I phNlWa0O4Wbb/g==; Date: Thu, 07 Aug 2025 19:19:15 +0300 Message-Id: <86cy97p0jg.fsf@gnu.org> From: Eli Zaretskii To: "Elijah G." , John Wiegley In-Reply-To: (eg642616@gmail.com) Subject: Re: bug#79106: [PATCH] Add new optional keywords to use-package References: <87wm7te6a6.fsf@gmail.com> <871pq03yt7.fsf@posteo.net> <87a54nfqv3.fsf@gmail.com> <87ms8mupvk.fsf@gmail.com> <87wm7pnuof.fsf@gmail.com> <86ecttrdot.fsf@gnu.org> <87jz3lbgr6.fsf@gmail.com> <877bzl5ns5.fsf@gmail.com> <87a54hgozj.fsf@gmail.com> <861ppnqlq0.fsf@gnu.org> <87fre32onn.fsf@posteo.net> <86ldnvp4kj.fsf@gnu.org> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79106 Cc: karthikchikmagalur@gmail.com, philipk@posteo.net, 79106@debbugs.gnu.org, shipmints@gmail.com, johnw@newartisans.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: "Elijah G." > Cc: karthikchikmagalur@gmail.com, 79106@debbugs.gnu.org, > shipmints@gmail.com, johnw@newartisans.com > Date: Thu, 07 Aug 2025 09:44:46 -0600 > > Eli Zaretskii writes: > > >> From: Philip Kaludercic > >> Cc: Elijah Gabe PĆ©rez , > >> karthikchikmagalur@gmail.com, > >> johnw@newartisans.com, 79106@debbugs.gnu.org, shipmints@gmail.com > >> Date: Thu, 07 Aug 2025 14:26:53 +0000 > >> > >> Eli Zaretskii writes: > >> > >> >> > Suggestion 1: allow many hooks to be specified in a list > >> >> > > >> >> > :hook+ (foo-mode . (bar baz quux)) > >> >> > > >> >> > adds functions bar, baz and quux to foo-mode-hook. (To > >> >> > disambiguate > >> >> > between a list of hook functions and a lambda, you can look at > >> >> > the car > >> >> > of the list maybe?) > >> >> > >> >> It is not possible because (foo-mode . (bar baz quux)) is > >> >> expanded as > >> >> (foo-mode bar baz quux), and this can be misinterpreted by :hook+ > >> >> as a > >> >> list of hooks. > >> >> > >> >> The only workaround i found is making a kind of separator > >> >> (:multi), > >> >> which tells :hook+ the cdr is a list of functions, not part of a > >> >> list of > >> >> hooks. > >> >> > >> >> I know that :multi can look weird (even i was thinking in rename > >> >> it [1] > >> >> or use a better separator), but it was the only solution i found > >> >> and > >> >> worked. > >> >> > >> >> > Suggestion 2: allow many hooks to be added to. (:hook already > >> >> > does > >> >> > this) > >> >> > > >> >> > :hook+ ((foo-mode cor-mode) . (bar baz quux)) > >> >> > > >> >> > Adds the three functions to both foo-mode-hook and > >> >> > cor-mode-hook. > >> >> > >> >> Similar problem as previous. > >> >> > >> >> > Suggestion 3: Allow DEPTH and LOCAL to be optionally specified > >> >> > with > >> >> > the functions, > >> >> > in the same order as add-hook. > >> >> > > >> >> > :hook+ (foo-mode . ((bar 90 t) > >> >> > baz > >> >> > (quux -30) > >> >> > (cor nil t)) > >> >> > > >> >> > will install > >> >> > - bar at depth 90, to be run buffer-locally when foo-mode-hook > >> >> > runs > >> >> > - baz without special accommodations, and > >> >> > - quux at depth -30. > >> >> > - cor buffer-locally with default depth > >> >> > >> >> I like this, i think i can implement only the "local" part. > >> >> But of course, only part of :multi. > >> >> > >> >> If i can get rid of `:multi` i can implement this, but it will > >> >> look > >> >> somewhat ugly: > >> >> > >> >> :hook+ (foo-mode . '((bar 90 t))) > >> > > >> > So what is the outcome of this discussion? Are you working on an > >> > updated patch, or should I install the last one you posted? > >> > >> I believe there was a reasonable doubt whether we need some of the > >> keywords at all from the initial patch. So my vote would be to hold > >> back from that option for now, and figure out what would make sense > >> to > >> add to the core. > > > > Figure out how? > > > > AFAIU, the latest round of comments just brought up an issue with > > :hook+, and the rest didn't cause any objections? Why not install > > them? > > AFAIU, the keywords are considered useless and perhaps unnecessary, and > actually, they are, most of them can be useless and redundant or > confusing, but to remember, most of these keywords are ideas and > concepts that people asked for in use-package and could not be > implemented due to lack of time or had to be eliminated. > > Based on the comments here and in emacs-devel, the only keyword i think > should be in core would be :hook+. > > And this is based on a recent comment in use-package bug tracker on github: > > --- > I myself have a wrapper around use-package for various reasons and > I'll be adding support for this as I don't like having things like: > > :config > ;; TODO: neo/use-package could support dept in :hook > (add-hook 'after-init-hook 'neo/desktop-restore 99) ; :hook doesn't support depth > > but if it were supported by use-package it could benefit more people. > --- John, would you please chime in and tel what you think about this? From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 23 07:32:55 2025 Received: (at 79106) by debbugs.gnu.org; 23 Aug 2025 11:32:55 +0000 Received: from localhost ([127.0.0.1]:38857 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1upmUQ-0002Rq-Mh for submit@debbugs.gnu.org; Sat, 23 Aug 2025 07:32:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48044) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1upmUO-0002RV-8l for 79106@debbugs.gnu.org; Sat, 23 Aug 2025 07:32:53 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1upmUI-0002WP-Ht; Sat, 23 Aug 2025 07:32:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=M+r88jLobRdT1oKar+FPGG0wTiFUhREeZQO9mN/tuf8=; b=BArEFcX9DWxnJpYlLDkT rTFnbyDo26n+tNiI30SIi6ODjmOJaPzlIi50P4GWckgtgwwca1R8ZIWh70jMOAmU+XnD/DKiYM0cE chuDSMhqvuD6aH2/5lAX15fvm5Rs/oUT15m1YjZV6bkHGjoH1WyxGTkjx60fmohIjXWEXZuxElfM3 Qblv6bYOcEAKyxDH3aYA6uR+70dX5OU4advLb55NStMvI93oCnO1FLigAS4wdiSkpqaApu3qFGfeB Hi024hYfjpbVZCB+jdmwje/kVOFvOIWV5rdUjKKx4pG3ppGhtQGd0AKbtRGQeL8z1ulw447TH7qbV UCrzcHq7Qbp/vg==; Date: Sat, 23 Aug 2025 14:32:42 +0300 Message-Id: <86sehib7dx.fsf@gnu.org> From: Eli Zaretskii To: johnw@gnu.org In-Reply-To: <86cy97p0jg.fsf@gnu.org> (message from Eli Zaretskii on Thu, 07 Aug 2025 19:19:15 +0300) Subject: Re: bug#79106: [PATCH] Add new optional keywords to use-package References: <87wm7te6a6.fsf@gmail.com> <871pq03yt7.fsf@posteo.net> <87a54nfqv3.fsf@gmail.com> <87ms8mupvk.fsf@gmail.com> <87wm7pnuof.fsf@gmail.com> <86ecttrdot.fsf@gnu.org> <87jz3lbgr6.fsf@gmail.com> <877bzl5ns5.fsf@gmail.com> <87a54hgozj.fsf@gmail.com> <861ppnqlq0.fsf@gnu.org> <87fre32onn.fsf@posteo.net> <86ldnvp4kj.fsf@gnu.org> <86cy97p0jg.fsf@gnu.org> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79106 Cc: johnw@newartisans.com, philipk@posteo.net, eg642616@gmail.com, shipmints@gmail.com, karthikchikmagalur@gmail.com, 79106@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Ping! John, please respond. > Cc: karthikchikmagalur@gmail.com, philipk@posteo.net, 79106@debbugs.gnu.org, > shipmints@gmail.com, johnw@newartisans.com > Date: Thu, 07 Aug 2025 19:19:15 +0300 > From: Eli Zaretskii > > > From: "Elijah G." > > Cc: karthikchikmagalur@gmail.com, 79106@debbugs.gnu.org, > > shipmints@gmail.com, johnw@newartisans.com > > Date: Thu, 07 Aug 2025 09:44:46 -0600 > > > > Eli Zaretskii writes: > > > > >> From: Philip Kaludercic > > >> Cc: Elijah Gabe PĆ©rez , > > >> karthikchikmagalur@gmail.com, > > >> johnw@newartisans.com, 79106@debbugs.gnu.org, shipmints@gmail.com > > >> Date: Thu, 07 Aug 2025 14:26:53 +0000 > > >> > > >> Eli Zaretskii writes: > > >> > > >> >> > Suggestion 1: allow many hooks to be specified in a list > > >> >> > > > >> >> > :hook+ (foo-mode . (bar baz quux)) > > >> >> > > > >> >> > adds functions bar, baz and quux to foo-mode-hook. (To > > >> >> > disambiguate > > >> >> > between a list of hook functions and a lambda, you can look at > > >> >> > the car > > >> >> > of the list maybe?) > > >> >> > > >> >> It is not possible because (foo-mode . (bar baz quux)) is > > >> >> expanded as > > >> >> (foo-mode bar baz quux), and this can be misinterpreted by :hook+ > > >> >> as a > > >> >> list of hooks. > > >> >> > > >> >> The only workaround i found is making a kind of separator > > >> >> (:multi), > > >> >> which tells :hook+ the cdr is a list of functions, not part of a > > >> >> list of > > >> >> hooks. > > >> >> > > >> >> I know that :multi can look weird (even i was thinking in rename > > >> >> it [1] > > >> >> or use a better separator), but it was the only solution i found > > >> >> and > > >> >> worked. > > >> >> > > >> >> > Suggestion 2: allow many hooks to be added to. (:hook already > > >> >> > does > > >> >> > this) > > >> >> > > > >> >> > :hook+ ((foo-mode cor-mode) . (bar baz quux)) > > >> >> > > > >> >> > Adds the three functions to both foo-mode-hook and > > >> >> > cor-mode-hook. > > >> >> > > >> >> Similar problem as previous. > > >> >> > > >> >> > Suggestion 3: Allow DEPTH and LOCAL to be optionally specified > > >> >> > with > > >> >> > the functions, > > >> >> > in the same order as add-hook. > > >> >> > > > >> >> > :hook+ (foo-mode . ((bar 90 t) > > >> >> > baz > > >> >> > (quux -30) > > >> >> > (cor nil t)) > > >> >> > > > >> >> > will install > > >> >> > - bar at depth 90, to be run buffer-locally when foo-mode-hook > > >> >> > runs > > >> >> > - baz without special accommodations, and > > >> >> > - quux at depth -30. > > >> >> > - cor buffer-locally with default depth > > >> >> > > >> >> I like this, i think i can implement only the "local" part. > > >> >> But of course, only part of :multi. > > >> >> > > >> >> If i can get rid of `:multi` i can implement this, but it will > > >> >> look > > >> >> somewhat ugly: > > >> >> > > >> >> :hook+ (foo-mode . '((bar 90 t))) > > >> > > > >> > So what is the outcome of this discussion? Are you working on an > > >> > updated patch, or should I install the last one you posted? > > >> > > >> I believe there was a reasonable doubt whether we need some of the > > >> keywords at all from the initial patch. So my vote would be to hold > > >> back from that option for now, and figure out what would make sense > > >> to > > >> add to the core. > > > > > > Figure out how? > > > > > > AFAIU, the latest round of comments just brought up an issue with > > > :hook+, and the rest didn't cause any objections? Why not install > > > them? > > > > AFAIU, the keywords are considered useless and perhaps unnecessary, and > > actually, they are, most of them can be useless and redundant or > > confusing, but to remember, most of these keywords are ideas and > > concepts that people asked for in use-package and could not be > > implemented due to lack of time or had to be eliminated. > > > > Based on the comments here and in emacs-devel, the only keyword i think > > should be in core would be :hook+. > > > > And this is based on a recent comment in use-package bug tracker on github: > > > > --- > > I myself have a wrapper around use-package for various reasons and > > I'll be adding support for this as I don't like having things like: > > > > :config > > ;; TODO: neo/use-package could support dept in :hook > > (add-hook 'after-init-hook 'neo/desktop-restore 99) ; :hook doesn't support depth > > > > but if it were supported by use-package it could benefit more people. > > --- > > John, would you please chime in and tel what you think about this? > > > > From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 23 17:53:37 2025 Received: (at 79106) by debbugs.gnu.org; 23 Aug 2025 21:53:37 +0000 Received: from localhost ([127.0.0.1]:41936 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1upwB6-00014T-RW for submit@debbugs.gnu.org; Sat, 23 Aug 2025 17:53:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53172) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1upwB3-00014F-U4 for 79106@debbugs.gnu.org; Sat, 23 Aug 2025 17:53:35 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1upwAy-0005gf-Gp; Sat, 23 Aug 2025 17:53:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=cRGobZKf9QpBTscStRE/O8ylbW36hy7NefpxnhFXdMk=; b=MoR9FUz79BQFzS5zS/vA UezL7ybSuS+pxHCPuufZcSel/uTIXEOO++fo0UNKPNghFLNdFvJIvaxClCTbbby0jz4XN/9i1dT45 swoZrZUsU88d89lejzGxSeVood8yaQYmf+c5GpH7BtSNAPv93+xLW/aNygm1QGZ2GoQDfhhUmplpq 8XsuMK+Ay78JtT1z5aTBYTEguxJJZHZZ4cU9eXylFigxmOsaRiq9DvH7kADD2ebivVgNqUNptb6U+ 7js7pAwBf49Sfu2zKElh3MHsJt7JNeQBy4AQvLLlR4uX8WStG7MtZd4A2iM1Sx4ApeOrZ3x9bCryC Je2vYgcvpZvYEQ==; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdduieejjeeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefujghffffkfgggtgfgsehtqhertddtreejnecuhfhrohhmpeflohhhnhcu hghivghglhgvhicuoehjohhhnhifsehgnhhurdhorhhgqeenucggtffrrghtthgvrhhnpe eiffdthedviedvtdfffeffffevkeeludejieeltddufeehfefhhfefgeejteefgeenucff ohhmrghinhepnhgvfigrrhhtihhsrghnshdrtghomhenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehjohhhnhifodhmvghsmhhtphgruhhthhhp vghrshhonhgrlhhithihqdeikeejkedtleeggedqudejjeehfeekudeiqdhjohhhnhifpe epghhnuhdrohhrghesnhgvfigrrhhtihhsrghnshdrtghomhdpnhgspghrtghpthhtohep iedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepshhhihhpmhhinhhtshesghhmrg hilhdrtghomhdprhgtphhtthhopeejledutdeiseguvggssghughhsrdhgnhhurdhorhhg pdhrtghpthhtohepphhhihhlihhpkhesphhoshhtvghordhnvghtpdhrtghpthhtohepkh grrhhthhhikhgthhhikhhmrghgrghluhhrsehgmhgrihhlrdgtohhmpdhrtghpthhtohep vghgieegvdeiudeisehgmhgrihhlrdgtohhmpdhrtghpthhtohepvghlihiisehgnhhurd horhhg X-ME-Proxy: Feedback-ID: ib64945b7:Fastmail From: John Wiegley To: Eli Zaretskii Subject: Re: bug#79106: [PATCH] Add new optional keywords to use-package In-Reply-To: <86sehib7dx.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 23 Aug 2025 14:32:42 +0300") References: <87wm7te6a6.fsf@gmail.com> <871pq03yt7.fsf@posteo.net> <87a54nfqv3.fsf@gmail.com> <87ms8mupvk.fsf@gmail.com> <87wm7pnuof.fsf@gmail.com> <86ecttrdot.fsf@gnu.org> <87jz3lbgr6.fsf@gmail.com> <877bzl5ns5.fsf@gmail.com> <87a54hgozj.fsf@gmail.com> <861ppnqlq0.fsf@gnu.org> <87fre32onn.fsf@posteo.net> <86ldnvp4kj.fsf@gnu.org> <86cy97p0jg.fsf@gnu.org> <86sehib7dx.fsf@gnu.org> Date: Sat, 23 Aug 2025 14:53:24 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79106 Cc: karthikchikmagalur@gmail.com, eg642616@gmail.com, 79106@debbugs.gnu.org, philipk@posteo.net, shipmints@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >>>>> Eli Zaretskii writes: > Ping! John, please respond. My apologies, I didn=E2=80=99t see this message asking for my input. Thank = you for the prompt! >> AFAIU, the keywords are considered useless and perhaps unnecessary, and >> actually, they are, most of them can be useless and redundant or confusi= ng, >> but to remember, most of these keywords are ideas and concepts that peop= le >> asked for in use-package and could not be implemented due to lack of time >> or had to be eliminated. >>=20 >> Based on the comments here and in emacs-devel, the only keyword i think >> should be in core would be :hook+. >>=20 >> And this is based on a recent comment in use-package bug tracker on gith= ub: >>=20 >> --- >> I myself have a wrapper around use-package for various reasons and I'll >> be adding support for this as I don't like having things like: >>=20 >> :config >> ;; TODO: neo/use-package could support dept in :hook >> (add-hook 'after-init-hook 'neo/desktop-restore 99) ; :hook doesn't = support depth >>=20 >> but if it were supported by use-package it could benefit more people. >> --- >=20 > John, would you please chime in and tel what you think about this? Personally, I think that =E2=80=9Cextra=E2=80=9D features shouldn=E2=80=99t= be in Core, but rather in ELPA. What=E2=80=99s in core should either be what is vital, or what is lik= ely to be used by the majority of users. Many of the keywords in this submission do n= ot satisfy either criteria. The desire to specify hook depth is a motivating reason to extend the behav= ior of `:hook`. I=E2=80=99m not sure we should add a new keyword, `:hook+`. I t= hink we should extend the parsing of `:hook` so that the following are supported: (SYM) (SYM . FUNC) (SYMS . FUNC) (SYMS FUNC KEYS) Where KEYS would initially include `:depth N`, and leaves the door open to further keywords if necessary. Note that another feature requested in the past is the ability to specify FUNCS as a list instead of just FUNC, but that would become impossible if we went with the above scheme. I=E2=80=99m not sure how much I like the MANY<-= >MANY possibility of both SYMS and FUNCS anyway. --=20 John Wiegley GPG fingerprint =3D 4710 CF98 AF9B 327B B80F http://newartisans.com 60E1 46C4 BD1A 7AC1 4BA2 From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 28 19:08:31 2025 Received: (at 79106) by debbugs.gnu.org; 28 Aug 2025 23:08:31 +0000 Received: from localhost ([127.0.0.1]:40545 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1urljK-00010i-KM for submit@debbugs.gnu.org; Thu, 28 Aug 2025 19:08:31 -0400 Received: from mail-oa1-x41.google.com ([2001:4860:4864:20::41]:58706) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1urlj9-0000yN-64 for 79106@debbugs.gnu.org; Thu, 28 Aug 2025 19:08:25 -0400 Received: by mail-oa1-x41.google.com with SMTP id 586e51a60fabf-31597d3b410so806988fac.1 for <79106@debbugs.gnu.org>; Thu, 28 Aug 2025 16:08:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756422492; x=1757027292; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BovfBgoqpsz+NQOk/2Cln3ZscmqBIjeyT6znDybd4ic=; b=XPgKoRhH3zfssI8KjEefGt04uBQjlBc0nugu6c1tKyCAQM4RMDVjHCo7WjN9abmQEf APtGVVvD1briCmzUHwMYyccuCsCStXryDut2Frxfkj/Dc7BKKG5fGV2Gnx9fkiZ+CVDw I6vHoyqD8PZe572bgRQ0S+CMhFs5CBd9l1tAQki61ovLviwXHknIp6b7QA0rgaheuecd iv8O7/1JRt8l+eAUVkVj5s6FNSQj/5iI2K1rOIT0PKh2zQChPctMg/jgH2GxNrhqn3Gg M6si4R7g00gAT0/3yg/Bc4Dvzvmq1sx76iEXxTTxJLhM2lAEyaKJ5/wjrs9/87yTrSkF yjkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756422492; x=1757027292; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=BovfBgoqpsz+NQOk/2Cln3ZscmqBIjeyT6znDybd4ic=; b=sakS5GNuw6fMuXuV4HzuVoOX60BzZVS4mgiKvgd2IxU9LcYgP2eqHI3L1a7BjAdO5G Lyavkj+VMhkE2H/3oN+yjqF0/6h0d/bL99YT6qlgeBhiAxfBF2B3TbNP264Rb4R4Jmcr mDaYBmVzG+yocmSr7J5vXq9V2hDEknX9L7/7afEBuOMNPdzkDnzvkvbPq0RYwiCMUizw 5kpjd8XKhFA3mJvtRFyyewrQq7nvPg7ze56Xx6m1qLaashpihJ8DYObEjhnnhaX5q5LG /6Djn2ydUIFbg9Re2QAjK5GFkRUqg47w+f0iB6Va5OYL6cJOCu5pBEU/BlLwG7kdZS9w yiuQ== X-Forwarded-Encrypted: i=1; AJvYcCVTK5EPup2qRCxkd0ME50Up4yk1Yr2eXmmE/znxQ6D0c3dmZu7zA19LFHFdWPeUULUzQ/yvdg==@debbugs.gnu.org X-Gm-Message-State: AOJu0YyR13F1860Ct5qUqj87Z4/sKUymog8AsVPyT+xHa6BXlu4el+3c 69i/dgsWd0HhnQEPMRB82pD0y00qiB+s4T+UWl5VM/IIHZgOYBHo6aLt X-Gm-Gg: ASbGncucnPWrRMHH169MMlesZd+O0fcOcuKYUMR0zaTJzLRjxlUhquOhKpFew1DE8Ir UV5PsSJ+gp5IjwI1CVkOPKC6SSbfln0BdnYT/Du6ljSNQRSA2iMmH3kkvAzDY+NoNvwuZvQvPWt KiZ8usT8BioGIy8sRbsIxu2rV2f1ElvU05HAK7dKaT8/+dA/o2GZ0r2LPpV0HoBoM6fGWg3ZO78 ej3Qc/S08zliJDfC2/ruUKcEoW90F/Lk+4owJ+VRjTJcT+lzghZg+LtWsqesqBjbAHJR5sXIpNS rI4jHo1kl01tVyzjBkNAzTA6bwr6inkl4AENPKSyNLAVQX9S+g+K9EG0QDSmrgtch1vSHOREVTl tb65IgeEGqSPKL4W8VkHo7zzb7w== X-Google-Smtp-Source: AGHT+IFbQNZqfAMbNC1EowY851H6R+E+aMYqwDy4+zWqF6Ro663GtYBL2DSOYKavz/kQa+Bawuizrw== X-Received: by 2002:a05:6870:e9aa:b0:2eb:b6a2:8d77 with SMTP id 586e51a60fabf-314dce14492mr14037060fac.29.1756422491912; Thu, 28 Aug 2025 16:08:11 -0700 (PDT) Received: from fedora ([189.215.165.181]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-315afe130d5sm528863fac.16.2025.08.28.16.08.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Aug 2025 16:08:11 -0700 (PDT) From: =?utf-8?Q?Elijah_Gabe_P=C3=A9rez?= To: John Wiegley Subject: Re: bug#79106: [PATCH] Add new optional keywords to use-package In-Reply-To: References: <87wm7te6a6.fsf@gmail.com> <871pq03yt7.fsf@posteo.net> <87a54nfqv3.fsf@gmail.com> <87ms8mupvk.fsf@gmail.com> <87wm7pnuof.fsf@gmail.com> <86ecttrdot.fsf@gnu.org> <87jz3lbgr6.fsf@gmail.com> <877bzl5ns5.fsf@gmail.com> <87a54hgozj.fsf@gmail.com> <861ppnqlq0.fsf@gnu.org> <87fre32onn.fsf@posteo.net> <86ldnvp4kj.fsf@gnu.org> <86cy97p0jg.fsf@gnu.org> <86sehib7dx.fsf@gnu.org> Date: Thu, 28 Aug 2025 17:08:08 -0600 Message-ID: <87cy8f82p3.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 79106 Cc: karthikchikmagalur@gmail.com, Eli Zaretskii , 79106@debbugs.gnu.org, philipk@posteo.net, shipmints@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) John Wiegley writes: [...] >> John, would you please chime in and tel what you think about this? > > Personally, I think that =E2=80=9Cextra=E2=80=9D features shouldn=E2=80= =99t be in Core, but rather in > ELPA. What=E2=80=99s in core should either be what is vital, or what is l= ikely to be > used by the majority of users. Many of the keywords in this submission do= not > satisfy either criteria. I agree. Then I think it would be better to move use-package-x to ELPA. > The desire to specify hook depth is a motivating reason to extend the beh= avior > of `:hook`. I=E2=80=99m not sure we should add a new keyword, `:hook+`. I= think we > should extend the parsing of `:hook` so that the following are supported: > > (SYM) > (SYM . FUNC) > (SYMS . FUNC) > (SYMS FUNC KEYS) > > Where KEYS would initially include `:depth N`, and leaves the door open to > further keywords if necessary. > > Note that another feature requested in the past is the ability to specify > FUNCS as a list instead of just FUNC, but that would become impossible if= we > went with the above scheme. I think the FUNCS logic can be only added to plain lists instead cons-cells. The cons-cell form seems to be designed only for single functions (SYM . FUNC) (SYMS . FUNC) On the other hand, with a list this could be easily implemented: (SYM FUNCS) (SYMS FUNCS) I honestly don't think I have the time (and energy) to add these features to :hook (the changes may be buggy). At the moment I think that having them in my package is a better way to avoid breaking use-package. > I=E2=80=99m not sure how much I like the MANY<->MANY possibility of both = SYMS and FUNCS anyway. Honestly, the FUNCS feature may not be necessary. There have been other alternatives, such as using a function or a lambda to group the functions: :preface (defun my/functions () (f1) (f2) (f3)) :hook (my-hook . my/functions) However, in my personal opinion, this is not usually convenient because if someone wants to remove one of the functions from that hook, they would have to remove the defun or lambda which includes the others functions. --=20 - E.G via Gnus and Org. From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 02 10:27:08 2025 Received: (at 79106) by debbugs.gnu.org; 2 Sep 2025 14:27:08 +0000 Received: from localhost ([127.0.0.1]:35229 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1utRyW-0000VJ-Bb for submit@debbugs.gnu.org; Tue, 02 Sep 2025 10:27:08 -0400 Received: from mout01.posteo.de ([185.67.36.65]:34645) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1utRyR-0000Ua-S2 for 79106@debbugs.gnu.org; Tue, 02 Sep 2025 10:27:04 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id B7CFF240027 for <79106@debbugs.gnu.org>; Tue, 2 Sep 2025 16:26:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=posteo.net; s=2017; t=1756823217; bh=djP8zlVih/HEs7AyKhHLVNTL4WyqHttLfsN5KcIJ4jI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: Content-Transfer-Encoding:From; b=n30z/Fm+Jr4MFsf/Mxk/ECQcd+vwYc1KlK543oCM9IiRx3NDZiAVBkWuh/at2TIZs r5vzCOWRjpkCqaP4lmfsb8V5h96SNlFqjDV+l2kfzMae1S0lbr7LfVhRoQ7ET7kEbs /1oBE4K+1VkE7HaP/uMDPgSjyKikNQ5Mj7bg1itl5TiPl5zU1ZGFKvMv45Qz0RdiJn PrREcLLxbK+/C70u2ncreehH7isYV9sHLnUzPVj2yWAUJ8bbZsU6nUI9uK+q1c6ZTa 5tiGCfNERvwhw7NQh0FUxGxDk0eRkkXBKTAMfprWRoLtIsm4WcoW0ummYz7UkMF6hQ GVB2jCu3OW0yQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4cGSjs0XJCz9rxY; Tue, 2 Sep 2025 16:26:57 +0200 (CEST) From: Philip Kaludercic To: Elijah Gabe =?utf-8?Q?P=C3=A9rez?= Subject: Re: bug#79106: [PATCH] Add new optional keywords to use-package In-Reply-To: <87cy8f82p3.fsf@gmail.com> References: <87wm7te6a6.fsf@gmail.com> <871pq03yt7.fsf@posteo.net> <87a54nfqv3.fsf@gmail.com> <87ms8mupvk.fsf@gmail.com> <87wm7pnuof.fsf@gmail.com> <86ecttrdot.fsf@gnu.org> <87jz3lbgr6.fsf@gmail.com> <877bzl5ns5.fsf@gmail.com> <87a54hgozj.fsf@gmail.com> <861ppnqlq0.fsf@gnu.org> <87fre32onn.fsf@posteo.net> <86ldnvp4kj.fsf@gnu.org> <86cy97p0jg.fsf@gnu.org> <86sehib7dx.fsf@gnu.org> <87cy8f82p3.fsf@gmail.com> Date: Tue, 02 Sep 2025 14:26:57 +0000 Message-ID: <87h5xlexqn.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79106 Cc: karthikchikmagalur@gmail.com, Eli Zaretskii , John Wiegley , 79106@debbugs.gnu.org, shipmints@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Elijah Gabe P=C3=A9rez writes: > John Wiegley writes: > > [...] > >>> John, would you please chime in and tel what you think about this? >> >> Personally, I think that =E2=80=9Cextra=E2=80=9D features shouldn=E2=80= =99t be in Core, but rather in >> ELPA. What=E2=80=99s in core should either be what is vital, or what is = likely to be >> used by the majority of users. Many of the keywords in this submission d= o not >> satisfy either criteria. > > I agree. > > Then I think it would be better to move use-package-x to ELPA. Right, this was the initial judgement as well, but Eli recommended adding the new functionality to the core. To be clear, this is my preference as well, but I don't want to override Eli's wishes, so I'd like to ask Eli: Do you still maintain that we should add (whatever subseteq of features we decide on) to the core, or is it OK to add them as a package to ELPA? [...] --=20 Philip Kaludercic