snippets: Fix move.
The current move is never correct. It flip-flops between car and cadr for the destination. Since the position of the destination is not actually a fixed point in the list of changes, use a more robust method of inferring it. * etc/snippets/tempel/text-mode (move\ ): Infer source and destination from washed diffs. Process new module before destination.master
parent
da281417cc
commit
5e63e51afe
|
@ -122,12 +122,34 @@ text-mode :when (and (fboundp 'git-commit-mode) (git-commit-mode))
|
||||||
nil 'noerror)
|
nil 'noerror)
|
||||||
(match-string-no-properties 1)))
|
(match-string-no-properties 1)))
|
||||||
var)
|
var)
|
||||||
": Move to "
|
": Move to ("
|
||||||
(concat "("
|
(p (with-temp-buffer
|
||||||
(string-replace "\.scm" ""
|
(magit-git-wash #'magit-diff-wash-diffs
|
||||||
(string-replace "/" " "
|
"diff" "--staged")
|
||||||
(car (magit-staged-files))))
|
(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
|
n
|
||||||
n "* " (car (magit-staged-files)) " (" (s var) "): Move from here…"
|
"* " (p (with-temp-buffer
|
||||||
n "* " (cadr (magit-staged-files)) " (" (s var) "): …to here.")
|
(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.")
|
||||||
|
|
Reference in New Issue