[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/objed 4b21416 112/216: Fix endless textblock search
From: |
Stefan Monnier |
Subject: |
[elpa] externals/objed 4b21416 112/216: Fix endless textblock search |
Date: |
Tue, 8 Jan 2019 12:29:22 -0500 (EST) |
branch: externals/objed
commit 4b2141646b49bf1c53afe47f86a4581695f5e5ef
Author: Clemera <address@hidden>
Commit: Clemera <address@hidden>
Fix endless textblock search
---
objed-objects.el | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/objed-objects.el b/objed-objects.el
index c3797e0..e02fb5b 100644
--- a/objed-objects.el
+++ b/objed-objects.el
@@ -203,6 +203,11 @@ Code to run which returns an object symbol which can be
used to
navigate references of an object. This defaults to the textual
content of an object.
+:max-search-forward (optional)
+
+Code to run which returns the maximal position an object of this type
+is searched for (in forward direction).
+
:no-skip (optional)
If this keyword is provided with a non-nil value, the current object
@@ -223,7 +228,7 @@ defined."
;; wrap code chunks
(args (objed--get-arg-plist
args
- '(:mode :no-skip :commands :atp :ref :get-obj :try-next
:try-prev
+ '(:mode :no-skip :max-search-forward :commands :atp :ref
:get-obj :try-next :try-prev
:beg :ibeg :iend :end)))
;; transform to final form if necessary
(args (if (plist-get args :get-obj) args
@@ -232,6 +237,7 @@ defined."
(cbody nil)
(doc (format "%s object." (capitalize (symbol-name name))))
(atp (plist-get args :atp))
+ (max (plist-get args :max-search-forward))
(obj (plist-get args :get-obj))
(next (plist-get args :try-next))
(prev (plist-get args :try-prev))
@@ -246,6 +252,12 @@ defined."
(push `((eq ,arg :atp)
,atp)
cbody))
+
+ (when max
+ (push `((eq ,arg :max-search-forward)
+ ,max)
+ cbody))
+
(when ref
(push `((eq ,arg :ref)
,ref)
@@ -574,9 +586,11 @@ to search backwards.
POS defaults to point. When no object is found at current
position returns the next accessible one in DIR. Object position
-order depends on `objed--obj-state'."
+order depends on `objed--obj-state'. To exit early from search objects
+can throw an error."
(save-excursion
(let ((darg (if dir :try-prev :try-next))
+ (max (objed--object :max-search-forward))
(stop (if dir #'bobp #'eobp)))
(when pos
(goto-char pos))
@@ -584,6 +598,8 @@ order depends on `objed--obj-state'."
;; while there is no new object found which is visible
;; and the buffer boundary is not reached
(while (and (not break)
+ (or (not max)
+ (< (point) max))
(or (not (and (setq nobj (objed--object :get-obj))
(and nobj (not (equal obj nobj)))))
(and nobj
@@ -1534,6 +1550,11 @@ Ignores simple structured expressions like words or
symbols."
(objed-define-object nil textblock
+ :max-search-forward
+ (save-excursion
+ (objed--with-narrow-for-text
+ (forward-paragraph 1)
+ (point)))
:get-obj
(when (or (not (derived-mode-p 'prog-mode))
(derived-mode-p 'text-mode)
@@ -1545,7 +1566,6 @@ Ignores simple structured expressions like words or
symbols."
(or (not (eq (car bounds) (point-min)))
(not (eq (cdr bounds) (point-max)))))
(objed-make-object :obounds bounds)))))
- ;; TODO: narrow for current string/object
:try-next
(objed--with-narrow-for-text
(forward-sentence 1))
- [elpa] externals/objed 2e1e5c1 110/216: Run compilation as part of make test, (continued)
- [elpa] externals/objed 2e1e5c1 110/216: Run compilation as part of make test, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 433e92d 104/216: Block objed advices in object body codes, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 79ec8af 116/216: Fix boundary error, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 5a1c9f7 122/216: Improve char switching with objec-ace, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 38887bb 107/216: Adjust textblock object, Stefan Monnier, 2019/01/08
- [elpa] externals/objed fc11d2b 119/216: Fix skipping ws if point is after the object, Stefan Monnier, 2019/01/08
- [elpa] externals/objed d50117d 114/216: Fix kill-op error, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 49e36fd 123/216: Change back to indentation behavior, Stefan Monnier, 2019/01/08
- [elpa] externals/objed ce608d8 115/216: Add symbol object back, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 051028c 129/216: Fix init for entry commands which use after-init-alist, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 4b21416 112/216: Fix endless textblock search,
Stefan Monnier <=
- [elpa] externals/objed 703d634 131/216: Move some op bindings to more emacsy bindings, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 92fd6e7 135/216: Fix marking instances in objects not surrounding point, Stefan Monnier, 2019/01/08
- [elpa] externals/objed b9866d6 101/216: Fix undo op behavior, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 0e1d041 105/216: Simplify object macro usage, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 69db302 126/216: Some mroe init changes, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 0c5a4e3 147/216: Version bump, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 7617799 136/216: Allow testing different emacs versions, Stefan Monnier, 2019/01/08
- [elpa] externals/objed f5904c2 142/216: Add eval commands to keeper commands, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 734711a 124/216: Add move-to-window-line-top-bottom to activation cmds, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 9c816e2 133/216: Improve mark all for repeated object invokation, Stefan Monnier, 2019/01/08