* bug#47168: 28.0.50; Infinite recursion in project-root
@ 2021-03-15 17:04 Juri Linkov
2021-03-17 2:47 ` Dmitry Gutov
0 siblings, 1 reply; 4+ messages in thread
From: Juri Linkov @ 2021-03-15 17:04 UTC (permalink / raw)
To: 47168
When for some reason the argument of 'project-root' becomes nil,
for example, when the current buffer is not under version control,
then
(project-root (project-current))
goes into infinite recursion:
Debugger entered--Lisp error: (error "Lisp nesting exceeds ‘max-lisp-eval-depth’")
project-root(nil)
project-roots(nil)
...
project-root(nil)
project-roots(nil)
...
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#47168: 28.0.50; Infinite recursion in project-root
2021-03-15 17:04 bug#47168: 28.0.50; Infinite recursion in project-root Juri Linkov
@ 2021-03-17 2:47 ` Dmitry Gutov
2021-03-17 3:54 ` Stefan Monnier
0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Gutov @ 2021-03-17 2:47 UTC (permalink / raw)
To: Juri Linkov, 47168, Stefan Monnier
Hi Juri,
On 15.03.2021 19:04, Juri Linkov wrote:
> When for some reason the argument of 'project-root' becomes nil,
> for example, when the current buffer is not under version control,
> then
>
> (project-root (project-current))
>
> goes into infinite recursion:
>
> Debugger entered--Lisp error: (error "Lisp nesting exceeds ‘max-lisp-eval-depth’")
> project-root(nil)
> project-roots(nil)
> ...
> project-root(nil)
> project-roots(nil)
> ...
Note that the right way to write this code is either
(project-root (project-current t))
or
(when-let ((project (project-current)))
(project-root project))
so we only see this when the programmer failed to account for the
absence of current project.
Still, it would be nice to never show a backtrace like this, even in
those cases.
The idea here was to keep compatibility with backends which implement
project-roots and not project-root (perhaps the built-in vc backend in
Emacs 27), as well as let the clients call either project-root or
project-roots, also for backward compatibility purposes. Worst case, we
can give up on that and require all 3rd party code standardize on
project-root and have all users install the latest project.el from ELPA.
But perhaps we still can have it both ways?
Stefan, any chance there's a relatively non-dirty way we can check
whether there is a non-default implementation for the generic function
with given args, before calling it? That would allow us to break recursion.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#47168: 28.0.50; Infinite recursion in project-root
2021-03-17 2:47 ` Dmitry Gutov
@ 2021-03-17 3:54 ` Stefan Monnier
2021-03-17 16:51 ` Dmitry Gutov
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2021-03-17 3:54 UTC (permalink / raw)
To: Dmitry Gutov; +Cc: 47168, Juri Linkov
> Stefan, any chance there's a relatively non-dirty way we can check whether
> there is a non-default implementation for the generic function with given
> args, before calling it?
Not really, no. We could refrain from providing a default
implementation, and instead add a method to `cl-no-next-method` or
something like that, but I'm not sure it would make much difference.
> That would allow us to break recursion.
But we could use some dynamically-scoped
`project--within-roots-fallback` variable to break such recursion ;-)
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-03-17 16:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-15 17:04 bug#47168: 28.0.50; Infinite recursion in project-root Juri Linkov
2021-03-17 2:47 ` Dmitry Gutov
2021-03-17 3:54 ` Stefan Monnier
2021-03-17 16:51 ` Dmitry Gutov
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.