]> git.earman.xyz Git - emacsinit.git/commitdiff
Add fetch for vc, update show-branches
authorrearman <rearman@r717.net>
Fri, 22 Aug 2025 15:33:37 +0000 (11:33 -0400)
committerrearman <rearman@r717.net>
Fri, 22 Aug 2025 15:33:37 +0000 (11:33 -0400)
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.

re/re-bindings.el
re/re-editing-defuns.el

index 87834c7a37da8c587f1fe790edac3e6e498a47a0..b86723ee4a53173dc22bea1ad4a393970278e414 100644 (file)
 ;; 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
 
index 8ede32856f8a024dc42c3f3f934ffca5a586a503..fdeb1e4c30468d45e42dd6948cb1574cba42ef13 100644 (file)
@@ -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.