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

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

[elpa] externals/objed 53cafee 085/216: Add new commands to move to firs


From: Stefan Monnier
Subject: [elpa] externals/objed 53cafee 085/216: Add new commands to move to first/last instance
Date: Tue, 8 Jan 2019 12:29:17 -0500 (EST)

branch: externals/objed
commit 53cafeec06929acdc455ae629752e45793b7a7fd
Author: Clemera <address@hidden>
Commit: Clemera <address@hidden>

    Add new commands to move to first/last instance
---
 README.asc |  6 +++---
 objed.el   | 28 +++++++++++++++++++++++++---
 2 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/README.asc b/README.asc
index d86e991..4af06ac 100644
--- a/README.asc
+++ b/README.asc
@@ -183,9 +183,6 @@ Basic movement commands (switch the object type on 
movement):
 
 |kbd:[n/p]
 |Move to the next/previous line and activate the line object.
-
-|kbd:[`/´]
-|Move forward/backward one symbol and activate the symbol object. Strings and 
comments are skipped.
 |===
 
 
@@ -229,6 +226,9 @@ determining the context:
 |kbd:[t/h]
 |If coming from basic movement the object at point is guessed based on 
context. Point is moved  to the beginning/end of object. This is useful to 
"jump out" of the current context. On repeat move to the previous/next instance 
of current object type
 
+|kbd:[`/´]
+|Goto first/last instance of current object type.
+
 |kbd:[o]
 |Activate the inner part of the object at point and move to the start. This is 
useful to act on the content of the string, brackets and so on. On repeat 
expand to other objects around current position.
 
diff --git a/objed.el b/objed.el
index 91f7ea3..4d3e0c3 100644
--- a/objed.el
+++ b/objed.el
@@ -680,8 +680,8 @@ the guessed object."
     (define-key map (kbd "<M-right>") 'objed-indent-to-right-tab-stop)
     (define-key map (kbd "<M-left>") 'objed-indent-to-left-tab-stop)
 
-    (define-key map "`" 'objed-backward-symbol)
-    (define-key map "´" 'objed-forward-symbol)
+    (define-key map "`" 'objed-top-object);;'objed-backward-symbol)
+    (define-key map "´" 'objed-bottom-object);;'objed-forward-symbol)
 
     ;; block expansions
     (define-key map "l" 'objed-expand-block)
@@ -1578,7 +1578,29 @@ postitive prefix argument ARG move to the nth next 
object."
   (if (objed--basic-p)
       (progn (objed-context-object)
              (goto-char (objed--end)))
-  (objed--goto-next (or arg 1))))
+    (objed--goto-next (or arg 1))))
+
+(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)
+        (message "Already at first instance")
+      (goto-char (car o))
+      (objed--update-current-object))))
+
+(defun objed-bottom-object ()
+  "Go to last instance of current object type."
+  (interactive)
+  (objed--get-next (point))
+  (let ((o (car (nreverse (objed--collect-forward
+                           (objed--max) (point-max))))))
+    (if (not o)
+        (message "Already at last instance")
+      (goto-char (car o))
+      (objed--update-current-object))))
 
 (defun objed-expand-context ()
   "Expand to objects based on context.



reply via email to

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