Skip to content
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

Removing unnecessary dependencies #51

Merged
merged 3 commits into from
Mar 6, 2024

Conversation

phikal
Copy link
Contributor

@phikal phikal commented Oct 27, 2023

The packages f and s are usually not necessary, and can be removed at no cost.

The background for this change is that I'd like to add leam4-mode to NonGNU ELPA, and therefore would like to remove hard dependencies on packages that are not included in the ELPA repositories.

@urkud
Copy link
Member

urkud commented Feb 23, 2024

@bustercopley Could you please have a look at this one? If you approve, then I'll merge it.

@bustercopley
Copy link
Contributor

bustercopley commented Feb 23, 2024

I approve! [Edit: with one minor correction (see review comment)]
Not yet please!

lean4-util.el Outdated Show resolved Hide resolved
lean4-util.el Outdated
@@ -38,16 +36,16 @@ Try to find an executable named `lean4-executable-name' in variable `exec-path'.
On succsess, return path to the directory with this executable."
(let ((root (executable-find lean4-executable-name)))
(when root
(setq lean4-rootdir (f-dirname (f-dirname root))))
(setq lean4-rootdir (file-name-directory (directory-file-name root))))
Copy link
Contributor

@bustercopley bustercopley Feb 23, 2024

Choose a reason for hiding this comment

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

Suggested change
(setq lean4-rootdir (file-name-directory (directory-file-name root))))
(setq lean4-rootdir
(file-name-directory
(directory-file-name
(file-name-directory root)))))

There were two calls to f-dirname! (I don't know why f-parent wasn't used.)

But also: the value should end in a slash since it's going to be used as default-directory later. (This was already incorrect before your changes.) [But not after! 😄]

Copy link
Contributor

Choose a reason for hiding this comment

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

@phikal, can you fix this on your branch and push, please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm sorry, I didn't realise that these was supposed to be "suggested changes".

@bustercopley
Copy link
Contributor

Thanks @phikal! But that's still not quite right.

(let ((root "/path/to/bin/lean.exe"))
  (file-name-directory (file-name-directory (directory-file-name root))))
;; => "/path/to/bin/"

(let ((root "/path/to/bin/lean.exe"))
  (file-name-directory (directory-file-name (file-name-directory root))))
;; => "/path/to/"

It is the latter that is needed here.

@phikal
Copy link
Contributor Author

phikal commented Feb 27, 2024 via email

@bustercopley
Copy link
Contributor

@phikal, no worries. But now there's a typo.

(setq lean4-rootdir ) ;; => (wrong-number-of-arguments setq 1)

Would you mind? Sorry, I'd fix it myself if I could!

@phikal
Copy link
Contributor Author

phikal commented Feb 27, 2024 via email

@bustercopley
Copy link
Contributor

bustercopley commented Feb 27, 2024

Really, don't worry about it. I'm not a maintainer. I don't have permission to edit PRs from other contributors.

Nearly there, I think, but you have

      (setq lean4-rootdir (file-name-directory (directory-file-name (directory-file-name root)))))

It should be

      (setq lean4-rootdir (file-name-directory (directory-file-name (file-name-directory root)))))

@bustercopley
Copy link
Contributor

bustercopley commented Feb 27, 2024

@urkud, with one last change (see my previous comment) this is will be ready to merge, unless you have any suggestions. I have tested each text change and there are no observable behaviour changes.

If possible, will you fetch branch "pr51" from the fork at "https://github.com/bustercopley/lean4-mode", update the PR to that commit (bustercopley@f526315), and merge please? The branch contains Philip's two commits and my fixup commit, rebased onto master.

@phikal
Copy link
Contributor Author

phikal commented Feb 29, 2024 via email

@bustercopley
Copy link
Contributor

Thanks @phikal. Don't be dispirited. It's no big deal.
@urkud, ready to merge to master now, from my point of view

Copy link
Contributor

@akirak akirak left a comment

Choose a reason for hiding this comment

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

I have made a few suggestions to simplify the code.


(defun lean4-lake-find-dir ()
"Find a parent directory of the current file with file \"lakefile.lean\"."
(and (buffer-file-name)
(lean4-lake-find-dir-in (f-dirname (buffer-file-name)))))
(lean4-lake-find-dir-in (directory-file-name (buffer-file-name)))))

This comment was marked as off-topic.

(equal (f-filename file) ".")
(equal (f-filename file) "..")))
(equal (file-name-nondirectory file) ".")
(equal (file-name-nondirectory file) "..")))
(directory-files path t))))

This comment was marked as off-topic.

(let ((lean4-bin-dir-name "bin"))
(f-full (f-join (lean4-get-rootdir) lean4-bin-dir-name exe-name))))
(let ((default-directory (lean4-get-rootdir)))
(expand-file-name exe-name (expand-file-name "bin"))))

This comment was marked as off-topic.

@phikal
Copy link
Contributor Author

phikal commented Feb 29, 2024 via email

@akirak
Copy link
Contributor

akirak commented Feb 29, 2024

I just think they should be relegated to a separate patch.

That's totally fine. My suggestions only depend on built-in functions, but I understand they are beyond the scope of this PR. Please ignore those.

@bustercopley
Copy link
Contributor

Thanks @akirak,
I am inclined to agree, let's play it safe in this PR, especially since @phikal says he is not in a position to test.
There is certainly a lot of tidying up that could be done!

@urkud urkud merged commit f1f24c1 into leanprover-community:master Mar 6, 2024
2 checks passed
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