branch: elpa/lua-mode
commit 85fda701e1f8cbfbe9b02330acbbd32addeee222
Author: juergen <juergen>
Commit: juergen <juergen>
Add patch from Olivier Andrieu for rudimentary long bracket support
---
lua-mode.el | 40 ++++++++++++++++++++++++++--------------
1 file changed, 26 insertions(+), 14 deletions(-)
diff --git a/lua-mode.el b/lua-mode.el
index 92d5513..25ee419 100755
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -35,16 +35,16 @@
;;; Commentary:
-;; Thanks to Tobias Polzin <polzin<at>gmx.de> for function indenting
+;; Thanks to Tobias Polzin <[email protected]> for function indenting
;; patch: Indent "(" like "{"
-;; Thanks to Fabien <fleutot<at>gmail.com> for imenu patches.
+;; Thanks to Fabien <[email protected]> for imenu patches.
-;; Special Thanks to Simon Marshall <[email protected]> for
-;; font-lock patches.
+;; Thanks to Simon Marshall <[email protected]> and Olivier
+;; Andrieu <[email protected]> for font-lock patches.
;; Additional font-lock highlighting and indentation tweaks by
-;; Adam D. Moss <[email protected]> <[email protected]>
+;; Adam D. Moss <[email protected]>.
;; INSTALLATION:
@@ -203,14 +203,6 @@ traceback location."
'("\\(\\(\\sw:\\|\\sw\\.\\|\\sw_\\|\\sw\\)+\\)[ \t]*=[
\t]*\\(function\\)\\>"
(1 font-lock-function-name-face nil t) (3 font-lock-keyword-face))
- ;; Long comment blocks.
- '("\\(?:^\\|[^-]\\)\\(--\\[\\(=*\\)\\[\\(?:.\\|\n\\)*?\\]\\2\\]\\)"
- (1 font-lock-comment-face t))
-
- ;; Long strings.
- '("\\(?:^\\|[^[-]\\)\\(\\[\\(=*\\)\\[\\(?:.\\|\n\\)*?\\]\\2\\]\\)"
- (1 font-lock-string-face t))
-
;; Keywords.
(concat "\\<"
(regexp-opt '("and" "break" "do" "else" "elseif" "end" "false"
@@ -221,6 +213,23 @@ traceback location."
"Default expressions to highlight in Lua mode.")))
+;; FIXME: Match the correct number of equals signs between open and close long
brackets
+(defvar lua-fls-keywords
+ '(("\\(-\\)-\\[=*\\[\\|\\(\\[\\)=*\\[" (1 "|" t t) (2 "|" t t))
+ ("\\]=*\\(\\]\\)" . (1 "|"))))
+
+(defun lua-fls-face-function (s)
+ (let ((in-string (nth 3 s))
+ (start (nth 8 s)))
+ (if in-string
+ (save-excursion
+ (goto-char start)
+ (if (looking-at "--\\[=*\\[")
+ 'font-lock-comment-face
+ 'font-lock-string-face))
+ 'font-lock-comment-face)))
+
+
(defvar lua-imenu-generic-expression
'((nil "^[ \t]*\\(?:local[ \t]+\\)?function[
\t]+\\(\\(\\sw:\\|\\sw_\\|\\sw\\.\\|\\sw\\)+\\)" 1))
"Imenu generic expression for lua-mode. See `imenu-generic-expression'.")
@@ -271,7 +280,10 @@ The following keys are bound:
(set (make-local-variable 'comment-start) "--")
(set (make-local-variable 'comment-start-skip) "--")
(set (make-local-variable 'font-lock-defaults)
- '(lua-font-lock-keywords nil nil ((?_ . "w"))))
+ '(lua-font-lock-keywords
+ nil nil ((?_ . "w")) nil
+ (font-lock-syntactic-keywords .
lua-fls-keywords)
+ (font-lock-syntactic-face-function .
lua-fls-face-function)))
(set (make-local-variable 'imenu-generic-expression)
lua-imenu-generic-expression)
(setq local-abbrev-table lua-mode-abbrev-table)