summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2020-04-16 23:30:08 -0400
committerKyle Meyer <kyle@kyleam.com>2020-04-16 23:54:15 -0400
commit1cd8435c566189ca3dfe0615a1b7d4ccb0357624 (patch)
tree0c8ca21df19a0c43c1bb5ae8454c9d4e91b6bd24
parentb708f92f3e7e498aff8f57fc97d0d38606e9c822 (diff)
downloademacs.d-1cd8435c566189ca3dfe0615a1b7d4ccb0357624.tar.gz
km-magit: Change name and default suffix of branch backup command
I've been using "__vN" to record published versions of branches and "__cpN" for making "check points" of a branch when I'm in a state that I might want to look back on or reset to (e.g., because I'm going to do an involved, multi-step rewrite). I tend to use "__cp" a lot more, so make it the default.
-rw-r--r--init.el2
-rw-r--r--lisp/km-magit.el10
2 files changed, 8 insertions, 4 deletions
diff --git a/init.el b/init.el
index e68ab8a..b8fb980 100644
--- a/init.el
+++ b/init.el
@@ -1177,7 +1177,7 @@
'("d" "Copy branch" km/magit-branch-copy))
(transient-append-suffix 'magit-branch "r"
- '("s" "Backup current branch" km/magit-branch-backup-current))
+ '("s" "Backup current branch" km/magit-branch-checkpoint))
(transient-append-suffix 'magit-branch "c"
'("m" "Checkout master" km/magit-checkout-master)))
diff --git a/lisp/km-magit.el b/lisp/km-magit.el
index 7f339cd..953b8f9 100644
--- a/lisp/km-magit.el
+++ b/lisp/km-magit.el
@@ -220,15 +220,15 @@ START-POINT set to the current branch.
(error "bug: version re should always match"))))
(km/magit-branch-get-set branch suffix)))))
-(defun km/magit-branch-backup-current (&optional suffix)
+(defun km/magit-branch-checkpoint (&optional suffix)
"Create a backup branch for the current branch.
-Name it as '<current-branch>__v<n>', where <n> is incremented
+Name it as '<current-branch>__cp<n>', where <n> is incremented
to form a refname that doesn't already exist. With the prefix
argument SUFFIX, prompt for a suffix to use instead of
'v'."
(interactive (list (and current-prefix-arg
(magit-read-string-ns "Backup suffix"))))
- (setq suffix (or suffix "v"))
+ (setq suffix (or suffix "cp"))
(let* ((current (or (magit-get-current-branch)
(user-error "No current branch")))
(versions (km/magit-branch--get-versions current suffix)))
@@ -239,6 +239,10 @@ argument SUFFIX, prompt for a suffix to use instead of
suffix
(if (null versions) 1 (1+ (apply #'max versions)))))))
+(defun km/magit-branch-version ()
+ (interactive)
+ (km/magit-branch-checkpoint "v"))
+
(defun km/magit-branch-archive (branches)
"Move BRANCHES from refs/heads/ to refs/archive/."
(interactive