branch: elpa/lua-mode
commit 08cff6e3c2aa860bc26a43dc2cde1ca66558597b
Author: immerrr <[email protected]>
Commit: immerrr <[email protected]>
Implement basic multiline-aware functionality
---
lua-mode.el | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/lua-mode.el b/lua-mode.el
index be6dac1..f8dc2eb 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -363,12 +363,13 @@ The following keys are bound:
,(regexp-opt (mapcar 'car lua-sexp-alist) 'words) ;start
,(regexp-opt (mapcar 'cdr lua-sexp-alist) 'words) ;end
nil lua-forward-sexp)))
+
+ (set (make-local-variable 'parse-sexp-lookup-properties) t)
(run-hooks 'lua-mode-hook)))
;;;###autoload
(add-to-list 'auto-mode-alist '("\\.lua$" . lua-mode))
-
(defun lua-electric-match (arg)
"Insert character and adjust indentation."
(interactive "P")
@@ -1165,6 +1166,35 @@ left out."
(define-key lua-mode-menu [search-documentation]
'("Search Documentation" . lua-search-documentation))
+(defsubst lua-put-char-property (pos property value &optional object)
+ (if value
+ (put-text-property pos (1+ pos) property value object)
+ (remove-text-properties pos (1+ pos) (list property nil))))
+
+(defsubst lua-put-char-syntax-table (pos value &optional object)
+ (lua-put-char-property pos 'syntax-table value object))
+
+(defsubst lua-get-multiline-delim-syntax (type)
+ (cond ((eq type 'string) '(15))
+ ((eq type 'comment) '(14))
+ (nil)))
+
+(defun lua-mark-char-multiline-delim (pos type)
+ "Mark character as a delimiter of Lua multiline construct
+
+If TYPE is string, mark char as string delimiter. If TYPE is comment,
+mark char as comment delimiter. Otherwise, remove the mark if any."
+ (lua-put-char-syntax-table pos (lua-get-multiline-delim-syntax type)))
+
+(defun lua-clear-multiline-delims (&optional begin end)
+ "Clears all Lua multiline construct markers in region
+
+If BEGIN is nil, start from `beginning-of-buffer'.
+If END is nil, stop at `end-of-buffer'."
+ (interactive)
+ (remove-text-properties (or begin 1) (or end (buffer-size)) '(syntax-table
()))
+ (font-lock-fontify-buffer))
+
(provide 'lua-mode)