From patchwork Tue Jan 16 17:10:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tomas Volf <~@wolfsden.cz> X-Patchwork-Id: 58939 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 7F54927BBEA; Tue, 16 Jan 2024 17:12:12 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 0BF2B27BBE2 for ; Tue, 16 Jan 2024 17:12:11 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rPmyp-0003JW-Ke; Tue, 16 Jan 2024 12:12:03 -0500 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 1rPmyo-0003Ip-6Y for guix-patches@gnu.org; Tue, 16 Jan 2024 12:12:02 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rPmyn-0002VJ-UI for guix-patches@gnu.org; Tue, 16 Jan 2024 12:12:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rPmyo-0006vs-CE for guix-patches@gnu.org; Tue, 16 Jan 2024 12:12:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68354] [PATCH v2 1/2] etc: snippets: Add skeletons for commit messages. References: In-Reply-To: Resent-From: Tomas Volf <~@wolfsden.cz> Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 16 Jan 2024 17:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68354 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 68354@debbugs.gnu.org Cc: Tomas Volf <~@wolfsden.cz> Received: via spool by 68354-submit@debbugs.gnu.org id=B68354.170542507826505 (code B ref 68354); Tue, 16 Jan 2024 17:12:02 +0000 Received: (at 68354) by debbugs.gnu.org; 16 Jan 2024 17:11:18 +0000 Received: from localhost ([127.0.0.1]:49630 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rPmy5-0006tL-PX for submit@debbugs.gnu.org; Tue, 16 Jan 2024 12:11:18 -0500 Received: from wolfsden.cz ([37.205.8.62]:34400) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <~@wolfsden.cz>) id 1rPmy2-0006tB-OQ for 68354@debbugs.gnu.org; Tue, 16 Jan 2024 12:11:16 -0500 Received: by wolfsden.cz (Postfix, from userid 104) id E64F6256FB2; Tue, 16 Jan 2024 17:11:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1705425071; bh=swEQJhLn/T/OuEPQd+vvLcyjo0JSHOWLXCLandLM0Jw=; h=From:To:Cc:Subject:Date; b=CthXxYBg7g/f+gHRhuL/lR9d3HzZHjVh9LYa4gjfbNsjknRNU8/hKzAFwkezGwZB9 j/OP3+iTyc51bU/oTLFVLsKMnK0+OZYd/vMjhS0yxoWrqKSRgzsYmkn+XW863PW/9u YLfzvU+2a35QUTixeYtnK4DTVPY3Z7bfXrNedA5r03jfe0DhWlQgZl1eU2YsKKiOHH /N+oZ4cUdVtaAASJ9Bd6kAEnEdri/crAXc8VMCaGGWQ7jLGLqFjL6gQz46zcmBwzeH Sv6mgjaIaePRETpK4s2B0Gj4ThrtWEwrPQLjhyeecp9JdI2LFt35ubMb3vdOFof0X2 3/F5XxpDFkB6aOc0Gf+Guu/PaIuhfZf4+tQ0vfxMiCvmRva2YlsKCGHAUzKvBLpOsO BDW7/bh5fHNylfhMR5MLj0YZyKTTX3JGNQhtbLOZJbY9TZYv3Y09Syh5lVDHVsdlnX xUfZeGNda9qqV2+cTmTSpaHiunWndXbRhP7RgP2iPy+c1HTqbeH/kl5cg4My7bO2uw N4UGylm+j++ftwWXH3y2zUsokRjgTspi/KbWd5BljhxokB3JODeyXZpNa2aSi/vhM1 eWkHg+xCX5Em5vZaRVsFVaB1DrgchRfS4TI/9iHW681fRiLOKdN+f9rdWquwyuoou6 mXWj7sDuYbYjNA2vRqtcOw8w= Received: from localhost (unknown [81.17.16.72]) by wolfsden.cz (Postfix) with ESMTPSA id 3B8B0256330; Tue, 16 Jan 2024 17:11:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1705425071; bh=swEQJhLn/T/OuEPQd+vvLcyjo0JSHOWLXCLandLM0Jw=; h=From:To:Cc:Subject:Date; b=CthXxYBg7g/f+gHRhuL/lR9d3HzZHjVh9LYa4gjfbNsjknRNU8/hKzAFwkezGwZB9 j/OP3+iTyc51bU/oTLFVLsKMnK0+OZYd/vMjhS0yxoWrqKSRgzsYmkn+XW863PW/9u YLfzvU+2a35QUTixeYtnK4DTVPY3Z7bfXrNedA5r03jfe0DhWlQgZl1eU2YsKKiOHH /N+oZ4cUdVtaAASJ9Bd6kAEnEdri/crAXc8VMCaGGWQ7jLGLqFjL6gQz46zcmBwzeH Sv6mgjaIaePRETpK4s2B0Gj4ThrtWEwrPQLjhyeecp9JdI2LFt35ubMb3vdOFof0X2 3/F5XxpDFkB6aOc0Gf+Guu/PaIuhfZf4+tQ0vfxMiCvmRva2YlsKCGHAUzKvBLpOsO BDW7/bh5fHNylfhMR5MLj0YZyKTTX3JGNQhtbLOZJbY9TZYv3Y09Syh5lVDHVsdlnX xUfZeGNda9qqV2+cTmTSpaHiunWndXbRhP7RgP2iPy+c1HTqbeH/kl5cg4My7bO2uw N4UGylm+j++ftwWXH3y2zUsokRjgTspi/KbWd5BljhxokB3JODeyXZpNa2aSi/vhM1 eWkHg+xCX5Em5vZaRVsFVaB1DrgchRfS4TI/9iHW681fRiLOKdN+f9rdWquwyuoou6 mXWj7sDuYbYjNA2vRqtcOw8w= From: Tomas Volf <~@wolfsden.cz> Date: Tue, 16 Jan 2024 18:10:12 +0100 Message-ID: <12887de50dc01339faf03aa66d298f1e16ec7b18.1705425013.git.~@wolfsden.cz> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches Some people use just plain old skeleton system, which comes with Emacs. This commit adds skeletons for generating commit messages for the common operations (updating packages, ...). * etc/snippets/skeleton/commit-message.el: New file. * doc/contributing.texi (The Perfect Setup): Document it. Change-Id: Ic37b6455a337fc431ad2b049d5b7261da97e5a06 --- doc/contributing.texi | 20 ++++ etc/snippets/skeleton/commit-message.el | 143 ++++++++++++++++++++++++ 2 files changed, 163 insertions(+) create mode 100644 etc/snippets/skeleton/commit-message.el base-commit: b212e6934643e085f168a5364cb593f61aa616ba diff --git a/doc/contributing.texi b/doc/contributing.texi index 5707ff5cde..1311098dfc 100644 --- a/doc/contributing.texi +++ b/doc/contributing.texi @@ -360,6 +360,26 @@ The Perfect Setup @code{origin} snippet in turn may insert other trigger strings ending on @code{...}, which also can be expanded further. +@cindex skeleton +If you use built-in skeleton system (@xref{Top,,,autotype}), you can +load the snippets from the @file{etc/snippets/skeleton} directory. + +Skeletons for editing commit messages are provided in +@file{etc/snippets/skeleton/commit-message.el}. + +@cindex @code{M-x guix-package-add} +@cindex @code{M-x guix-package-remove} +@cindex @code{M-x guix-package-update} +@cindex @code{M-x guix-package-rename} +@cindex @code{M-x guix-package-move} +Once you load the file, the following functions are provided: +@code{guix-package-add}, @code{guix-package-remove}, +@code{guix-package-update}, @code{guix-package-rename} and +@code{guix-package-move}. When editing a commit message, invoke the +appropriate one using @code{M-x} to insert a message for the change. + +The commit message skeletons depend on @url{https://magit.vc/, Magit}. + @cindex insert or update copyright @cindex @code{M-x guix-copyright} @cindex @code{M-x copyright-update} diff --git a/etc/snippets/skeleton/commit-message.el b/etc/snippets/skeleton/commit-message.el new file mode 100644 index 0000000000..698079a004 --- /dev/null +++ b/etc/snippets/skeleton/commit-message.el @@ -0,0 +1,143 @@ +;;; commit-message.el --- skeletons for Guix's commit messages -*- lexical-binding: t; -*- +;;; Copyright © 2024 Tomas Volf <~@wolfsden.cz> + +;; Author: Tomas Volf <~@wolfsden.cz> +;; Keywords: vc, convenience + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Code: + +(defun guix--package-name-from-magit-diff (regex) + (with-temp-buffer + (magit-git-wash #'magit-diff-wash-diffs "diff" "--cached") + (goto-char (point-min)) + (when (re-search-forward regex + nil 'noerror) + (match-string-no-properties 1)))) + +(defun guix--first-file-from-magit-diff () + (car (magit-staged-files))) + +(define-skeleton guix-package-add + "Insert a commit message for adding a package." + nil + '(setq v1 (or (guix--package-name-from-magit-diff + (rx "+(define-public " (group (+ (not (syntax whitespace)))))) + (skeleton-read "Package: "))) + '(setq v2 (or (guix--first-file-from-magit-diff) + (skeleton-read "File: "))) + ;; v1 - package, v2 - file + "gnu: Add " v1 "." \n + _ \n + "* " v2 " (" v1 "): New variable." \n) + +(define-skeleton guix-package-remove + "Insert a commit message for removing a package." + nil + '(setq v1 (or (guix--package-name-from-magit-diff + (rx "-(define-public " (group (+ (not (syntax whitespace)))))) + (skeleton-read "Package: "))) + '(setq v2 (or (guix--first-file-from-magit-diff) + (skeleton-read "File: "))) + ;; v1 - package, v2 - file + "gnu: Remove " v1 "." \n + _ \n + "* " v2 " (" v1 "): Delete variable." \n) + +(define-skeleton guix-package-update + "Insert a commit message for updating a package." + (or (guix--package-name-from-magit-diff + (rx line-start (* (syntax whitespace)) + "(define-public " (group (+ (not (syntax whitespace)))))) + (skeleton-read "Package: ")) + '(setq v1 (or (with-temp-buffer + (magit-git-wash #'magit-diff-wash-diffs + "diff" "--cached") + (goto-char (point-min)) + (search-forward "name" nil 'noerror) + (search-forward "+" nil 'noerror) ; first change + (when (and (search-forward "version " nil 'noerror) + (looking-at-p "\"")) + (let ((end (save-excursion (search-forward "\")" + nil 'noerror)))) + (when end + (forward-char) + (buffer-substring-no-properties (point) (- end 2)))))) + (skeleton-read "New version: "))) + '(setq v2 (or (guix--first-file-from-magit-diff) + (skeleton-read "File: "))) + ;; str - package, v1 - new version, v2 - file + "gnu: " str ": Update to " v1 "." \n + _ \n + "* " v2 " (" str "): Update to " v1 "." \n) + +(define-skeleton guix-package-rename + "Insert a commit message for renaming a package." + (or (guix--first-file-from-magit-diff) + (skeleton-read "File: ")) + '(setq v1 (or (guix--package-name-from-magit-diff + (rx "-(define-public " (group (+ (not (syntax whitespace)))))) + (skeleton-read "Old package: "))) + '(setq v2 (or (guix--package-name-from-magit-diff + (rx "+(define-public " (group (+ (not (syntax whitespace)))))) + (skeleton-read "New package: "))) + ;; str - file, v1 - old package, v2 - new package + "gnu: " v1 ": Rename package to " v2 "." \n + _ \n + @ + "* " str " (" v1 "): Define in terms of `deprecated-package'." \n + "(" v2 "): New variable, formerly known as `crawl'." \n + @ + '(fill-region (cadr skeleton-positions) (car skeleton-positions))) + +(define-skeleton guix-package-move + "Insert a commit message for moving a package." + (or (guix--package-name-from-magit-diff + (rx "-(define-public " (group (+ (not (syntax whitespace)))))) + (skeleton-read "Package: ")) + '(setq v1 (or (with-temp-buffer + (magit-git-wash #'magit-diff-wash-diffs + "diff" "--cached" "--no-prefix") + (goto-char (point-min)) + (when (and + (re-search-forward "\\-(define-public \\(\\S-+\\)" + nil 'noerror) + (re-search-backward "modified[ ]*\\(\\S-+\\)" + nil 'noerror)) + (match-string-no-properties 1))) + (skeleton-read "Old file: "))) + '(setq v2 (or (with-temp-buffer + (magit-git-wash #'magit-diff-wash-diffs + "diff" "--cached" "--no-prefix") + (goto-char (point-min)) + (when (and + (re-search-forward "\\+(define-public \\(\\S-+\\)" + nil 'noerror) + (re-search-backward "modified[ ]*\\(\\S-+\\)" + nil 'noerror)) + (match-string-no-properties 1))) + (skeleton-read "New file: "))) + ;; str - package, v1 - old file, v2 - new file + "gnu: " str ": Move to (" + (string-replace ".scm" "" (string-replace "/" " " v2)) + ")." \n + _ \n + @ + "* " v1 " (" str "): Move from here..." \n + "* " v2 " (" str "): ...to here." \n + @ + '(fill-region (cadr skeleton-positions) (car skeleton-positions))) + +;;; commit-message.el ends here