From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ergus Newsgroups: gmane.emacs.devel Subject: Re: Project local variables. Date: Sun, 8 Nov 2020 16:21:29 +0100 Message-ID: <20201108152129.cvwisshc2focpbwd@Ergus> References: <20201103194140.cyjy56zgx7757pxx.ref@Ergus> <20201103194140.cyjy56zgx7757pxx@Ergus> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22951"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Emacs-Devel List To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Nov 08 16:22:33 2020 Return-path: Envelope-to: ged-emacs-devel@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 1kbmWX-0005s3-E1 for ged-emacs-devel@m.gmane-mx.org; Sun, 08 Nov 2020 16:22:33 +0100 Original-Received: from localhost ([::1]:54548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kbmWW-0007Zb-Gj for ged-emacs-devel@m.gmane-mx.org; Sun, 08 Nov 2020 10:22:32 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kbmVo-0006rp-WA for emacs-devel@gnu.org; Sun, 08 Nov 2020 10:21:49 -0500 Original-Received: from sonic302-2.consmr.mail.bf2.yahoo.com ([74.6.135.41]:35788) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kbmVm-0007HI-Lu for emacs-devel@gnu.org; Sun, 08 Nov 2020 10:21:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1604848904; bh=kuFTk5DcLKutqqcrmYE0vHyfBk6bb78sdJMH1r8GJ+k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From:Subject; b=bPwV9+oSGimPPmpDttKcwL2Y1i9N4VxAzBVl8psftgX5WYFl5bturZidKbKoZWeMYyUd0WziGLfEIjp92obkfjmOiJj9BpTgMgFHNWd0+KsnYBJ1lnRzOGMxCAjsQ+43LHWmd8LS2Z4chT7DwHqMIw6HXjKSLJp4mLo9oqotlq80Rai6OJLqxlekh/ZBSLT3O+BZUW7rykMy4sr0OoSIW7qzQLGGh6LjP+QbcG1CSlNO3b89QS6DF2WyQVtF4Bu4GpvnJpnBEjhEyGubYbYpy8gbGUqEEvqcBE3tSronw+y3dxmCyUy+RbDzNM6sGvp6ShSyCTsbtHbiMeOfG8JTPQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1604848904; bh=URmgi6JQZFNFWvyGSVc2wCsx+9sYxQI0Du3iPdyIqJi=; h=Date:From:To:Subject; b=mINsspuTSSucj12YmMutgznYp03ad0i6U0bcRrGLIYDlnOrnkEaiaB7OTeuT6zaVX6qYpkzL8wZQF90aao9y0ilpTQEL85ceU19BKTvhmwct66NqruSjs+JwdJ8Vz6IZGcxRnBDR3C53INzXjRBQk+wz4R8CZb9xeLYkL8nv6AzkXe3pPQ8MO0FSJxyN86SNQOenfIKSXbZu9m2eepdU7YLeVDaBja0UQ066BybSGT5T24ML5U2gCj9S9cy4arWTFtk0vYAXRBlexVIf7U85IijrgmycQ6WU7Cm+TA7fkUdOfz59soev87mkoOnumMes/ISPRzY7xTSTq5kbF9oFNg== X-YMail-OSG: fr2LA5QVM1nsFpABwS9tzu67D.3Y8QAZ_VPlNNNYclasEqurLP_wb0L.lzrZhDJ WV4YawFxIC06X5QETm.k4OFFqr59awzR39yPf9c8fBOveQPyhPk5TVQOtmOaGCNt8qL74.Hkcje. cGP8Lh2M6KH6cLFgd7EBPA.CrIkvJ6dYFmQJW0KxEnOSqQmNTrQGWT2jSin6QNvUW392U3eM7hc_ icKuR89LsZm41_r3gS7tB7wUnhscTcSKJWdB2ULmVYMolw5xELGX12ckktaOyOf4VWsy9B83KDLT lMNYbYwouujhnFlAh17GEw7gdi4m_L7BnNE3SrzblQp6DjtpKistIvqHFZGfqL2GhFRF2D5CkLRX zEQ1rH0xhtuyzSLJQQPJZljURyphN6LABY.dcCNr1WlawWI4veUg07T..Bya.uY9VOYY6TD099v3 zsgaSstx.wqLabCL2NL46uOVa9pgcTUTxxMHzaR7LntadLyB7HgcFNYMm1pKquw5zPDft1nV3MlB szxgBQy9lQJmz25dlLW_L3RYXNPth38VPozsbWRC8ORfi.LzgZ_4UKzArJQa4HiKhERNNY77xYxA pvVFA.FOd9nO8z_eP64e.0fMYLvnn7uGOaCUUqrWKIM8Z6UhHO2mpNgqyqjI.J2qQjIGvk.Z3.sA 0jQrQ1PGJvN1ytdQ.aGQJTELPp23gESz.bJmG.7qLhLn8SN6r8vDXItfQmP0Vf5X1vQUGQkHtF9x BmmcIIX7gh1KQvkKtMfI9iI43uZHOXfpEACIvLU1XP9sV2RJyO_4eT8LdDAAJP_VubuvZFPUNF0Z UsCw7zv0Svt8qOYhlbtaEbVUzHNPGps4fiFcGee7bq Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic302.consmr.mail.bf2.yahoo.com with HTTP; Sun, 8 Nov 2020 15:21:44 +0000 Original-Received: by smtp410.mail.bf1.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 62fd4071cebc42c1890ba2e4a7d54401; Sun, 08 Nov 2020 15:21:42 +0000 (UTC) Content-Disposition: inline In-Reply-To: X-Mailer: WebService/1.1.16944 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.aol Apache-HttpAsyncClient/4.1.4 (Java/11.0.8) Received-SPF: pass client-ip=74.6.135.41; envelope-from=spacibba@aol.com; helo=sonic302-2.consmr.mail.bf2.yahoo.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/08 10:21:44 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:258905 Archived-At: Hi: Thanks for replying On Sun, Nov 08, 2020 at 03:48:45AM +0200, Dmitry Gutov wrote: >Hi! > >On 03.11.2020 21:41, Ergus wrote: > > >Something like project-set and project-get could be arranged (or >perhaps just a project-session hash table). But given that the values >won't persist between Emacs sessions, we'd have to consider to use >cases first. > Yes, I was not thinking in variables that persist among sessions; but only in the active session, so initialize them once. Let's say; when a file is open Emacs now checks if it belongs to a project; such a project is detected (AFAIK) looking up for a vc directory like .git or something similar. Is exactly in this case where some environment could be shared/scoped to the current project. In LSP I see that most of the checks are made every time a file is opened; when using ctags it asks every time for the tags file to use instead of reusing "what could be inferred" from the current project information if there are other files open. To persist among session in the worst case we can add some declarations in dir-locals... but I was not thinking on that. > >Two things to consider: the performance of the operation you're trying >to "cache", and the performance of 'project-current'. > >The latter is not "free". And my near-term plan is to make >project-try-vc slower by removing the vc-file-getprop/vc-file-setprop >dance because it can lead to outdated information. Or at least try >that and see which problems that brings. > >In any case, what I'm saying is, 'project-current' on a remote host >might not be fast either. Though it could be cached to at least only >do the search once per user command. > I don't really know how both performance will compare indeed. In general I would expect that looking into the local memory hash-table will be faster that looking in a remote file system among the network for an executable/file or path. Ex: parallel files-systems, slow networks, or experimental boards with slow processors, big processes and so on. I mean; after opening a file, of course a check in the file system will be needed to know if that file is in a current opened project (I use project-root). If it is not, then we need to initialize some things like read the dir-locals, TAGS, look for ctags/gtags/etags executables, tag files, clang files and so on. Else, we don't need to repeat anything. If the project has 3000 files, that saves a lot of overhead opening files and probably in some search engines for completions (I am not really sure if this is actually possible). In my case; when I open many projects at the same time I get completions in one from the other... which is conceptually wrong too. > >Have you tried using (file-remote-p buffer-file-name) as the hash key? > I am using project-root and setting a buffer local variables to use as the key. I set the variable after opening a file (in a hook); the rest of my variables are set lazily... if-set->use else set-and-use. And also added a function hook to check if other files of the same projects remain open when I kill a buffer; else I delete the info from the hash table". >If the operation to be sped up is really (executable-find "cat"), the >result is really project-independent and should only depend on the >host. > Every file I open in one of the projects may share the project-root at least. executable-find will be host dependent, but TAGS file, a build directory, compile_commands.json, root to build or open a shell/vterm, maybe some modes that I want to enable temporally for this project (ex: lsp, company, langtool for Latex). >If there are other, actually project-dependent examples, the >project-local variables (or "session cache", rather) could be >implemented as a hash of hashes, keyed by project instance. There >implementation seems like it will be rather trivial, but first I would >like to know the use cases. > Se above; maybe this is not enough to justify the implementation of a new level of scopes in emacs; I am just mentioning the use cases I had in mind and facing very often.