[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/lua-mode ab9783f 041/468: Applied patch from Reuben Thomas
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/lua-mode ab9783f 041/468: Applied patch from Reuben Thomas: |
Date: |
Thu, 5 Aug 2021 04:58:04 -0400 (EDT) |
branch: elpa/lua-mode
commit ab9783fafd953b58e8c821f4642d424723825949
Author: juergen <juergen>
Commit: juergen <juergen>
Applied patch from Reuben Thomas:
Revert patch from Olivier Andrieu (1.36) to support long strings and
comments, as it is problematic: [[ and ]] simply cause string
colouring mode to be flipped into and out of, which means that for
example "a[b[i]]" causes string colouring from the second "]" onwards.
This is not easy to fix except by inserting extra spaces at these
points. I've asked the contributor to supply a version of the patch
which can be turned on by a config variable as a workaround solution.
Fix lua-beginning-of-proc when point is over "function (". Thanks to
Law Chi Ying for the report.
---
lua-mode.el | 99 ++++++++++++++++++++++---------------------------------------
1 file changed, 36 insertions(+), 63 deletions(-)
diff --git a/lua-mode.el b/lua-mode.el
index a28cf4f..e03a548 100755
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -196,40 +196,23 @@ traceback location."
(2 font-lock-variable-name-face))
;; Function name declarations.
- '("^[ \t]*\\<\\(\\(local[ \t]+\\)?function\\)\\>[
\t]+\\(\\(\\sw:\\|\\sw\\.\\|\\sw_\\|\\sw\\)+\\)"
+ '("^[ \t]*\\_<\\(\\(local[ \t]+\\)?function\\)\\_>[
\t]+\\(\\(\\sw:\\|\\sw\\.\\|\\sw_\\|\\sw\\)+\\)"
(1 font-lock-keyword-face) (3 font-lock-function-name-face nil t))
;; Handle function names in assignments
- '("\\(\\(\\sw:\\|\\sw\\.\\|\\sw_\\|\\sw\\)+\\)[ \t]*=[
\t]*\\(function\\)\\>"
+ '("\\(\\(\\sw:\\|\\sw\\.\\|\\sw_\\|\\sw\\)+\\)[ \t]*=[
\t]*\\(function\\)\\_>"
(1 font-lock-function-name-face nil t) (3 font-lock-keyword-face))
;; Keywords.
- (concat "\\<"
+ (concat "\\_<"
(regexp-opt '("and" "break" "do" "else" "elseif" "end" "false"
"for" "function" "if" "in" "local" "nil" "not"
"or" "repeat" "return" "then" "true" "until"
"while") t)
- "\\>")
+ "\\_>")
"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'.")
@@ -281,9 +264,7 @@ The following keys are bound:
(set (make-local-variable 'comment-start-skip) "--")
(set (make-local-variable 'font-lock-defaults)
'(lua-font-lock-keywords
- nil nil ((?_ . "w")) nil
- (font-lock-syntactic-keywords . lua-fls-keywords)
- (font-lock-syntactic-face-function . lua-fls-face-function)))
+ nil nil ((?_ . "w"))))
(set (make-local-variable 'imenu-generic-expression)
lua-imenu-generic-expression)
(setq local-abbrev-table lua-mode-abbrev-table)
@@ -308,9 +289,6 @@ The following keys are bound:
(modify-syntax-entry ?\n ">")
(modify-syntax-entry ?\' "\"")
(modify-syntax-entry ?\" "\"")
- ;; _ needs to be part of a word, or the regular expressions will
- ;; incorrectly regognize end_ to be matched by "\\<end\\>"!
- (modify-syntax-entry ?_ "w")
(if (and (featurep 'menubar)
current-menubar
(not (assoc "Lua" current-menubar)))
@@ -433,12 +411,11 @@ ignored, nil otherwise."
(defconst lua-block-regexp
(eval-when-compile
- ;; This is the code we used to generate the regexp:
(concat
- "\\(\\<"
+ "\\(\\_<"
(regexp-opt '("do" "function" "repeat" "then"
"else" "elseif" "end" "until") t)
- "\\>\\)\\|"
+ "\\_>\\)\\|"
(regexp-opt '("{" "(" "[" "]" ")" "}") t))
))
@@ -450,16 +427,16 @@ ignored, nil otherwise."
;; of "else", should we look backward for "then/elseif" or forward
;; for "end"?
;; Maybe later we will find a way to handle it.
- '(("do" "\\<end\\>" open)
- ("function" "\\<end\\>" open)
- ("repeat" "\\<until\\>" open)
- ("then" "\\<\\(e\\(lseif\\|nd\\)\\)\\>" open)
+ '(("do" "\\_<end\\_>" open)
+ ("function" "\\_<end\\_>" open)
+ ("repeat" "\\_<until\\_>" open)
+ ("then" "\\_<\\(e\\(lseif\\|nd\\)\\)\\_>" open)
("{" "}" open)
("[" "]" open)
("(" ")" open)
- ("elseif" "\\<then\\>" close)
- ("end" "\\<\\(do\\|function\\|then\\)\\>" close)
- ("until" "\\<repeat\\>" close)
+ ("elseif" "\\_<then\\_>" close)
+ ("end" "\\_<\\(do\\|function\\|then\\)\\_>" close)
+ ("until" "\\_<repeat\\_>" close)
("}" "{" close)
("]" "\\[" close)
(")" "(" close)))
@@ -469,16 +446,15 @@ ignored, nil otherwise."
;; The absence of else is deliberate, since it does not modify the
;; indentation level per se. It only may cause the line, in which the
;; else is, to be shifted to the left.
- ;; This is the code we used to generate the regexp:
(concat
- "\\(\\<"
- ; n.b. "local function" is a bit of a
hack, allowing only a single space
+ "\\(\\_<"
+ ;; n.b. "local function" is a bit of a hack, allowing only a single space
(regexp-opt '("do" "local function" "function" "repeat" "then") t)
- "\\>\\|"
+ "\\_>\\|"
(regexp-opt '("{" "(" "["))
- "\\)\\|\\(\\<"
+ "\\)\\|\\(\\_<"
(regexp-opt '("elseif" "end" "until") t)
- "\\>\\|"
+ "\\_>\\|"
(regexp-opt '("]" ")" "}"))
"\\)")
@@ -532,7 +508,7 @@ matching keyword that ends the block, and vice versa."
(interactive)
;; search backward to the beginning of the keyword if necessary
(if (eq (char-syntax (following-char)) ?w)
- (re-search-backward "\\<" nil t))
+ (re-search-backward "\\_<" nil t))
(let ((position (lua-goto-matching-block-token)))
(if (and (not position)
(not noreport))
@@ -567,28 +543,25 @@ Returns the point, or nil if it reached the end of the
buffer"
(defconst lua-cont-eol-regexp
(eval-when-compile
- ;; expression used to generate the regexp
(concat
- "\\(\\<"
+ "\\(\\_<"
(regexp-opt '("and" "or" "not" "in" "for" "while"
"local" "function") t)
- "\\>\\|"
+ "\\_>\\|"
"\\(^\\|[^" lua-operator-class "]\\)"
(regexp-opt '("+" "-" "*" "/" "^" ".." "==" "=" "<" ">" "<=" ">=" "~=") t)
"\\)"
"\\s *\\=")
-
))
(defconst lua-cont-bol-regexp
(eval-when-compile
- ;; expression used to generate the regexp
(concat
"\\=\\s *"
- "\\(\\<"
+ "\\(\\_<"
(regexp-opt '("and" "or" "not") t)
- "\\>\\|"
+ "\\_>\\|"
(regexp-opt '("+" "-" "*" "/" "^" ".." "==" "=" "<" ">" "<=" ">=" "~=") t)
"\\($\\|[^" lua-operator-class "]\\)"
"\\)")
@@ -662,7 +635,7 @@ use standalone."
((string-equal found-token "end")
(save-excursion
(lua-goto-matching-block-token nil found-pos)
- (if (looking-at "\\<function\\>")
+ (if (looking-at "\\_<function\\_>")
(cons 'absolute
(+ (current-indentation)
(lua-calculate-indentation-block-modifier
@@ -753,20 +726,19 @@ one."
(defconst lua-left-shift-regexp-1
(concat "\\("
- "\\(\\<" (regexp-opt '("else" "elseif" "until") t)
- "\\>\\)\\($\\|\\s +\\)"
+ "\\(\\_<" (regexp-opt '("else" "elseif" "until") t)
+ "\\_>\\)\\($\\|\\s +\\)"
"\\)"))
(defconst lua-left-shift-regexp-2
- (concat "\\(\\<"
+ (concat "\\(\\_<"
(regexp-opt '("end") t)
- "\\>\\)"))
+ "\\_>\\)"))
(defconst lua-left-shift-regexp
- ;; This is the code we used to generate the regexp:
- ;; ("else", "elseif", "until" followed by whitespace, or "end"/closing
+ ;; "else", "elseif", "until" followed by whitespace, or "end"/closing
;; brackets followed by
- ;; whitespace, punctuation, or closing parentheses)
+ ;; whitespace, punctuation, or closing parentheses
(concat lua-left-shift-regexp-1
"\\|\\(\\("
lua-left-shift-regexp-2
@@ -854,9 +826,6 @@ Returns t unless search stops due to beginning or end of
buffer."
(setq arg 1))
(let ((found nil)
(ret t))
- (if (and (< arg 0)
- (looking-at "^function[ \t]"))
- (forward-char 1))
(while (< arg 0)
(if (re-search-forward "^function[ \t]" nil t)
(setq arg (1+ arg)
@@ -865,6 +834,10 @@ Returns t unless search stops due to beginning or end of
buffer."
arg 0)))
(if found
(beginning-of-line))
+ (if (> arg 0)
+ (if (re-search-forward "^function[ \t]" nil t)
+ (setq arg (1+ arg))
+ (goto-char (point-max))))
(while (> arg 0)
(if (re-search-backward "^function[ \t]" nil t)
(setq arg (1- arg))
@@ -1051,7 +1024,7 @@ t, otherwise return nil. BUF must exist."
(if lua-always-show
(display-buffer lua-process-buffer))))
- ; FIXME: This needs work... -Bret
+;; FIXME: This needs work... -Bret
(defun lua-send-buffer ()
"Send whole buffer to lua subprocess."
(interactive)
- [nongnu] elpa/lua-mode 31acb6b 029/468: Fix bug #621: Wrong comment block detection, (continued)
- [nongnu] elpa/lua-mode 31acb6b 029/468: Fix bug #621: Wrong comment block detection, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 8f17c27 021/468: fix [#472] lua-mode colorization, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode b11a136 022/468: implemented lua-forward-sexp using lua-find-matching-token-word, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode c49fb68 023/468: Fixed lua-prompt-regex and handling of output without newline (bug #425), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 99324a4 034/468: minor font-lock fix, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode c61bda2 040/468: Commit from Reuben:, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode cd5fa7d 010/468: lua-start-process: made program &optional argument (defaults to name), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 13363db 017/468: Fixed typo (#470), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 9730289 027/468: Insert Project page Link, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode bf0b902 033/468: New Release 20070708, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode ab9783f 041/468: Applied patch from Reuben Thomas:,
Philip Kaludercic <=
- [nongnu] elpa/lua-mode 2786823 043/468: Add example code to trigger lua-mode for hash-bang lines containing, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 4f4d3de 047/468: Add Makefile with dist and release targets, and ignore release zips., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 16861a3 032/468: Fix bug #620 again: Wrong identation with tables, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode e10183d 037/468: handle font-lock-variable-name-face (Reuben Thomas), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode ab2d44c 038/468: Multiple changes by Reuben Thomas:, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode e057e22 044/468: Rename install.rst to README to help github and users., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode b20ca34 051/468: Add note to send update to ELPA., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode afdf074 053/468: Make defcustom declaration formats consistent., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode ec1a0f2 063/468: Remove extraneous variable lua-indent-whitespace, use back-to-indentation instead, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 47ac4f3 056/468: Don't have the echo command printed itself., Philip Kaludercic, 2021/08/05