Function: org-metadown

org-metadown is an interactive and byte-compiled function defined in org.el.gz.

Signature

(org-metadown &optional ARG)

Documentation

Move subtree down or move table row down.

Calls org-move-subtree-down or org-table-move-row or org-move-item-down, depending on context. Everywhere else, move forward the element at point. See the individual commands for more information.

This function runs the functions in org-metadown-hook one by one as a first step, and exits immediately if a function from the hook returns non-nil. In the absence of a specific context, the function runs org-metadown-final-hook using the same logic.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/org/org.el.gz
(defun org-metadown (&optional _arg)
  "Move subtree down or move table row down.
Calls `org-move-subtree-down' or `org-table-move-row' or
`org-move-item-down', depending on context.  Everywhere else,
move forward the element at point.  See the individual commands
for more information.

This function runs the functions in `org-metadown-hook' one by
one as a first step, and exits immediately if a function from the
hook returns non-nil.  In the absence of a specific context, the
function runs `org-metadown-final-hook' using the same logic."
  (interactive "P")
  (cond
   ((run-hook-with-args-until-success 'org-metadown-hook))
   ((and (org-region-active-p)
         (org-with-limited-levels
          (save-excursion
            (goto-char (region-beginning))
            (org-at-heading-p))))
    (when (org-check-for-hidden 'headlines) (org-hidden-tree-error))
    (let ((beg (region-beginning))
          (end (region-end)))
      (save-excursion
        (goto-char beg)
        (setq beg (point-marker))
        (let ((level (org-current-level)))
          (when (or (and (> level 1) (re-search-forward (format "^\\*\\{1,%s\\} " (1- level)) end t))
                    ;; Search next subtree.
                    (progn
                      (goto-char end)
                      (not (re-search-forward (format "^\\*\\{%s\\} " level) nil t))))
            (user-error "Cannot move past superior level or buffer limit"))
          ;; Drag first subtree below above the selected.
          (while (> (point) beg)
            (let ((deactivate-mark nil))
              (call-interactively 'org-move-subtree-up)))))))
   ((org-region-active-p)
    (let* ((a (save-excursion
                (goto-char (region-beginning))
                (line-beginning-position)))
	   (b (save-excursion
                (goto-char (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)))
           (deactivate-mark nil)
           (swap? (< (point) (mark))))
      (transpose-regions a b c d)
      (set-mark (+ 1 a (- d c)))
      (goto-char (+ 1 a (- d c) (- b a)))
      (when swap? (exchange-point-and-mark))))
   ((org-at-table-p) (call-interactively 'org-table-move-row))
   ((and (featurep 'org-inlinetask)
         (org-inlinetask-in-task-p))
    (org-drag-element-forward))
   ((org-at-heading-p) (call-interactively 'org-move-subtree-down))
   ((org-at-item-p) (call-interactively 'org-move-item-down))
   ((run-hook-with-args-until-success 'org-metadown-final-hook))
   (t (org-drag-element-forward))))