From: Juri Linkov Date: Thu, 2 May 2024 06:28:53 +0000 (+0300) Subject: * lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode): Add 'text' (bug#67036). X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=419bc4a3a48bd84f4b3611571541b83baeafaebd;p=emacs.git * lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode): Add 'text' (bug#67036). Add 'text' lambda to 'treesit-thing-settings' that should fall back to the default functions for sentence/sexp navigation. (cherry picked from commit a1613505e24e8d5eae79b130809d217b1db23065) --- diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index 7133cb0b5b0..5f4e11e0b4c 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el @@ -1171,7 +1171,22 @@ leading double colon is not added." "global_variable" ) eol) - #'ruby-ts--sexp-p))))) + #'ruby-ts--sexp-p)) + (text ,(lambda (node) + (or (member (treesit-node-type node) + '("comment" "string_content" "heredoc_content")) + ;; for C-M-f in hash[:key] and hash['key'] + (and (member (treesit-node-text node) + '("[" "]")) + (equal (treesit-node-type + (treesit-node-parent node)) + "element_reference")) + ;; for C-M-f in "abc #{ghi} def" + (and (member (treesit-node-text node) + '("#{" "}")) + (equal (treesit-node-type + (treesit-node-parent node)) + "interpolation")))))))) ;; AFAIK, Ruby can not nest methods (setq-local treesit-defun-prefer-top-level nil)