Browse Source

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.
Bastien Guerry 12 years ago
parent
commit
7efbd4222d
2 changed files with 12 additions and 7 deletions
  1. 2 0
      lisp/org-element.el
  2. 10 7
      lisp/org.el

+ 2 - 0
lisp/org-element.el

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

+ 10 - 7
lisp/org.el

@@ -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-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\C-x\C-mp"    'org-mobile-push)
 (org-defkey org-mode-map "\C-c@" 'org-mark-subtree)
 (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-subtree)
 ;;(org-defkey org-mode-map [?\C-c (control ?-)] 'org-list-make-list-from-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
   (message
    "Entry marked for action; press `k' at desired date in agenda or calendar"))
    "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.
   "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
   (let ((inline-task-p
 	 (and (featurep 'org-inlinetask)
 	 (and (featurep 'org-inlinetask)
 	      (org-inlinetask-in-task-p)))
 	      (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))
      (inline-task-p (org-inlinetask-goto-beginning))
      ((org-at-heading-p) (beginning-of-line))
      ((org-at-heading-p) (beginning-of-line))
      (t (org-with-limited-levels (outline-previous-visible-heading 1))))
      (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))
     (setq beg (point))
     ;; Get end of it
     ;; Get end of it
-    (if	inline-task-p
+    (if inline-task-p
 	(org-inlinetask-goto-end)
 	(org-inlinetask-goto-end)
       (org-end-of-subtree))
       (org-end-of-subtree))
     ;; Mark zone
     ;; Mark zone