[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/objed 9f565e4 30/34: Make transposing objects work with
From: |
Stefan Monnier |
Subject: |
[elpa] externals/objed 9f565e4 30/34: Make transposing objects work with active region |
Date: |
Mon, 15 Mar 2021 22:21:12 -0400 (EDT) |
branch: externals/objed
commit 9f565e44d511eab64e2e2e34d589a9779659777c
Author: Clemens Radermacher <clemera@posteo.net>
Commit: Clemens Radermacher <clemera@posteo.net>
Make transposing objects work with active region
---
objed.el | 93 ++++++++++++++++++++++++++++++++++++++--------------------------
1 file changed, 56 insertions(+), 37 deletions(-)
diff --git a/objed.el b/objed.el
index b586aa6..3de48e9 100644
--- a/objed.el
+++ b/objed.el
@@ -3042,49 +3042,68 @@ Moves point over any whitespace afterwards."
Swaps the current object with the next one."
(interactive)
- (let* ((current (buffer-substring (objed--beg)
- (objed--end)))
-
- (nexto (objed--get-next))
- (next (and nexto (apply #'buffer-substring
- (objed--current nexto))))
- (nend (objed--end nexto)))
- (apply #'delete-region (objed--current nexto))
- (goto-char (objed--beg nexto))
- (insert current)
-
- (apply #'delete-region (objed--current))
- (goto-char (objed--beg))
- (insert next)
-
- (goto-char (- nend (length current)))
- (objed--update-current-object)))
-
+ (let ((reg (use-region-p)))
+ (when reg
+ (setq objed--current-obj
+ (objed-make-object :beg (region-beginning)
+ :end (region-end)))
+ (deactivate-mark))
+
+ (let* ((current (buffer-substring (objed--beg)
+ (objed--end)))
+ (nexto (objed--get-next))
+ (next (and nexto (apply #'buffer-substring
+ (objed--current nexto))))
+ (nend (objed--end nexto)))
+ (apply #'delete-region (objed--current nexto))
+ (goto-char (objed--beg nexto))
+ (insert current)
+
+ (apply #'delete-region (objed--current))
+ (goto-char (objed--beg))
+ (insert next)
+
+ (when reg
+ (push-mark nend t t)
+ (setq deactivate-mark nil))
+ (goto-char (- nend (length current)))
+ (unless reg
+ (objed--update-current-object)))))
(defun objed-move-object-backward ()
"Move object backward.
Swaps the current object with the previous one."
(interactive)
- (let* ((current (buffer-substring (objed--beg)
- (objed--end)))
-
- (prevo (objed--get-prev))
- (prev (and prevo (apply #'buffer-substring
- (objed--current prevo))))
- (pbeg (objed--beg prevo)))
-
- (apply #'delete-region (objed--current))
- (goto-char (objed--beg))
- (insert prev)
-
- (apply #'delete-region (objed--current prevo))
- (goto-char (objed--beg prevo))
- (insert current)
- (goto-char pbeg)
- (objed--update-current-object)))
-
-
+ (let ((reg (use-region-p)))
+ (when reg
+ (setq objed--current-obj
+ (objed-make-object :beg (region-beginning)
+ :end (region-end)))
+ (deactivate-mark))
+
+ (let* ((current (buffer-substring (objed--beg)
+ (objed--end)))
+
+ (prevo (objed--get-prev))
+ (prev (and prevo (apply #'buffer-substring
+ (objed--current prevo))))
+ (pbeg (objed--beg prevo)))
+
+ (apply #'delete-region (objed--current))
+ (goto-char (objed--beg))
+ (insert prev)
+
+ (apply #'delete-region (objed--current prevo))
+ (goto-char (objed--beg prevo))
+ (insert current)
+
+ (when reg
+ (push-mark (point) t t)
+ (setq deactivate-mark nil))
+ (goto-char pbeg)
+ (unless reg
+ (objed--update-current-object)))))
(defun objed--switch-and-move (o dir)
"Switch to object O and move it in direction DIR."
- [elpa] externals/objed c3106c9 13/34: Make note about changes even more promiment, (continued)
- [elpa] externals/objed c3106c9 13/34: Make note about changes even more promiment, Stefan Monnier, 2021/03/15
- [elpa] externals/objed dea5a64 14/34: Rephrase, Stefan Monnier, 2021/03/15
- [elpa] externals/objed a2bd06b 15/34: Autoload dired-jump, Stefan Monnier, 2021/03/15
- [elpa] externals/objed 56d3906 21/34: Drop obsolete avy--process function, Stefan Monnier, 2021/03/15
- [elpa] externals/objed 9d2ad56 25/34: Fix undo for objed-comment-duplicate, Stefan Monnier, 2021/03/15
- [elpa] externals/objed f4e7cab 24/34: Also allow prefix syntax for objed-include-backward, Stefan Monnier, 2021/03/15
- [elpa] externals/objed 70f9fb5 34/34: Add notice for paused development, Stefan Monnier, 2021/03/15
- [elpa] externals/objed 0f75d33 32/34: Fix compiler warnings, Stefan Monnier, 2021/03/15
- [elpa] externals/objed 9f7f6e5 23/34: Improve include commands to also cover punctuation and constituents, Stefan Monnier, 2021/03/15
- [elpa] externals/objed 2287436 19/34: Include possible active region when acting on multiple objects, Stefan Monnier, 2021/03/15
- [elpa] externals/objed 9f565e4 30/34: Make transposing objects work with active region,
Stefan Monnier <=
- [elpa] externals/objed e93dda7 33/34: Require cl-lib in all files, Stefan Monnier, 2021/03/15
- [elpa] externals/objed 410a425 29/34: Refactor isearch handling and add missing commands, Stefan Monnier, 2021/03/15
- [elpa] externals/objed 8dc1770 01/34: Stay on at boundary for M-[/] (Fix #68), Stefan Monnier, 2021/03/15
- [elpa] externals/objed 31c5ded 03/34: Add separate option for auto init behavior on buffer change, Stefan Monnier, 2021/03/15
- [elpa] externals/objed 9bb3513 04/34: Fix differing initialization conditions, Stefan Monnier, 2021/03/15
- [elpa] externals/objed e046331 07/34: Implemented objed-local-mode (#72), Stefan Monnier, 2021/03/15
- [elpa] externals/objed e89d8da 06/34: Fix bytecompile and linting errors, Stefan Monnier, 2021/03/15
- [elpa] externals/objed f5ddab2 08/34: Update objed-exit-op: Check range was passed, Stefan Monnier, 2021/03/15
- [elpa] externals/objed e871e0f 11/34: Mention changes of public interface, Stefan Monnier, 2021/03/15
- [elpa] externals/objed ae47cf6 10/34: Ensure to never shrink on expansion for objed-beg/end-of-block, Stefan Monnier, 2021/03/15