Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strip whitespace in latexsub :exit-function #206

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions julia-mode-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -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 "))
Expand Down
8 changes: 6 additions & 2 deletions julia-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -910,8 +910,12 @@ buffer where the LaTeX symbol starts."
;; <https://github.com/abo-abo/swiper/issues/2345>). 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))

Expand Down
Loading