Skip to content

Commit

Permalink
Merge pull request #43 from tpapp/tp/activate-prefix
Browse files Browse the repository at this point in the history
add activation option for home project
  • Loading branch information
tpapp authored Sep 23, 2018
2 parents 0f85f2c + 5744563 commit d8b94c6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ If you want to use a Julia executable other than `julia` in your path, see [belo
| `C-c C-m` | expand macro |
| `C-c C-p` | change directory to that of the buffer |
| `C-c C-a` | activate if there is a `Project.toml` in parent directories |
| `C-u C-c C-a` | activate home project |

All actions that send something to the REPL terminate with a **newline**, triggering evaluation. If you want to avoid sending a newline (eg maybe because you want to edit an expression), use prefix arguments (`C--` or `C-u`, currently both have the same effect). This of course does not apply to `C-c C-b`.

Expand Down
32 changes: 19 additions & 13 deletions julia-repl.el
Original file line number Diff line number Diff line change
Expand Up @@ -524,19 +524,25 @@ this with a prefix argument ARG."
(julia-repl--send-string (concat "cd(\"" (file-name-directory filename) "\")"))
(warn "buffer not associated with a file")))

(defun julia-repl-activate-parent ()
"Look for a project file in the parent directories, if found, activate the project."
(interactive)
(cl-flet ((find-projectfile (filename)
(locate-dominating-file (buffer-file-name) filename)))
(if-let ((projectfile (or (find-projectfile "Project.toml")
(find-projectfile "JuliaProject.toml"))))
(progn
(message "activating %s" projectfile)
(julia-repl--send-string
(concat "import Pkg; Pkg.activate(\""
(expand-file-name (file-name-directory projectfile)) "\")")))
(message "could not find project file"))))
(defun julia-repl-activate-parent (arg)
"Look for a project file in the parent directories, if found, activate the project.
When called with a prefix argument, activate the home project."
(interactive "P")
(if arg
(progn
(message "activating home project")
(julia-repl--send-string "import Pkg; Pkg.activate()"))
(cl-flet ((find-projectfile (filename)
(locate-dominating-file (buffer-file-name) filename)))
(if-let ((projectfile (or (find-projectfile "Project.toml")
(find-projectfile "JuliaProject.toml"))))
(progn
(message "activating %s" projectfile)
(julia-repl--send-string
(concat "import Pkg; Pkg.activate(\""
(expand-file-name (file-name-directory projectfile)) "\")")))
(message "could not find project file")))))

;;;###autoload
(define-minor-mode julia-repl-mode
Expand Down

0 comments on commit d8b94c6

Please sign in to comment.