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

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

[elpa] externals/objed 74204af 037/166: Add ability to jump to objects i


From: Clemens Radermacher
Subject: [elpa] externals/objed 74204af 037/166: Add ability to jump to objects inside current one
Date: Sun, 29 Dec 2019 08:20:57 -0500 (EST)

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

    Add ability to jump to objects inside current one
---
 objed-objects.el | 16 +++++++++-------
 objed.el         | 21 +++++++++++++++------
 2 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/objed-objects.el b/objed-objects.el
index dfe831c..d24c0ad 100644
--- a/objed-objects.el
+++ b/objed-objects.el
@@ -603,13 +603,15 @@ and after current object.
 
 The resulting list contains cons cells of the start positions of
 the objects and the current window."
-  (append (objed--collect-backward
-           (or fromp (objed--min))
-           beg)
-          (objed--collect-forward
-           (or fromp (if (objed--no-skipper-p)
-                         (objed--min) (objed--max)))
-           end)))
+  (save-restriction
+    (narrow-to-region beg end)
+    (append (objed--collect-backward
+             (or fromp (objed--min))
+             beg)
+            (objed--collect-forward
+             (or fromp (if (objed--no-skipper-p)
+                           (objed--min) (objed--max)))
+             end))))
 
 
 (defun objed--collect-object-lines ()
diff --git a/objed.el b/objed.el
index e6ca0ec..1a772c2 100644
--- a/objed.el
+++ b/objed.el
@@ -987,6 +987,7 @@ Use `objed-define-dispatch' to define a dispatch command.")
 
 
 (objed-define-dispatch "#" objed--ace-switch-object)
+(objed-define-dispatch "=" objed--ace-switch-in-current)
 (objed-define-dispatch "-" objed--backward-until)
 (objed-define-dispatch "+" objed--forward-until)
 
@@ -1082,6 +1083,11 @@ Use `objed-define-dispatch' to define a dispatch 
command.")
   "Switch to objed NAME using avy."
   (objed-ace name))
 
+(defun objed--ace-switch-in-current (obj)
+  "Ace for OBJ inside current object."
+  (let ((reg (objed--current)))
+    (apply #'objed-ace (cons obj reg))))
+
 
 (defun objed--until (n &optional back)
   "Get object N and move point accordingly.
@@ -2232,10 +2238,12 @@ textual content of an object via the content object."
 
 (defvar avy-all-windows)
 (defvar avy-action)
-(defun objed-ace (&optional obj)
+(defun objed-ace (&optional obj beg end)
   "Jump to an object with `avy'.
 
-OBJ defaults to current object."
+OBJ defaults to current object. BEG and END limit the region
+which should be searched for candidates and default to
+`window-start' and `window-end.'"
   (interactive)
   (if (eq objed--object 'char)
       (progn (call-interactively #'avy-goto-char)
@@ -2246,11 +2254,12 @@ OBJ defaults to current object."
     (let* ((avy-action #'goto-char)
            (avy-style 'at-full)
            (avy-all-windows t)
-           (posns (let* ((oo objed--object)
-                         (objed--object (or obj objed--object)))
+           (posns (let* ((objed--object (or obj objed--object))
+                         (beg (or beg (window-start)))
+                         (end (or end (window-end))))
                     (objed--collect-object-positions
-                     (window-start) (window-end)
-                     (unless (eq oo objed--object)
+                     beg end
+                     (when obj
                        (point))))))
         (cond (posns
                (if (> (length posns) 1)



reply via email to

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