emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/lua-mode d4ee03e 278/468: Use syntax-propertize-function i


From: Philip Kaludercic
Subject: [nongnu] elpa/lua-mode d4ee03e 278/468: Use syntax-propertize-function if it is available
Date: Thu, 5 Aug 2021 04:58:52 -0400 (EDT)

branch: elpa/lua-mode
commit d4ee03edad67efcf7d8c054c6dc8f27e848a6c5a
Author: immerrr <immerrr+lua@gmail.com>
Commit: immerrr <immerrr+lua@gmail.com>

    Use syntax-propertize-function if it is available
    
    font-lock-syntactic-keywords aren't considered if font-lock-mode is off.
---
 lua-mode.el | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/lua-mode.el b/lua-mode.el
index 1c772f9..2555da4 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -717,8 +717,13 @@ Groups 6-9 can be used in any of argument regexps."
                                         nil                    ;; syntax-alist
                                         nil                    ;; syntax-begin
                                         ))
-  (lua--setq-local
-   font-lock-syntactic-keywords 'lua-font-lock-syntactic-keywords)
+
+  (if (boundp 'syntax-propertize-function)
+      (lua--setq-local syntax-propertize-function
+                       'lua--propertize-multiline-bounds)
+    (with-no-warnings
+     (lua--setq-local
+      font-lock-syntactic-keywords 'lua-font-lock-syntactic-keywords)))
   (lua--setq-local font-lock-extra-managed-props  '(syntax-table))
   (lua--setq-local parse-sexp-lookup-properties   t)
   (lua--setq-local indent-line-function           'lua-indent-line)
@@ -896,6 +901,22 @@ Returns nil so that it's only called once as a syntactic 
keyword.
      (1 "!" nil noerror)
      (2 "|" nil noerror))))
 
+
+(defun lua--propertize-multiline-bounds (start end)
+  "Put text properties on beginnings and ends of multiline literals.
+
+Intended to be used as a `syntax-propertize-function'."
+  (save-excursion
+    (goto-char start)
+    (while (lua-match-multiline-literal-bounds end)
+      (when (match-beginning 1)
+        (put-text-property (match-beginning 1) (match-end 1)
+                           'syntax-table (string-to-syntax "!")))
+      (when (match-beginning 2)
+        (put-text-property (match-beginning 2) (match-end 2)
+                           'syntax-table (string-to-syntax "|"))))))
+
+
 (defun lua-indent-line ()
   "Indent current line for Lua mode.
 Return the amount the indentation changed by."



reply via email to

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