emacs-diffs
[Top][All Lists]
Advanced

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

master 7f32224: Fontify strings in {} better in tcl-mode


From: Lars Ingebrigtsen
Subject: master 7f32224: Fontify strings in {} better in tcl-mode
Date: Tue, 27 Oct 2020 04:32:30 -0400 (EDT)

branch: master
commit 7f32224dc324b0ee0f1b512c8d8b19aeb80141c1
Author: mvar <mvar.40k@gmail.com>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Fontify strings in {} better in tcl-mode
    
    * lisp/progmodes/tcl.el (tcl-syntax-propertize-function):
    Propertize {} forms after commands as strings (bug#39277).
    (tcl-set-font-lock-keywords): Fontify as strings.  This allows
    things like puts {"foo} to be fontified correctly.
    
    Copyright-paperwork-exempt: yes
---
 lisp/progmodes/tcl.el | 45 +++++++++++++++++++++++++--------------------
 1 file changed, 25 insertions(+), 20 deletions(-)

diff --git a/lisp/progmodes/tcl.el b/lisp/progmodes/tcl.el
index 717008a..583f4e3 100644
--- a/lisp/progmodes/tcl.el
+++ b/lisp/progmodes/tcl.el
@@ -386,32 +386,36 @@ Call `tcl-set-font-lock-keywords' after changing this 
list.")
 Default list includes some TclX keywords.
 Call `tcl-set-font-lock-keywords' after changing this list.")
 
-(defvar tcl-builtin-list
-  '("after" "append" "array" "bgerror" "binary" "catch" "cd" "clock"
-    "close" "concat" "console" "dde" "encoding" "eof" "exec" "expr"
-    "fblocked" "fconfigure" "fcopy" "file" "fileevent" "flush"
-    "format" "gets" "glob" "history" "incr" "info" "interp" "join"
-    "lappend" "lindex" "linsert" "list" "llength" "load" "lrange"
-    "lreplace" "lsort" "namespace" "open" "package" "pid" "puts" "pwd"
-    "read" "regexp" "registry" "regsub" "rename" "scan" "seek" "set"
-    "socket" "source" "split" "string" "subst" "tell" "time" "trace"
-    "unknown" "unset" "vwait")
-  "List of Tcl commands.  Used only for highlighting.
-Call `tcl-set-font-lock-keywords' after changing this list.
-This list excludes those commands already found in `tcl-proc-list' and
-`tcl-keyword-list'.")
-
 (defvar tcl-font-lock-keywords nil
   "Keywords to highlight for Tcl.  See variable `font-lock-keywords'.
 This variable is generally set from `tcl-proc-regexp',
 `tcl-typeword-list', and `tcl-keyword-list' by the function
 `tcl-set-font-lock-keywords'.")
 
-(defconst tcl-syntax-propertize-function
-  (syntax-propertize-rules
-   ;; Mark the few `#' that are not comment-markers.
-   ("[^;[{ \t\n][ \t]*\\(#\\)" (1 ".")))
-  "Syntactic keywords for `tcl-mode'.")
+(eval-and-compile
+  (defvar tcl-builtin-list
+    '("after" "append" "array" "bgerror" "binary" "catch" "cd" "clock"
+      "close" "concat" "console" "dde" "encoding" "eof" "exec" "expr"
+      "fblocked" "fconfigure" "fcopy" "file" "fileevent" "flush"
+      "format" "gets" "glob" "history" "incr" "info" "interp" "join"
+      "lappend" "lindex" "linsert" "list" "llength" "load" "lrange"
+      "lreplace" "lsort" "namespace" "open" "package" "pid" "puts" "pwd"
+      "read" "regexp" "registry" "regsub" "rename" "scan" "seek" "set"
+      "socket" "source" "split" "string" "subst" "tell" "time" "trace"
+      "unknown" "unset" "vwait")
+    "List of Tcl commands.  Used only for highlighting.
+Call `tcl-set-font-lock-keywords' after changing this list.
+This list excludes those commands already found in `tcl-proc-list' and
+`tcl-keyword-list'.")
+
+  (defconst tcl-syntax-propertize-function
+    (syntax-propertize-rules
+     ;; Mark the few `#' that are not comment-markers.
+     ("[^;[{ \t\n][ \t]*\\(#\\)" (1 "."))
+     ((concat "\\_<" (regexp-opt tcl-builtin-list t)
+              "\\_>" "\s*{\\([^}].*\\)}")
+      (2 "_")))
+    "Syntactic keywords for `tcl-mode'."))
 
 ;; FIXME need some way to recognize variables because array refs look
 ;; like 2 sexps.
@@ -506,6 +510,7 @@ Uses variables `tcl-proc-regexp' and `tcl-keyword-list'."
          ;; number of "namespace::" qualifiers.  A leading "::" refers
          ;; to the global namespace.
          '("\\${\\([^}]+\\)}" 1 font-lock-variable-name-face)
+         '("{\\([^}]+\\)}" 1 font-lock-string-face)
          '("\\$\\(\\(?:::\\)?\\(?:[[:alnum:]_]+::\\)*[[:alnum:]_]+\\)"
            1 font-lock-variable-name-face)
          '("\\(?:\\s-\\|^\\|\\[\\)set\\s-+{\\([^}]+\\)}"



reply via email to

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