GNU bug report logs - #50499
28.0.50; project.el: Root of current project

Previous Next

Package: emacs;

Reported by: Augusto Stoffel <arstoffel <at> gmail.com>

Date: Fri, 10 Sep 2021 05:27:02 UTC

Severity: wishlist

Tags: wontfix

Found in version 28.0.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Augusto Stoffel <arstoffel <at> gmail.com>, 50499 <at> debbugs.gnu.org
Subject: bug#50499: 28.0.50; project.el: Root of current project
Date: Fri, 10 Sep 2021 15:16:56 +0300
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.

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?




This bug report was last modified 2 years and 331 days ago.

Previous Next


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