GNU bug report logs - #48747
28.0.50; add project-name generic

Previous Next

Package: emacs;

Reported by: Stephen Leake <stephen_leake <at> stephe-leake.org>

Date: Sun, 30 May 2021 17:40:01 UTC

Severity: wishlist

Found in version 28.0.50

Done: Stephen Leake <stephen_leake <at> stephe-leake.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 48747 in the body.
You can then email your comments to 48747 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#48747; Package emacs. (Sun, 30 May 2021 17:40:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stephen Leake <stephen_leake <at> stephe-leake.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 30 May 2021 17:40:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Stephen Leake <stephen_leake <at> stephe-leake.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50; add project-name generic
Date: Sun, 30 May 2021 10:38:59 -0700
In project.el, add a 'project-name' cl-defgeneric, to be used in prompts
and other situations where the user is asked to identify a project.

It must return a string, which is nominally unique among the user's
various projects.

The default could be 'project-root'.
-- 
-- Stephe




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48747; Package emacs. (Mon, 07 Jun 2021 02:09:02 GMT) Full text and rfc822 format available.

Message #8 received at 48747 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Stephen Leake <stephen_leake <at> stephe-leake.org>, 48747 <at> debbugs.gnu.org
Subject: Re: bug#48747: 28.0.50; add project-name generic
Date: Mon, 7 Jun 2021 05:08:34 +0300
Hi Stephen,

On 30.05.2021 20:38, Stephen Leake wrote:
> In project.el, add a 'project-name' cl-defgeneric, to be used in prompts
> and other situations where the user is asked to identify a project.
> 
> It must return a string, which is nominally unique among the user's
> various projects.
> 
> The default could be 'project-root'.

Would you like to attach a patch that includes the places where we would 
use the new method?

project-prefixed-buffer-name?

I was also thinking project-prompt-project-dir, but we use absolute 
directory names there, so it seems difficult to incorporate, even if we 
agree to rename and update the docstring: the default implementation of 
'project-name' will supposedly be the base name of the root dir, and 
those are not always unique and easy to recognize.

Or, if the default impl returns the absolute directory name, we couldn't 
use it in project-prefixed-buffer-name.




Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Sun, 24 Oct 2021 07:28:04 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48747; Package emacs. (Fri, 15 Jul 2022 11:49:01 GMT) Full text and rfc822 format available.

Message #13 received at 48747 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: Stephen Leake <stephen_leake <at> stephe-leake.org>, 48747 <at> debbugs.gnu.org
Subject: Re: bug#48747: 28.0.50; add project-name generic
Date: Fri, 15 Jul 2022 13:48:02 +0200
Dmitry Gutov <dgutov <at> yandex.ru> writes:

>> In project.el, add a 'project-name' cl-defgeneric, to be used in prompts
>> and other situations where the user is asked to identify a project.
>> It must return a string, which is nominally unique among the user's
>> various projects.
>> The default could be 'project-root'.
>
> Would you like to attach a patch that includes the places where we
> would use the new method?
>
> project-prefixed-buffer-name?

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

This was a year ago, and the original bug report didn't really include a
rationale for the cl-defgeneric.  Stephen, what would you use this for?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 15 Jul 2022 11:49:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48747; Package emacs. (Fri, 15 Jul 2022 13:11:01 GMT) Full text and rfc822 format available.

Message #18 received at 48747 <at> debbugs.gnu.org (full text, mbox):

From: Stephen Leake <stephen_leake <at> stephe-leake.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 48747 <at> debbugs.gnu.org, Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#48747: 28.0.50; add project-name generic
Date: Fri, 15 Jul 2022 06:09:48 -0700
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Dmitry Gutov <dgutov <at> yandex.ru> writes:
>
>>> In project.el, add a 'project-name' cl-defgeneric, to be used in prompts
>>> and other situations where the user is asked to identify a project.
>>> It must return a string, which is nominally unique among the user's
>>> various projects.
>>> The default could be 'project-root'.
>>
>> Would you like to attach a patch that includes the places where we
>> would use the new method?
>>
>> project-prefixed-buffer-name?
>
> (I'm going through old bug reports that unfortunately weren't resolved
> at the time.)
>
> This was a year ago, and the original bug report didn't really include a
> rationale for the cl-defgeneric.  Stephen, what would you use this for?

My wisi package has a menu of defined projects, allowing the user to
choose which one is the "current project"; it shows a project name,
which is currently defined in the wisi project type.

wisi also has a command to delete a project definition, which prompts
for a project, completing on the project name.

eglot needs to identify projects; it currently uses the project root,
which is not always the best way.

The current project.el assumes that projects are only identified by
"project-current" in some buffer, so there isn't anywhere in the current
code that would use this. Adding it is mainly for extensions like wisi
and eglot.

-- 
-- Stephe




Removed tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 12 Aug 2022 15:59:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48747; Package emacs. (Sun, 20 Nov 2022 22:18:01 GMT) Full text and rfc822 format available.

Message #23 received at 48747 <at> debbugs.gnu.org (full text, mbox):

From: Stephen Leake <stephen_leake <at> stephe-leake.org>
To: 48747 <at> debbugs.gnu.org
Subject: add project-name generic
Date: Sun, 20 Nov 2022 14:17:34 -0800
eglot provides a use case:

eglot builds a name for a server using the root directory of the
project - in effect:

(file-name-base (directory-file-name (project-root (project-current))))

That name shows up in the elgot mode line, to tell the user which server
the buffer is connected to, in progress report messages, and in the name
of the EGLOT log buffer, which is useful for debugging things.

If the project root directory happens to have a meaningful name, that's
fine. In my use cases, it's usually not meaningful. For example, I have
two worktrees of my wisitoken project, one for the main branch, one for
a work branch. The eglot names, and the ones I'd like to see, are:

    default     desired
    "build"     "wisitoken main"
    "build"     "wisitoken work"

Similarly, the name for the ada_language_server worktree is:

    "gnat"      "als main"

I could override project-name that in my projects to provide my desired
name, and eglot will use my desired name.

-- 
-- Stephe




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48747; Package emacs. (Sun, 20 Nov 2022 22:58:02 GMT) Full text and rfc822 format available.

Message #26 received at 48747 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Stephen Leake <stephen_leake <at> stephe-leake.org>, 48747 <at> debbugs.gnu.org
Subject: Re: bug#48747: add project-name generic
Date: Mon, 21 Nov 2022 00:57:33 +0200
On 21.11.2022 00:17, Stephen Leake wrote:
> eglot builds a name for a server using the root directory of the
> project - in effect:
> 
> (file-name-base (directory-file-name (project-root (project-current))))
> 
> That name shows up in the elgot mode line, to tell the user which server
> the buffer is connected to, in progress report messages, and in the name
> of the EGLOT log buffer, which is useful for debugging things.
> 
> If the project root directory happens to have a meaningful name, that's
> fine. In my use cases, it's usually not meaningful. For example, I have
> two worktrees of my wisitoken project, one for the main branch, one for
> a work branch. The eglot names, and the ones I'd like to see, are:
> 
>      default     desired
>      "build"     "wisitoken main"
>      "build"     "wisitoken work"
> 
> Similarly, the name for the ada_language_server worktree is:
> 
>      "gnat"      "als main"
> 
> I could override project-name that in my projects to provide my desired
> name, and eglot will use my desired name.

Okay, that sounds good.

But let's please go back to my question: could we use the new generic in 
project-prompt-project-dir? And should we?

If we do, we'll have to default the return value to

  (abbreviate-file-name (project-root pr))

rather than your suggested

  (file-name-base (directory-file-name (project-root pr)))

. Would you say you intend to override project-name a lot? Or do you 
want to take advantage of the shorter default name in most cases?

What do you think about the first option anyway?

OTOH, it's also possible that some Powerline-style mode-line packages 
might want to use this method as well. And it seems they generally 
prefer the latter look because it's more compact. They currently don't 
show such info, though.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48747; Package emacs. (Mon, 21 Nov 2022 19:00:02 GMT) Full text and rfc822 format available.

Message #29 received at 48747 <at> debbugs.gnu.org (full text, mbox):

From: Stephen Leake <stephen_leake <at> stephe-leake.org>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 48747 <at> debbugs.gnu.org
Subject: Re: [SPAM UNSURE] Re: bug#48747: add project-name generic
Date: Mon, 21 Nov 2022 10:59:05 -0800
Dmitry Gutov <dgutov <at> yandex.ru> writes:

> On 21.11.2022 00:17, Stephen Leake wrote:
>
> But let's please go back to my question: could we use the new generic
> in project-prompt-project-dir? And should we?

project-prompt-project-dir used to chose a project, by choosing a root
directory (in project-current, project-forget-project, and
project-switch-project). (that's not guarranteed to be a one-to-one
mapping, but that's a separate issue). It currently completes on a list
of file names.

Those file names come from project-list-file which relies on users or
clients calling project-remember-project.

It might be useful to include the project name in the completion list
for project-prompt-project-dir, but with the default implementation
returning the abbreviated project root it would only duplicate
information already in the completion table.

Instead, we could have project-prompt-project-by-name, which would
complete on project names. The list of names could also be in
project-list file, with a change in format; also maintained by
project-remember-project.

The functions that ask the user to complete on projects would have to
choose which way to do that; there would have to be a
project-prompt-style defcustom for the user to set.

I think a better design would be for the default project-name to return
nil; then project-prompt-project-dir could use names if they are
non-nil, falling back to abbreviated file names if the project name is
nil. That would allow a mix of named and un-named projects. Eglot could
do the same. project-list-file should store the project name.

In that case, project-prompt-project-dir could be renamed to
project-prompt-project.

> If we do, we'll have to default the return value to
>
>   (abbreviate-file-name (project-root pr))
>
> rather than your suggested
>
>   (file-name-base (directory-file-name (project-root pr)))

That's a reasonable choice; it does not work for the eglot use case.
Which argues for the default to be nil.

I'm not clear why you want this to be the default;
project-prompt-project-dir does not currently use abbreviate-file-name
(perhaps it should?).

> Would you say you intend to override project-name a lot? 

I'm not sure what counts as "a lot" here. All wisi projects have a name
provided by the user, and almost all projects I use are wisi projects.
So yes? On the other hand, I don't have plans to write any new projects
that need names. So no?

> Or do you want to take advantage of the shorter default name in most
> cases?

Deriving the project name from the root directory of the project is not
useful in my use cases. Abbreviating does not make it more useful; the
only useful label is the string provided by the user. And I
have situations where the root directory is the same for two projects;
for example, ada_language_server has main and test projects.

So wisi will continue to store a user provided string in a project
object slot; it will override project-name to return that slot.

Transient projects could also store a name as a plist entry in the
project object: '(transient /a/root/dir :name "wisitoken main")

> What do you think about the first option anyway?

I don't follow; what is "the first option"?

-- 
-- Stephe




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48747; Package emacs. (Tue, 22 Nov 2022 02:42:02 GMT) Full text and rfc822 format available.

Message #32 received at 48747 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Stephen Leake <stephen_leake <at> stephe-leake.org>
Cc: 48747 <at> debbugs.gnu.org
Subject: Re: bug#48747: [SPAM UNSURE] Re: bug#48747: add project-name generic
Date: Tue, 22 Nov 2022 04:41:06 +0200
On 21/11/22 20:59, Stephen Leake wrote:
> Dmitry Gutov <dgutov <at> yandex.ru> writes:
> 
>> On 21.11.2022 00:17, Stephen Leake wrote:
>>
>> But let's please go back to my question: could we use the new generic
>> in project-prompt-project-dir? And should we?
> 
> project-prompt-project-dir used to chose a project, by choosing a root
> directory (in project-current, project-forget-project, and
> project-switch-project). (that's not guarranteed to be a one-to-one
> mapping, but that's a separate issue). It currently completes on a list
> of file names.
> 
> Those file names come from project-list-file which relies on users or
> clients calling project-remember-project.

I guess what you might be saying is that the file contains directories 
and not project instances. Thus, going to the project name is a 
non-trivial transition anyway. And for the whole list, potentially costly.

> I think a better design would be for the default project-name to return
> nil; then project-prompt-project-dir could use names if they are
> non-nil, falling back to abbreviated file names if the project name is
> nil. That would allow a mix of named and un-named projects. Eglot could
> do the same. project-list-file should store the project name.

That's a problem: if the default is nil, then for every project the user 
will have to customize it somehow. Otherwise the method is not going to 
be usable. That's not a great workflow from my POV.

If the place where you want to use it in Eglot, currently calls

  (file-name-base (directory-file-name root))

then that is probably the best default after all.

> In that case, project-prompt-project-dir could be renamed to
> project-prompt-project.
> 
>> If we do, we'll have to default the return value to
>>
>>    (abbreviate-file-name (project-root pr))
>>
>> rather than your suggested
>>
>>    (file-name-base (directory-file-name (project-root pr)))
> 
> That's a reasonable choice; it does not work for the eglot use case.
> Which argues for the default to be nil.
> 
> I'm not clear why you want this to be the default;
> project-prompt-project-dir does not currently use abbreviate-file-name
> (perhaps it should?).

Abbreviate or not is a minor detail. Not too important for 
project-prompt-project-dir, but could be more valuable in other 
potential places, such as mode-line, which value compactness.

>> Would you say you intend to override project-name a lot?
> 
> I'm not sure what counts as "a lot" here. All wisi projects have a name
> provided by the user, and almost all projects I use are wisi projects.
> So yes? On the other hand, I don't have plans to write any new projects
> that need names. So no?
> 
>> Or do you want to take advantage of the shorter default name in most
>> cases?
> 
> Deriving the project name from the root directory of the project is not
> useful in my use cases. Abbreviating does not make it more useful; the
> only useful label is the string provided by the user. And I
> have situations where the root directory is the same for two projects;
> for example, ada_language_server has main and test projects.
> 
> So wisi will continue to store a user provided string in a project
> object slot; it will override project-name to return that slot.

That answers my questions, thanks.

> Transient projects could also store a name as a plist entry in the
> project object: '(transient /a/root/dir :name "wisitoken main")

Yes, but, for a transient object, there's nowhere to get the custom name 
from. The user just chooses a directory.

Anyway, I think we can proceed with your original proposal (where the 
default name is the base name of the root directory). Some users of 
project-vc backend will probably want to customize it too, we can add a 
buffer-local variable for that (now or later).




Reply sent to Stephen Leake <stephen_leake <at> stephe-leake.org>:
You have taken responsibility. (Tue, 22 Nov 2022 19:04:01 GMT) Full text and rfc822 format available.

Notification sent to Stephen Leake <stephen_leake <at> stephe-leake.org>:
bug acknowledged by developer. (Tue, 22 Nov 2022 19:04:02 GMT) Full text and rfc822 format available.

Message #37 received at 48747-close <at> debbugs.gnu.org (full text, mbox):

From: Stephen Leake <stephen_leake <at> stephe-leake.org>
To: 48747-close <at> debbugs.gnu.org
Subject: Re: bug#48747: [SPAM UNSURE] Re: bug#48747: add project-name generic
Date: Tue, 22 Nov 2022 11:02:41 -0800
Done in 361297c6f4be54d4699c588937d7ceb142ba99d7
-- 
-- Stephe




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48747; Package emacs. (Tue, 22 Nov 2022 22:21:01 GMT) Full text and rfc822 format available.

Message #40 received at 48747 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: 48747 <at> debbugs.gnu.org, stephen_leake <at> stephe-leake.org
Subject: Re: bug#48747: [SPAM UNSURE] Re: bug#48747: add project-name generic
Date: Wed, 23 Nov 2022 00:20:08 +0200
On 22/11/22 21:02, Stephen Leake wrote:
> Done in 361297c6f4be54d4699c588937d7ceb142ba99d7

Thanks Stephen.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 21 Dec 2022 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 127 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.