From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.bugs Subject: bug#73357: [PATCH] Make vc-clone interactive Date: Tue, 24 Sep 2024 10:22:31 +0000 Message-ID: <87ed59tkpk.fsf@posteo.net> References: <875xqrlr3b.fsf@disroot.org> <86ploz935f.fsf@gnu.org> <87y13nk39b.fsf@disroot.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24450"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , 73357@debbugs.gnu.org To: Aleksandr Vityazev Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Sep 24 12:24:03 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 1st2iA-0006EV-W6 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 24 Sep 2024 12:24:03 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1st2hp-000834-1D; Tue, 24 Sep 2024 06:23:41 -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 1st2hn-00082v-Ca for bug-gnu-emacs@gnu.org; Tue, 24 Sep 2024 06:23:39 -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 1st2hn-0005IA-0Y for bug-gnu-emacs@gnu.org; Tue, 24 Sep 2024 06:23:39 -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=Mb+rO5JsMmwbvKS/ko/LWcyyYOEGXo7jtH59cq2wcMg=; b=nNhaptYOsFiIoBXurJNAQgJmoy/cPiHVcgvK0v9q33D26xxnPY62Mm68bSokxLIQoUzsqAJf2pzyP2C2fz+wlZqb/uN2QZnJ6W12t9Jgprq8ATB+idiagukpEfLOplNF8piEa38mY4eIzU+0tIrnXP+eQi5cLltlzQg0d6LAiSVgv+pPPTIhP4h+ZBHNpOmxu5Zq/xyHwtB/dVvXLBnNj4iO2eFaz4+JC3S/1qxrAwt4I8jOP+VROLcTu9RIjEPWAhubMwEBF15VXRDZfweSQcPmkpIiP7UsOjMzjgHRpel+7er9yKH9BpBxRVJnqdHNBPuroScb9sllvu+bvEhZKg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1st2iA-0007u7-HZ for bug-gnu-emacs@gnu.org; Tue, 24 Sep 2024 06:24:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Philip Kaludercic Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 24 Sep 2024 10:24: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.172717338730266 (code B ref 73357); Tue, 24 Sep 2024 10:24:02 +0000 Original-Received: (at 73357) by debbugs.gnu.org; 24 Sep 2024 10:23:07 +0000 Original-Received: from localhost ([127.0.0.1]:45367 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1st2hH-0007s3-22 for submit@debbugs.gnu.org; Tue, 24 Sep 2024 06:23:07 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:45493) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1st2hF-0007rR-3A for 73357@debbugs.gnu.org; Tue, 24 Sep 2024 06:23:06 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id E98F9240103 for <73357@debbugs.gnu.org>; Tue, 24 Sep 2024 12:22:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1727173353; bh=sJUp9bVoBLlu5xktUahoChc95DcLzpfr3pnlIEvQ5ak=; h=From:To:Cc:Subject:Autocrypt:OpenPGP:Date:Message-ID:MIME-Version: Content-Type:From; b=eEwV7j9MBMb+NBWTlR9rCrs+HXWK41ndPXfybKYqDD6SqfgUbXRCH4g1CRgKIEzPh T65DJG5D5Bz6fz5QvBx8x9QCYg5ww5v/VfAjpCCkrKxSnCvCG6f7f+ihUkqszqyvlq 9dgCDoZme7NUCqV9c8Zo2Ieqc3fhTbqwxDTxeF4Jlabc7phyc7dlXsoBYLu3PQV1N2 +NqBEMnH4L5YAyn3sxY1/oQrN6U8ECg/jYFHxCANEdn9X6q0AZBWvd9OKbtW7Rw8O9 GxzhcZl+kgfKj/IEJWDtCjPBj0vtkSv0boAIXzD9sWQav5+3w4RrwxwA2zsGEo/5jm EK8OFce11xf6Q== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4XCbX91JB5z9rxS; Tue, 24 Sep 2024 12:22:32 +0200 (CEST) In-Reply-To: <87y13nk39b.fsf@disroot.org> (Aleksandr Vityazev's message of "Thu, 19 Sep 2024 19:38:24 +0300") Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM OpenPGP: id=philipk@posteo.net; url="https://keys.openpgp.org/vks/v1/by-email/philipk@posteo.net"; preference=signencrypt 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:292317 Archived-At: Aleksandr Vityazev writes: > 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: > >>>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. Try to avoid passive voice, as in "be used" and "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)) We could consider moving `package-vc-heuristic-alist' to vc so as to provide some useful default when cloning. > + (expand-file-name Here also, I think it would make sense to re-use the same interface as `package-vc-checkout' provides, by prompting for a not-yet existing directory. > + (read-directory-name "Clone dir: ")))) > + (let ((directory (expand-file-name (or directory default-directory)))) > + (setq directory I think binding this in a `let*' expression would look nicer. > + (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) Perhaps we can add a FIND-FILE argument to the end, so that it is also possible to open the directory from a script as well. > + (find-file directory) > + directory)))) I'd always return `directory', that seems simpler. > > (declare-function log-view-current-tag "log-view" (&optional pos)) > (defun vc-default-last-change (_backend file line) > -- > 2.46.0 -- Philip Kaludercic on siskin