[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/d-mode e42c1c1 340/346: Implement r"..." string literal sy
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/d-mode e42c1c1 340/346: Implement r"..." string literal syntax |
Date: |
Sun, 29 Aug 2021 11:00:56 -0400 (EDT) |
branch: elpa/d-mode
commit e42c1c1f967cfe1b916d0a0f05cea2f8b7f29f09
Author: Vladimir Panteleev <git@thecybershadow.net>
Commit: Vladimir Panteleev <git@thecybershadow.net>
Implement r"..." string literal syntax
Use the existing `...` syntax logic for this syntax as well.
---
d-mode.el | 49 ++++++++++++++++++++++++++++++-------------------
1 file changed, 30 insertions(+), 19 deletions(-)
diff --git a/d-mode.el b/d-mode.el
index 404552a..9c5bf23 100644
--- a/d-mode.el
+++ b/d-mode.el
@@ -854,28 +854,39 @@ CONTEXT is as in `c-forward-decl-or-cast-1'."
;;----------------------------------------------------------------------------
;; Borrowed from
https://github.com/josteink/csharp-mode/blob/master/csharp-mode.el
+
+(defmacro d--syntax-propertize-string (open close)
+ (unless (eq (length close) 1)
+ (error "`close' should be a single character"))
+ (let ((syntax-punctuation (string-to-syntax "."))
+ (skip-chars-pattern (concat "^" close "\\\\"))
+ (close-char (elt close 0)))
+ `(progn
+ (goto-char beg)
+ (while (search-forward ,open end t)
+ (let ((in-comment-or-string-p (save-excursion
+ (goto-char (match-beginning 0))
+ (or (nth 3 (syntax-ppss))
+ (nth 4 (syntax-ppss))))))
+ (when (not in-comment-or-string-p)
+ (let (done)
+ (while (and (not done) (< (point) end))
+ (skip-chars-forward ',skip-chars-pattern end)
+ (cond
+ ((eq (following-char) ?\\)
+ (put-text-property (point) (1+ (point))
+ 'syntax-table ',syntax-punctuation)
+ (forward-char 1))
+ ((eq (following-char) ',close-char)
+ (forward-char 1)
+ (setq done t)))))))))))
+
(defun d--syntax-propertize-function (beg end)
"Apply syntax table properties to special constructs in region BEG to END.
-Currently handles `-delimited string literals."
+Handles `...` and r\"...\" WYSIWYG string literals."
(save-excursion
- (goto-char beg)
- (while (search-forward "`" end t)
- (let ((in-comment-or-string-p (save-excursion
- (goto-char (match-beginning 0))
- (or (nth 3 (syntax-ppss))
- (nth 4 (syntax-ppss))))))
- (when (not in-comment-or-string-p)
- (let (done)
- (while (and (not done) (< (point) end))
- (skip-chars-forward "^`\\\\" end)
- (cond
- ((= (following-char) ?\\)
- (put-text-property (point) (1+ (point))
- 'syntax-table (string-to-syntax "."))
- (forward-char 1))
- ((= (following-char) ?\`)
- (forward-char 1)
- (setq done t))))))))))
+ (d--syntax-propertize-string "`" "`")
+ (d--syntax-propertize-string "r\"" "\"")))
;;----------------------------------------------------------------------------
- [nongnu] elpa/d-mode e2b70b7 289/346: tests: New testcase, (continued)
- [nongnu] elpa/d-mode e2b70b7 289/346: tests: New testcase, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode c2f332e 291/346: tests: Add test for c-decl-start-kwds, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode c1f5d0d 298/346: Remove a redundant (or), ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode b4496fc 300/346: Conditionally compile out code for newer Emacs versions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 4b3cf20 305/346: Be more restrictive when recognizing lambdas, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 6624fcb 326/346: Unbreak indentation of access labels, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 1931ec9 330/346: Merge pull request #103 from CyberShadow/pull-20201201-111620, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode daaa518 336/346: Migrate from Travis CI to GitHub Actions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 203ef14 335/346: Don't call easy-menu-add on Emacs 28+, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 80fad30 345/346: Merge pull request #108 from CyberShadow/github-actions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode e42c1c1 340/346: Implement r"..." string literal syntax,
ELPA Syncer <=
- [nongnu] elpa/d-mode dee393b 228/346: Fix setting the mode menu, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode ac898c0 245/346: Fix parsing of scope-statements, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 459732e 243/346: Fix parsing associative arrays in function types, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 362be11 250/346: Fix imenu false positive with e.g. private{...}, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode ea32e73 264/346: Makefile: Test byte-compiled version, too, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 979c946 256/346: Fix testing multiple nested imenu entries, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 8ffe5ac 265/346: Remove doxygen-font-lock-*, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 80f2019 261/346: Don't nest imenu to arbitrary depths, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode bdd5d78 281/346: Replace d-forward-decl-or-cast-1 implementation with a custom one, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 02d1c7f 290/346: tests: Add more binary operation tests, ELPA Syncer, 2021/08/29