From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Danny Freeman Newsgroups: gmane.emacs.devel Subject: Re: Eglot, project.el, and python virtual environments Date: Sat, 19 Nov 2022 14:17:46 -0500 Message-ID: <87o7t2vj19.fsf@dfreeman.email> References: <87zgcq68zp.fsf@ericabrahamsen.net> <878rkale3l.fsf@dfreeman.email> <4c5f4b07-3df6-d700-83f8-9a9d1b684afc@yandex.ru> <84781346-5b88-2be5-38bb-02696fcf1364@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32982"; mail-complaints-to="usenet@ciao.gmane.io" Cc: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= , Eric Abrahamsen , emacs-devel To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Nov 19 20:31:50 2022 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 1owTZ7-0008Q0-Ka for ged-emacs-devel@m.gmane-mx.org; Sat, 19 Nov 2022 20:31:50 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1owTYI-0007he-Li; Sat, 19 Nov 2022 14:30:58 -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 1owTYC-0007hF-NK for emacs-devel@gnu.org; Sat, 19 Nov 2022 14:30:53 -0500 Original-Received: from out0.migadu.com ([94.23.1.103]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1owTY9-0008Os-QQ for emacs-devel@gnu.org; Sat, 19 Nov 2022 14:30:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dfreeman.email; s=key1; t=1668886246; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=rcjSOZNxZBTqgu70e9JYDECVtgEJ6kz8T/K9nrXu+nE=; b=UhE1jVN07n97CRUdX2atu1/IEqPGhQGrXTDMiYYu8eWpNgQ6I9xthfjl9RGpOgGqkCBr5j BTD5hzxNkrhU2y74hP1y/NAf+JgEPl1ogWtE500ONxjG3I5Z3FMN4nGG+Rq6/MAzhgmfMx DmAkvczSUzZCkxmzdiEDBi/RLAg+apg= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. In-reply-to: <84781346-5b88-2be5-38bb-02696fcf1364@yandex.ru> X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=94.23.1.103; envelope-from=danny@dfreeman.email; helo=out0.migadu.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-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.29 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:300199 Archived-At: Dmitry Gutov writes: > Anyway, this is the problem with the popular recommendation: just add a thing to > 'project-find-functions'. It degrades performance and changes how project commands work too. Does it really change how the project commands work? That is not what I have seen. The special project-find-functions thing only returns a value when eglot is calling `project-current`. This only happens from one function, `eglot--current-project`, which is called infrequently. All other times that function returns nil so project.el falls back to `project-try-vc`. Outside of eglot's one call to `project-current` the special `project-find-functions` thing is only checking a single var for truthyness and returning nil. I don't see how it could adversely impact performance. For reference this is the code I'm talking about: ``` (defun project-find-virtualenv-for-eglot (dir) (when eglot-lsp-context ;; ALWAYS NIL, except when called from `eglot--curent-project` (let ((root (locate-dominating-file dir ".virtualenv"))) (when root (cons 'transient root))))) (add-hook 'project-find-functions #'project-find-virtualenv-for-eglot) ``` -- Danny Freeman