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

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

[elpa] externals/objed 7374a35 128/166: Improve sexp fallback


From: Clemens Radermacher
Subject: [elpa] externals/objed 7374a35 128/166: Improve sexp fallback
Date: Sun, 29 Dec 2019 08:21:13 -0500 (EST)

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

    Improve sexp fallback
---
 objed-objects.el |  6 +++++-
 objed.el         | 35 +++++++++++++++++++++--------------
 2 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/objed-objects.el b/objed-objects.el
index bead3f7..32e4345 100644
--- a/objed-objects.el
+++ b/objed-objects.el
@@ -1829,7 +1829,11 @@ comments."
                           (when (/= pos (point))
                             (cons pos
                                   (point)))))))))
-    bounds)
+    (when bounds
+      (objed-make-object
+       :obounds bounds
+       :ibeg (1+ (car bounds))
+       :iend (1- (cdr bounds)))))
   :try-next
   (or (ignore-errors
         (forward-sexp 1)
diff --git a/objed.el b/objed.el
index 6e8d7b1..1aa3b8e 100644
--- a/objed.el
+++ b/objed.el
@@ -1853,17 +1853,20 @@ to an object containing the current one."
         (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))))
+        (cond ((or (looking-at "\\<[a-z]")
+                   (looking-back "[a-z]\\>" (1- (point))))
+               'word)
+              ((or (looking-at "\\_<[a-z]")
+                   (looking-back "[a-z]\\_>" (1- (point))))
+               'identifier)))))
 
 
-(defun objed--switch-to-sexp-fallback (&optional pos)
+(defun objed--maybe-switch-to-sexp-fallback (&optional pos)
   "Switch to sexp fallback at POS."
-  (let ((fallback (objed--sexp-fallback pos)))
-    (when fallback
-      (objed--switch-to fallback))))
+  (when (eq objed--object 'sexp)
+    (let ((fallback (objed--sexp-fallback pos)))
+      (when fallback
+        (objed--switch-to fallback)))))
 
 (defun objed--toggle-state ()
   "Toggle state of object."
@@ -2011,8 +2014,8 @@ Default to sexp at point."
 
 Switches between inner and whole object state."
   (interactive)
-  (when (eq objed--object 'sexp)
-    (objed--switch-to-sexp-fallback))
+  (unless (objed--inner-p)
+    (objed--maybe-switch-to-sexp-fallback))
   (let ((boo (eq (point) (objed--beg)))
         (eoo (eq (point) (objed--end))))
     (objed--toggle-state)
@@ -3663,8 +3666,10 @@ If nil ‘eval-region’ is used instead.")
 (defun objed-forward-slurp-sexp ()
   "Slurp following sexp into current object."
   (interactive)
-  (when (eq objed--object 'sexp)
-    (objed--switch-to-sexp-fallback))
+  (unless (memq last-command
+                '(objed-forward-slurp-sexp
+                  objed-forward-barf-sexp))
+    (objed--maybe-switch-to-sexp-fallback))
   (objed--markify-current-object)
   (let ((iend (objed--iend))
         (oend (objed--oend)))
@@ -3680,8 +3685,10 @@ If nil ‘eval-region’ is used instead.")
 (defun objed-forward-barf-sexp ()
   "Barf last sexp out of current object."
   (interactive)
-  (when (eq objed--object 'sexp)
-    (objed--switch-to-sexp-fallback))
+  (unless (memq last-command
+                '(objed-forward-slurp-sexp
+                  objed-forward-barf-sexp))
+    (objed--maybe-switch-to-sexp-fallback))
   (objed--markify-current-object)
   (let ((iend (objed--iend))
         (oend (objed--oend)))



reply via email to

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