From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ivan Sokolov Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Option for sorting package-selected-packages Date: Sun, 26 Mar 2023 12:00:39 +0000 Message-ID: <4BB1F1A5-B85E-4D0D-BEBE-FBE768C4458A@ya.ru> References: <87a600mmdy.fsf@ya.ru> <87mt3z3j4g.fsf@posteo.net> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=----42G2RMN9AUZ7MI569SX0I9T44ISLQO Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19831"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Philip Kaludercic Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Mar 26 14:02:29 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pgP4u-0004nn-VQ for ged-emacs-devel@m.gmane-mx.org; Sun, 26 Mar 2023 14:02:29 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pgP3Q-0003ix-Kf; Sun, 26 Mar 2023 08:00:56 -0400 Original-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 1pgP3N-0003hb-Vm for emacs-devel@gnu.org; Sun, 26 Mar 2023 08:00:54 -0400 Original-Received: from forward502b.mail.yandex.net ([178.154.239.146]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pgP3L-000128-JO for emacs-devel@gnu.org; Sun, 26 Mar 2023 08:00:53 -0400 Original-Received: from mail-nwsmtp-smtp-production-main-60.sas.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-60.sas.yp-c.yandex.net [IPv6:2a02:6b8:c08:8212:0:640:cefe:0]) by forward502b.mail.yandex.net (Yandex) with ESMTP id 218CD5EA35; Sun, 26 Mar 2023 15:00:47 +0300 (MSK) Original-Received: by mail-nwsmtp-smtp-production-main-60.sas.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id i0EXqhgDTGk0-PEU0xXzW; Sun, 26 Mar 2023 15:00:46 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ya.ru; s=mail; t=1679832046; bh=oMQrrWgnOnWS5Epoc18nlgBKU+tWxWVZ0gcNFPBV8FA=; h=Message-ID:Subject:References:To:From:In-Reply-To:CC:Date; b=UArcHofg2wIHaH0mg3Iuf6pdvi2PDARAdd0BPmTkdlaDD0pr2Qt9AOipwpQ/0o14N JlLnLPDKalNi00j39cN7PhpXWJcG9Q5zAPffLCnpQ8OwhmUT0XzyVeUDXxF1brqflC F+TlrUdxCVSgUKZ23ebEKM0+CvFwCaXx8vtAIiz8= Authentication-Results: mail-nwsmtp-smtp-production-main-60.sas.yp-c.yandex.net; dkim=pass header.i=@ya.ru In-Reply-To: <87mt3z3j4g.fsf@posteo.net> Received-SPF: pass client-ip=178.154.239.146; envelope-from=ivan-p-sokolov@ya.ru; helo=forward502b.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_FROM=0.001, HTML_MESSAGE=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-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:304774 Archived-At: ------42G2RMN9AUZ7MI569SX0I9T44ISLQO Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mind-blowing, I don't know of such use cases=2E 26 =D0=BC=D0=B0=D1=80=D1=82=D0=B0 2023 =D0=B3=2E 10:24:47 UTC, Philip Kalu= dercic =D0=BF=D0=B8=D1=88=D0=B5=D1=82: >Ivan Sokolov writes: > >> Nowadays many people keep their configuration under a VCS=2E I think th= is >> new option might help them get tidier diffs and avoid merge conflicts= =2E >> >> It might make sense to enable this option by default=2E >> >> From eb996ddc331e34a1c97331768420b9c6dfd30c15 Mon Sep 17 00:00:00 2001 >> From: Ivan Sokolov >> Date: Fri, 24 Mar 2023 23:27:13 +0300 >> Subject: [PATCH] New option for sorting package-selected-packages >> >> * lisp/emacs-lisp/package=2Eel (package-sort-selected-packages): New de= fcustom=2E >> --- >> lisp/emacs-lisp/package=2Eel | 12 +++++++++++- >> 1 file changed, 11 insertions(+), 1 deletion(-) >> >> diff --git a/lisp/emacs-lisp/package=2Eel b/lisp/emacs-lisp/package=2Ee= l >> index 0258ed52bee=2E=2E1e11be4ab3b 100644 >> --- a/lisp/emacs-lisp/package=2Eel >> +++ b/lisp/emacs-lisp/package=2Eel >> @@ -404,6 +404,13 @@ a sane initial value=2E" >> :version "25=2E1" >> :type '(repeat symbol)) >> =20 >> +(defcustom package-sort-selected-packages nil >> + "If non-nil interactive functions will sort `package-selected-packag= es'=2E >> +You can use this variable to get a nicer diffs if you keep your >> +`custom-file' under version control system=2E" >> + :version "30=2E1" >> + :type 'boolean) >> >> (defcustom package-native-compile nil >> "Non-nil means to natively compile packages as part of their install= ation=2E >> This controls ahead-of-time compilation of packages when they are >> @@ -1974,7 +1981,10 @@ Used to populate `package-selected-packages'=2E" >> (defun package--save-selected-packages (&optional value) >> "Set and save `package-selected-packages' to VALUE=2E" >> (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-sele= cted-packages) >> (add-hook 'after-init-hook #'package--save-selected-packages))) > >--=20 >Philip Kaludercic --=20 Sent from my Android device with K-9 Mail=2E Please excuse my brevity=2E ------42G2RMN9AUZ7MI569SX0I9T44ISLQO Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mind-blowing, I don't know of such use cases=2E
26 =D0=BC=D0=B0=D1=80=D1=82=D0=B0 2023 =D0= =B3=2E 10:24:47 UTC, Philip Kaludercic <philipk@posteo=2Enet> =D0=BF= =D0=B8=D1=88=D0=B5=D1=82:
Ivan Sokolov <ivan-p-sokolov@ya=2Eru=
> writes:

Nowad= ays many people keep their configuration under a VCS=2E I think this
ne= w option might help them get tidier diffs and avoid merge conflicts=2E
<= br> It might make sense to enable this option by default=2E

From eb= 996ddc331e34a1c97331768420b9c6dfd30c15 Mon Sep 17 00:00:00 2001
From: I= van Sokolov <ivan-p-sokolov@ya=2Eru>
Date: Fri, 24 Mar 2023 23:27= :13 +0300
Subject: [PATCH] New option for sorting package-selected-pack= ages

* lisp/emacs-lisp/package=2Eel (package-sort-selected-packages= ): New defcustom=2E
lisp/emacs-lisp/package=2Eel | 12 +++++++++++-
= 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lisp= /emacs-lisp/package=2Eel b/lisp/emacs-lisp/package=2Eel
index 0258ed52b= ee=2E=2E1e11be4ab3b 100644
--- a/lisp/emacs-lisp/package=2Eel
+++ b= /lisp/emacs-lisp/package=2Eel
@@ -404,6 +404,13 @@ a sane initial value= =2E"
:version "25=2E1"
:type '(repeat symbol))

+(de= fcustom package-sort-selected-packages nil
+ "If non-nil interactive f= unctions will sort `package-selected-packages'=2E
+You can use this var= iable to get a nicer diffs if you keep your
+`custom-file' under versio= n control system=2E"
+ :version "30=2E1"
+ :type 'boolean)
(defcustom package-native-compile nil
"Non-nil means to natively = compile packages as part of their installation=2E
This controls ahead-= of-time compilation of packages when they are
@@ -1974,7 +1981,10 @@ Us= ed to populate `package-selected-packages'=2E"
(defun package--save-se= lected-packages (&optional value)
"Set and save `package-selecte= d-packages' to VALUE=2E"
(when value
- (setq package-selected= -packages value))
+ (setq package-selected-packages
+ (= if package-sort-selected-packages
+ (sort value #'string&l= t;)
+ value)))

Why not just always sort = it? Or is there a use-case where keeping the
"arbitrary" order is prefe= rable?

(if after-in= it-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=2E Please e= xcuse my brevity=2E
------42G2RMN9AUZ7MI569SX0I9T44ISLQO--