* [bug#68354] [PATCH 1/2] etc: snippets: Add skeletons for commit messages.
2024-01-09 22:46 [bug#68354] [PATCH 0/2] Add snippets based on skeleton system Tomas Volf
@ 2024-01-09 22:47 ` Tomas Volf
2024-01-09 22:47 ` [bug#68354] [PATCH 2/2] etc: snippets: Add skeletons for scheme-mode Tomas Volf
2024-01-16 17:10 ` [bug#68354] [PATCH v2 1/2] etc: snippets: Add skeletons for commit messages Tomas Volf
2 siblings, 0 replies; 5+ messages in thread
From: Tomas Volf @ 2024-01-09 22:47 UTC (permalink / raw)
To: 68354; +Cc: Tomas Volf
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
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 <https://www.gnu.org/licenses/>.
+
+;;; 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
--
2.41.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [bug#68354] [PATCH 2/2] etc: snippets: Add skeletons for scheme-mode.
2024-01-09 22:46 [bug#68354] [PATCH 0/2] Add snippets based on skeleton system Tomas Volf
2024-01-09 22:47 ` [bug#68354] [PATCH 1/2] etc: snippets: Add skeletons for commit messages Tomas Volf
@ 2024-01-09 22:47 ` Tomas Volf
2024-01-16 17:10 ` [bug#68354] [PATCH v2 1/2] etc: snippets: Add skeletons for commit messages Tomas Volf
2 siblings, 0 replies; 5+ messages in thread
From: Tomas Volf @ 2024-01-09 22:47 UTC (permalink / raw)
To: 68354; +Cc: Tomas Volf
Some people use just plain old skeleton system, which comes with Emacs. This
commit adds skeletons for generating package definition and some other common
parts.
* etc/snippets/skeleton/scheme.el: New file.
* doc/contributing.texi (The Perfect Setup): Document it.
Change-Id: Ided31c06266b0d3c70ae1e050ae8694fd5e47751
---
doc/contributing.texi | 22 ++++++
etc/snippets/skeleton/scheme.el | 117 ++++++++++++++++++++++++++++++++
2 files changed, 139 insertions(+)
create mode 100644 etc/snippets/skeleton/scheme.el
diff --git a/doc/contributing.texi b/doc/contributing.texi
index 1311098dfc..b5ee046c0a 100644
--- a/doc/contributing.texi
+++ b/doc/contributing.texi
@@ -380,6 +380,28 @@ The Perfect Setup
The commit message skeletons depend on @url{https://magit.vc/, Magit}.
+Additional skeletons for editing the package definitions are provided in
+@file{etc/snippets/skeleton/scheme.el}.
+
+@cindex @code{M-x guix-insert-package}
+@cindex @code{M-x guix-insert-origin}
+@cindex @code{M-x guix-insert-git-reference}
+@cindex @code{M-x guix-insert-hg-reference}
+@cindex @code{M-x guix-insert-svn-reference}
+@cindex @code{M-x guix-insert-bzr-reference}
+@cindex @code{M-x guix-insert-cvs-reference}
+@cindex @code{M-x guix-insert-:phases}
+Once you load the file, the following functions are provided:
+@code{guix-insert-package}, @code{guix-insert-origin},
+@code{guix-insert-git-reference}, @code{guix-insert-hg-reference},
+@code{guix-insert-svn-reference}, @code{guix-insert-bzr-reference},
+@code{guix-insert-cvs-reference} and @code{guix-insert-:phases}. They
+do what you would expect based on the name, inserting the implied
+snippet while asking for data to fill in. @code{guix-insert-:phases}
+inserts commonly used snippet to edit phases for the package.
+
+The scheme skeletons might depend on paredit for correct indentation.
+
@cindex insert or update copyright
@cindex @code{M-x guix-copyright}
@cindex @code{M-x copyright-update}
diff --git a/etc/snippets/skeleton/scheme.el b/etc/snippets/skeleton/scheme.el
new file mode 100644
index 0000000000..6114b2ffbf
--- /dev/null
+++ b/etc/snippets/skeleton/scheme.el
@@ -0,0 +1,117 @@
+;;; scheme.el --- skeletons for scheme-mode -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2024 Tomas Volf
+
+;; Author: Tomas Volf <~@wolfsden.cz>
+;; Keywords: 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 <https://www.gnu.org/licenses/>.
+
+;;; Code:
+
+(define-skeleton guix-insert-package
+ "Insert a Guix package definition."
+ "Name: "
+ "(define-public " str
+ \n"(package"
+ \n "(name \"" str "\")"
+ \n "(version \"" (skeleton-read "Version: ") "\")"
+ \n "(source " _ ")"
+ \n "(build-system " (skeleton-read "Build system: " "gnu") "-build-system)"
+ \n "(home-page \"" (skeleton-read "Homepage: ") "\")"
+ \n "(synopsis " (format "%S" (skeleton-read "Synopsis: ")) ")"
+ \n "(description " (format "%S" (skeleton-read "Description: ")) ")"
+ \n "(license license:" (skeleton-read "License: " "unknown") ")))"
+ \n)
+
+(define-skeleton guix-insert-origin
+ "Insert a Guix origin definition."
+ nil
+ '(setq v1 (skeleton-read "Method: " "url"))
+ '(setq v1 (if (string-search "-fetch" v1)
+ v1
+ (concat v1 "-fetch")))
+ "(origin"
+ \n"(method " v1 ")"
+ \n"(uri " (let ((skeleton-end-newline nil))
+ (pcase v1
+ ((or "git-fetch" "git-fetch/lfs")
+ (guix-insert-git-reference))
+ ("hg-fetch"
+ (guix-insert-hg-reference))
+ ("svn-fetch"
+ (guix-insert-svn-reference))
+ ("bzr-fetch"
+ (guix-insert-bzr-reference))
+ ("cvs-fetch"
+ (guix-insert-cvs-reference))
+ ("url-fetch"
+ (insert (format "%S" (skeleton-read "URI: ")))))
+ nil)
+ ")"
+ \n (pcase v1
+ ((or "git-fetch" "git-fetch/lfs")
+ "(file-name (git-file-name name version))")
+ ("hg-fetch"
+ "(file-name (hg-file-name name version))")
+ ((or "svn-fetch" "bzr-fetch" "cvs-fetch")
+ "(file-name (string-append name \"-\" version \"-checkout\"))"))
+ & \n"(sha256"
+ \n "(base32 "
+ ;; Hash of an empty directory
+ \n (format "%S" "0sjjj9z1dhilhpc8pq4154czrb79z9cm044jvn75kxcjv6v5l2m5") ")))")
+
+(define-skeleton guix-insert-git-reference
+ "Insert a Guix git-reference definition."
+ nil
+ "(git-reference"
+ \n"(url \"" (skeleton-read "URL: ") "\")"
+ \n"(commit \"" (skeleton-read "Commit / Tag: ") "\"))")
+
+(define-skeleton guix-insert-hg-reference
+ "Insert a Guix hg-reference definition."
+ nil
+ "(hg-reference"
+ \n"(url \"" (skeleton-read "URL: ") "\")"
+ \n"(changeset \"" (skeleton-read "Changeset: ") "\"))")
+
+(define-skeleton guix-insert-svn-reference
+ "Insert a Guix svn-reference definition."
+ nil
+ "(svn-reference"
+ \n"(url \"" (skeleton-read "URL: ") "\")"
+ \n"(revision \"" (skeleton-read "Revision: ") "\"))")
+
+(define-skeleton guix-insert-bzr-reference
+ "Insert a Guix bzr-reference definition."
+ nil
+ "(bzr-reference"
+ \n"(url \"" (skeleton-read "URL: ") "\")"
+ \n"(revision \"" (skeleton-read "Revision: ") "\"))")
+
+(define-skeleton guix-insert-cvs-reference
+ "Insert a Guix cvs-reference definition."
+ nil
+ "(cvs-reference"
+ \n"(root-directory \"" (skeleton-read "Root directory: ") "\")"
+ \n"(module \"" (skeleton-read "Module: ") "\")"
+ \n"(revision \"" (skeleton-read "Revision: ") "\"))")
+
+(define-skeleton guix-insert-:phases
+ "Insert a Guix #:phases snippet."
+ nil
+ "#:phases " \n
+ "(modify-phases %standard-phases" \n
+ _ ")")
+;;; scheme.el ends here
--
2.41.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [bug#68354] [PATCH v2 1/2] etc: snippets: Add skeletons for commit messages.
2024-01-09 22:46 [bug#68354] [PATCH 0/2] Add snippets based on skeleton system Tomas Volf
2024-01-09 22:47 ` [bug#68354] [PATCH 1/2] etc: snippets: Add skeletons for commit messages Tomas Volf
2024-01-09 22:47 ` [bug#68354] [PATCH 2/2] etc: snippets: Add skeletons for scheme-mode Tomas Volf
@ 2024-01-16 17:10 ` Tomas Volf
2024-01-16 17:10 ` [bug#68354] [PATCH v2 2/2] etc: snippets: Add skeletons for scheme-mode Tomas Volf
2 siblings, 1 reply; 5+ messages in thread
From: Tomas Volf @ 2024-01-16 17:10 UTC (permalink / raw)
To: 68354; +Cc: Tomas Volf
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
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 <https://www.gnu.org/licenses/>.
+
+;;; 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
base-commit: b212e6934643e085f168a5364cb593f61aa616ba
--
2.41.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [bug#68354] [PATCH v2 2/2] etc: snippets: Add skeletons for scheme-mode.
2024-01-16 17:10 ` [bug#68354] [PATCH v2 1/2] etc: snippets: Add skeletons for commit messages Tomas Volf
@ 2024-01-16 17:10 ` Tomas Volf
0 siblings, 0 replies; 5+ messages in thread
From: Tomas Volf @ 2024-01-16 17:10 UTC (permalink / raw)
To: 68354; +Cc: Tomas Volf
Some people use just plain old skeleton system, which comes with Emacs. This
commit adds skeletons for generating package definition and some other common
parts.
* etc/snippets/skeleton/scheme.el: New file.
* doc/contributing.texi (The Perfect Setup): Document it.
Change-Id: Ided31c06266b0d3c70ae1e050ae8694fd5e47751
---
v2:
* Fix whitespace in the guix-insert-origin.
doc/contributing.texi | 22 ++++++
etc/snippets/skeleton/scheme.el | 117 ++++++++++++++++++++++++++++++++
2 files changed, 139 insertions(+)
create mode 100644 etc/snippets/skeleton/scheme.el
diff --git a/doc/contributing.texi b/doc/contributing.texi
index 1311098dfc..b5ee046c0a 100644
--- a/doc/contributing.texi
+++ b/doc/contributing.texi
@@ -380,6 +380,28 @@ The Perfect Setup
The commit message skeletons depend on @url{https://magit.vc/, Magit}.
+Additional skeletons for editing the package definitions are provided in
+@file{etc/snippets/skeleton/scheme.el}.
+
+@cindex @code{M-x guix-insert-package}
+@cindex @code{M-x guix-insert-origin}
+@cindex @code{M-x guix-insert-git-reference}
+@cindex @code{M-x guix-insert-hg-reference}
+@cindex @code{M-x guix-insert-svn-reference}
+@cindex @code{M-x guix-insert-bzr-reference}
+@cindex @code{M-x guix-insert-cvs-reference}
+@cindex @code{M-x guix-insert-:phases}
+Once you load the file, the following functions are provided:
+@code{guix-insert-package}, @code{guix-insert-origin},
+@code{guix-insert-git-reference}, @code{guix-insert-hg-reference},
+@code{guix-insert-svn-reference}, @code{guix-insert-bzr-reference},
+@code{guix-insert-cvs-reference} and @code{guix-insert-:phases}. They
+do what you would expect based on the name, inserting the implied
+snippet while asking for data to fill in. @code{guix-insert-:phases}
+inserts commonly used snippet to edit phases for the package.
+
+The scheme skeletons might depend on paredit for correct indentation.
+
@cindex insert or update copyright
@cindex @code{M-x guix-copyright}
@cindex @code{M-x copyright-update}
diff --git a/etc/snippets/skeleton/scheme.el b/etc/snippets/skeleton/scheme.el
new file mode 100644
index 0000000000..4e6ddad0dc
--- /dev/null
+++ b/etc/snippets/skeleton/scheme.el
@@ -0,0 +1,117 @@
+;;; scheme.el --- skeletons for scheme-mode -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2024 Tomas Volf
+
+;; Author: Tomas Volf <~@wolfsden.cz>
+;; Keywords: 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 <https://www.gnu.org/licenses/>.
+
+;;; Code:
+
+(define-skeleton guix-insert-package
+ "Insert a Guix package definition."
+ "Name: "
+ "(define-public " str
+ \n"(package"
+ \n "(name \"" str "\")"
+ \n "(version \"" (skeleton-read "Version: ") "\")"
+ \n "(source " _ ")"
+ \n "(build-system " (skeleton-read "Build system: " "gnu") "-build-system)"
+ \n "(home-page \"" (skeleton-read "Homepage: ") "\")"
+ \n "(synopsis " (format "%S" (skeleton-read "Synopsis: ")) ")"
+ \n "(description " (format "%S" (skeleton-read "Description: ")) ")"
+ \n "(license license:" (skeleton-read "License: " "unknown") ")))"
+ \n)
+
+(define-skeleton guix-insert-origin
+ "Insert a Guix origin definition."
+ nil
+ '(setq v1 (skeleton-read "Method: " "url"))
+ '(setq v1 (if (string-search "-fetch" v1)
+ v1
+ (concat v1 "-fetch")))
+ "(origin"
+ \n"(method " v1 ")"
+ \n"(uri " (let ((skeleton-end-newline nil))
+ (pcase v1
+ ((or "git-fetch" "git-fetch/lfs")
+ (guix-insert-git-reference))
+ ("hg-fetch"
+ (guix-insert-hg-reference))
+ ("svn-fetch"
+ (guix-insert-svn-reference))
+ ("bzr-fetch"
+ (guix-insert-bzr-reference))
+ ("cvs-fetch"
+ (guix-insert-cvs-reference))
+ ("url-fetch"
+ (insert (format "%S" (skeleton-read "URI: ")))))
+ nil)
+ ")"
+ \n (pcase v1
+ ((or "git-fetch" "git-fetch/lfs")
+ "(file-name (git-file-name name version))")
+ ("hg-fetch"
+ "(file-name (hg-file-name name version))")
+ ((or "svn-fetch" "bzr-fetch" "cvs-fetch")
+ "(file-name (string-append name \"-\" version \"-checkout\"))"))
+ & \n"(sha256"
+ \n "(base32"
+ ;; Hash of an empty directory
+ \n (format "%S" "0sjjj9z1dhilhpc8pq4154czrb79z9cm044jvn75kxcjv6v5l2m5") ")))")
+
+(define-skeleton guix-insert-git-reference
+ "Insert a Guix git-reference definition."
+ nil
+ "(git-reference"
+ \n"(url \"" (skeleton-read "URL: ") "\")"
+ \n"(commit \"" (skeleton-read "Commit / Tag: ") "\"))")
+
+(define-skeleton guix-insert-hg-reference
+ "Insert a Guix hg-reference definition."
+ nil
+ "(hg-reference"
+ \n"(url \"" (skeleton-read "URL: ") "\")"
+ \n"(changeset \"" (skeleton-read "Changeset: ") "\"))")
+
+(define-skeleton guix-insert-svn-reference
+ "Insert a Guix svn-reference definition."
+ nil
+ "(svn-reference"
+ \n"(url \"" (skeleton-read "URL: ") "\")"
+ \n"(revision \"" (skeleton-read "Revision: ") "\"))")
+
+(define-skeleton guix-insert-bzr-reference
+ "Insert a Guix bzr-reference definition."
+ nil
+ "(bzr-reference"
+ \n"(url \"" (skeleton-read "URL: ") "\")"
+ \n"(revision \"" (skeleton-read "Revision: ") "\"))")
+
+(define-skeleton guix-insert-cvs-reference
+ "Insert a Guix cvs-reference definition."
+ nil
+ "(cvs-reference"
+ \n"(root-directory \"" (skeleton-read "Root directory: ") "\")"
+ \n"(module \"" (skeleton-read "Module: ") "\")"
+ \n"(revision \"" (skeleton-read "Revision: ") "\"))")
+
+(define-skeleton guix-insert-:phases
+ "Insert a Guix #:phases snippet."
+ nil
+ "#:phases " \n
+ "(modify-phases %standard-phases" \n
+ _ ")")
+;;; scheme.el ends here
--
2.41.0
^ permalink raw reply related [flat|nested] 5+ messages in thread