[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 4c765d93ab3: Refine the previous change
From: |
Dmitry Gutov |
Subject: |
emacs-29 4c765d93ab3: Refine the previous change |
Date: |
Fri, 3 Feb 2023 21:17:13 -0500 (EST) |
branch: emacs-29
commit 4c765d93ab3dd646c1b9722bdd5a91da525d06f2
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
Refine the previous change
* lisp/progmodes/ruby-ts-mode.el (ruby-ts--s-p-query): Fix a typo.
(ruby-ts--syntax-propertize): Use pcase-exhaustive to avoid typos.
Put the last s-t property after heredoc's end (apparently
parse-partial-sexp likes that more). Move first s-t property on
percent literals to the very beginning (to be refined later).
Differentiate the %r{} literals from /.../ ones -- tree-sitter
parses them exactly the same.
---
lisp/progmodes/ruby-ts-mode.el | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el
index 02cc1aad5e6..c0971193244 100644
--- a/lisp/progmodes/ruby-ts-mode.el
+++ b/lisp/progmodes/ruby-ts-mode.el
@@ -1026,7 +1026,7 @@ leading double colon is not added."
;; Backtick method redefinition.
((operator "`" @backtick))
;; TODO: Stop at interpolations.
- ((regex "/" @regex-slash))
+ ((regex "/" @regex_slash))
;; =begin...=end
((comment) @comm
(:match "\\`=" @comm))
@@ -1037,10 +1037,16 @@ leading double colon is not added."
(defun ruby-ts--syntax-propertize (beg end)
(let ((captures (treesit-query-capture 'ruby ruby-ts--s-p-query beg end)))
(pcase-dolist (`(,name . ,node) captures)
- (pcase name
+ (pcase-exhaustive name
('regex_slash
- (put-text-property (treesit-node-start node) (treesit-node-end node)
- 'syntax-table (string-to-syntax "\"/")))
+ ;; N.B.: A regexp literal with modifiers actually includes them in
+ ;; the trailing "/" node.
+ (put-text-property (treesit-node-start node) (1+ (treesit-node-start
node))
+ 'syntax-table
+ ;; Differentiate the %r{...} literals.
+ (if (eq ?/ (char-after (treesit-node-start node)))
+ (string-to-syntax "\"/")
+ (string-to-syntax "|"))))
('ident
(put-text-property (1- (treesit-node-end node)) (treesit-node-end
node)
'syntax-table (string-to-syntax "_")))
@@ -1050,10 +1056,11 @@ leading double colon is not added."
('heredoc
(put-text-property (treesit-node-start node) (1+ (treesit-node-start
node))
'syntax-table (string-to-syntax "\""))
- (put-text-property (1- (treesit-node-end node)) (treesit-node-end
node)
+ (put-text-property (treesit-node-end node) (1+ (treesit-node-end
node))
'syntax-table (string-to-syntax "\"")))
('percent
- (put-text-property (1+ (treesit-node-start node)) (+ 2
(treesit-node-start node))
+ ;; TODO: Put the first one on the first paren in both %Q{} and %().
+ (put-text-property (treesit-node-start node) (1+ (treesit-node-start
node))
'syntax-table (string-to-syntax "|"))
(put-text-property (1- (treesit-node-end node)) (treesit-node-end
node)
'syntax-table (string-to-syntax "|")))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-29 4c765d93ab3: Refine the previous change,
Dmitry Gutov <=