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

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

[elpa] externals/objed 6907e69 058/216: Improve face object


From: Stefan Monnier
Subject: [elpa] externals/objed 6907e69 058/216: Improve face object
Date: Tue, 8 Jan 2019 12:29:11 -0500 (EST)

branch: externals/objed
commit 6907e69da6717fb5b85fcd89c326f13a6e2d2506
Author: Clemera <address@hidden>
Commit: Clemera <address@hidden>

    Improve face object
---
 objed-objects.el | 79 +++++++++++++++++++++++++++++++-------------------------
 1 file changed, 44 insertions(+), 35 deletions(-)

diff --git a/objed-objects.el b/objed-objects.el
index f57218c..dfb3ebe 100644
--- a/objed-objects.el
+++ b/objed-objects.el
@@ -1910,49 +1910,58 @@ non-nil the indentation block can contain empty lines."
         (start (point))
         (end (point)))
 
-    ;; check chars backward,
-    ;; stop when char is not white space and has different face
-    (save-excursion
-      (let ((continue t))
-        (while (and continue (>= (- (point) 1) (point-min)))
-          (backward-char)
-          (let ((backward-point-face (objed--what-face)))
-            (if (= 32 (char-syntax (char-after)))
-                (setq backward-point (point))
-              (if (equal point-face backward-point-face)
-                  (progn (setq backward-point (point))
-                         (setq backward-none-space-point (point)))
-                (setq continue nil)))))))
-
-    ;; check chars forward,
-    ;; stop when char is not white space and has different face
-    (save-excursion
-      (let ((continue t))
-        (while (and continue (< (+ (point) 1) (point-max)))
-          (forward-char)
-          (let ((forward-point-face (objed--what-face)))
-            (if (= 32 (char-syntax (char-after)))
-                (setq forward-point (point))
-              (if (equal point-face forward-point-face)
-                  (progn (setq forward-point (point))
-                         (setq forward-none-space-point (point)))
-                (setq continue nil)))))))
-    (progn (setq start backward-none-space-point)
-           (setq end forward-none-space-point)
-           (cons start (+ end 1)))))
-
-
-(objed-define-object nil syntax
     (when (eq real-this-command #'objed-face-object)
       (setq objed--last-face point-face))
+
+    (when (equal objed--last-face
+                 (objed--what-face))
+      ;; check chars backward,
+      ;; stop when char is not white space and has different face
+      (save-excursion
+        (let ((continue t))
+          (while (and continue (>= (- (point) 1) (point-min)))
+            (backward-char)
+            (let ((backward-point-face (objed--what-face)))
+              (if (= 32 (char-syntax (char-after)))
+                  (setq backward-point (point))
+                (if (equal point-face backward-point-face)
+                    (progn (setq backward-point (point))
+                           (setq backward-none-space-point (point)))
+                  (setq continue nil)))))))
+
+      ;; check chars forward,
+      ;; stop when char is not white space and has different face
+      (save-excursion
+        (let ((continue t))
+          (while (and continue (< (+ (point) 1) (point-max)))
+            (forward-char)
+            (let ((forward-point-face (objed--what-face)))
+              (if (= 32 (char-syntax (char-after)))
+                  (setq forward-point (point))
+                (if (equal point-face forward-point-face)
+                    (progn (setq forward-point (point))
+                           (setq forward-none-space-point (point)))
+                  (setq continue nil)))))))
+
+      (progn (setq start backward-none-space-point)
+             (setq end forward-none-space-point)
+             (cons start (+ end 1))))))
+
+
 (objed-define-object nil face
   :get-obj
   (objed--get-face-range)
   ;; TODO: search for next same face as current...
   :try-next
-  (re-search-forward "\\<" nil t)
+  (while (not (equal objed--last-face
+                     (objed--what-face)))
+    (forward-char 1))
   :try-prev
-  (re-search-backward "\\<" nil t))
+  ;; get out of current
+  (forward-char -1)
+  (while (not (equal objed--last-face
+                     (objed--what-face)))
+    (forward-char -1)))
 
 
 (declare-function org-mark-element "ext:org")



reply via email to

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