From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Aleksandr Vityazev via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#73357: [PATCH] Make vc-clone interactive Date: Thu, 19 Sep 2024 19:38:24 +0300 Message-ID: <87y13nk39b.fsf@disroot.org> References: <875xqrlr3b.fsf@disroot.org> <86ploz935f.fsf@gnu.org> Reply-To: Aleksandr Vityazev Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12251"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 73357@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 19 18:39:08 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1srKBP-0002zf-VP for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 19 Sep 2024 18:39:08 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1srKB5-0003UT-2P; Thu, 19 Sep 2024 12:38:47 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1srKB2-0003Tm-SE for bug-gnu-emacs@gnu.org; Thu, 19 Sep 2024 12:38:44 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1srKB2-00018M-JP for bug-gnu-emacs@gnu.org; Thu, 19 Sep 2024 12:38:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=A6zT9LTYm7FzzjEGdmKMpj9yKLLPPGcv7iGgptOIJh4=; b=NiH7+u1paJhdDW+93l/nPItUGs446FRhQGi1Np8sENwYiPBY2TpdgwI5SiSKd+lyUNqxGWPOSlQoysu+msaw2fYUqo7H6Y2OGk7063u5CG/B91VcplSxnm5BeBHGz+Knv5ViaoryD4C3IjEWeCv5Bd3R9raenoqPq+PXdorDvF2HGtwxfb3eqldJd6RSHyH0RHzlmHilBJkn21brcUxYLjy1mJpAoyz+66vB4V7+Knl+xlDLSH82q4nkYh+MGLRP4gt1SuUsAJbZlVRbdNRclvqOf6JO+JH3UgpchNFdRjUCdfUz9SEyYsV1KzW2fzidJnLqmeAuG7bS+Oq0h/Nr4A==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1srKBK-0001V8-5w for bug-gnu-emacs@gnu.org; Thu, 19 Sep 2024 12:39:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Aleksandr Vityazev Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 19 Sep 2024 16:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73357 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 73357-submit@debbugs.gnu.org id=B73357.17267639345751 (code B ref 73357); Thu, 19 Sep 2024 16:39:02 +0000 Original-Received: (at 73357) by debbugs.gnu.org; 19 Sep 2024 16:38:54 +0000 Original-Received: from localhost ([127.0.0.1]:33416 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1srKBA-0001Ug-TI for submit@debbugs.gnu.org; Thu, 19 Sep 2024 12:38:54 -0400 Original-Received: from layka.disroot.org ([178.21.23.139]:46036) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1srKB8-0001UU-MU for 73357@debbugs.gnu.org; Thu, 19 Sep 2024 12:38:51 -0400 Original-Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id B8B8723E07; Thu, 19 Sep 2024 18:38:30 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Original-Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id ZMsiiGqRkitu; Thu, 19 Sep 2024 18:38:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1726763910; bh=9xJC9zeo/SHxsxQ80ntdtonbXMBCEZyWC7YCwD5sucM=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=lPfCTIZ/Gx1OAxPhBYVcAelgob/fy6RdsE1X2h6Vd5y3mG4/BCFr1KelbnQ3xhuPg Qz3xwsgbjAsKpT7kvS2C2xQuyqAjaw+Ld5RGYIv+h6MxhH6Kjt6yRv0Cm8OWI1TdTs g4lyPCfp6IAXwYTl3b8IOP20WVR4qTC6OHWK7NVpxiiWi08k4yEQCOFOQ8Y0//G3S6 UMJdDDkaBRJ8OmBFJCxEy9c9wHAWCCr54b0O0kvzyLB5cl8mys8HPteSgVLTBwpOFJ rYKO5Ssa+tSp4spzMYScbEo9zeeTycoXB6Ljr3A0hsQJPDs1ipGWXhNuxhdw/Wsi0X nqVfYWd0kg2HA== In-Reply-To: <86ploz935f.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 19 Sep 2024 16:36:12 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:292068 Archived-At: --=-=-= Content-Type: text/plain On 2024-09-19 16:36, Eli Zaretskii wrote: >> Date: Thu, 19 Sep 2024 16:18:16 +0300 >> From: Aleksandr Vityazev via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" >> >> Cloning is used quite often, so I would like to have an interactive >> command. A patch is attached to the email. WDYT? > > Thanks, but making this function a command will take more than just > adding the interactive form. I think we need at least: > > . mention that in interactive usage the command prompts for the > argument (why do we have to prompt for REV, btw?) I clarified in the docstring. We can agree that we shouldn't prompt for REV when cloning interactively, removed. > . announce the change in NEWS Announced but did not mark the news with +++ or ---. > . maybe update the user manual maybe if I have to, I'll do it. > . maybe make the command fall back to 'checkout' method if 'clone' > is not supported it's worth thinking about, because I can't say for sure right now if it's worth it. And how to do this when vc-checkout requires a file as an argument. >> + (when (file-directory-p directory) >> + (if (called-interactively-p 'interactive) >> + (find-file directory) >> + directory)))) > > This changes the value returned by the function from what it did > before, no? If the function is called from the code, it returns nil or the directory, just like in the previous version. Or am I missing something? V2 patch: --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Make-vc-clone-interactive.patch Content-Description: [PATCH] Make vc-clone interactive >From b302b5c42e01fe0b6f7607128ed660babf55e35a Mon Sep 17 00:00:00 2001 Message-ID: From: Aleksandr Vityazev Date: Thu, 19 Sep 2024 16:11:31 +0300 Subject: [PATCH] Make vc-clone interactive * lisp/vc/vc.el (vc-clone): Make interactive. Mention this in the doc string. (vc--remotes-history): New defvar. * etc/NEWS: Announce it. --- etc/NEWS | 7 +++++++ lisp/vc/vc.el | 42 ++++++++++++++++++++++++++++-------------- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index b52ad001a2e..db5f05c823c 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -359,6 +359,13 @@ functionality of the standard 'xref' commands in TeX buffers. You can restore the standard 'etags' backend with the 'M-x xref-etags-mode' toggle. +** VC + +*** 'vc-clone' is now an interactive command. +When called interactively, 'vc-clone' now prompts for the address of the +remote repository, the backend that will be used for cloning, as well as +the directory where the repository will be cloned. + * New Modes and Packages in Emacs 31.1 diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 597a1622f5a..fc964803a02 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; @@ -3814,20 +3816,32 @@ vc-clone If BACKEND is nil or omitted, the function iterates through every known 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))))))) +cloning; the syntax of REV depends on what BACKEND accepts. +If called interactively, prompt for REMOTE, BACKEND and DIRECTORY in +the minibuffer." + (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: ")))) + (let ((directory (expand-file-name (or directory default-directory)))) + (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 --=-=-= Content-Type: text/plain -- Best regards, Aleksandr Vityazev --=-=-=--