all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#73357: [PATCH] Make vc-clone interactive
@ 2024-09-19 13:18 Aleksandr Vityazev via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-09-19 13:36 ` Eli Zaretskii
  0 siblings, 1 reply; 14+ messages in thread
From: Aleksandr Vityazev via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-09-19 13:18 UTC (permalink / raw)
  To: 73357

[-- Attachment #1: Type: text/plain, Size: 123 bytes --]

Hi,

Cloning is used quite often, so I would like to have an interactive
command. A patch is attached to the email. WDYT?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: [PATCH] Make vc-clone interactive --]
[-- Type: text/x-patch, Size: 3031 bytes --]

From 1fd3aa4b3afe4064bcc78787b99f4fa336e4031d Mon Sep 17 00:00:00 2001
Message-ID: <1fd3aa4b3afe4064bcc78787b99f4fa336e4031d.1726751543.git.avityazev@disroot.org>
From: Aleksandr Vityazev <avityazev@disroot.org>
Date: Thu, 19 Sep 2024 16:11:31 +0300
Subject: [PATCH] Make vc-clone interactive

* lisp/vc/vc.el (vc-clone): Make interactive.
(vc--remotes-history): New defvar.
---
 lisp/vc/vc.el | 40 +++++++++++++++++++++++++++-------------
 1 file changed, 27 insertions(+), 13 deletions(-)

diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 597a1622f5a..d3d3a302d45 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -3804,6 +3804,8 @@ vc-check-headers
   (interactive)
   (vc-call-backend (vc-backend buffer-file-name) 'check-headers))
 
+(defvar vc--remotes-history)
+
 (defun vc-clone (remote &optional backend directory rev)
   "Clone repository REMOTE using version-control BACKEND, into DIRECTORY.
 If successful, return the string with the directory of the checkout;
@@ -3815,19 +3817,31 @@ vc-clone
 backend in `vc-handled-backends' until one succeeds to clone REMOTE.
 If REV is non-nil, it indicates a specific revision to check out after
 cloning; the syntax of REV depends on what BACKEND accepts."
-  (setq directory (expand-file-name (or directory default-directory)))
-  (if backend
-      (progn
-        (unless (memq backend vc-handled-backends)
-          (error "Unknown VC backend %s" backend))
-        (vc-call-backend backend 'clone remote directory rev))
-    (catch 'ok
-      (dolist (backend vc-handled-backends)
-        (ignore-error vc-not-supported
-          (when-let ((res (vc-call-backend
-                           backend 'clone
-                           remote directory rev)))
-            (throw 'ok res)))))))
+  (interactive
+   (list (read-string "Remote: " nil 'vc--remotes-history)
+         (intern (completing-read "Backend: " vc-handled-backends nil t))
+         (expand-file-name
+          (read-directory-name "Clone dir: "))
+         (read-string "Revision (RET if not needed): ")))
+  (let ((directory (expand-file-name (or directory default-directory)))
+        (rev (unless (string-empty-p rev) rev)))
+    (setq directory
+          (if backend
+              (progn
+                (unless (memq backend vc-handled-backends)
+                  (error "Unknown VC backend %s" backend))
+                (vc-call-backend backend 'clone remote directory rev))
+            (catch 'ok
+              (dolist (backend vc-handled-backends)
+                (ignore-error vc-not-supported
+                  (when-let ((res (vc-call-backend
+                                   backend 'clone
+                                   remote directory rev)))
+                    (throw 'ok res)))))))
+    (when (file-directory-p directory)
+      (if (called-interactively-p 'interactive)
+          (find-file directory)
+        directory))))
 
 (declare-function log-view-current-tag "log-view" (&optional pos))
 (defun vc-default-last-change (_backend file line)
-- 
2.46.0


[-- Attachment #3: Type: text/plain, Size: 39 bytes --]



-- 
Best regards,
Aleksandr Vityazev

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2024-10-24 14:19 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-19 13:18 bug#73357: [PATCH] Make vc-clone interactive Aleksandr Vityazev via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-19 13:36 ` Eli Zaretskii
2024-09-19 16:38   ` Aleksandr Vityazev via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-24 10:22     ` Philip Kaludercic
2024-09-29 18:23       ` Aleksandr Vityazev via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-01 11:09         ` Philip Kaludercic
2024-10-06 14:50           ` Aleksandr Vityazev via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-12 12:06             ` Eli Zaretskii
2024-10-24 10:19               ` Aleksandr Vityazev via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-24 10:43                 ` Philip Kaludercic
2024-10-24 11:26                   ` Sean Whitton
2024-10-24 12:31                     ` Aleksandr Vityazev via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-24 13:45                       ` Sean Whitton
2024-10-24 14:19                         ` Philip Kaludercic

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.