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: [PATCH] Option for sorting package-selected-packages Date: Sun, 26 Mar 2023 02:39:21 +0300 Message-ID: <87a600mmdy.fsf@ya.ru> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36743"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Mar 26 00:40:44 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 1pgDV6-0009LF-1L for ged-emacs-devel@m.gmane-mx.org; Sun, 26 Mar 2023 00:40:44 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pgDUF-0003fk-Nl; Sat, 25 Mar 2023 19:39:51 -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 1pgDUC-0003fV-45 for emacs-devel@gnu.org; Sat, 25 Mar 2023 19:39:48 -0400 Original-Received: from forward102c.mail.yandex.net ([2a02:6b8:c03:500:1:45:d181:d102]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pgDU8-0005Fh-Ra for emacs-devel@gnu.org; Sat, 25 Mar 2023 19:39:47 -0400 Original-Received: from mail-nwsmtp-smtp-production-main-85.iva.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-85.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:b9e:0:640:94e:0]) by forward102c.mail.yandex.net (Yandex) with ESMTP id D02FD600D5 for ; Sun, 26 Mar 2023 02:39:38 +0300 (MSK) Original-Received: by mail-nwsmtp-smtp-production-main-85.iva.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id WdOmbbYDS0U0-J3vdxiEf; Sun, 26 Mar 2023 02:39:38 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ya.ru; s=mail; t=1679787578; bh=OOzoO37MMPSfe1mMKObji4WstBeZdvAmUCJMU0KZvhE=; h=Message-ID:Date:Subject:To:From; b=XYWcfpEY3bzhVHBrh8YxcXG5STqkOGW97xL94j7ul8shLetZW7zFtEQqRi3cQBp/0 4MMNDmP80O7hPSX9rq8P266rIUZvAnF31OMS/IQISUzTfgDjGw72MFtjklVGG7UJRc RwpR63ecufPA0wuO7q5i3sEiN+1vIFZvABK5grFs= Authentication-Results: mail-nwsmtp-smtp-production-main-85.iva.yp-c.yandex.net; dkim=pass header.i=@ya.ru Received-SPF: pass client-ip=2a02:6b8:c03:500:1:45:d181:d102; envelope-from=ivan-p-sokolov@ya.ru; helo=forward102c.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, 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:304771 Archived-At: --=-=-= Content-Type: text/plain 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. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-New-option-for-sorting-package-selected-packages.patch Content-Description: [PATCH] New option for sorting package-selected-packages >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.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 --=-=-=--