From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: Add cl-defgeneric project-name; first use case eglot Date: Mon, 28 Nov 2022 03:21:07 +0200 Message-ID: References: <86zgcll1le.fsf@stephe-leake.org> <83a64k4fru.fsf@gnu.org> <87h6yrxqga.fsf@gmail.com> <0d0c80fa-7db1-be68-0dba-a9dd466d34d5@yandex.ru> <87pmd8i6ae.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23723"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Cc: Eli Zaretskii , Stephen Leake , emacs-devel@gnu.org, joaotavora@gmail.com To: =?UTF-8?Q?K=c3=a9vin_Le_Gouguec?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Nov 28 02:21:46 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 1ozSq8-0005sz-Gg for ged-emacs-devel@m.gmane-mx.org; Mon, 28 Nov 2022 02:21:44 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ozSph-0004bM-HQ; Sun, 27 Nov 2022 20:21:17 -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 1ozSpf-0004Zp-5r for emacs-devel@gnu.org; Sun, 27 Nov 2022 20:21:15 -0500 Original-Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ozSpc-0003qJ-PE; Sun, 27 Nov 2022 20:21:14 -0500 Original-Received: by mail-wr1-x435.google.com with SMTP id bs21so14502786wrb.4; Sun, 27 Nov 2022 17:21:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=qHFS1Q15KUctCX+W7LeJTmBVnfrwgJ+acytjEl6F5qE=; b=MODZOQPZSMEO44Sr5uM1hY9cCRXtfi2uDOcPJ0QEDe/4boHHGLv7/q0J2PtvlHnvJ4 kvFngq+HVPgMLOiqnXg4bTcvMlLnl9ZYtx3IoocBhHNqjwDnmjOrRfPriVSXkKjN2GUy tT67kYTP3yn0oMfhrK/q3fndB/8hu5RCOXBIoL3EFVh7ozIX1UqpLaDJqVpuNVpj2nAE OYPqamrfuyLmnpZJIt5+26pHVTU2gOGKXwAr0SdTLDIu5yyYtqv2XWwCjlA+9YGfG9zt 2zSMby8ZgT76IK6cur7TmbhnnurMqvZbi8MSNs2Mfb1Gs7cxvR1wPLPLD1UJ21iB5xbk Jy9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qHFS1Q15KUctCX+W7LeJTmBVnfrwgJ+acytjEl6F5qE=; b=DrV/XfNm+U+XrUsSTfPjvExOG38JUGduvVhNTSy7UbwlYgBQFyRTfXQBiu7zCk3f3I fNE8yMsr/DUSPoBEsLridxW2sxk4oWOJHaYNRCsSOfWJ/LmtXbOyLUxlxah79eMDB6NN hCx7ae+5/ep2Ga9VjxRck0Zdh9g6DK4R3xTmR8qx0AQD6I4smJsZUOPpCnhDrMc1F0+U cKZpEs3OlfINBmQk95yQ2x3WlLEIuCiEdBJqtbKQqq/rxdYLggAV1qlwHMUS82jlvMCq ujEZyfYDt9ZxennxrHQ1JbIucuCCqMoN7LfM04eu9lLC+TAnyPgpIHTE7nGOBPtp80jC +JOA== X-Gm-Message-State: ANoB5pmSRVBHuhVAbgo38SVjgJ5vzH6HJFB4mihMxpaCNiAoe02ipdtW 3rE4ck8CETAPnIv+DxbHTvo= X-Google-Smtp-Source: AA0mqf6v5rv8UwEC8Ac6r+6iDbxqz8P+IQSQ8mx2s50SeAlyqj7bmVDViPQa4iYi+uBkaBiF0NyQJg== X-Received: by 2002:adf:d0c4:0:b0:242:cc3:d5ac with SMTP id z4-20020adfd0c4000000b002420cc3d5acmr4827637wrh.218.1669598470063; Sun, 27 Nov 2022 17:21:10 -0800 (PST) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id m24-20020a05600c3b1800b003cf47556f21sm19345694wms.2.2022.11.27.17.21.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 27 Nov 2022 17:21:09 -0800 (PST) Content-Language: en-US In-Reply-To: <87pmd8i6ae.fsf@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=raaahh@gmail.com; helo=mail-wr1-x435.google.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, NICE_REPLY_A=-0.257, RCVD_IN_DNSWL_NONE=-0.0001, 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.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:300658 Archived-At: On 27/11/22 20:47, Kévin Le Gouguec wrote: >> Not sure if this way will be to your liking, but it's the most >> straightforward. Though I suppose we could also make this variable take an alist >> value, associating root dirs with names. > > Thanks! So to recap, IIUC now users have a couple of ways to control > how projects are named: > > (1) Coding up their own project-name defmethod; AFAIU this is what > Stephen has in mind, when he talked about overriding the default > implementation? > > Not very familiar with generic functions yet, so currently going through > "(elisp) Generic Functions" to better understand the mechanics. > > ( > Thoughts after experimenting for 5 minutes: my first instinct was to > specialize methods by regex-matching on (project-root project), but > that doesn't seem straightforward to do. AFAICT the defmethod ARGS > are not in scope when &context EXPR forms are evaluated? So I can't > use &context as an "escape hatch" to string-match-p on (project-root > project). > > IIUC I could define my own "regex" specializer with > cl-generic-generalizers? No idea how judicious that is. > ) I suppose you could just write your own override form (copying either the default definition, or the specialized one -- e.g. for (head vc)), and if you make sure it's evaluated after project.el, you'll use the updated definition. > (2) Through the project-vc-name variable you introduced, using either > .dir-locals.el files or directory classes. > > > (Neither here nor there, but: I was surprised to see project-name go in > master "so soon"; OT1H I realize that some discussion had already > happened in bug#48747, OTOH I wouldn't have expected this feature to be > committed before the emacs-29 branch was cut, since that pretty much > "cements" the current design, to some extent?) It's been a long-requested feature, and I haven't seen many comments or alternative suggestions. If you find problems, especially conceptual ones, please don't hesitate to report. Also, for a :core package, using parallel branches for development is a pain. >>> [… KLG: lots of my vaporware elided …] >> >> Cool. Hopefully the performance of 'project-current' won't make any of these >> applications unfeasible (like the mode-line which has to refresh after every >> change in any buffer, every keypress, etc). > > Hopefully 🤞 As an anecdata point, I've had project-current in my > frame-title-format for years, with no ill effects. > > (<87h7vy9wrv.fsf@gmail.com> is the only time I remember experiencing any > kind of impact, and you dealt with it swiftly enough 🙇) Nice! Good to hear that. >>> ISTM those look like "use-cases" for teaching project.el about "project >>> names" untangled from project root paths. I'd make use of that feature, >>> regardless of what Eglot does. >>> (Can't say whether a defgeneric is the most suited technical answer; >>> FWIW I'd expect my project-naming code to look at various things, >>> e.g. the project path, the repo's upstream URL, the current branch. Not >>> sure it matters much to me whether we use a defgeneric or a >>> project-name-function, but then I'm not very familiar with generics) >> >> The general design is we leave it up to the project implementations how to >> implement things internally. E.g. Projectile might already have its own way to >> specify the name. So we don't have any global vars which affect what all >> projects do. > > (Noted; if anything, that's one more reason for me to get around to > learning generics) Writing a new project backend might not be a best idea for everyone, though, especially if you only wanted to tweak one thing. So if you don't find a comfortable enough way to customize project-name's logic, we can still plug in a var somewhere. E.g. either introduce a project-name-default-function, or allow project-vc-name to be set to a function as well.