org.el: Enhance C-c @' and use M-h' for `org-element-mark-element'.

* org.el (org-mode-map): Use `M-h' for
`org-element-mark-element'.
(org-mark-subtree): Allow a numeric prefix argument to move up
into the hierarchy of headlines.

* org-element.el (org-element-up, org-element-down): Autoload.
This commit is contained in:
Bastien Guerry 2012-08-06 20:02:54 +02:00
parent 1276ab3ff1
commit 7efbd4222d
2 changed files with 12 additions and 7 deletions

View file

@ -4329,6 +4329,7 @@ Move to the previous element at the same level, when possible."
((not prev-elem) (error "Cannot move further up"))
(t (goto-char (org-element-property :begin prev-elem)))))))
;;;###autoload
(defun org-element-up ()
"Move to upper element."
(interactive)
@ -4341,6 +4342,7 @@ Move to the previous element at the same level, when possible."
(error "No surrounding element")
(org-with-limited-levels (org-back-to-heading)))))))
;;;###autoload
(defun org-element-down ()
"Move to inner element."
(interactive)

View file

@ -17979,7 +17979,7 @@ BEG and END default to the buffer boundaries."
(org-defkey org-mode-map "\C-c\C-x\C-mg" 'org-mobile-pull)
(org-defkey org-mode-map "\C-c\C-x\C-mp" 'org-mobile-push)
(org-defkey org-mode-map "\C-c@" 'org-mark-subtree)
(org-defkey org-mode-map "\C-c\C-@" 'org-element-mark-element)
(org-defkey org-mode-map "\M-h" 'org-element-mark-element)
(org-defkey org-mode-map [?\C-c (control ?*)] 'org-list-make-subtree)
;;(org-defkey org-mode-map [?\C-c (control ?-)] 'org-list-make-list-from-subtree)
@ -20675,12 +20675,13 @@ which make use of the date at the cursor."
(message
"Entry marked for action; press `k' at desired date in agenda or calendar"))
(defun org-mark-subtree ()
(defun org-mark-subtree (&optional up)
"Mark the current subtree.
This puts point at the start of the current subtree, and mark at the end.
If point is in an inline task, mark that task instead."
(interactive)
This puts point at the start of the current subtree, and mark at
the end. If point is in an inline task, mark that task instead.
If a numeric prefix UP is given, move up into the hierarchy of
headlines by UP levels before marking the subtree."
(interactive "P")
(let ((inline-task-p
(and (featurep 'org-inlinetask)
(org-inlinetask-in-task-p)))
@ -20690,9 +20691,11 @@ If point is in an inline task, mark that task instead."
(inline-task-p (org-inlinetask-goto-beginning))
((org-at-heading-p) (beginning-of-line))
(t (org-with-limited-levels (outline-previous-visible-heading 1))))
;; Move up
(when up (dotimes (c (abs up)) (ignore-errors (org-element-up))))
(setq beg (point))
;; Get end of it
(if inline-task-p
(if inline-task-p
(org-inlinetask-goto-end)
(org-end-of-subtree))
;; Mark zone