Function: ruby-ts--syntax-propertize

ruby-ts--syntax-propertize is a byte-compiled function defined in ruby-ts-mode.el.gz.

Signature

(ruby-ts--syntax-propertize BEG END)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/ruby-ts-mode.el.gz
(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-exhaustive name
        ('regex_slash
         ;; 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 "_")))
        ('symbol
         (goto-char (treesit-node-end node))
         (skip-syntax-backward "." (treesit-node-start node))
         (put-text-property (point) (treesit-node-end node)
                            'syntax-table (string-to-syntax "_")))
        ('heredoc
         (put-text-property (treesit-node-start node) (1+ (treesit-node-start node))
                            'syntax-table (string-to-syntax "\""))
         (when (< (treesit-node-end node) (point-max))
           (put-text-property (treesit-node-end node) (1+ (treesit-node-end node))
                              'syntax-table (string-to-syntax "\""))))
        ('percent
         ;; FIXME: Put the first one on the first paren in both %Q{} and %().
         ;; That would stop electric-pair-mode from pairing, though.  Hmm.
         (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 "|")))
        ((or 'global_var 'char)
         (put-text-property (treesit-node-start node) (1+ (treesit-node-start node))
                            'syntax-table (string-to-syntax "'"))
         (put-text-property (1+ (treesit-node-start node)) (treesit-node-end node)
                            'syntax-table (string-to-syntax "_")))
        ('backtick
         (put-text-property (treesit-node-start node) (treesit-node-end node)
                            'syntax-table (string-to-syntax "_")))
        ('comm
         (dolist (pos (list (treesit-node-start node)
                            (1- (treesit-node-end node))))
           (put-text-property pos (1+ pos) 'syntax-table
                              (string-to-syntax "!"))))))))