[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/zig-mode 9bdc960 025/104: Support multiline string literal
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/zig-mode 9bdc960 025/104: Support multiline string literals (#8) |
Date: |
Sun, 29 Aug 2021 11:36:56 -0400 (EDT) |
branch: elpa/zig-mode
commit 9bdc960bbb9d4a79a36e0930f31ef183a8aa16e5
Author: Matthew D. Steele <mdsteele@alum.mit.edu>
Commit: GitHub <noreply@github.com>
Support multiline string literals (#8)
---
zig-mode.el | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/zig-mode.el b/zig-mode.el
index 9172fbc..eeb012c 100644
--- a/zig-mode.el
+++ b/zig-mode.el
@@ -138,6 +138,31 @@
("var" . font-lock-variable-name-face)
("fn" . font-lock-function-name-face)))))
+(defun zig-currently-in-str () (nth 3 (syntax-ppss)))
+(defun zig-start-of-current-str-or-comment () (nth 8 (syntax-ppss)))
+
+(defun zig-syntax-propertize-newline-if-in-multiline-str (end)
+ (when (and (zig-currently-in-str)
+ (save-excursion
+ (goto-char (zig-start-of-current-str-or-comment))
+ (looking-at "\\\\\\\\"))
+ (re-search-forward "\n" end t))
+ (put-text-property (match-beginning 0) (match-end 0)
+ 'syntax-table (string-to-syntax "|"))
+ (goto-char (match-end 0))))
+
+(defun zig-syntax-propertize (start end)
+ (goto-char start)
+ (zig-syntax-propertize-newline-if-in-multiline-str end)
+ (funcall
+ (syntax-propertize-rules
+ ;; Multiline strings
+ ("\\(\\\\\\)\\\\"
+ (1 (prog1 "|"
+ (goto-char (match-end 0))
+ (zig-syntax-propertize-newline-if-in-multiline-str end)))))
+ (point) end))
+
;;;###autoload
(define-derived-mode zig-mode c-mode "Zig"
"A major mode for the zig programming language."
@@ -145,6 +170,7 @@
(set (make-local-variable 'c-syntactic-indentation) nil)
(setq-local comment-start "// ")
(setq-local comment-end "")
+ (setq-local syntax-propertize-function 'zig-syntax-propertize)
(setq font-lock-defaults '(zig-font-lock-keywords)))
;;;###autoload
- [nongnu] branch elpa/zig-mode created (now acf3ee8), ELPA Syncer, 2021/08/29
- [nongnu] elpa/zig-mode 9bdc960 025/104: Support multiline string literals (#8),
ELPA Syncer <=
- [nongnu] elpa/zig-mode b410d5a 031/104: Add AppVeyor config, ELPA Syncer, 2021/08/29
- [nongnu] elpa/zig-mode f26f5d0 033/104: Add "Testing" and "License" sections to README.md, ELPA Syncer, 2021/08/29
- [nongnu] elpa/zig-mode b0eb489 051/104: [+] Guarantee Unix line endings to avoid compiler complaining with DOS carriage return, ELPA Syncer, 2021/08/29
- [nongnu] elpa/zig-mode 32aec72 064/104: Add previous-line doc comments, ELPA Syncer, 2021/08/29
- [nongnu] elpa/zig-mode 8df4efd 078/104: Merge pull request #33 from joachimschmidt557/use-rx, ELPA Syncer, 2021/08/29
- [nongnu] elpa/zig-mode 6a3522f 084/104: Merge pull request #45 from joachimschmidt557/revert-rx, ELPA Syncer, 2021/08/29
- [nongnu] elpa/zig-mode 88b429d 083/104: Merge pull request #46 from travv0/master, ELPA Syncer, 2021/08/29
- [nongnu] elpa/zig-mode 8f59f86 089/104: Implement beginning/end-of-defun, ELPA Syncer, 2021/08/29
- [nongnu] elpa/zig-mode 9ad0ccf 008/104: Indentation is 4 spaces by default., ELPA Syncer, 2021/08/29
- [nongnu] elpa/zig-mode ff0bc79 006/104: Full symbols., ELPA Syncer, 2021/08/29