[Top][All Lists]

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

Re: [PATCH] Option for sorting package-selected-packages

From: Ivan Sokolov
Subject: Re: [PATCH] Option for sorting package-selected-packages
Date: Sun, 26 Mar 2023 12:00:39 +0000

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)))

Sent from my Android device with K-9 Mail. Please excuse my brevity.

reply via email to

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