Skip to content

Refactor lake find dir #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 1, 2025

Conversation

zaz
Copy link
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

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
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
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
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.

(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
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
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
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
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
Collaborator

mekeor commented Jun 1, 2025 via email

@urkud
Copy link
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