branch: elpa/julia-mode commit faee243e6fad50a949da02a8f1a55e1aa5451c54 Author: Wilfred Hughes <m...@wilfred.me.uk> Commit: Yichao Yu <yyc1...@gmail.com>
Implementing julia-in-string and julia-in-char. --- julia-mode.el | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/julia-mode.el b/julia-mode.el index b1cfa67..a5b6d94 100644 --- a/julia-mode.el +++ b/julia-mode.el @@ -222,6 +222,35 @@ This function provides equivalent functionality, but makes no efforts to optimis Handles both single-line and multi-line comments." (nth 4 (syntax-ppss))) +(defun julia-in-string () + "Return non-nil if point is inside a string." + (nth 3 (syntax-ppss))) + +(defun julia-in-char () + "Return non-nil if point is inside a character." + (cond + ((julia-in-comment) nil) + ((julia-in-string) nil) + (:else + (save-excursion + ;; See if point is inside a character, e.g. '|x' + ;; + ;; Move back past the single quote. + (backward-char 1) + ;; Move back one more character, as julia-char-regex checks + ;; for whitespace/paren/etc before the single quote. + (backward-char 1) + + (if (looking-at julia-char-regex) + t + ;; If point was in a \ character (i.e. we started at '\|\'), + ;; we need to move back once more. + (if (looking-at (rx "'\\")) + (progn + (backward-char 1) + (looking-at julia-char-regex)) + nil)))))) + (defun julia-strcount (str chr) (let ((i 0) (c 0))