bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#50499: 28.0.50; project.el: Root of current project


From: Augusto Stoffel
Subject: bug#50499: 28.0.50; project.el: Root of current project
Date: Fri, 10 Sep 2021 18:08:52 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

On Fri, 10 Sep 2021 at 15:16, Dmitry Gutov <dgutov@yandex.ru> wrote:

> On 10.09.2021 08:26, Augusto Stoffel wrote:
>> I guess most uses of `project-root' will be of the form
>>      (when-let ((p (project-current)))
>>         (project-root p))
>> Or at least this is true in the case of an user who is quickly
>> defining
>> a shortcut command in their config.
>> Wouldn't it make sense to make the PROJECT argument of
>> `project-root'
>> optional, giving the above result when omitted?
>
> Given the way it this works, it would need to be a helper function.

Okay, introducing a new name is probably not worth the trouble for such
a small benefit.  Only if it was possible/easy to overload the existing
function (and make it analogous the typical “&optional BUFFER” kind of
argument) would there be a gain in it, I think.

>
> IIUC cl-defmethod does not support default values for arguments, and
> if it did, we'd have to have an implementation of project-root, etc,
> for nil argument. Which is a bad idea because someone else might not
> want to simply do nothing when there is no project found, and our type
> system would then fail to help them notice that.
>
> I don't mind adding said helper (naming suggestions welcome), but the
> way things work now seems fine to me already. Either you have:
>
>   (project-root (project-current t))
>
> where there is no risk of returning nil, and thus no need for when-let,
> or you call (project-current) first, check it for nil, and then
> _probably_ use some other fallbacks. If you don't have fallbacks, then
> the other approach seems better, no?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]