From: "Philip K." <philipk@posteo.net>
To: Gregory Heytings <gregory@heytings.org>
Cc: help-gnu-emacs@gnu.org
Subject: Re: PROPOSAL: Repurpose one key and reserve it for third-party packages
Date: Thu, 11 Feb 2021 16:47:45 +0100 [thread overview]
Message-ID: <87y2fua9ni.fsf@posteo.net> (raw)
In-Reply-To: <87lfbubthl.fsf@posteo.net> (Philip K.'s message of "Thu, 11 Feb 2021 14:53:58 +0100")
[-- Attachment #1.1: Type: text/plain, Size: 500 bytes --]
"Philip K." <philipk@posteo.net> writes:
> All in all, I don't have a problem with Emacs being able to support it,
> but as I've shown with the example in my last message, it doesn't need
> to be done automatically, nor does it require a separate key. It's
> ultimately up to the user what he or she wants to do, and clever
> behind-your-back customization seems more harmful and confusing than the
> current state of affairs.
Just for the sake of it, this is a draft of how this could look like:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-Add-package-suggest-configuration.patch --]
[-- Type: text/x-patch, Size: 6146 bytes --]
From 3e78e4e61462f116a56224e0750401e9b9596e1f Mon Sep 17 00:00:00 2001
From: Philip K <philipk@posteo.net>
Date: Thu, 11 Feb 2021 16:30:09 +0100
Subject: [PATCH] Add package-suggest-configuration
---
lisp/emacs-lisp/package.el | 99 ++++++++++++++++++++++++++++++++------
1 file changed, 85 insertions(+), 14 deletions(-)
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 90b7b88d58..6ddd363003 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -145,6 +145,7 @@
(require 'cl-lib)
(eval-when-compile (require 'subr-x))
+(eval-when-compile (require 'pcase))
(eval-when-compile (require 'epg)) ;For setf accessors.
(require 'seq)
@@ -2087,6 +2088,88 @@ package--archives-initialize
(unless package-archive-contents
(package-refresh-contents)))
+(defcustom package-ignore-suggestions nil
+ "Should package-"
+ :type '(choice (const :tag "Ask the user" nil)
+ (const :tag "Never ask" t)
+ (set :tag "Ignore certain suggestions"
+ (const :tag "Keybindings" key)
+ (const :tag "User Options" option)
+ (const :tag "Hooks" hook)))
+ :version "28.1")
+
+(defvar pacakge-configuration-suggestions nil
+ "An alist of advertised default configuration.
+Each entry has the form (PACKAGE . SUGGESTIONS), where PACAKGE is
+a symbol designating the package, and SUGGESTIONS is another
+alist. SUGGESTIONS have the form (TYPE . DATA), where TYPE says
+what kind of a suggestion is being made and DATA is the content
+of the suggestion. Currently, the following values for TYPE are
+understood:
+
+- `key', where DATA has the form (KEY FUNCTION). It suggests
+ binding FUNCTION globally to KEY, unless KEY is already bound.
+ KEY is passed to the function `kbd'.
+
+- `option', where DATA has the form (OPT VAL). It setting the
+ symbol OPT to the value VAL.
+
+- `hook', where DATA has the form (HOOK FUNCTION). It suggests
+ adding FUNCTION to the hook HOOK.
+
+All other values for TYPE are ignored.")
+
+(defun package--query-name (&optional kind verb)
+ "Query the user for a package name.
+If KIND is nil, prompt for all kinds of packages. If KIND is
+`installed' only prompt for installed packages. If KIND is
+`not-installed', only prompt for packages that have not been
+installed. VERB modified to prompt."
+ ;; Initialize the package system to get the list of package
+ ;; symbols for completion.
+ (package--archives-initialize)
+ (intern (completing-read
+ (format "%s package: " (or verb "Select"))
+ (delq nil (mapcar (lambda (elt)
+ (when (cond
+ ((eq kind 'installed)
+ (package-installed-p (car elt)))
+ ((eq kind 'not-installed)
+ (not (package-installed-p (car elt))))
+ ((null kind))
+ (t (error "Invalid kind")))
+ (symbol-name (car elt))))
+ package-archive-contents))
+ nil t)))
+
+(defun package-suggest-configuration (package &optional dont-load)
+ "Query the user to automatically configure PACKAGE.
+If DONT-LOAD is non-nil, do not load the new customization."
+ (interactive (list (package--query-name 'installed) current-prefix-arg))
+ (unless (and (not (called-interactively-p 'any))
+ (eq package-ignore-suggestions t))
+ (let ((temp-buffer-show-function #'ignore)
+ (save-silently t))
+ (with-temp-buffer
+ (with-output-to-temp-buffer (current-buffer)
+ (dolist (sug (cdr (assq package pacakge-configuration-suggestions)))
+ (unless (memq (car sug) package-ignore-suggestions)
+ (terpri nil t)
+ (pcase sug
+ (`(key ,key ,fn)
+ (when (yes-or-no-p (format "Bind %s to \"%s\"?" fn key))
+ (prin1 `(global-set-key (kbd ,key) #',fn))))
+ (`(option ,opt ,val)
+ (when (yes-or-no-p (format "Set option %s to %S?" opt val))
+ (prin1 `(customize-set-variable ',opt ,val))))
+ (`(hook ,hook ,fn)
+ (when (yes-or-no-p (format "Add %s to hook %S?" fn hook))
+ (prin1 `(add-hook ',hook #',fn)))))))
+ (unless dont-load
+ (eval-buffer))
+ (append-to-file (point-min) (point-max)
+ (or custom-file user-init-file)))))))
+
;;;###autoload
(defun package-install (pkg &optional dont-select)
"Install the package PKG.
@@ -2103,20 +2186,7 @@ package-install
If PKG is a `package-desc' and it is already installed, don't try
to install it but still mark it as selected."
- (interactive
- (progn
- ;; Initialize the package system to get the list of package
- ;; symbols for completion.
- (package--archives-initialize)
- (list (intern (completing-read
- "Install package: "
- (delq nil
- (mapcar (lambda (elt)
- (unless (package-installed-p (car elt))
- (symbol-name (car elt))))
- package-archive-contents))
- nil t))
- nil)))
+ (interactive (list (package--query-name 'not-installed "Install")))
(package--archives-initialize)
(add-hook 'post-command-hook #'package-menu--post-refresh)
(let ((name (if (package-desc-p pkg)
@@ -2134,6 +2204,7 @@ package-install
(progn
(package-download-transaction transaction)
(package--quickstart-maybe-refresh)
+ (package-suggest-configuration pkg)
(message "Package `%s' installed." name))
(message "`%s' is already installed" name))))
--
2.29.2
[-- Attachment #1.3: Type: text/plain, Size: 19 bytes --]
--
Philip K.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 658 bytes --]
next prev parent reply other threads:[~2021-02-11 15:47 UTC|newest]
Thread overview: 185+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-07 22:05 PROPOSAL: Repurpose one key and reserve it for third-party packages Gregory Heytings
2021-02-08 0:13 ` Ergus
2021-02-08 2:57 ` Jorge Javier Araya Navarro
2021-02-08 3:46 ` Richard Stallman
2021-02-08 7:20 ` Stefan Kangas
2021-02-08 14:58 ` Lars Ingebrigtsen
2021-02-08 21:00 ` Gregory Heytings
2021-02-08 21:33 ` Stefan Monnier
2021-02-09 8:13 ` Lars Ingebrigtsen
2021-02-09 16:54 ` Sean Whitton
2021-02-09 17:13 ` Lars Ingebrigtsen
2021-02-09 17:43 ` Eli Zaretskii
2021-02-09 21:21 ` Sean Whitton
2021-02-10 21:43 ` Bindings for setting faces (was: PROPOSAL: Repurpose one key and reserve it for third-party packages) Kévin Le Gouguec
2021-02-09 18:37 ` PROPOSAL: Repurpose one key and reserve it for third-party packages Stefan Monnier
2021-02-08 22:45 ` Stefan Kangas
2021-02-08 15:45 ` Thibaut Verron
2021-02-08 23:01 ` Stefan Kangas
2021-02-09 3:20 ` [External] : " Drew Adams
2021-02-09 9:13 ` Simen Heggestøyl
2021-02-09 9:30 ` Juri Linkov
2021-02-09 13:01 ` Gregory Heytings
2021-02-08 21:00 ` Gregory Heytings
2021-02-09 6:03 ` Richard Stallman
2021-02-08 12:36 ` Alan Mackenzie
2021-02-08 21:00 ` Gregory Heytings
2021-02-08 4:52 ` Robin Tarsiger
2021-02-08 8:41 ` Thibaut Verron
2021-02-08 17:07 ` Robin Tarsiger
2021-02-11 12:59 ` Arthur Miller
2021-02-08 21:00 ` Gregory Heytings
2021-02-09 7:42 ` Yuri Khan
2021-02-09 8:23 ` Gregory Heytings
2021-02-08 23:14 ` Stefan Monnier
2021-02-09 8:23 ` Gregory Heytings
2021-02-08 12:42 ` Augusto Stoffel
2021-02-08 21:00 ` Gregory Heytings
2021-02-08 14:54 ` Dmitry Gutov
2021-02-08 21:00 ` Gregory Heytings
2021-02-08 17:59 ` Sean Whitton
2021-02-08 22:40 ` Eric Abrahamsen
2021-02-09 16:45 ` Sean Whitton
2021-02-10 5:28 ` Richard Stallman
2021-02-10 9:29 ` Thibaut Verron
2021-02-11 13:37 ` Richard Stallman
2021-02-11 13:52 ` Thibaut Verron
2021-02-10 10:42 ` Alfred M. Szmidt
2021-02-10 11:35 ` Thibaut Verron
2021-02-10 12:59 ` Alfred M. Szmidt
2021-02-10 13:09 ` vc-magit mode (was: Re: PROPOSAL: Repurpose one key and reserve it for third-party packages) Alfred M. Szmidt
2021-02-10 13:25 ` Thibaut Verron
2021-02-10 13:34 ` vc-magit mode Dmitry Gutov
2021-02-10 15:33 ` vc-magit mode (was: Re: PROPOSAL: Repurpose one key and reserve it for third-party packages) Eli Zaretskii
2021-02-10 16:47 ` Alfred M. Szmidt
2021-02-10 17:22 ` Eli Zaretskii
2021-02-11 13:37 ` PROPOSAL: Repurpose one key and reserve it for third-party packages Richard Stallman
2021-02-11 14:38 ` Stefan Kangas
2021-02-11 15:13 ` Robert Pluim
2021-02-11 16:08 ` Stefan Monnier
2021-02-12 8:21 ` Alfred M. Szmidt
2021-02-12 8:36 ` Robert Pluim
2021-02-12 15:11 ` Alfred M. Szmidt
2021-02-13 3:26 ` Richard Stallman
2021-02-10 11:07 ` Gregory Heytings
2021-02-10 13:00 ` Alfred M. Szmidt
2021-02-10 13:59 ` Gregory Heytings
2021-02-10 14:10 ` Alfred M. Szmidt
2021-02-10 14:51 ` Gregory Heytings
2021-02-10 15:12 ` Alfred M. Szmidt
2021-02-10 15:23 ` Gregory Heytings
2021-02-10 16:35 ` [External] : " Drew Adams
2021-02-10 16:35 ` Drew Adams
2021-02-10 17:05 ` Stefan Monnier
2021-02-11 13:37 ` Richard Stallman
2021-02-11 13:55 ` Gregory Heytings
2021-02-12 9:40 ` Jean Louis
2021-02-08 20:32 ` Ulrich Mueller
2021-02-08 21:00 ` Gregory Heytings
2021-02-08 21:37 ` Ulrich Mueller
2021-02-08 22:00 ` Gregory Heytings
2021-02-09 16:57 ` Sean Whitton
2021-02-09 17:19 ` Gregory Heytings
2021-02-09 17:59 ` Ulrich Mueller
2021-02-09 18:24 ` Gregory Heytings
2021-02-09 18:19 ` Thibaut Verron
2021-02-09 19:16 ` Gregory Heytings
2021-02-09 19:28 ` Thibaut Verron
2021-02-09 20:15 ` Gregory Heytings
2021-02-09 19:47 ` Stefan Monnier
2021-02-09 22:19 ` Gregory Heytings
2021-02-09 21:34 ` Sean Whitton
[not found] ` <8735y56naf.fsf@posteo.net>
[not found] ` <8ed9b43502ae9a36b057@heytings.org>
2021-02-09 23:18 ` Philip K.
2021-02-10 11:07 ` Gregory Heytings
2021-02-10 23:35 ` Philip K.
2021-02-11 8:45 ` Gregory Heytings
2021-02-11 13:53 ` Philip K.
2021-02-11 15:47 ` Philip K. [this message]
2021-02-11 15:59 ` Gregory Heytings
2021-02-11 16:20 ` Philip K.
2021-02-11 17:48 ` Gregory Heytings
2021-02-11 18:34 ` Philip K.
2021-02-11 21:15 ` Gregory Heytings
2021-02-11 22:48 ` Philip K.
2021-02-12 0:01 ` Gregory Heytings
2021-02-12 10:27 ` Philip K.
2021-02-12 11:59 ` Gregory Heytings
2021-02-12 13:23 ` Philip K.
2021-02-12 13:54 ` Gregory Heytings
2021-02-12 14:09 ` Philip Kaludercic
2021-02-12 16:04 ` Gregory Heytings
2021-02-12 17:25 ` Philip Kaludercic
2021-02-12 17:54 ` Gregory Heytings
2021-02-12 18:16 ` Philip Kaludercic
2021-02-12 21:48 ` Gregory Heytings
2021-02-13 0:37 ` Philip Kaludercic
2021-02-13 8:33 ` Gregory Heytings
2021-02-13 9:09 ` Philip Kaludercic
2021-02-13 13:06 ` Gregory Heytings
2021-02-13 14:28 ` Philip Kaludercic
2021-02-13 15:01 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-13 16:08 ` Philip Kaludercic
2021-02-13 15:02 ` Gregory Heytings
2021-02-13 15:21 ` Jean Louis
2021-02-13 15:28 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-13 15:39 ` Nothing is the list - " Jean Louis
2021-02-13 20:14 ` Philip Kaludercic
2021-02-13 20:58 ` Jean Louis
2021-02-13 21:18 ` Gregory Heytings
2021-02-13 21:32 ` Philip Kaludercic
2021-02-13 21:37 ` PROPOSAL: Repurpose one key (why only one?) " Jean Louis
2021-02-13 23:55 ` Philip Kaludercic
2021-02-14 6:19 ` Jean Louis
2021-02-14 6:33 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-14 8:06 ` Jean Louis
2021-02-14 18:30 ` [External] : " Drew Adams
2021-02-14 19:21 ` Jean Louis
2021-02-14 19:44 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-14 23:30 ` Drew Adams
2021-02-15 0:33 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-15 5:59 ` Jean Louis
2021-02-14 17:59 ` Gregory Heytings
2021-02-14 18:14 ` libraries (was: Re: PROPOSAL: Repurpose one key (why only one?) and reserve it for third-party packages) Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-14 18:23 ` PROPOSAL: Repurpose one key (why only one?) and reserve it for third-party packages Philip Kaludercic
2021-02-14 21:37 ` Gregory Heytings
2021-02-15 0:28 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-15 5:02 ` Robert Thorpe
2021-02-15 11:08 ` Gregory Heytings
2021-02-17 9:07 ` Robert Thorpe
2021-02-20 17:50 ` Gregory Heytings
2021-02-14 18:30 ` [External] : " Drew Adams
2021-02-14 18:50 ` Gregory Heytings
2021-02-14 19:24 ` Jean Louis
2021-02-14 19:41 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-14 23:30 ` [External] : " Drew Adams
2021-02-13 10:05 ` PROPOSAL: Repurpose one key " Jean Louis
2021-02-13 8:24 ` Jean Louis
2021-02-13 12:44 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-13 14:26 ` Jean Louis
2021-02-13 15:09 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-13 15:24 ` Jean Louis
2021-02-13 15:38 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-13 15:45 ` Jean Louis
2021-02-12 4:45 ` Robert Thorpe
2021-02-12 9:58 ` Philip K.
2021-02-11 16:59 ` [External] : " Drew Adams
2021-02-11 16:58 ` Drew Adams
2021-02-11 16:59 ` Leo Butler
-- strict thread matches above, loose matches on Subject: below --
2021-02-08 10:02 Gregory Heytings
2021-02-08 16:41 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-08 22:01 ` Francis Belliveau
2021-02-09 0:05 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-10 22:54 ` Francis Belliveau
2021-02-09 6:31 ` Jean Louis
2021-02-09 9:13 ` Gregory Heytings
2021-02-10 11:17 ` Jean Louis
2021-02-09 17:13 ` [External] : " Drew Adams
2021-02-09 17:49 ` Gregory Heytings
2021-02-09 18:12 ` Drew Adams
2021-02-09 19:23 ` Gregory Heytings
2021-02-09 20:52 ` [External] : " Drew Adams
2021-02-09 21:15 ` Gregory Heytings
2021-02-09 21:47 ` [External] : " Drew Adams
2021-02-10 11:07 ` Gregory Heytings
2021-02-10 9:05 ` Robert Thorpe
2021-02-10 14:42 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-10 14:59 ` Gregory Heytings
2021-02-09 8:13 ` Marcin Borkowski
2021-02-09 9:13 ` Gregory Heytings
2021-02-15 19:01 Gregory Heytings
2021-02-15 19:55 ` Dmitry Gutov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y2fua9ni.fsf@posteo.net \
--to=philipk@posteo.net \
--cc=gregory@heytings.org \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.