Skip to content

Refactor lake find dir#100

Merged
urkud merged 5 commits intoleanprover-community:masterfrom
zaz:refactor-lake-find-dir
Jun 1, 2025
Merged

Refactor lake find dir#100
urkud merged 5 commits intoleanprover-community:masterfrom
zaz:refactor-lake-find-dir

Conversation

@zaz
Copy link
Copy Markdown
Contributor

@zaz zaz commented Feb 16, 2025

Fixes

lean4-lake-find-dir-in: Lisp nesting exceeds ‘max-lisp-eval-depth’: 1601

See also Issue #90

zaz added 3 commits February 16, 2025 14:09
to use built-in locate-dominating-file
It is not used anywhere else but `lean4-lake-find-dir`.
@save-buffer
Copy link
Copy Markdown

Any update here from maintainers? I'm also getting bitten by this infinite loop if we're using a lakefile.toml instead of a lakefile.lean!

@mekeor
Copy link
Copy Markdown
Collaborator

mekeor commented May 5, 2025

First of all, thanks for your efforts and the PR.

While I do see that it fixes a problem, I'd prefer to continue my work on work-in-progress PR #96 which aims to reach Milestone Three which includes issue #90, and in particular aims to solve this problem in greater depth.

Of course, I'm just a contributor, and it's the maintainer @urkud who decides.

(when dir
(or (when (file-exists-p (expand-file-name "lakefile.lean" dir)) dir)
(lean4-lake-find-dir-in (file-name-directory (directory-file-name dir))))))
(defun lean4-root-dir-p (dir)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a docstring.

lean4-lake.el Outdated

(defun lean4-lake-find-dir ()
"Find a parent directory of the current file with file \"lakefile.lean\"."
"Find a parent directory of the current file with a \"lakefile.lean\"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first line of a docstring should be a full sentence ending with a full stop.

or \"lakefile.toml\" file."
(and (buffer-file-name)
(lean4-lake-find-dir-in (directory-file-name (buffer-file-name)))))
(locate-dominating-file (buffer-file-name) #'lean4-root-dir-p)))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how long locate-dominating-file takes when you open a Lean source file inside a large Nix or Guix store.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why this should take a long time in any case. You check for existence of 2 files in each of the (grand)parent directories. It's just 2 stats per a (grand)parent.

@urkud
Copy link
Copy Markdown
Member

urkud commented May 5, 2025

Hi, I'm going to apply a quick fix taking code from both branches tonight.

@mekeor mekeor mentioned this pull request May 13, 2025
44 tasks
@urkud
Copy link
Copy Markdown
Member

urkud commented Jun 1, 2025

I'm sorry for the delay. I'm going to wait for CI, then merge it.

@urkud urkud merged commit 1d8d35a into leanprover-community:master Jun 1, 2025
1 check passed
@mekeor
Copy link
Copy Markdown
Collaborator

mekeor commented Jun 1, 2025 via email

@urkud
Copy link
Copy Markdown
Member

urkud commented Jun 1, 2025

Probably, I've misinterpreted the docstring. I'll try running it with strace tonight. I'm sorry about the tone of my comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants