# -*- mode: snippet -*-
# name: guix-commit-message-update-package
# key: update
# condition: git-commit-mode
# --

gnu: ${1:`(with-temp-buffer
           (magit-git-wash #'magit-diff-wash-diffs
             "diff" "--staged")
           (goto-char (point-min))
           (when (re-search-forward "^[ ]*(define-public \\(\\S-+\\)" nil 'noerror)
             (match-string-no-properties 1)))`}: Update to ${2:`(with-temp-buffer
    (magit-git-wash #'magit-diff-wash-diffs
      "diff" "--staged")
    (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))))))`}.

* `(car (magit-staged-files))` ($1): Update to $2.$0
`(mapconcat (lambda (file) (concat "* " file)) (cdr (magit-staged-files)) "\n")`/td></tr></table>
<table class='tabs'><tr><td>
<a href='/guix/about/'>about</a><a href='/guix/'>summary</a><a href='/guix/refs/?id=79928c5e585aae10d6a15c18642bc9878f3cfa9c'>refs</a><a class='active' href='/guix/log/etc/snippets/text-mode/guix-commit-message-add-cl-package'>log</a><a href='/guix/tree/etc/snippets/text-mode/guix-commit-message-add-cl-package?id=79928c5e585aae10d6a15c18642bc9878f3cfa9c'>tree</a><a href='/guix/commit/etc/snippets/text-mode/guix-commit-message-add-cl-package?id=79928c5e585aae10d6a15c18642bc9878f3cfa9c'>commit</a><a href='/guix/diff/etc/snippets/text-mode/guix-commit-message-add-cl-package?id=79928c5e585aae10d6a15c18642bc9878f3cfa9c'>diff</a></td><td class='form'><form class='right' method='get' action='/guix/log/etc/snippets/text-mode/guix-commit-message-add-cl-package'>
<input type='hidden' name='id' value='79928c5e585aae10d6a15c18642bc9878f3cfa9c'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/guix/log/?id=79928c5e585aae10d6a15c18642bc9878f3cfa9c'>root</a>/<a href='/guix/log/etc?id=79928c5e585aae10d6a15c18642bc9878f3cfa9c'>etc</a>/<a href='/guix/log/etc/snippets?id=79928c5e585aae10d6a15c18642bc9878f3cfa9c'>snippets</a>/<a href='/guix/log/etc/snippets/text-mode?id=79928c5e585aae10d6a15c18642bc9878f3cfa9c'>text-mode</a>/<a href='/guix/log/etc/snippets/text-mode/guix-commit-message-add-cl-package?id=79928c5e585aae10d6a15c18642bc9878f3cfa9c'>guix-commit-message-add-cl-package</a></div><div class='content'><table class='list nowrap'><tr class='nohover'><th class='left'>Age</th><th class='left'>Commit message (<a href='/guix/log/etc/snippets/text-mode/guix-commit-message-add-cl-package?id=79928c5e585aae10d6a15c18642bc9878f3cfa9c&amp;showmsg=1'>Expand</a>)</th><th class='left'>Author</th></tr>
<tr><td><span title='2020-11-25 10:45:42 +0100'>2020-11-25</span></td><td><a href='/guix/commit/etc/snippets/text-mode/guix-commit-message-add-cl-package?id=402f1104e58b8e76d42689770d0c6b106afaffc8'>etc: snippets: Fix "gnu: Add ..." name when prefilling Common Lisp commits me...</a><span class='msg-avail'>...<span class='msg-tooltip'>* etc/snippets/text-mode/guix-commit-message-add-cl-package: Fix name and
simplify the "New variables" line.
</span></span></td><td>Pierre Neidhardt</td></tr>
<tr><td><span title='2020-11-23 11:14:22 +0100'>2020-11-23</span></td><td><a href='/guix/commit/etc/snippets/text-mode/guix-commit-message-add-cl-package?id=add47499170222f1d449a9a63444e01f115805ff'>etc: snippets: Prefill Common Lisp package names.</a><span class='msg-avail'>...<span class='msg-tooltip'>* etc/snippets/text-mode/guix-commit-message-add-cl-package: New file.
</span></span></td><td>Pierre Neidhardt</td></tr>