branch: elpa/lua-mode
commit 694421c383d7e92ebb38805a72df4f1e24f99d40
Author: immerrr <[email protected]>
Commit: immerrr <[email protected]>

    Add lua-remove-syntax-table-property to syntactic keywords
    
    Sometimes font-lock doesn't unfontify the region when applying syntactic
    keywords and that broke multiline literal recognition.
---
 lua-mode.el | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/lua-mode.el b/lua-mode.el
index c4f087d..96cfbfd 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -871,8 +871,21 @@ If none can be found before reaching LIMIT, return nil."
   (or (lua-try-match-multiline-end limit)
       (lua-try-match-multiline-begin limit)))
 
+(defun lua-remove-syntax-table-property (limit)
+  "Remove syntax-table property on given region.
+
+This is a workaround for `font-lock-default-fontify-region'
+sometimes forgetting to unpropertize region which may cause
+multiline recognition to fail.
+
+Returns nil so that it's only called once as a syntactic keyword.
+"
+  (remove-text-properties (point) limit '(syntax-table))
+  nil)
+
 (defvar lua-font-lock-syntactic-keywords
-  '((lua-match-multiline-literal-bounds
+  '((lua-remove-syntax-table-property nil)
+    (lua-match-multiline-literal-bounds
      (1 "!" nil noerror)
      (2 "|" nil noerror))))
 

Reply via email to