Skip to content

Commit 0b849cb

Browse files
committed
Work with proposed updates to julia-mode LaTeX completion
JuliaEditorSupport/julia-emacs#100 changes LaTeX completion in julia-mode to work by a combination of completion-at-point-function and abbrev-mode. This is the necessary change to give full-featured LaTeX completion with emacs-jupyter julia buffers with the PR in its current form.
1 parent 3322ce7 commit 0b849cb

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

jupyter-julia.el

+17-18
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,10 @@
2929
(eval-when-compile (require 'subr-x))
3030
(require 'jupyter-repl)
3131

32-
(declare-function julia-latexsub-or-indent "ext:julia-mode" (arg))
33-
34-
(cl-defmethod jupyter-indent-line (&context (major-mode julia-mode))
35-
"Call `julia-latexsub-or-indent'."
36-
(call-interactively #'julia-latexsub-or-indent))
32+
(declare-function julia-mode-latexsub-completion-at-point-before
33+
"ext:julia-mode" ())
34+
(declare-function julia-mode-latexsub-completion-at-point-around
35+
"ext:julia-mode" ())
3736

3837
(cl-defmethod jupyter-load-file-code (file &context (jupyter-lang julia))
3938
(format "include(\"%s\");" file))
@@ -68,18 +67,6 @@
6867
(not (memq (char-syntax (char-before (1- beg))) '(?w ?_))))
6968
(setcar prefix (concat ":" (car prefix))))))))))))
7069

71-
(cl-defmethod jupyter-completion-post-completion (candidate
72-
&context (jupyter-lang julia))
73-
"Insert the unicode representation of a LaTeX completion."
74-
(if (eq (aref candidate 0) ?\\)
75-
(when (get-text-property 0 'annot candidate)
76-
(search-backward candidate)
77-
(delete-region (point) (match-end 0))
78-
;; Alternatively use `julia-latexsub-or-indent', but I have found
79-
;; problems with that.
80-
(insert (string-trim (get-text-property 0 'annot candidate))))
81-
(cl-call-next-method)))
82-
8370
;;; `markdown-mode'
8471

8572
(cl-defmethod jupyter-markdown-follow-link (link-text url _ref-label _title-text _bang
@@ -187,6 +174,7 @@ nil."
187174
;;; `jupyter-repl-after-init'
188175

189176
(defun jupyter-julia--setup-hooks (client)
177+
(require 'julia-mode)
190178
(let ((jupyter-inhibit-handlers t))
191179
(jupyter-send-execute-request client
192180
:store-history nil
@@ -207,7 +195,18 @@ if !isdefined(Main, :__JUPY_saved_dir)
207195
IJulia.push_posterror_hook(popdir)
208196
IJulia.push_postexecute_hook(popdir)
209197
end
210-
end")))
198+
end"))
199+
(add-hook 'completion-at-point-functions
200+
#'julia-mode-latexsub-completion-at-point-before nil t)
201+
(add-hook 'completion-at-point-functions
202+
#'julia-mode-latexsub-completion-at-point-around nil t)
203+
(define-abbrev-table 'jupyter-julia-abbrev-table ()
204+
"Abbrev table for IJulia kernel with jupyter."
205+
:parents (list julia-latexsub-abbrev-table))
206+
(setq local-abbrev-table jupyter-julia-abbrev-table)
207+
(when julia-force-tab-complete
208+
(setq-local tab-always-indent 'complete)
209+
(abbrev-mode 1)))
211210

212211
(cl-defmethod jupyter-repl-after-init (&context (jupyter-lang julia))
213212
(add-function

0 commit comments

Comments
 (0)