Skip to content

Commit 32938fc

Browse files
committed
Implement ability to switch from .purs to .js FFI file
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.
1 parent 421fb28 commit 32938fc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

purescript-mode.el

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
(require 'purescript-string)
3838
(require 'purescript-font-lock)
3939
(require 'cl-lib)
40+
(cl-eval-when 'compile (require 'find-file))
4041

4142
;; All functions/variables start with `(literate-)purescript-'.
4243

@@ -341,7 +342,9 @@ see documentation for that variable for more details."
341342
(set (make-local-variable 'dabbrev-case-replace) nil)
342343
(set (make-local-variable 'dabbrev-abbrev-char-regexp) "\\sw\\|[.]")
343344
(setq-local beginning-of-defun-function 'purescript-beginning-of-defun)
344-
(setq prettify-symbols-alist purescript-font-lock-prettify-symbols-alist)
345+
(setq prettify-symbols-alist purescript-font-lock-prettify-symbols-alist
346+
;; make (ff-find-other-file) find .js FFI file, given .purs
347+
ff-other-file-alist '((".purs\\'" (".js"))))
345348
(when (bound-and-true-p purescript-font-lock-symbols)
346349
(warn "`purescript-font-lock-symbols' is obsolete: please enable `prettify-symbols-mode' locally or globally instead."))
347350
)

0 commit comments

Comments
 (0)