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

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

[elpa] externals/phps-mode db5ceb56f1 2/3: Improvements in (beginning-of


From: Christian Johansson
Subject: [elpa] externals/phps-mode db5ceb56f1 2/3: Improvements in (beginning-of-defun) and (end-of-defun)
Date: Tue, 14 Feb 2023 12:11:37 -0500 (EST)

branch: externals/phps-mode
commit db5ceb56f1c4b31f1bd0d5a1c7e0485e51c968c5
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>

    Improvements in (beginning-of-defun) and (end-of-defun)
---
 phps-mode-lex-analyzer.el | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/phps-mode-lex-analyzer.el b/phps-mode-lex-analyzer.el
index 33b8826faa..26332406a6 100644
--- a/phps-mode-lex-analyzer.el
+++ b/phps-mode-lex-analyzer.el
@@ -1512,22 +1512,30 @@ of performed operations.  Optionally do it 
FORCE-SYNCHRONOUS."
 
 (defun phps-mode-lex-analyzer--beginning-of-defun (&optional arg)
   "Custom implementation of `beginning-of-defun'."
-  (let ((iterations (if arg arg 1))
+  (let ((iterations (if arg (abs arg) 1))
+        (forward-p (and arg (< arg 0)))
         (index 0)
         (found-index t))
     (save-excursion
-      (move-end-of-line nil)
       (while (and found-index (< index iterations))
         (setq found-index nil)
         (setq index (1+ index))
-        (when
-            (search-backward-regexp
-             "[\n\t ]+function\\([\t\n ]+\\|(\\)"
-             nil
-             t)
-          (search-forward-regexp "[\n]*")
-          (move-beginning-of-line nil)
-          (setq found-index (point)))))
+        (if forward-p
+            (when
+                (search-forward-regexp
+                 "[\n\t ]+function\\([\t\n ]+\\|(\\)"
+                 nil
+                 t)
+              (move-beginning-of-line nil)
+              (setq found-index (point)))
+            (when
+                (search-backward-regexp
+                 "[\n\t ]+function\\([\t\n ]+\\|(\\)"
+                 nil
+                 t)
+              (search-forward-regexp "[\n]*")
+              (move-beginning-of-line nil)
+              (setq found-index (point))))))
     (if found-index
         (progn
           (goto-char found-index)
@@ -1545,6 +1553,7 @@ of performed operations.  Optionally do it 
FORCE-SYNCHRONOUS."
               (< index iterations))
         (setq found-index nil)
         (setq index (1+ index))
+        (move-end-of-line nil)
         (when (phps-mode-lex-analyzer--beginning-of-defun)
           (let ((bracket-level 0)
                 (found-initial-bracket)



reply via email to

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