From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#41572: 28.0.50; [PATCH] Support plain project marked with file .emacs-project Date: Wed, 30 Nov 2022 22:32:27 +0200 Message-ID: <83wn7ci3ok.fsf@gnu.org> References: <2a70c748-e250-2f96-5d74-712b6d71e8be@yandex.ru> <871riitzch.fsf@gnus.org> <9781acc2-e4c0-b53c-6422-ef2e0a96f400@yandex.ru> <83sfi6tavq.fsf@gnu.org> <83mt8dssdn.fsf@gnu.org> <29c1c5f3-b189-ff30-c5bc-92a4d35e0683@yandex.ru> <83fse4rj2s.fsf@gnu.org> <2bc8b5dd-83c9-8bbc-82d5-e296f60e47c3@yandex.ru> <83lenwpj5k.fsf@gnu.org> <83fse4pctt.fsf@gnu.org> <8335a3p9xy.fsf@gnu.org> <62aab865-7c71-8c12-9e51-688f588b1e51@yandex.ru> <83lenvnrgs.fsf@gnu.org> <83a64bnngm.fsf@gnu.org> <834jujnhtr.fsf@gnu.org> <14c44382-1c57-4c09-d9ae-7991b8296572@yandex.ru> <83edtklge2.fsf@gnu.org> <162e7230-8295-884f-6ed0-04920b8b5325@yandex.ru> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19423"; mail-complaints-to="usenet@ciao.gmane.io" Cc: philipk@posteo.net, rudi@constantly.at, eric@ericabrahamsen.net, cjpeople2013@gmail.com, theo@thornhill.no, mardani29@yahoo.es, joaotavora@gmail.com, manuel.uberti@inventati.org, juri@linkov.net, salutis@me.com, arstoffel@gmail.com, 41572@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 30 21:34:26 2022 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 1p0Tmi-0004oR-UX for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 30 Nov 2022 21:34:25 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0TmP-0003Lc-7I; Wed, 30 Nov 2022 15:34:05 -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 1p0TmN-0003Kj-AL for bug-gnu-emacs@gnu.org; Wed, 30 Nov 2022 15:34:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p0TmM-0001li-KY for bug-gnu-emacs@gnu.org; Wed, 30 Nov 2022 15:34:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p0TmM-0005Ml-Ap for bug-gnu-emacs@gnu.org; Wed, 30 Nov 2022 15:34:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 30 Nov 2022 20:34:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41572 X-GNU-PR-Package: emacs Original-Received: via spool by 41572-submit@debbugs.gnu.org id=B41572.166984039020613 (code B ref 41572); Wed, 30 Nov 2022 20:34:02 +0000 Original-Received: (at 41572) by debbugs.gnu.org; 30 Nov 2022 20:33:10 +0000 Original-Received: from localhost ([127.0.0.1]:34950 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0TlV-0005MP-RN for submit@debbugs.gnu.org; Wed, 30 Nov 2022 15:33:10 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:38184) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0TlT-0005M5-3o for 41572@debbugs.gnu.org; Wed, 30 Nov 2022 15:33:08 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0TlK-0001ht-Pe; Wed, 30 Nov 2022 15:32:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=iEcK5RkFp2ABJTVL+kC6vkEUPqX3c2GQCd8vGILm54U=; b=bqJpSjOdMux4 onDoKSR5Fr8wYIkR/bKBZyjhxSAaYbgqFQe7sfHL16fIMNFJW6mTs3QcE7OZQiKQyEJUGOjYGpE1B KLFFNd46j8LIHVRQ33j3f8464Cp48pn+QtWuCdl+NSD0x6/eOm1H4nK2KggS5qri81wszE9LnPRgX cMFvueCFggQJxgP1m4tTD2ByCiMccCDjk55+N2q/o0F/gaeIAq68K8AICJiZUVDTzhCvtjUVSruMZ AiuIJ+zMfulVZIlIn9rPnragnpASTEcHBaMtGvc03Fg2pSm0WspCC46J3VkGW694QF6KExKWLSUFp iuv6VFPHjRUahlKKwTMo+A==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0TlJ-0008Lc-8N; Wed, 30 Nov 2022 15:32:58 -0500 In-Reply-To: <162e7230-8295-884f-6ed0-04920b8b5325@yandex.ru> (message from Dmitry Gutov on Wed, 30 Nov 2022 20:52:32 +0200) 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:249570 Archived-At: > Date: Wed, 30 Nov 2022 20:52:32 +0200 > Cc: philipk@posteo.net, rudi@constantly.at, eric@ericabrahamsen.net, > cjpeople2013@gmail.com, theo@thornhill.no, mardani29@yahoo.es, > joaotavora@gmail.com, manuel.uberti@inventati.org, juri@linkov.net, > salutis@me.com, arstoffel@gmail.com, 41572@debbugs.gnu.org > From: Dmitry Gutov > > >> Eli, what do you think about this feature > >> (project-vc-extra-root-markers) for emacs-29? > > Where can I see the code that you are proposing? > > Here you go, I also added some documentation updates and 2 tests. Thanks. But I don't see any tests... > +;; If the repository is using any other VCS than Git or Hg, the file > +;; listing uses the default mechanism based on 'find'. Instead of a literal 'find', this should probably say something like If the repository is using any other VCS than Git or Hg, the file listing uses the default mechanism based on the program specified by `find-program'. > (defun project-try-vc (dir) > + (defvar vc-svn-admin-directory) > + (require 'vc-svn) > + ;; FIXME: Learn to invalidate when the value of > + ;; `project-vc-merge-submodules' or `project-vc-extra-root-markers' > + ;; changes. > (or (vc-file-getprop dir 'project-vc) > - (let* ((backend (ignore-errors (vc-responsible-backend dir))) > + (let* ((backend-markers-alist `((Git . ".git") > + (Hg . ".hg") > + (Bzr . ".bzr") > + (SVN . ,vc-svn-admin-directory) > + (DARCS . "_darcs") > + (Fossil . ".fslckout"))) > + (backend-markers > + (delete > + nil > + (mapcar > + (lambda (b) (assoc-default b backend-markers-alist)) > + vc-handled-backends))) > + (marker-re > + (mapconcat > + (lambda (m) (format "\\(%s\\)" (wildcard-to-regexp m))) > + (append backend-markers project-vc-extra-root-markers) > + "\\|")) > + (locate-dominating-stop-dir-regexp > + (or vc-ignore-dir-regexp locate-dominating-stop-dir-regexp)) > + last-matches > (root > - (pcase backend > - ('Git > - ;; Don't stop at submodule boundary. > - (or (vc-file-getprop dir 'project-git-root) > - (let ((root (vc-call-backend backend 'root dir))) > - (vc-file-setprop > - dir 'project-git-root > - (if (and > - ;; FIXME: Invalidate the cache when the value > - ;; of this variable changes. > - project-vc-merge-submodules > - (project--submodule-p root)) > - (let* ((parent (file-name-directory > - (directory-file-name root)))) > - (vc-call-backend backend 'root parent)) > - root))))) > - ('nil nil) > - (_ (ignore-errors (vc-call-backend backend 'root dir))))) > + (locate-dominating-file > + dir > + (lambda (d) > + (setq last-matches (directory-files d nil marker-re t 100))))) > + (backend > + (cl-find-if > + (lambda (b) > + (member (assoc-default b backend-markers-alist) > + last-matches)) > + vc-handled-backends)) > project) > + (when (and > + (eq backend 'Git) > + project-vc-merge-submodules > + (project--submodule-p root)) > + (let* ((parent (file-name-directory (directory-file-name root)))) > + (setq root (vc-call-backend 'Git 'root parent)))) > (when root > (setq project (list 'vc backend root)) > ;; FIXME: Cache for a shorter time. This is a significant change of the implementation of a public API. Isn't it risky to make such changes on the release branch? But if you are okay with that, it's fine by me.