From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Konstantin Kharlamov Newsgroups: gmane.emacs.bugs Subject: bug#68579: [PATCH] Support a local repo as URL in treesit-language-source-alist Date: Fri, 19 Jan 2024 11:57:48 +0300 Message-ID: <7010aa960be524d13f4dd96a1c7ea9102b580adf.camel@yandex.ru> References: <0ffc2f474cf84ed3c63aa82091c967807e5ca0e6.camel@yandex.ru> <83frytwwly.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="953"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.50.3 Cc: 68579@debbugs.gnu.org To: Eli Zaretskii , Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jan 19 09:58:14 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 1rQkhZ-000AZK-8n for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 19 Jan 2024 09:58:13 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQkhN-0003kl-Gr; Fri, 19 Jan 2024 03:58:01 -0500 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 1rQkhM-0003kQ-8R for bug-gnu-emacs@gnu.org; Fri, 19 Jan 2024 03:58:00 -0500 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 1rQkhL-0005RG-W2 for bug-gnu-emacs@gnu.org; Fri, 19 Jan 2024 03:58:00 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rQkhO-00074e-1Y for bug-gnu-emacs@gnu.org; Fri, 19 Jan 2024 03:58:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Konstantin Kharlamov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 19 Jan 2024 08:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68579 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 68579-submit@debbugs.gnu.org id=B68579.170565468127186 (code B ref 68579); Fri, 19 Jan 2024 08:58:02 +0000 Original-Received: (at 68579) by debbugs.gnu.org; 19 Jan 2024 08:58:01 +0000 Original-Received: from localhost ([127.0.0.1]:57478 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rQkhM-00074M-Sd for submit@debbugs.gnu.org; Fri, 19 Jan 2024 03:58:01 -0500 Original-Received: from forward502b.mail.yandex.net ([2a02:6b8:c02:900:1:45:d181:d502]:40210) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rQkhK-000747-7R for 68579@debbugs.gnu.org; Fri, 19 Jan 2024 03:57:59 -0500 Original-Received: from mail-nwsmtp-smtp-production-main-92.myt.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-92.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:2a0c:0:640:2804:0]) by forward502b.mail.yandex.net (Yandex) with ESMTP id D9A8F5EEFC; Fri, 19 Jan 2024 11:57:49 +0300 (MSK) Original-Received: by mail-nwsmtp-smtp-production-main-92.myt.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id mvJMsT1Ooa60-mdiFyTjf; Fri, 19 Jan 2024 11:57:49 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1705654669; bh=+/y+nv6hr0gJImXg7gyNGoGohtHeKu0LCZtU5prrC9s=; h=In-Reply-To:Cc:References:To:From:Date:Subject:Message-ID; b=f8vplkWY7JjUuVrBEMGZ39ODy0sJLNfRbdWyUtXqXVi6+8ccwGRn8Ng7YxgvSYAiA +LRWSV1WAZELk68t3YMRxKy/2YigdAyqbR7r4J8w07zHJEG3RdeI9Dmhx0s0eL0iEb DjakhR8jY6FhH3XGxWszFwKND79PjyF9zRFzu5VE= Authentication-Results: mail-nwsmtp-smtp-production-main-92.myt.yp-c.yandex.net; dkim=pass header.i=@yandex.ru In-Reply-To: <83frytwwly.fsf@gnu.org> 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:278487 Archived-At: On Fri, 2024-01-19 at 10:33 +0200, Eli Zaretskii wrote: [=E2=80=A6] Thank you! >=20 > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (url-is-path (string-= prefix-p "/" url)) >=20 > "Path" used wrongly again.=C2=A0 Also, the string-prefix-p test is too > na=C3=AFve and unportable.=C2=A0 I think file-name-absolute-p is a better= test > (assuming we expect an absolute file name there), perhaps also > augmented by file-accessible-directory-p. I would presume if the directory inaccessible some later commands such as `git checkout` will fail anyway, so no point in adding the `file- accessible-directory-p` check on Emacs side=E2=80=A6? > > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (workdir (expand-file= -name "repo")) > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (workdir (if url-is-p= ath url (expand-file-name "repo"))) >=20 > Not sure about this hunk: why do we not need to expand-file-name if > URL is not a local directory but a real URL? Idk, that was there =F0=9F=98=85 But yeah, I can remove if it's not needed.= I presume if it's really needed, there needs to be an explanation comment > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (if url-is-path > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 (when revision > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 (treesit--git-checkout-branch url revision)) >=20 > Isn't the above equivalent to >=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = (and url-is-path revision > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (treesit--git-checkout-branch url revision)) >=20 > ? Good point! > > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (when (file-exists-p workdir) > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (when (and (not url-is-path) (file-exis= ts-p workdir)) > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (delete-directory work= dir t))))) >=20 > Why?=C2=A0 Does workdir have different semantics in these two use cases? > Isn't it the directory where we cloned the repository? When an absolute path is passed as URL, that means the user have cloned the repo, not us. So we do not want to remove the directory. This is a different semantics from the case where we created a temporary clone ourselves, and want to get rid of the temporary directory after everything is done. I can add a comment explaining that there