diff --git a/julia-mode-tests.el b/julia-mode-tests.el index 1b4e990..f15b382 100644 --- a/julia-mode-tests.el +++ b/julia-mode-tests.el @@ -963,6 +963,8 @@ end" 'end-of-defun "n == 0" "return fact(x)[ \n]+end" 'end 2)) (should (equal (julia--call-latexsub-exit-function "\\kappa\\alpha(" 7 13 "\\alpha" t) "\\kappaα(")) + ;; Test that whitespace is stripped from `:exit-function' NAME for compatibility with helm + (should (equal (julia--call-latexsub-exit-function "x\\alpha " 2 8 "\\alpha " t) "xα ")) ;; test that LaTeX not expanded when `julia-automatic-latexsub' is nil (should (equal (julia--call-latexsub-exit-function "\\alpha" 1 7 "\\alpha" nil) "\\alpha")) (should (equal (julia--call-latexsub-exit-function "x\\alpha " 2 8 "\\alpha" nil) "x\\alpha ")) diff --git a/julia-mode.el b/julia-mode.el index 0260046..744515e 100644 --- a/julia-mode.el +++ b/julia-mode.el @@ -910,8 +910,12 @@ buffer where the LaTeX symbol starts." ;; ). Instead of automatic ;; expansion, user can either enable `abbrev-mode' or call `expand-abbrev'. (when-let (((eq status 'finished)) - (symb (abbrev-symbol name julia-latexsub-abbrev-table)) - (end (+ beg (length name)))) + ;; helm-mode passes NAME with an extra whitespace at the end. Since + ;; `julia--latexsub-start-symbol' won't include whitespace, we can safely + ;; strip whitespace. + (clean-name (string-trim-right name)) + (symb (abbrev-symbol clean-name julia-latexsub-abbrev-table)) + (end (+ beg (length clean-name)))) (abbrev-insert symb name beg end))) #'ignore))