mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-18 10:40:14 +00:00
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.
This commit is contained in:
parent
1fe42fd0bc
commit
9fb530dc48
44
lisp/org.el
44
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.
|
||||
|
|
Loading…
Reference in a new issue