branch: elpa/julia-mode
commit 4d2047666fea43e053ead0c5501781b08520bd98
Author: Adam Beckmeyer <[email protected]>
Commit: Adam Beckmeyer <[email protected]>
Remove old latexsub implementation
---
julia-mode-tests.el | 44 +++++++++++++++++++++++++++++++++-----------
julia-mode.el | 30 +-----------------------------
2 files changed, 34 insertions(+), 40 deletions(-)
diff --git a/julia-mode-tests.el b/julia-mode-tests.el
index 72314a6dc4..ba4b488566 100644
--- a/julia-mode-tests.el
+++ b/julia-mode-tests.el
@@ -880,25 +880,47 @@ return fact(x)
end" 'end-of-defun "n == 0" "return fact(x)[ \n]+end" 'end 2))
;;;
-;;; substitution tests
+;;; latex completion tests
;;;
-(defun julia--substitute (contents position)
- "Call LaTeX subsitution in a buffer with `contents' at point
-`position', and return the resulting buffer."
+(defun julia--find-latex (contents position)
+ "Find bounds of LaTeX symbol in CONTENTS with point at POSITION."
(with-temp-buffer
(julia-mode)
(insert contents)
(goto-char position)
- (julia-latexsub)
+ (cons (julia-mode--latexsub-start-symbol)
(julia-mode--latexsub-end-symbol))))
+
+(ert-deftest julia--test-find-latex ()
+ (should (equal (julia--find-latex "\\alpha " 7) (cons 1 7)))
+ (should (equal (julia--find-latex "\\alpha " 3) (cons 1 7)))
+ (should (equal (julia--find-latex "x\\alpha " 8) (cons 2 8)))
+ (should (equal (julia--find-latex "x\\alpha " 3) (cons 2 8)))
+ ;; There is no valid substitution for \alpha(, but there could
+ ;; be. julia-mode-latexsub-completion-at-point-before will still
+ ;; give correct completion in this situation.
+ (should (equal (julia--find-latex "\\kappa\\alpha(" 13) (cons 7 14)))
+ (should (equal (julia--find-latex "\\kappa\\alpha(" 4) (cons 1 7))))
+
+;;;
+;;; abbrev tests
+;;;
+
+(defun julia--abbrev (contents position)
+ "Call `expand-abbrev' in buffer with CONTENTS at POSITION."
+ (with-temp-buffer
+ (julia-mode)
+ (abbrev-mode)
+ (insert contents)
+ (goto-char position)
+ (expand-abbrev)
(buffer-string)))
-(ert-deftest julia--test-substitutions ()
- (should (equal (julia--substitute "\\alpha " 7) "α "))
- (should (equal (julia--substitute "x\\alpha " 8) "xα "))
- (should (equal (julia--substitute "\\kappa\\alpha(" 13) "\\kappaα("))
- (should (equal (julia--substitute "\\alpha" 7) "α"))
- ; (should (equal (julia--substitute "\\alpha" 6) "α")) ; BROKEN
+(ert-deftest julia--test-latex-abbrev ()
+ (should (equal (julia--abbrev "\\alpha " 7) "α "))
+ (should (equal (julia--abbrev "x\\alpha " 8) "xα "))
+ (should (equal (julia--abbrev "\\kappa\\alpha(" 13) "\\kappaα("))
+ ; (should (equal (julia--abbrev "\\alpha(" 6) "α")) ; BROKEN
)
;;; syntax-propertize-function tests
diff --git a/julia-mode.el b/julia-mode.el
index 21efc27913..c367e5cada 100644
--- a/julia-mode.el
+++ b/julia-mode.el
@@ -786,31 +786,6 @@ strings."
(define-key julia-mode-map (kbd "<backtab>") 'julia-manual-deindent)
;; (See Julia issue #8947 for why we don't use the Emacs tex input mode.)
-(defun julia-latexsub ()
- "Perform a LaTeX-like Unicode symbol substitution."
- (interactive "*i")
- (let ((orig-pt (point)))
- (while (not (or (bobp) (= ?\\ (char-before))
- (= ?\s (char-syntax (char-before)))))
- (backward-char))
- (if (and (not (bobp)) (= ?\\ (char-before)))
- (progn
- (backward-char)
- (let ((sub (gethash (buffer-substring (point) orig-pt)
julia-mode-latexsubs)))
- (if sub
- (progn
- (delete-region (point) orig-pt)
- (insert sub))
- (goto-char orig-pt))))
- (goto-char orig-pt))))
-
-(defun julia-latexsub-or-indent (arg)
- "Either indent according to mode or perform a LaTeX-like symbol substution"
- (interactive "*i")
- (if (julia-latexsub)
- (indent-for-tab-command arg)))
-(define-key julia-mode-map (kbd "TAB") 'julia-latexsub-or-indent)
-
(defun julia-mode--latexsub-start-symbol ()
"Determine the start location for LaTeX-like symbol at point.
If there is not a LaTeX-like symbol at point, return nil."
@@ -898,10 +873,7 @@ following commands are defined:
"Regexp for matching `inferior-julia' prompt.")
(defvar inferior-julia-mode-map
- (let ((map2 (nconc (make-sparse-keymap) comint-mode-map)))
- ;; example definition
- (define-key map2 (kbd "TAB") 'julia-latexsub-or-indent)
- map2)
+ (nconc (make-sparse-keymap) comint-mode-map)
"Basic mode map for `inferior-julia-mode'.")
;;;###autoload