summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2018-06-15 18:52:09 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2018-06-15 18:52:09 +0200
commitb3981d6ad0a50c2f0706d94f67af7371a0af40ea (patch)
tree243e339fb1c1da0dc7020fcd3ce1621ce7fdeb36
parentf47917ce26678d7d730947729bc87bdab2875e19 (diff)
downloadorg-mode-b3981d6ad0a50c2f0706d94f67af7371a0af40ea.tar.gz
Fix `org-metaup' and `org-metadown' on regions
* lisp/org.el (org-metaup): Do not leave a character behind when transposing regions. (org-metadown): Fix "Transposed regions overlap" error. Reported-by: Adam Porter <adam@alphapapa.net> <http://lists.gnu.org/r/emacs-orgmode/2018-06/msg00184.html>
-rw-r--r--lisp/org.el40
1 files changed, 28 insertions, 12 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 6bf5807..2dba348 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -19791,12 +19791,20 @@ for more information."
(cond
((run-hook-with-args-until-success 'org-metaup-hook))
((org-region-active-p)
- (let* ((a (min (region-beginning) (region-end)))
- (b (1- (max (region-beginning) (region-end))))
- (c (save-excursion (goto-char a)
- (move-beginning-of-line 0)))
- (d (save-excursion (goto-char a)
- (move-end-of-line 0) (point))))
+ (let* ((a (save-excursion
+ (goto-char (min (region-beginning) (region-end)))
+ (line-beginning-position)))
+ (b (save-excursion
+ (goto-char (max (region-beginning) (region-end)))
+ (if (bolp) (1- (point)) (line-end-position))))
+ (c (save-excursion
+ (goto-char a)
+ (move-beginning-of-line 0)
+ (point)))
+ (d (save-excursion
+ (goto-char a)
+ (move-end-of-line 0)
+ (point))))
(transpose-regions a b c d)
(goto-char c)))
((org-at-table-p) (org-call-with-arg 'org-table-move-row 'up))
@@ -19813,12 +19821,20 @@ commands for more information."
(cond
((run-hook-with-args-until-success 'org-metadown-hook))
((org-region-active-p)
- (let* ((a (min (region-beginning) (region-end)))
- (b (max (region-beginning) (region-end)))
- (c (save-excursion (goto-char b)
- (move-beginning-of-line 1)))
- (d (save-excursion (goto-char b)
- (move-end-of-line 1) (1+ (point)))))
+ (let* ((a (save-excursion
+ (goto-char (min (region-beginning) (region-end)))
+ (line-beginning-position)))
+ (b (save-excursion
+ (goto-char (max (region-beginning) (region-end)))
+ (if (bolp) (1- (point)) (line-end-position))))
+ (c (save-excursion
+ (goto-char b)
+ (move-beginning-of-line (if (bolp) 1 2))
+ (point)))
+ (d (save-excursion
+ (goto-char b)
+ (move-end-of-line (if (bolp) 1 2))
+ (point))))
(transpose-regions a b c d)
(goto-char d)))
((org-at-table-p) (call-interactively 'org-table-move-row))