(treesit-fontify-with-override (max plus-1 start) (min node-end end)
font-lock-comment-face override)))
-(defun ruby-ts--builtin-method-p (node)
- (string-match-p ruby-ts--builtin-methods (treesit-node-text node t)))
-
(defun ruby-ts--font-lock-settings (language)
"Tree-sitter font-lock settings for Ruby."
(treesit-font-lock-rules
:language language
:feature 'builtin-function
`((((identifier) @font-lock-builtin-face)
- (:pred ruby-ts--builtin-method-p @font-lock-builtin-face)))
+ (:match ,ruby-ts--builtin-methods @font-lock-builtin-face)))
;; Yuan recommends also putting method definitions into the
;; 'function' category (thus keeping it in both). I've opted to
ptrdiff_t, ptrdiff_t *);
extern ptrdiff_t find_before_next_newline (ptrdiff_t, ptrdiff_t,
ptrdiff_t, ptrdiff_t *);
+extern EMACS_INT search_buffer (Lisp_Object, ptrdiff_t, ptrdiff_t,
+ ptrdiff_t, ptrdiff_t, EMACS_INT,
+ int, Lisp_Object, Lisp_Object, bool);
extern void syms_of_search (void);
extern void clear_regexp_cache (void);
static EMACS_INT boyer_moore (EMACS_INT, unsigned char *, ptrdiff_t,
Lisp_Object, Lisp_Object, ptrdiff_t,
ptrdiff_t, int);
-static EMACS_INT search_buffer (Lisp_Object, ptrdiff_t, ptrdiff_t,
- ptrdiff_t, ptrdiff_t, EMACS_INT, int,
- Lisp_Object, Lisp_Object, bool);
Lisp_Object re_match_object;
return result;
}
-static EMACS_INT
+EMACS_INT
search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
ptrdiff_t lim, ptrdiff_t lim_byte, EMACS_INT n,
int RE, Lisp_Object trt, Lisp_Object inverse_trt, bool posix)
build_string ("The second argument to `match' should "
"be a capture name, not a string"));
- Lisp_Object text = treesit_predicate_capture_name_to_text (capture_name,
+ Lisp_Object node = treesit_predicate_capture_name_to_node (capture_name,
captures);
- if (fast_string_match (regexp, text) >= 0)
+ struct buffer *old_buffer = current_buffer;
+ struct buffer *buffer = XBUFFER (XTS_PARSER (XTS_NODE (node)->parser)->buffer);
+ set_buffer_internal (buffer);
+
+ TSNode treesit_node = XTS_NODE (node)->node;
+ ptrdiff_t visible_beg = XTS_PARSER (XTS_NODE (node)->parser)->visible_beg;
+ uint32_t start_byte_offset = ts_node_start_byte (treesit_node);
+ uint32_t end_byte_offset = ts_node_end_byte (treesit_node);
+ ptrdiff_t start_byte = visible_beg + start_byte_offset;
+ ptrdiff_t end_byte = visible_beg + end_byte_offset;
+ ptrdiff_t start_pos = buf_bytepos_to_charpos (buffer, start_byte);
+ ptrdiff_t end_pos = buf_bytepos_to_charpos (buffer, end_byte);
+ ptrdiff_t old_begv = BEGV;
+ ptrdiff_t old_begv_byte = BEGV_BYTE;
+ ptrdiff_t old_zv = ZV;
+ ptrdiff_t old_zv_byte = ZV_BYTE;
+
+ BEGV = start_pos;
+ BEGV_BYTE = start_byte;
+ ZV = end_pos;
+ ZV_BYTE = end_byte;
+
+ ptrdiff_t val = search_buffer (regexp, start_pos, start_byte, end_pos, end_byte,
+ 1, 1, Qnil, Qnil, false);
+
+ BEGV = old_begv;
+ BEGV_BYTE = old_begv_byte;
+ ZV = old_zv;
+ ZV_BYTE = old_zv_byte;
+
+ set_buffer_internal (old_buffer);
+
+ if (val > 0)
return true;
else
return false;