Skip to content

Commit 40e6b03

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 4551667 commit 40e6b03

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
@@ -188,6 +175,7 @@ nil."
188175
;;; `jupyter-repl-after-init'
189176

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

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

0 commit comments

Comments
 (0)