branch: elpa/julia-mode commit d74b8a311c4eac92bea3a3998343e02711d54f1f Author: Wilfred Hughes <m...@wilfred.me.uk> Commit: Yichao Yu <yyc1...@gmail.com>
Use the syntax table to detect if point is in a comment. This fixes #8538, where `julia-comment-open` was getting confused by strings inside comments. It also generalises `julia-in-comment` to handle multi-line comments. --- julia-mode.el | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/julia-mode.el b/julia-mode.el index d3932ce..cb66002 100644 --- a/julia-mode.el +++ b/julia-mode.el @@ -189,24 +189,10 @@ (or (equal item (car lst)) (julia-member item (cdr lst))))) -(if (not (fboundp 'evenp)) - (defun evenp (x) (zerop (% x 2)))) - -(defun julia-find-comment-open (p0) - (if (< (point) p0) - nil - (if (and (equal (char-after (point)) ?#) - (evenp (julia-strcount - (buffer-substring p0 (point)) ?\"))) - t - (if (= (point) p0) - nil - (progn (backward-char 1) - (julia-find-comment-open p0)))))) - (defun julia-in-comment () - (save-excursion - (julia-find-comment-open (line-beginning-position)))) + "Return non-nil if point is inside a comment. +Handles both single-line and multi-line comments." + (nth 4 (syntax-ppss))) (defun julia-strcount (str chr) (let ((i 0)