From d76f7e7ac8dd5ced9bde43a72676a1043af01afd Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Tue, 2 Sep 2014 01:26:14 -0400 Subject: Add magit-branch-and-checkout-from-current Bind to 'c' in popup menu, and rebind magit-branch from 'c' to 'C'. --- lisp/init-git.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lisp') diff --git a/lisp/init-git.el b/lisp/init-git.el index 57f8620..bed87c1 100644 --- a/lisp/init-git.el +++ b/lisp/init-git.el @@ -40,6 +40,15 @@ Useful for non-source code repos (e.g., Org mode note files)." (magit-list-remote-branch-names)))) (magit-run-git "checkout" "-t" remote-branch)) +(defun km/magit-branch-and-checkout-from-current (branch) + "Create and checkout BRANCH at current branch. +This is equivalent to running `magit-branch-and-checkout' with +START-POINT set to the current branch. + +\(git checkout -b BRANCH)" + (interactive (list (magit-read-string "Branch name"))) + (magit-run-git "checkout" "-b" branch)) + (defun km/magit-backup-branch () "Create a backup branch for the current branch. \(git branch b/\)" @@ -78,6 +87,11 @@ Useful for non-source code repos (e.g., Org mode note files)." ?t "Local tracking" 'km/magit-checkout-local-tracking) (magit-define-popup-action 'magit-branch-popup ?s "Backup current branch" 'km/magit-backup-branch) + (magit-define-popup-action 'magit-branch-popup + ?C "Create" 'magit-branch) + (magit-define-popup-action 'magit-branch-popup + ?c "Create & checkout from current" + 'km/magit-branch-and-checkout-from-current) (setq magit-branch-popup-defaults (delete "--track" magit-branch-popup-defaults))) -- cgit v1.2.3