Skip to content

Implement ability to switch from .purs to .js FFI file #22

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

Conversation

Hi-Angel
Copy link
Member

@Hi-Angel Hi-Angel commented Oct 7, 2024

Emacs provides a (ff-find-other-file nil t) function to switch between header and implementations. The closest PureScript has to such idea is the FFI, where given Foo.purs there has to be similarly named Foo.js, and unsurprisingly I keep pressing a keybind trying to switch between them.

So add the mapping from .purs to .js.

Worth noting that this doesn't provide the reverse mapping .js → .purs because js is a different major mode and we can't be making assumptions on whether it's related to PureScript… Usually. We probably could reassign in case the js file was open by the ff-find-other-file, but let's keep it simple for now.

@Hi-Angel Hi-Angel force-pushed the impl-ability-so-switch-to-js-ffi branch from 3ff2fde to 00076da Compare October 7, 2024 19:34
(setq prettify-symbols-alist purescript-font-lock-prettify-symbols-alist)
(setq prettify-symbols-alist purescript-font-lock-prettify-symbols-alist
;; make (ff-find-other-file) find .js FFI file, given .purs
ff-other-file-alist '((".purs$" (".js"))))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ff-other-file-alist '((".purs$" (".js"))))
ff-other-file-alist '((".purs\\'" (".js"))))

End-of-string match should be preferred to end-of-line match for filenames, as in auto-mode-alist.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you, done!

Emacs provides a `(ff-find-other-file nil t)` function to switch
between header and implementations. The closest PureScript has to such
idea is the FFI, where given `Foo.purs` there has to be similarly
named `Foo.js`, and unsurprisingly I keep pressing a keybind trying to
switch between them.

So add the mapping from `.purs` to `.js`.

Worth noting that this doesn't provide the reverse mapping `.js →
.purs` because js is a different major mode and we can't be making
assumptions on whether it's related to PureScript… Usually. We
probably could reassign in case the js file was open by the
`ff-find-other-file`, but let's keep it simple for now.
@Hi-Angel Hi-Angel force-pushed the impl-ability-so-switch-to-js-ffi branch from 00076da to 32938fc Compare December 9, 2024 19:36
@purcell purcell merged commit ec8409e into purescript-emacs:master Dec 10, 2024
10 checks passed
@purcell
Copy link
Member

purcell commented Dec 10, 2024

Great, thanks!

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.

2 participants