From: rearman Date: Fri, 22 Aug 2025 15:33:37 +0000 (-0400) Subject: Add fetch for vc, update show-branches X-Git-Url: https://git.earman.xyz/?a=commitdiff_plain;h=b84244f5cf3c0bf23dd0670185e7a37a65271fdf;p=emacsinit.git Add fetch for vc, update show-branches Fetch bound on `f' in vc-map and vc-dir-map. Does not check if `backend' is anything other than `Git'. Calls `fetch --all --verbose', or with arg, prompts for location from which to fetch. re/vc-show-branches now takes an optional arg, which will enable showing of remote branches. --- diff --git a/re/re-bindings.el b/re/re-bindings.el index 87834c7..b86723e 100644 --- a/re/re-bindings.el +++ b/re/re-bindings.el @@ -72,9 +72,12 @@ ;; Draftweilding (keymap-global-set "C-x v C" #'re/vc-clone) (keymap-global-set "C-x v b b" #'re/vc-show-branches) +(keymap-global-set "C-x v f" #'re/vc-fetch) + (add-hook 'vc-dir-mode-hook (lambda () - (keymap-set vc-dir-mode-map "b b" #'re/vc-show-branches))) + (keymap-set vc-dir-mode-map "b b" #'re/vc-show-branches) + (keymap-set vc-dir-mode-map "f" #'re/vc-fetch))) ;; (E)Lisp diff --git a/re/re-editing-defuns.el b/re/re-editing-defuns.el index 8ede328..fdeb1e4 100644 --- a/re/re-editing-defuns.el +++ b/re/re-editing-defuns.el @@ -168,17 +168,43 @@ Prompt for url and local dir." (dir (read-string "Local Dir: " (file-name-base url)))) (vc-clone url nil dir nil))) -(defun re/vc-show-branches () - "Display all Git branches in a separate buffer." - (interactive) +(defun re/vc-show-branches (&optional arg) + "Display all Git branches in a separate buffer. +Remotes as well when arg." + (interactive "P") (let ((default-directory (if (boundp 'vc-dir-directory) vc-dir-directory default-directory))) - (vc-git-command "*git-branches*" nil nil "branch" "--verbose") + (vc-git-command "*git-branches*" + nil + nil + "branch" + "--verbose" + (when arg "--remotes")) (pop-to-buffer "*git-branches*") (goto-char (point-min)) (special-mode))) +(defun re/vc-fetch (&optional arg) + "Interactively fetch with vc-mode. +Allows separate fetch in addition to pull. Only care about git. +With arg, ask for remote, otherwise fetch all." + (interactive "P") + (let* ((default-directory (if (boundp 'vc-dir-directory) + vc-dir-directory + default-directory))) + (vc-git-command "*vc-fetch*" + nil + nil + "fetch" + (if arg + (read-string "Fetch From: " "origin") + "--all") + "--verbose") + (pop-to-buffer "*vc-fetch*") + (goto-char (point-min)) + (special-mode))) + (defun re/keyboard-quit () "Smarter version of `keyboard-quit'. Close the minibuffer if not focused when hit.