From d6234620ace1863d8102b065311ef3d94e0931da Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Thu, 7 Mar 2019 23:55:24 +0100 Subject: etc: snippets: Prefill package name and version. * etc/snippets/text-mode/guix-commit-message-update-package: Extract package name and version from git diff output. --- .../text-mode/guix-commit-message-update-package | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'etc/snippets') diff --git a/etc/snippets/text-mode/guix-commit-message-update-package b/etc/snippets/text-mode/guix-commit-message-update-package index 79fcf7c6e3..2cdb6ea28d 100644 --- a/etc/snippets/text-mode/guix-commit-message-update-package +++ b/etc/snippets/text-mode/guix-commit-message-update-package @@ -3,7 +3,24 @@ # key: update # condition: git-commit-mode # -- -gnu: $1: Update to $2. + +gnu: ${1:`(with-temp-buffer + (magit-git-wash #'magit-diff-wash-diffs + "diff" "--staged") + (beginning-of-buffer) + (when (search-forward "(define-public " nil 'noerror) + (thing-at-point 'sexp 'no-properties)))`}: Update to ${2:`(with-temp-buffer + (magit-git-wash #'magit-diff-wash-diffs + "diff" "--staged") + (beginning-of-buffer) + (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))))))`}. * `(car (magit-staged-files))` ($1): Update to $2.$0 `(mapconcat (lambda (file) (concat "* " file)) (cdr (magit-staged-files)) "\n")` \ No newline at end of file -- cgit v1.2.3