[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/julia-mode 36aa038 181/352: Fix julia-in-brackets so it is
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/julia-mode 36aa038 181/352: Fix julia-in-brackets so it isn't confused by strings, characters or comments. |
Date: |
Sun, 29 Aug 2021 11:22:40 -0400 (EDT) |
branch: elpa/julia-mode
commit 36aa03807e798e85b6675ab019d68285ca4f2ecb
Author: Wilfred Hughes <me@wilfred.me.uk>
Commit: Yichao Yu <yyc1992@gmail.com>
Fix julia-in-brackets so it isn't confused by strings, characters or
comments.
---
julia-mode.el | 34 ++++++++++++++++++++++------------
1 file changed, 22 insertions(+), 12 deletions(-)
diff --git a/julia-mode.el b/julia-mode.el
index efbc9df..89216a9 100644
--- a/julia-mode.el
+++ b/julia-mode.el
@@ -35,6 +35,8 @@
;;; Code:
+(require 'cl) ;; incf, decf, plusp
+
(defvar julia-mode-hook nil)
(defvar julia-basic-offset)
@@ -258,19 +260,27 @@ Handles both single-line and multi-line comments."
(looking-at julia-char-regex))
nil))))))
-(defun julia-strcount (str chr)
- (let ((i 0)
- (c 0))
- (while (< i (length str))
- (if (equal (elt str i) chr)
- (setq c (+ c 1)))
- (setq i (+ i 1)))
- c))
-
(defun julia-in-brackets ()
- (let ((before (buffer-substring (line-beginning-position) (point))))
- (> (julia-strcount before ?[)
- (julia-strcount before ?]))))
+ "Return non-nil if point is inside square brackets."
+ (let ((start-pos (point))
+ (open-count 0))
+ ;; Count all the [ and ] characters on the current line.
+ (save-excursion
+ (beginning-of-line)
+
+ (while (< (point) start-pos)
+ ;; Don't count [ or ] inside strings, characters or comments.
+ (unless (or (julia-in-string) (julia-in-char) (julia-in-comment))
+
+ (when (looking-at (rx "["))
+ (incf open-count))
+ (when (looking-at (rx "]"))
+ (decf open-count)))
+
+ (forward-char 1)))
+
+ ;; If we've opened more than we've closed, we're inside brackets.
+ (plusp open-count)))
(defun julia-at-keyword (kw-list)
"Return the word at point if it matches any keyword in KW-LIST.
- [nongnu] elpa/julia-mode a95b06b 252/352: Merge pull request #20 from tpapp/indent-export, (continued)
- [nongnu] elpa/julia-mode a95b06b 252/352: Merge pull request #20 from tpapp/indent-export, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 847908e 249/352: Add indent for import and export., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 7b1d3fb 253/352: Merge pull request #21 from kshramt/python-paren-indent, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode f591c6d 275/352: Merge pull request #41 from rfourquet/rf/where-return, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 8449c95 295/352: Merge pull request #69 from emmt/master, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 47d2fb0 282/352: Merge pull request #51 from non-Jedi/arg-list, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode e27e6d2 290/352: fix compilation error, silence byte-compiler warnings in emacs>23, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 7102542 304/352: fix tests, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 646f758 156/352: Don't skip over end keywords., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 11e3904 176/352: Backporting regexp-opt functionality to Emacs 23., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 36aa038 181/352: Fix julia-in-brackets so it isn't confused by strings, characters or comments.,
ELPA Syncer <=
- [nongnu] elpa/julia-mode d7a7607 184/352: Make julia-last-open-block-pos a pure function that only returns the position., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 3597e9a 186/352: Comment improvements., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 6603c79 190/352: rename Uint -> UInt in contrib files for syntax highlighting, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode f3f2ad1 198/352: Highlight triple quoted strings., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 65cfc0d 201/352: julia-mode.el: add a bunch of builtin types, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode fabafad 200/352: julia-mode.el: improve matching of function assignment syntax, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 4b41b85 207/352: julia-mode.el: `f(x) == something` does not define a function, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode a37d541 214/352: Changed input from TeX mode to use Julia unicode input, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 2e72a0b 213/352: Removed (setq comint-proccess-echoes t) from contrib/julia-mode.el, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 716d58c 217/352: Added autoload cookie to inferior-julia function in contrib/julia-mode.el, ELPA Syncer, 2021/08/29