[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/objed 2a25ff2 081/166: Make toggle smarter for sexp obj
From: |
Clemens Radermacher |
Subject: |
[elpa] externals/objed 2a25ff2 081/166: Make toggle smarter for sexp objects |
Date: |
Sun, 29 Dec 2019 08:21:05 -0500 (EST) |
branch: externals/objed
commit 2a25ff215d212c20244c5bd8f1b9c8ba06c94e01
Author: Clemens Radermacher <address@hidden>
Commit: Clemens Radermacher <address@hidden>
Make toggle smarter for sexp objects
---
objed-objects.el | 15 +--------------
objed.el | 19 +++++++++++++++++--
2 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/objed-objects.el b/objed-objects.el
index 7add776..6648e11 100644
--- a/objed-objects.el
+++ b/objed-objects.el
@@ -1773,20 +1773,7 @@ comments."
(when (/= pos (point))
(cons pos
(point)))))))))
-
- (when bounds
- (objed-make-object
- :obounds bounds
- :ibounds (when bounds
- (goto-char (car bounds))
- ;; include leading punctuation
- (skip-syntax-forward ".'")
- (let ((beg (point)))
- (goto-char (cdr bounds))
- (with-syntax-table text-mode-syntax-table
- (skip-syntax-backward "."))
- (skip-syntax-backward " .'")
- (cons beg (point)))))))
+ bounds)
:try-next
(or (ignore-errors
(forward-sexp 1)
diff --git a/objed.el b/objed.el
index 2e9fca1..739f934 100644
--- a/objed.el
+++ b/objed.el
@@ -1801,13 +1801,28 @@ to an object containing the current one."
(or (objed--switch-to 'defun 'inner)
(objed--switch-to 'line 'inner))))))
+
+(defun objed--sexp-fallback (&optional pos)
+ "Return fallback object for sexp at POS."
+ (let ((pos (or pos (point))))
+ (goto-char pos)
+ (or (objed--at-p '(bracket string tag))
+ (and (or (not (= 0 (skip-syntax-forward "'")))
+ (not (= 0 (skip-syntax-backward "'"))))
+ (objed--at-p '(bracket string)))
+ (if (equal (bounds-of-thing-at-point 'symbol)
+ (objed--bounds))
+ 'word
+ 'identifier))))
+
(defun objed--toggle-state ()
"Toggle state of object.
Shrinks to inner objects on repeat if possible."
(when (eq objed--object 'sexp)
- (save-excursion
- (objed-context-object)))
+ (let ((fallback (objed--sexp-fallback)))
+ (when fallback
+ (objed--switch-to fallback))))
(objed--reverse))
(defun objed-backward-until-context ()
- [elpa] externals/objed 210d3db 077/166: Improve sexp object for non symetric commands, (continued)
- [elpa] externals/objed 210d3db 077/166: Improve sexp object for non symetric commands, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed fa06574 075/166: Don't init when other modes have set overriding-terminal-local-map, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 752d11e 080/166: Change binding for sexp object, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 50f79c8 091/166: Include textblock for block expansion when at comment, too, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed dcea2bc 124/166: Add window resize commands, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed fc93d49 134/166: Improve error object when flymake is used, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed d111035 140/166: Require mc if necessary, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 6a2663e 138/166: Don't bind C-o by default, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed dc23da4 153/166: Add objed-exit-hook #57, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed faa9fb0 158/166: Allow defining objects without ending regexp (#58), Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 2a25ff2 081/166: Make toggle smarter for sexp objects,
Clemens Radermacher <=
- [elpa] externals/objed 2f50485 102/166: Add css defun object, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed d3ab36c 108/166: Add kill-this-buffer to command alist, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed be4c3cd 114/166: Make indenting defuns repeatable, too, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 4a22002 120/166: Improve reformat command, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 9267f38 125/166: Improve open line command, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed cab7cee 130/166: Update hl init, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 7374a35 128/166: Improve sexp fallback, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 42a553e 139/166: Don't override M-o binding, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 4d1a445 141/166: Add public object bounds functions, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed b6b7c3f 144/166: Disable during a company completion, Clemens Radermacher, 2019/12/29