]> git.eshelyaron.com Git - emacs.git/commitdiff
(ruby-ts-mode): Split font-lock feature 'builtin' into two
authorDmitry Gutov <dgutov@yandex.ru>
Fri, 6 Jan 2023 01:12:20 +0000 (03:12 +0200)
committerDmitry Gutov <dgutov@yandex.ru>
Fri, 6 Jan 2023 01:32:46 +0000 (03:32 +0200)
* lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode):
Split the 'builtin' feature in two: 'builtin-constant' and
'builtin-variable'.
(ruby-ts-highlight-predefined-constants):
Drop the user option, the highlighting granularity can be chosen
using treesit-font-lock-recompute-features.
(ruby-ts--font-lock-settings): Update accordingly.
(ruby-ts--predefined-constants, ruby-ts--predefined-variables):
Fix docstrings.

lisp/progmodes/ruby-ts-mode.el

index 5c173ad24c7a15330699322e6d31a396ee34d687..6daeb8fdb661e1366af8d0e0a77e1c27927e88a5 100644 (file)
@@ -52,7 +52,8 @@
 ;; following levels:
 ;;   1: comment method-definition
 ;;   2: keyword regexp string type
-;;   3: builtin constant delimiter escape-sequence
+;;   3: builtin-variable builtin-constant constant
+;;      delimiter escape-sequence
 ;;      global instance
 ;;      interpolation literal symbol variable
 ;;   4: bracket error function operator punctuation
   :prefix "ruby-ts-"
   :group 'languages)
 
-(defcustom ruby-ts-highlight-predefined-constants t
-  "When non-nil, the pre-defined constants are highlighted.
-They will be highlighted the same way as the pre-defined variables."
-  :type 'boolean)
-
 (defvar ruby-ts--operators
   '("+" "-" "*" "/" "%" "**"
     "==" "!=" ">" "<" ">=" "<=" "<=>" "==="
@@ -113,8 +109,7 @@ They will be highlighted the same way as the pre-defined variables."
           "RUBY_PATCHLEVEL" "RUBY_PLATFORM" "RUBY_RELEASE_DATE"
           "RUBY_REVISION" "RUBY_VERSION" "STDERR" "STDIN" "STDOUT"
           "TOPLEVEL_BINDING"))
-  "Ruby predefined global constants.
-These are currently unused")
+  "Ruby predefined global constants.")
 
 (defvar ruby-ts--predefined-variables
   (rx (or "$!" "$@" "$~" "$&" "$‘" "$‘" "$+" "$=" "$/" "$\\" "$," "$;"
@@ -122,7 +117,7 @@ These are currently unused")
           "$LOADED_FEATURES" "$DEBUG" "$FILENAME" "$stderr" "$stdin"
           "$stdout" "$VERBOSE" "$-a" "$-i" "$-l" "$-p"
           (seq "$" (+ digit))))
-  "Ruby global variables (but not global constants.")
+  "Ruby predefined global variables.")
 
 (defconst ruby-ts--class-or-module-regex
   (rx string-start
@@ -201,10 +196,12 @@ values of OVERRIDE"
    '((comment) @ruby-ts--comment-font-lock)
 
    :language language
-   :feature 'builtin
-   `(((global_variable) @var (:match ,ruby-ts--predefined-variables @var)) @font-lock-builtin-face
-     ,@(when ruby-ts-highlight-predefined-constants
-         `(((constant) @var (:match ,ruby-ts--predefined-constants @var)) @font-lock-builtin-face)))
+   :feature 'builtin-variable
+   `(((global_variable) @var (:match ,ruby-ts--predefined-variables @var)) @font-lock-builtin-face)
+
+   :language language
+   :feature 'builtin-constant
+   `(((constant) @var (:match ,ruby-ts--predefined-constants @var)) @font-lock-builtin-face)
 
    :language language
    :feature 'keyword
@@ -932,9 +929,9 @@ leading double colon is not added."
   (setq-local treesit-font-lock-feature-list
               '(( comment method-definition )
                 ( keyword regexp string type)
-                ( builtin constant
-                  delimiter escape-sequence global
-                  instance
+                ( builtin-variable builtin-constant constant
+                  delimiter escape-sequence
+                  global instance
                   interpolation literal symbol variable)
                 ( bracket error function operator punctuation)))