emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/lua-mode b11a136 022/468: implemented lua-forward-sexp usi


From: Philip Kaludercic
Subject: [nongnu] elpa/lua-mode b11a136 022/468: implemented lua-forward-sexp using lua-find-matching-token-word
Date: Thu, 5 Aug 2021 04:58:01 -0400 (EDT)

branch: elpa/lua-mode
commit b11a1364178f41f09cad5b7926d0ecc1b9d0de8a
Author: juergen <juergen>
Commit: juergen <juergen>

    implemented lua-forward-sexp using lua-find-matching-token-word
---
 lua-mode.el | 32 +++++++++++++++++++++++++++-----
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/lua-mode.el b/lua-mode.el
index dff2616..db60e62 100755
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -239,6 +239,10 @@ traceback location."
 (defvar lua-mode-abbrev-table nil
   "Abbreviation table used in lua-mode buffers.")
 
+(defvar lua-sexp-alist '(("then" . "end")
+                        ("function" . "end")
+                        ("do" . "end")))
+
 (define-abbrev-table 'lua-mode-abbrev-table
   '(
         ("end" "end" lua-indent-line 0)
@@ -336,8 +340,8 @@ The following keys are bound:
     (unless (assq 'lua-mode hs-special-modes-alist)
       (add-to-list 'hs-special-modes-alist
                   `(lua-mode  
-                    ,(regexp-opt '("do" "function" "then") 'words) ;start
-                    ,(regexp-opt '("end") 'words) ;end
+                    ,(regexp-opt (mapcar 'car lua-sexp-alist) 'words);start
+                    ,(regexp-opt (mapcar 'cdr lua-sexp-alist) 'words) ;end
                     nil lua-forward-sexp)))
     (run-hooks 'lua-mode-hook)))
 
@@ -1238,9 +1242,27 @@ left out."
 ;;{{{ lua-forward-sexp
 
 (defun lua-forward-sexp (&optional count)
-  "Find begin and end of Lua block."
-  (let ((case-fold-search t))
-    (re-search-forward "\\<end\\>" nil t)))
+ "Forward to block end"
+ (interactive "p")
+ (save-match-data
+ (let* ((count (or count 1))
+       (stackheight 0)
+       (block-start (mapcar 'car lua-sexp-alist))
+       (block-end (mapcar 'cdr lua-sexp-alist))
+       (block-regex (regexp-opt (append  block-start block-end) 'words))
+       current-exp
+       )
+   (while (> count 0)
+     ;; skip whitespace
+     (skip-chars-forward " \t\n")
+     (if (looking-at (regexp-opt block-start 'words)) 
+        (let ((keyword (match-string 1)))
+          (lua-find-matching-token-word keyword nil))
+       ;; If the current keyword is not a "begin" keyword, then just
+       ;; perform the normal forward-sexp.
+       (forward-sexp 1))
+     (setq count (1- count))))))
+
 
 ;;}}}
 ;;{{{ menu bar



reply via email to

[Prev in Thread] Current Thread [Next in Thread]