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

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

[elpa] externals/objed cac61c3 084/216: Improve block objects


From: Stefan Monnier
Subject: [elpa] externals/objed cac61c3 084/216: Improve block objects
Date: Tue, 8 Jan 2019 12:29:16 -0500 (EST)

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

    Improve block objects
---
 objed-objects.el | 18 ++++++++++++++----
 objed.el         | 28 ++++++++++++++--------------
 2 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/objed-objects.el b/objed-objects.el
index cc4a331..419c309 100644
--- a/objed-objects.el
+++ b/objed-objects.el
@@ -1483,8 +1483,13 @@ non-nil the indentation block can contain empty lines."
   :get-obj
   (let ((bounds (objed--get-indent-bounds 'inner)))
     (when bounds
-      (objed-make-object :obounds (cons (car bounds)
-                                        (1+ (cdr bounds))))))
+      (objed-make-object
+       :obounds
+       (cons (car bounds)
+             (if (eq (cdr bounds)
+                     (point-max))
+                 (cdr bounds)
+               (1+ (cdr bounds)))))))
   :try-next
   ;;(error "No next indent")
   (objed--skip-ws)
@@ -1497,8 +1502,13 @@ non-nil the indentation block can contain empty lines."
   :get-obj
   (let ((bounds (objed--get-indent-bounds nil t)))
     (when bounds
-      (objed-make-object :obounds (cons (car bounds)
-                                        (1+ (cdr bounds))))))
+      (objed-make-object
+       :obounds
+       (cons (car bounds)
+             (if (eq (cdr bounds)
+                     (point-max))
+                 (cdr bounds)
+               (1+ (cdr bounds)))))))
   :try-next
   (objed--skip-ws)
   :try-prev
diff --git a/objed.el b/objed.el
index 26f0afc..91f7ea3 100644
--- a/objed.el
+++ b/objed.el
@@ -1258,7 +1258,7 @@ matches IREGEX is not displayed."
 
 ;; * Basic Movement, Block Objects (textblocks)
 
-(defvar objed--block-objects '(line buffer iblock section textblock indent 
paragraph)
+(defvar objed--block-objects '(buffer iblock section paragraph textblock 
indent line)
   "List of objects which are 'line based'.
 
 Objects which are built by lines of text.")
@@ -1318,8 +1318,8 @@ order. ISTATE is the object state to use and defaults to 
whole."
     ;; TODO: use size of object for sorting
     (dolist (ps (sort states (lambda (a b)
                                ;; ensure line comes first
-                               (and (not (eq (cadr (cddr a)) 'line))
-                                    ;; TODO: fix state format
+                               (and t;(not (eq (cadr (cddr a)) 'line))
+                                    ;; TODO: when eq sort with opposite end
                                     (<= (car a) (car b)))))
                 nos)
       (push (cdr ps) nos)))))
@@ -1339,17 +1339,17 @@ See also `objed--block-objects'."
                          (list this-command
                                'objed-toggle-side)))))
     (when init
-      (setq blocks (cl-remove
-                    nil
-                    (objed--get-blocks
-                     ;; ignore current or allow toggle between
-                     ;; inner/whole here as well?
-                     objed--object
-                     #'objed--beg)
-                    :test (lambda (_ a)
-                            (let ((as (objed--beg (car (nthcdr 3 a)))))
-                              ;; make sure position is not below start
-                              (> as (objed--skip-forward (point) 'ws)))))))
+      (setq blocks
+            (cl-remove-duplicates
+             (objed--get-blocks
+              ;; ignore current or allow toggle between
+              ;; inner/whole here as well?
+              objed--object
+              #'objed--beg)
+             :test (lambda (a b)
+                     (let ((as (car (nthcdr 3 a)))
+                           (bs (car (nthcdr 3 b))))
+                       (equal as bs))))))
   (when blocks
      (let ((sdiff (abs (- (point) (objed--beg))))
            (ediff (abs (- (point) (objed--end)))))



reply via email to

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