* [PATCH] Option for sorting package-selected-packages
@ 2023-03-25 23:39 Ivan Sokolov
2023-03-26 10:24 ` Philip Kaludercic
2023-04-02 21:10 ` [PATCH v2] Sort package-selected-packages on save Ivan Sokolov
0 siblings, 2 replies; 5+ messages in thread
From: Ivan Sokolov @ 2023-03-25 23:39 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 199 bytes --]
Nowadays many people keep their configuration under a VCS. I think this
new option might help them get tidier diffs and avoid merge conflicts.
It might make sense to enable this option by default.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: [PATCH] New option for sorting package-selected-packages --]
[-- Type: text/x-patch, Size: 1696 bytes --]
From eb996ddc331e34a1c97331768420b9c6dfd30c15 Mon Sep 17 00:00:00 2001
From: Ivan Sokolov <ivan-p-sokolov@ya.ru>
Date: Fri, 24 Mar 2023 23:27:13 +0300
Subject: [PATCH] New option for sorting package-selected-packages
* lisp/emacs-lisp/package.el (package-sort-selected-packages): New defcustom.
---
lisp/emacs-lisp/package.el | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 0258ed52bee..1e11be4ab3b 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -404,6 +404,13 @@ a sane initial value."
:version "25.1"
:type '(repeat symbol))
+(defcustom package-sort-selected-packages nil
+ "If non-nil interactive functions will sort `package-selected-packages'.
+You can use this variable to get a nicer diffs if you keep your
+`custom-file' under version control system."
+ :version "30.1"
+ :type 'boolean)
+
(defcustom package-native-compile nil
"Non-nil means to natively compile packages as part of their installation.
This controls ahead-of-time compilation of packages when they are
@@ -1974,7 +1981,10 @@ Used to populate `package-selected-packages'."
(defun package--save-selected-packages (&optional value)
"Set and save `package-selected-packages' to VALUE."
(when value
- (setq package-selected-packages value))
+ (setq package-selected-packages
+ (if package-sort-selected-packages
+ (sort value #'string<)
+ value)))
(if after-init-time
(customize-save-variable 'package-selected-packages package-selected-packages)
(add-hook 'after-init-hook #'package--save-selected-packages)))
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Option for sorting package-selected-packages
2023-03-25 23:39 [PATCH] Option for sorting package-selected-packages Ivan Sokolov
@ 2023-03-26 10:24 ` Philip Kaludercic
2023-03-26 12:00 ` Ivan Sokolov
2023-04-02 21:10 ` [PATCH v2] Sort package-selected-packages on save Ivan Sokolov
1 sibling, 1 reply; 5+ messages in thread
From: Philip Kaludercic @ 2023-03-26 10:24 UTC (permalink / raw)
To: Ivan Sokolov; +Cc: emacs-devel
Ivan Sokolov <ivan-p-sokolov@ya.ru> writes:
> Nowadays many people keep their configuration under a VCS. I think this
> new option might help them get tidier diffs and avoid merge conflicts.
>
> It might make sense to enable this option by default.
>
> From eb996ddc331e34a1c97331768420b9c6dfd30c15 Mon Sep 17 00:00:00 2001
> From: Ivan Sokolov <ivan-p-sokolov@ya.ru>
> Date: Fri, 24 Mar 2023 23:27:13 +0300
> Subject: [PATCH] New option for sorting package-selected-packages
>
> * lisp/emacs-lisp/package.el (package-sort-selected-packages): New defcustom.
> ---
> lisp/emacs-lisp/package.el | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
> index 0258ed52bee..1e11be4ab3b 100644
> --- a/lisp/emacs-lisp/package.el
> +++ b/lisp/emacs-lisp/package.el
> @@ -404,6 +404,13 @@ a sane initial value."
> :version "25.1"
> :type '(repeat symbol))
>
> +(defcustom package-sort-selected-packages nil
> + "If non-nil interactive functions will sort `package-selected-packages'.
> +You can use this variable to get a nicer diffs if you keep your
> +`custom-file' under version control system."
> + :version "30.1"
> + :type 'boolean)
>
> (defcustom package-native-compile nil
> "Non-nil means to natively compile packages as part of their installation.
> This controls ahead-of-time compilation of packages when they are
> @@ -1974,7 +1981,10 @@ Used to populate `package-selected-packages'."
> (defun package--save-selected-packages (&optional value)
> "Set and save `package-selected-packages' to VALUE."
> (when value
> - (setq package-selected-packages value))
> + (setq package-selected-packages
> + (if package-sort-selected-packages
> + (sort value #'string<)
> + value)))
Why not just always sort it? Or is there a use-case where keeping the
"arbitrary" order is preferable?
> (if after-init-time
> (customize-save-variable 'package-selected-packages package-selected-packages)
> (add-hook 'after-init-hook #'package--save-selected-packages)))
--
Philip Kaludercic
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Option for sorting package-selected-packages
2023-03-26 10:24 ` Philip Kaludercic
@ 2023-03-26 12:00 ` Ivan Sokolov
0 siblings, 0 replies; 5+ messages in thread
From: Ivan Sokolov @ 2023-03-26 12:00 UTC (permalink / raw)
To: Philip Kaludercic; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 2462 bytes --]
Mind-blowing, I don't know of such use cases.
26 марта 2023 г. 10:24:47 UTC, Philip Kaludercic <philipk@posteo.net> пишет:
>Ivan Sokolov <ivan-p-sokolov@ya.ru> writes:
>
>> Nowadays many people keep their configuration under a VCS. I think this
>> new option might help them get tidier diffs and avoid merge conflicts.
>>
>> It might make sense to enable this option by default.
>>
>> From eb996ddc331e34a1c97331768420b9c6dfd30c15 Mon Sep 17 00:00:00 2001
>> From: Ivan Sokolov <ivan-p-sokolov@ya.ru>
>> Date: Fri, 24 Mar 2023 23:27:13 +0300
>> Subject: [PATCH] New option for sorting package-selected-packages
>>
>> * lisp/emacs-lisp/package.el (package-sort-selected-packages): New defcustom.
>> ---
>> lisp/emacs-lisp/package.el | 12 +++++++++++-
>> 1 file changed, 11 insertions(+), 1 deletion(-)
>>
>> diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
>> index 0258ed52bee..1e11be4ab3b 100644
>> --- a/lisp/emacs-lisp/package.el
>> +++ b/lisp/emacs-lisp/package.el
>> @@ -404,6 +404,13 @@ a sane initial value."
>> :version "25.1"
>> :type '(repeat symbol))
>>
>> +(defcustom package-sort-selected-packages nil
>> + "If non-nil interactive functions will sort `package-selected-packages'.
>> +You can use this variable to get a nicer diffs if you keep your
>> +`custom-file' under version control system."
>> + :version "30.1"
>> + :type 'boolean)
>>
>> (defcustom package-native-compile nil
>> "Non-nil means to natively compile packages as part of their installation.
>> This controls ahead-of-time compilation of packages when they are
>> @@ -1974,7 +1981,10 @@ Used to populate `package-selected-packages'."
>> (defun package--save-selected-packages (&optional value)
>> "Set and save `package-selected-packages' to VALUE."
>> (when value
>> - (setq package-selected-packages value))
>> + (setq package-selected-packages
>> + (if package-sort-selected-packages
>> + (sort value #'string<)
>> + value)))
>
>Why not just always sort it? Or is there a use-case where keeping the
>"arbitrary" order is preferable?
>
>> (if after-init-time
>> (customize-save-variable 'package-selected-packages package-selected-packages)
>> (add-hook 'after-init-hook #'package--save-selected-packages)))
>
>--
>Philip Kaludercic
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
[-- Attachment #2: Type: text/html, Size: 2999 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] Sort package-selected-packages on save
2023-03-25 23:39 [PATCH] Option for sorting package-selected-packages Ivan Sokolov
2023-03-26 10:24 ` Philip Kaludercic
@ 2023-04-02 21:10 ` Ivan Sokolov
2023-10-01 12:27 ` Stefan Kangas
1 sibling, 1 reply; 5+ messages in thread
From: Ivan Sokolov @ 2023-04-02 21:10 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 74 bytes --]
As Philip suggested I removed the option and make sorting unconditional.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: [PATCH] Sort package-selected-packages on save --]
[-- Type: text/x-patch, Size: 963 bytes --]
From 071abcf1510489e5fa109384c6004008a2c0208f Mon Sep 17 00:00:00 2001
From: Ivan Sokolov <ivan-p-sokolov@ya.ru>
Date: Fri, 24 Mar 2023 23:27:13 +0300
Subject: [PATCH] Sort package-selected-packages on save
---
lisp/emacs-lisp/package.el | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 0258ed52bee..bf423143059 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -1974,7 +1974,7 @@ Used to populate `package-selected-packages'."
(defun package--save-selected-packages (&optional value)
"Set and save `package-selected-packages' to VALUE."
(when value
- (setq package-selected-packages value))
+ (setq package-selected-packages (sort value #'string<)))
(if after-init-time
(customize-save-variable 'package-selected-packages package-selected-packages)
(add-hook 'after-init-hook #'package--save-selected-packages)))
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-10-01 12:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-25 23:39 [PATCH] Option for sorting package-selected-packages Ivan Sokolov
2023-03-26 10:24 ` Philip Kaludercic
2023-03-26 12:00 ` Ivan Sokolov
2023-04-02 21:10 ` [PATCH v2] Sort package-selected-packages on save Ivan Sokolov
2023-10-01 12:27 ` Stefan Kangas
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.