battering/snippets/tempel/text-mode.eld
Hanketsu f94834585f
Add vendorremove snippet for vendored packages.
* snippets/tempel/text-mode.eld: New snippet.
2024-12-23 18:47:03 +01:00

146 lines
5.7 KiB
Text

text-mode :when (bound-and-true-p git-commit-mode)
(add\ "battering: Add "
(p (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)))
var)
"." n n
"* " (p (or (car (magit-staged-files)) ""))
" (" (s var ) "): New variable.")
(vendoradd\ "battering: Add "
(with-temp-buffer
(magit-git-wash #'magit-diff-wash-diffs
"diff" "--staged")
(goto-char (point-min))
(number-to-string
(count-matches "\\+(define \\(\\S-+\\)"
nil 'noerror)))
" vendored packages." n n
"* " (p (or (car (magit-staged-files)) ""))
": New vendored packages.")
(vendorremove\ "battering: Remove "
(with-temp-buffer
(magit-git-wash #'magit-diff-wash-diffs
"diff" "--staged")
(goto-char (point-min))
(number-to-string
(count-matches "-(define \\(\\S-+\\)"
nil 'noerror)))
" vendored packages." n n
"* " (p (or (car (magit-staged-files)) ""))
": Delete vendored packages.")
(remove\ "battering: Remove "
(p (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)))
var)
"." n n
"* " (p (or (car (magit-staged-files)) ""))
" (" (s var) "): Delete variable.")
(rename\ "battering: "
(p (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)))
prev-var)
": Rename package to "
(p (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)))
new-var)
"." n n
"* " (p (or (car (magit-staged-files)) "")) " (" (s prev-var) "): "
"Define in terms of" n
"'deprecated-package'." n
"(" (s new-var) "): New variable, formerly known as \""
(s prev-var) "\".")
(update\ "battering: "
(p (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)))
var)
": Update to "
(p (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))))))
version)
"." n n
"* " (p (or (car (magit-staged-files)) "")) " (" (s var) "): "
"Update to " (s version) "." n
(mapconcat (lambda (file) (concat "* " file))
(cdr (magit-staged-files))
"\n"))
(move\ "battering: "
(p (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)))
var)
": Move to ("
(p (with-temp-buffer
(magit-git-wash #'magit-diff-wash-diffs
"diff" "--staged")
(goto-char (point-min))
(when (and
(re-search-forward "\\+(define-public \\(\\S-+\\)"
nil 'noerror)
(re-search-backward "modified[ ]*\\(\\S-+\\)"
nil 'noerror))
(string-replace
"\.scm" ""
(string-replace "/" " "
(match-string-no-properties 1)))))
new-module)
")." n
n
"* " (p (with-temp-buffer
(magit-git-wash #'magit-diff-wash-diffs
"diff" "--staged")
(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))
source))
" (" (s var) "): Move from here…" n
"* " (concat (string-replace " " "/" new-module) ".scm")
" (" (s var) "): …to here.")