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

using symbol-file can be brittle #147

Closed
MasonProtter opened this issue Feb 29, 2024 · 8 comments
Closed

using symbol-file can be brittle #147

MasonProtter opened this issue Feb 29, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@MasonProtter
Copy link
Contributor

Julia Snail currently uses symbol-file to locate itself, but that seems to cause trouble. E.g.: radian-software/straight.el#1150 (comment)

@gcv
Copy link
Owner

gcv commented Feb 29, 2024

Can you try replacing calls to (symbol-file 'julia-snail) with (find-library-name "julia-snail") and check if that works better?

@MasonProtter
Copy link
Contributor Author

That seems to also not work.

@raxod502
Copy link

raxod502 commented Mar 2, 2024

Why not use load-file-name?

@gcv
Copy link
Owner

gcv commented Mar 3, 2024

@raxod502: Because load-file-name is always nil in development when I'm changing functions and reloading Elisp source buffers. It feels like it might break in other situations.

Based on the documentation quoted in the Straight ticket, I see why symbol-file doesn't work, but I'm far more confused about why find-library-name fails.

Also, with the Straight changes happening, does Snail have to be modified at all to resolve this?

@raxod502
Copy link

raxod502 commented Mar 3, 2024

I typically use (or load-file-name buffer-file-name) when initializing a variable for the location of my library. It seems to handle all cases both in development and production.

I haven't looked into find-library-name at all so I can't comment on that at the moment.

As far as continuing to use symbol-file... I guess if it works, it works, but I would be worried about it failing in the future because (as documented in the Emacs manual), it is not guaranteed to return an actual filepath, and may just return the library name instead.

@gcv
Copy link
Owner

gcv commented Mar 3, 2024

(or load-file-name buffer-file-name) doesn't work (1) when it's used in a function that has been redefined, and (2) called when the current buffer is not the one where it was redefined. It probably works most of the time, but I feel like I'll mess up when using it.

@MasonProtter: It looks like I've also used locate-library for this purpose. Not sure why symbol-file ended up the shipping implementation. I have no clue why find-library-name didn't work for you, or what the difference between locate-library and find-library-name might be. For now, I pushed a change replacing symbol-file with locate-library. It seems to work for me. Please try it and let me know.

@gcv gcv added the bug Something isn't working label Mar 3, 2024
@raxod502
Copy link

(or load-file-name buffer-file-name) doesn't work (1) when it's used in a function that has been redefined, and (2) called when the current buffer is not the one where it was redefined

Right, that's why I define a variable with the value, and then use that variable anywhere I need. It's more performant than scanning load-path at runtime, anyway.

But it is fine either way you prefer to write the code.

@gcv
Copy link
Owner

gcv commented May 20, 2024

Please reopen if this is still something I should look into.

@gcv gcv closed this as completed May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants