From 1cd8435c566189ca3dfe0615a1b7d4ccb0357624 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Thu, 16 Apr 2020 23:30:08 -0400 Subject: 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. --- init.el | 2 +- lisp/km-magit.el | 10 +++++++--- 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 '__v', where is incremented +Name it as '__cp', where 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 -- cgit v1.2.3