Skip to content

Commit

Permalink
Add integration with project.el
Browse files Browse the repository at this point in the history
This code is already used by eglot-jl to locate Julia projects and
will be useful in the future for other Julia packages (such as for
REPLs to decide which files they're associated with). Putting it in
the julia-mode package means it doesn't have to be redefined each time
it's used.
  • Loading branch information
non-Jedi committed Mar 23, 2020
1 parent 6e9e60b commit f99e8c0
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion julia-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

(require 'cl-lib)
(require 'julia-mode-latexsubs)
(require 'project nil t)

(defvar julia-mode-hook nil)

Expand Down Expand Up @@ -758,7 +759,14 @@ Return nil if point is not in a function, otherwise point."
(setq-local end-of-defun-function #'julia-end-of-defun)
(setq indent-tabs-mode nil)
(setq imenu-generic-expression julia-imenu-generic-expression)
(imenu-add-to-menubar "Imenu"))
(imenu-add-to-menubar "Imenu")
;; project.el integration
(when (featurep 'project)
(add-hook 'project-find-functions
(lambda (dir)
(let ((root (or (locate-dominating-file dir "JuliaProject.toml")
(locate-dominating-file dir "Project.toml"))))
(when root (cons 'julia root)))))))

(defun julia-manual-deindent ()
"Deindent by `julia-indent-offset' regardless of current
Expand Down Expand Up @@ -819,6 +827,12 @@ following commands are defined:
(if julia-math-mode
(setq-local LaTeX-math-insert-function #'julia-math-insert)))))

;;; project.el integration
;; project.el was added to emacs in 25.1, so we can't assume it's available
(when (featurep 'project)
(cl-defmethod project-roots ((project (head julia)))
(list (cdr project))))

;; Code for `inferior-julia-mode'
(require 'comint)

Expand Down

0 comments on commit f99e8c0

Please sign in to comment.