From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?K=C3=A9vin_Le_Gouguec?= Newsgroups: gmane.emacs.devel Subject: Re: Add cl-defgeneric project-name; first use case eglot Date: Tue, 22 Nov 2022 10:56:37 +0100 Message-ID: <87h6yrxqga.fsf@gmail.com> References: <86zgcll1le.fsf@stephe-leake.org> <83a64k4fru.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="38786"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Stephen Leake , emacs-devel@gnu.org, joaotavora@gmail.com To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Nov 22 10:58:25 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 1oxQ2n-0009jv-46 for ged-emacs-devel@m.gmane-mx.org; Tue, 22 Nov 2022 10:58:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oxQ1M-0003Os-VQ; Tue, 22 Nov 2022 04:56:53 -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 1oxQ1G-0003DP-Vr for emacs-devel@gnu.org; Tue, 22 Nov 2022 04:56:49 -0500 Original-Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oxQ1A-0004O7-G4; Tue, 22 Nov 2022 04:56:45 -0500 Original-Received: by mail-wr1-x42a.google.com with SMTP id v1so23831586wrt.11; Tue, 22 Nov 2022 01:56:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=T5QVJYgfGQ+FCv3z/bqtTsXZTJLPjzPTn9mmZ+E1Og4=; b=QaP//P/W7qRWaezuw5yEtjdPlH3SBENGqXKbVOwlC8d3H85wt7fX9PLoJHImVUdVS/ whbUMHE9erQZUZdeW6jjIYQnGYxTM3s1ArjxneqDdABTt86qK70dBN5mJ10wDx2pvOOu +RNan2wMmuGtTqv7lEO5zxFPimNYe24/suJGv9LVqwgS8iWunBDAc9BjkUPzfVMs80MQ vq27z0Yc2nlgGphzV4/+gkBTbVKbs3JZFHoT5qmJCOAQxeBSogcU2kZsM/DqMztNEkcq kwTGtmYEmHXRyQpdREK3CO6gBsp07Xim3O0mtdVtiMSzYQIMWi2ABUTvKKdmD1YCkCTy hcfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=T5QVJYgfGQ+FCv3z/bqtTsXZTJLPjzPTn9mmZ+E1Og4=; b=CYC+L7pSrOEB7oekG70SY3H2ZMpUwjS7f7N4pc2ECQsTV2DnKjgIaUQtv7KGshU3sy j73NvNYX7Ify4k1Eiz81IdK2oNv43P07uXgQnQC8TsHj9GHdXTZUNRuP/g9cRHbQN4wg x8PKo5eMwslbVmmUll5EGNJ8lpYlKk8a/Rs8wXirN2km3SyQsgTXxHxkyRM8DWz+yDAf IQ4RVHqU2ofmoGbjGXZ5/5atf9TnO+xD/hBtH5WU6m094UZzFGN6QGgQLL1ebTGOm+kz GlnwW8vcKI/nlblMvcMBb0NcZUVJStCOMhnctTxAl1TbugGozdavrf6eW8JVd3Z2e68L cmDA== X-Gm-Message-State: ANoB5pnLK9YOUMdMdcrqWH/IHvdHjRdJPIR2BndNvpCOInirQCkycr+q d5wJPtX9q/L0gUsNC0DSQ4g= X-Google-Smtp-Source: AA0mqf6G7xuvcIiiunv2CClN4I/nsitKtgzQLyoDHtBgZXcxpZgbZZL5iLdTJIX4Ex7kd1oivKEZcA== X-Received: by 2002:a05:6000:112:b0:241:d25a:e57b with SMTP id o18-20020a056000011200b00241d25ae57bmr6144539wrx.418.1669110998439; Tue, 22 Nov 2022 01:56:38 -0800 (PST) Original-Received: from amdahl30 ([2a01:e0a:253:fe0:2ef0:5dff:fed2:7b49]) by smtp.gmail.com with ESMTPSA id l18-20020a05600c4f1200b003c6f3f6675bsm23223676wmq.26.2022.11.22.01.56.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 01:56:37 -0800 (PST) In-Reply-To: <83a64k4fru.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 21 Nov 2022 15:07:49 +0200") Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=kevin.legouguec@gmail.com; helo=mail-wr1-x42a.google.com 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, 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:300328 Archived-At: Eli Zaretskii writes: >> From: Stephen Leake >> Cc: Jo=C3=A3o T=C3=A1vora >> Date: Sun, 20 Nov 2022 14:09:49 -0800 [...] >> So I'd like to add a new cl-defgeneric to project.el: >>=20 >> (cl-defgeneric project-name (project) >> "A human-readable name for the project." >> (file-name-base (directory-file-name (project-root project)))) >>=20 >> Then I can override that in my projects, and eglot will use my desired >> name. > > I don't see why the needs of Eglot usage justify another generic in > project.el, or should be solved in project.el to begin with. If Dmitry > wants to add such a generic for his own reasons, with some future > development of project.el in mind, I won't object, of course. FWIW, being able to tell project.el "this project is named foobar, nevermind the path" would help me in a couple of situations: (1) C-x p p emacs TAB is currently rather crowded, because I stuff a lot of things under ~/src/emacs: emacs.git worktrees, elpa.git, upstream repos for *ELPA packages=E2=80=A6 If I could "name" projects such that only emacs.git worktrees included the string "emacs" (rather than all repos under ~/src/emacs), that'd make completion more efficient. (2) I'd like to be able to give nicknames to projects. I could make project-prompt-project-dir use the flex style to match e.g. "fts" to "foo-testsuite", but I can think of other nicknames that wouldn't match (e.g. "xfoo" for "cross-foo"). (3) I'd like to stick (project-name) in my frame-title-format; currently using "(file-name-base (directory-file-name (project-root (project-current))))", but my lack of creativity in worktree naming is biting me in the rear ("ah yes, the =E2=80=9Cmaster=E2=80=9D project =F0=9F= =98=90"). Granted, I would still need to come up with my own logic for more informative project names, but at least I could keep it separate from my frame-title-format logic. E.g. if I had different project-naming conventions for $HOBBIES and $DAYJOB, I could keep frame-title-format in sync everywhere, but give different machines different project-naming code. Granted=C2=B2, I can already define my own indirection layer today; I don't need to wait for project-name to be introduced. (4) Similar itch with Magit buffer names: (info "(magit) Naming Buffers") https://magit.vc/manual/magit.html#Naming-Buffers Being able to stick a (project-name) in there (or a "%p") would be convenient, for the same reasons as frame-title-format: use the same Magit buffer-name config everywhere; keep project-naming logic "workplace-bound". 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) > Otherwise,= it > sounds like the wrong way of solving specific problems: by generalizing t= he > heck out of them. E.g., tomorrow we decide that Eglot shouldn't use the > project name on the mode line, and puff! your solution evaporates.