emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/julia-mode faee243 179/352: Implementing julia-in-string a


From: ELPA Syncer
Subject: [nongnu] elpa/julia-mode faee243 179/352: Implementing julia-in-string and julia-in-char.
Date: Sun, 29 Aug 2021 11:22:40 -0400 (EDT)

branch: elpa/julia-mode
commit faee243e6fad50a949da02a8f1a55e1aa5451c54
Author: Wilfred Hughes <me@wilfred.me.uk>
Commit: Yichao Yu <yyc1992@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))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]