Skip to content

Commit

Permalink
Use syntax-propertize-function if it is available
Browse files Browse the repository at this point in the history
font-lock-syntactic-keywords aren't considered if font-lock-mode is off.
  • Loading branch information
immerrr committed Oct 18, 2014
1 parent 13f6ffa commit d4ee03e
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions lua-mode.el
Expand Up @@ -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)
Expand Down Expand Up @@ -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."
Expand Down

0 comments on commit d4ee03e

Please sign in to comment.