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

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

[nongnu] elpa/lua-mode 79e6815 216/468: Rewrite lua-beginning-of-proc


From: Philip Kaludercic
Subject: [nongnu] elpa/lua-mode 79e6815 216/468: Rewrite lua-beginning-of-proc
Date: Thu, 5 Aug 2021 04:58:39 -0400 (EDT)

branch: elpa/lua-mode
commit 79e681530b17c7be227208b94ae407cdd9118ee4
Author: immerrr <immerrr@gmail.com>
Commit: immerrr <immerrr@gmail.com>

    Rewrite lua-beginning-of-proc
---
 lua-mode.el | 36 ++++++++++++++----------------------
 1 file changed, 14 insertions(+), 22 deletions(-)

diff --git a/lua-mode.el b/lua-mode.el
index 9121753..7b1db51 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -1482,32 +1482,24 @@ If not, return nil."
 
 (defun lua-beginning-of-proc (&optional arg)
   "Move backward to the beginning of a lua proc (or similar).
+
 With argument, do it that many times.  Negative arg -N
 means move forward to Nth following beginning of proc.
+
 Returns t unless search stops due to beginning or end of buffer."
   (interactive "P")
-  (or arg
-      (setq arg 1))
-  (let ((found nil)
-        (ret t))
-    (while (< arg 0)
-      (if (re-search-forward "^function[ \t]" nil t)
-          (setq arg (1+ arg)
-                found t)
-        (setq ret nil
-              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))
-        (setq ret nil
-              arg 0)))
-    ret))
+  (or arg (setq arg 1))
+
+  (while (and (> arg 0)
+              (re-search-backward "^function[ \t]" nil t))
+    (setq arg (1- arg)))
+
+  (while (and (< arg 0)
+              (re-search-forward "^function[ \t]" nil t))
+    (beginning-of-line)
+    (setq arg (1+ arg)))
+
+  (zerop arg))
 
 (defun lua-end-of-proc (&optional arg)
   "Move forward to next end of lua proc (or similar).



reply via email to

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