emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-25 28532a9 1/2: Propertize character literals and sp


From: Dmitry Gutov
Subject: [Emacs-diffs] emacs-25 28532a9 1/2: Propertize character literals and special global variables differently
Date: Thu, 10 Mar 2016 12:36:59 +0000

branch: emacs-25
commit 28532a91a96f30ab468d06b410bd199fb08dd5e9
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    Propertize character literals and special global variables differently
    
    * lisp/progmodes/ruby-mode.el (ruby-syntax-propertize): Propertize
    character literals and global variables with special names with
    prefix and symbol syntax classes, for SMIE to tokenize them
    together automatically.
    (ruby-font-lock-keywords): Fix an old regression in highlighting
    character literals.
---
 lisp/progmodes/ruby-mode.el |    8 +++++---
 test/indent/ruby.rb         |    3 +++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 0c5e8fe..94fd277 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -1844,13 +1844,15 @@ It will be properly highlighted even when the call 
omits parens.")
      (syntax-propertize-rules
       ;; $' $" $` .... are variables.
       ;; ?' ?" ?` are character literals (one-char strings in 1.9+).
-      ("\\([?$]\\)[#\"'`]"
+      ("\\([?$]\\)[#\"'`:?]"
        (1 (if (save-excursion
                 (nth 3 (syntax-ppss (match-beginning 0))))
               ;; Within a string, skip.
               (ignore
                (goto-char (match-end 1)))
-            (string-to-syntax "\\"))))
+            (put-text-property (match-end 1) (match-end 0)
+                               'syntax-table (string-to-syntax "_"))
+            (string-to-syntax "'"))))
       ;; Symbols with special characters.
       
("\\(^\\|[^:]\\)\\(:\\(address@hidden|[/%&|^`]\\|\\*\\*?\\|<\\(<\\|=>?\\)?\\|>[>=]?\\|===?\\|=~\\|![~=]?\\|\\[\\]=?\\)\\)"
        (3 (string-to-syntax "_")))
@@ -2222,7 +2224,7 @@ See `font-lock-syntax-table'.")
      1 font-lock-negation-char-face)
     ;; Character literals.
     ;; FIXME: Support longer escape sequences.
-    ("\\_<\\?\\\\?\\S " 0 font-lock-string-face)
+    ("\\?\\\\?\\_<.\\_>" 0 font-lock-string-face)
     ;; Regexp options.
     ("\\(?:\\s|\\|/\\)\\([imxo]+\\)"
      1 (when (save-excursion
diff --git a/test/indent/ruby.rb b/test/indent/ruby.rb
index 3fdb680..522c3bd 100644
--- a/test/indent/ruby.rb
+++ b/test/indent/ruby.rb
@@ -174,6 +174,9 @@ qux :+,
     bar,
     :a
 
+b = $:
+c = ??
+
 # Example from http://www.ruby-doc.org/docs/ProgrammingRuby/html/language.html
 d = 4 + 5 +      # no '\' needed
     6 + 7



reply via email to

[Prev in Thread] Current Thread [Next in Thread]