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
Make find-file-at-point support <nixpkgs> #59
Conversation
If STR contains nixpkgs, call nix-instantiate to find the | ||
location of STR." | ||
;; The < > around <nixpkgs> don't get passed to us | ||
(when (string-match "nixpkgs" str) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm... can this be altered to generally match any path within <...>
s? It won't always be <nixpkgs...>
but instead could be almost anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The <
and >
characters don't get passed through to us, unfortunately. So we can't tell if we're inside <> or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can keep the brackets with:
(push '(nix-mode "--:\\\\${}<>+@-Z_[:alpha:]~*?" "@" "@;.,!:") ffap-string-at-point-mode-alist)
After applying this patch locally, I get:
When I call |
I'm not sure why you'd get a warning about nix-instantiate-executable not being defined yet. It's in nix.el, which is required by nix-mode.el It won't work if point is on the |
(let ((file (shell-command-to-string | ||
(concat nix-instantiate-executable " --eval -E '<" str ">'")))) | ||
;; Remove trailing newline | ||
(replace-regexp-in-string "\n$" "" file)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid the regex you can do (substring 0 (- (length file) 1) file)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I guess that kind of breaks when we don't have a trailing new line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
Here is a small modification to the function, feel free to use them:
|
call-process is useful because we can get the exit code of nix-instantiate. |
I think nix-instantiate-executable was added recently so that could be causing problems. The first warning should have been fixed with: |
Merged in 9d4eb7d. Thanks! |
Closes #58
I think this also respects direnv but I don't use it so it would be nice if someone could check.