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

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

[elpa] externals/objed 4a22002 120/166: Improve reformat command


From: Clemens Radermacher
Subject: [elpa] externals/objed 4a22002 120/166: Improve reformat command
Date: Sun, 29 Dec 2019 08:21:12 -0500 (EST)

branch: externals/objed
commit 4a22002ed6d7baa6fe0b5b1e3274f8a19597c33f
Author: Clemens Radermacher <address@hidden>
Commit: Clemens Radermacher <address@hidden>

    Improve reformat command
---
 objed-objects.el | 24 ++++++++++++------------
 objed.el         | 16 ++++++++++------
 2 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/objed-objects.el b/objed-objects.el
index a708ab7..bead3f7 100644
--- a/objed-objects.el
+++ b/objed-objects.el
@@ -1217,12 +1217,12 @@ OBJ defaults to `objed--current-obj'."
   "Move to the next object.
 
 With postitive prefix argument ARG move to the nth next object."
-  (let ((arg (or arg 1)))
-    (dotimes (_ arg)
-      (let ((obj (objed--get-next)))
-        (when obj
-          (objed--update-current-object obj)
-          (objed--goto-char (objed--beg obj)))))))
+  (let ((arg (or arg 1))
+        (obj nil))
+    (dotimes (_ arg obj)
+      (when (setq obj  (objed--get-next))
+        (objed--update-current-object obj)
+        (objed--goto-char (objed--beg obj))))))
 
 
 (defun objed--goto-previous (&optional arg)
@@ -1230,12 +1230,12 @@ With postitive prefix argument ARG move to the nth next 
object."
 
 With postitive prefix argument ARG move to the nth previous
 object."
-  (let ((arg (or arg 1)))
-    (dotimes (_ arg)
-      (let ((obj (objed--get-prev)))
-        (when obj
-          (objed--update-current-object obj)
-          (objed--goto-char (objed--beg obj)))))))
+  (let ((arg (or arg 1))
+        (obj nil))
+    (dotimes (_ arg obj)
+      (when (setq obj (objed--get-prev))
+        (objed--update-current-object obj)
+        (objed--goto-char (objed--beg obj))))))
 
 (defun objed--make-object-overlay (&optional obj)
   "Create an overlay to mark current object.
diff --git a/objed.el b/objed.el
index ab7be55..edf9e51 100644
--- a/objed.el
+++ b/objed.el
@@ -604,11 +604,13 @@ selected one."
              (not buffer-read-only))
         (progn
           (when (eq last-command this-command)
-            (objed-next))
-          (cond ((or (eq major-mode 'fundamental-mode)
-                     (derived-mode-p 'text-mode)
-                     (objed--at-comment-p)
-                     (objed--in-string-or-comment-p))
+            (or (objed--goto-next)
+                (objed--switch-to 'defun)))
+          (cond ((and (not (eq objed--object 'defun))
+                      (or (eq major-mode 'fundamental-mode)
+                          (derived-mode-p 'text-mode)
+                          (objed--at-comment-p)
+                          (objed--in-string-or-comment-p)))
                  (call-interactively 'fill-paragraph)
                  (objed--switch-to 'textblock)
                  (message "Filled paragraph."))
@@ -3720,7 +3722,9 @@ and RANGE hold the object position data."
                   ((memq obj '(char word defun sentence line paragraph))
                    ;; keepers
                    objed--object)
-                  ((memq obj (append objed--block-objects (list 'comment)))
+                  ((memq obj (append objed--block-objects
+                                     (list 'comment
+                                           'region)))
                    ;; liners
                    'line)
                   (t



reply via email to

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