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

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

[elpa] externals/objed af6490a 2/9: Speedup goto first/last object


From: Clemens Radermacher
Subject: [elpa] externals/objed af6490a 2/9: Speedup goto first/last object
Date: Fri, 1 Mar 2019 15:30:42 -0500 (EST)

branch: externals/objed
commit af6490a6aebf14a5f4de6917043b362a4fae14f1
Author: Clemens Radermacher <address@hidden>
Commit: Clemens Radermacher <address@hidden>

    Speedup goto first/last object
---
 objed.el | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/objed.el b/objed.el
index be44287..1248de1 100644
--- a/objed.el
+++ b/objed.el
@@ -1664,24 +1664,26 @@ postitive prefix argument ARG move to the nth next 
object."
 (defun objed-top-object ()
   "Go to first instance of current object type."
   (interactive)
-  (objed--get-next (point))
-  (let ((o (car (objed--collect-backward
-                 (objed--min) (point-min)))))
-    (if (not o)
+  (let ((top (save-excursion
+               (goto-char (point-min))
+               (objed--get-next (point)))))
+    (if (equal top objed--current-obj)
         (message "Already at first instance")
-      (goto-char (car o))
-      (objed--update-current-object))))
+      (objed--update-current-object top)
+      (goto-char (objed--beg)))))
+
 
 (defun objed-bottom-object ()
-  "Go to last instance of current object type."
+  "Go to first instance of current object type."
   (interactive)
-  (objed--get-next (point))
-  (let ((o (car (nreverse (objed--collect-forward
-                           (objed--max) (point-max))))))
-    (if (not o)
+  (let ((bot (save-excursion
+               (goto-char (point-max))
+               (objed--get-prev (point)))))
+    (if (equal bot objed--current-obj)
         (message "Already at last instance")
-      (goto-char (car o))
-      (objed--update-current-object))))
+      (objed--update-current-object bot)
+      (goto-char (objed--beg)))))
+
 
 (defun objed-expand-context ()
   "Expand to objects based on context.



reply via email to

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