summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2012-07-12 11:57:05 +0200
committerBastien Guerry <bzg@altern.org>2012-07-12 11:57:05 +0200
commit9fb530dc480308fcd3a04ced8600845cc3e7e4ef (patch)
tree33ad569e1c06fbc3ed04fd9bf9f9f730bdc5be2e
parent1fe42fd0bcc7e567128ebe36e01c14c622d75a8e (diff)
downloadorg-mode-9fb530dc480308fcd3a04ced8600845cc3e7e4ef.tar.gz
org.el: Allow moving the region by one line up and down.
* org.el (org-move-line-down, org-move-line-up): Remove. (org-metaup, org-metadown): When the region is active, move it up/down by one line, with no regard to the context.
-rw-r--r--lisp/org.el44
1 files changed, 18 insertions, 26 deletions
diff --git a/lisp/org.el b/lisp/org.el
index be0549c..40e723e 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -18461,6 +18461,15 @@ for more information."
(interactive "P")
(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))))
+ (transpose-regions a b c d)
+ (goto-char c)))
((org-at-table-p) (org-call-with-arg 'org-table-move-row 'up))
((org-at-heading-p) (call-interactively 'org-move-subtree-up))
((org-at-item-p) (call-interactively 'org-move-item-up))
@@ -18474,6 +18483,15 @@ commands for more information."
(interactive "P")
(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)))))
+ (transpose-regions a b c d)
+ (goto-char d)))
((org-at-table-p) (call-interactively 'org-table-move-row))
((org-at-heading-p) (call-interactively 'org-move-subtree-down))
((org-at-item-p) (call-interactively 'org-move-item-down))
@@ -20342,32 +20360,6 @@ ones and overrule settings in the other lists."
(setq rtn (plist-put rtn p v))))
rtn))
-(defun org-move-line-down (arg)
- "Move the current line down. With prefix argument, move it past ARG lines."
- (interactive "p")
- (let ((col (current-column))
- beg end pos)
- (beginning-of-line 1) (setq beg (point))
- (beginning-of-line 2) (setq end (point))
- (beginning-of-line (+ 1 arg))
- (setq pos (move-marker (make-marker) (point)))
- (insert (delete-and-extract-region beg end))
- (goto-char pos)
- (org-move-to-column col)))
-
-(defun org-move-line-up (arg)
- "Move the current line up. With prefix argument, move it past ARG lines."
- (interactive "p")
- (let ((col (current-column))
- beg end pos)
- (beginning-of-line 1) (setq beg (point))
- (beginning-of-line 2) (setq end (point))
- (beginning-of-line (- arg))
- (setq pos (move-marker (make-marker) (point)))
- (insert (delete-and-extract-region beg end))
- (goto-char pos)
- (org-move-to-column col)))
-
(defun org-replace-escapes (string table)
"Replace %-escapes in STRING with values in TABLE.
TABLE is an association list with keys like \"%a\" and string values.