branch: elpa/lua-mode
commit 3ba5bf1c9ddb2b9fff348664c5dda0caace16ff7
Author: immerrr <[email protected]>
Commit: immerrr <[email protected]>

    Redo lua-toggle-electric-state, remove extra function lua-calculate-state
---
 lua-mode.el | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/lua-mode.el b/lua-mode.el
index de643f4..f4d372a 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -1055,29 +1055,24 @@ t, otherwise return nil.  BUF must exist."
   (interactive)
   (browse-url (concat lua-search-url-prefix (current-word t))))
 
-(defun lua-calculate-state (arg prevstate)
-  ;; Calculate the new state of PREVSTATE, t or nil, based on arg. If
-  ;; arg is nil or zero, toggle the state. If arg is negative, turn
-  ;; the state off, and if arg is positive, turn the state on
-  (if (or (not arg)
-          (zerop (setq arg (prefix-numeric-value arg))))
-      (not prevstate)
-    (> arg 0)))
-
 (defun lua-toggle-electric-state (&optional arg)
   "Toggle the electric indentation feature.
 Optional numeric ARG, if supplied, turns on electric indentation when
 positive, turns it off when negative, and just toggles it when zero or
 left out."
   (interactive "P")
-  (setq lua-electric-flag (lua-calculate-state arg lua-electric-flag)))
+  (let ((num_arg (prefix-numeric-value arg)))
+    (setq lua-electric-flag (cond ((or (null arg)
+                                       (zerop num_arg)) (not 
lua-electric-flag))
+                                  ((< num_arg 0) nil)
+                                  ((> num_arg 0) t))))
+  (message "%S" lua-electric-flag))
 
 (defun lua-forward-sexp (&optional count)
   "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))

Reply via email to