diff options
author | Bastien Guerry <bzg@altern.org> | 2012-09-24 17:19:12 +0200 |
---|---|---|
committer | Bastien Guerry <bzg@altern.org> | 2012-09-24 17:19:12 +0200 |
commit | 6c92eca5eba94c2bda4f8e94adc2ebdf08b3a3ab (patch) | |
tree | 1ece784d17fd09db3fb8324cd07629f07142e397 | |
parent | b61ff117bc129e5843c7f38592385c07dba04bf5 (diff) | |
download | org-mode-6c92eca5eba94c2bda4f8e94adc2ebdf08b3a3ab.tar.gz |
Small enhancements to the main Org menu.
* org.el (org-in-subtree-not-table-p): New utility function
for building the menu.
(org-org-menu): Add an item for refiling. Check more contexts
when activating items.
(org-tree-to-indirect-buffer): Use `org-up-heading-safe'.
* org-agenda.el (org-agenda-tree-to-indirect-buffer)
(org-agenda-do-tree-to-indirect-buffer): Use argument `arg'.
-rwxr-xr-x | lisp/org-agenda.el | 25 | ||||
-rw-r--r-- | lisp/org.el | 58 |
2 files changed, 46 insertions, 37 deletions
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 24e5ebb..e0e5de5 100755 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -2200,7 +2200,7 @@ The following commands are available: ["Capture with cursor date" org-agenda-capture t] ["Follow Mode" org-agenda-follow-mode :style toggle :selected org-agenda-follow-mode :active t] - ; ["Tree to indirect frame" org-agenda-tree-to-indirect-buffer t] + ;; ["Tree to indirect frame" org-agenda-tree-to-indirect-buffer t] "--" ("TODO" ["Cycle TODO" org-agenda-todo t] @@ -7480,7 +7480,7 @@ When called with a prefix argument, include all archive files as well." (when (and (markerp m) (marker-buffer m)) (and org-agenda-follow-mode (if org-agenda-follow-indirect - (org-agenda-tree-to-indirect-buffer) + (org-agenda-tree-to-indirect-buffer nil) (org-agenda-show))) (and org-agenda-show-outline-path (org-with-point-at m (org-display-outline-path t)))))) @@ -7865,22 +7865,23 @@ docstring of `org-agenda-show-1'." (defun org-agenda-error () (error "Command not allowed in this line")) -(defun org-agenda-tree-to-indirect-buffer () +(defun org-agenda-tree-to-indirect-buffer (arg) "Show the subtree corresponding to the current entry in an indirect buffer. -This calls the command `org-tree-to-indirect-buffer' from the original -Org-mode buffer. -With numerical prefix arg ARG, go up to this level and then take that tree. +This calls the command `org-tree-to-indirect-buffer' from the original buffer. + +With a numerical prefix ARG, go up to this level and then take that tree. +With a negative numeric ARG, go up by this number of levels. With a \\[universal-argument] prefix, make a separate frame for this tree (i.e. don't use the dedicated frame)." - (interactive) - (if (and current-prefix-arg (listp current-prefix-arg)) - (org-agenda-do-tree-to-indirect-buffer) + (interactive "P") + (if current-prefix-arg + (org-agenda-do-tree-to-indirect-buffer arg) (let ((agenda-buffer (buffer-name)) (agenda-window (selected-window)) (indirect-window (and org-last-indirect-buffer (get-buffer-window org-last-indirect-buffer)))) - (save-window-excursion (org-agenda-do-tree-to-indirect-buffer)) + (save-window-excursion (org-agenda-do-tree-to-indirect-buffer arg)) (unless (or (eq org-indirect-buffer-display 'new-frame) (eq org-indirect-buffer-display 'dedicated-frame)) (unwind-protect @@ -7892,7 +7893,7 @@ use the dedicated frame)." (fit-window-to-buffer indirect-window))) (select-window (get-buffer-window agenda-buffer))))) -(defun org-agenda-do-tree-to-indirect-buffer () +(defun org-agenda-do-tree-to-indirect-buffer (arg) "Same as `org-agenda-tree-to-indirect-buffer' without saving window." (org-agenda-check-no-diary) (let* ((marker (or (org-get-at-bol 'org-marker) @@ -7902,7 +7903,7 @@ use the dedicated frame)." (with-current-buffer buffer (save-excursion (goto-char pos) - (call-interactively 'org-tree-to-indirect-buffer))))) + (funcall 'org-tree-to-indirect-buffer arg))))) (defvar org-last-heading-marker (make-marker) "Marker pointing to the headline that last changed its TODO state diff --git a/lisp/org.el b/lisp/org.el index eadc92d..ffff62a 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -7092,8 +7092,9 @@ or nil." (defun org-tree-to-indirect-buffer (&optional arg) "Create indirect buffer and narrow it to current subtree. -With numerical prefix ARG, go up to this level and then take that tree. +With a numerical prefix ARG, go up to this level and then take that tree. If ARG is negative, go up that many levels. + If `org-indirect-buffer-display' is not `new-frame', the command removes the indirect buffer previously made with this command, to avoid proliferation of indirect buffers. However, when you call the command with a \ @@ -7115,7 +7116,7 @@ frame is not changed." (setq level (org-outline-level)) (if (< arg 0) (setq arg (+ level arg))) (while (> (setq level (org-outline-level)) arg) - (outline-up-heading 1 t))) + (org-up-heading-safe))) (setq beg (point) heading (org-get-heading)) (org-end-of-subtree t t) @@ -19584,6 +19585,11 @@ See the individual commands for more information." ;;; Menu entries +(defsubst org-in-subtree-not-table-p () + "Are we in a subtree and not in a table?" + (and (not (org-before-first-heading-p)) + (not (org-at-table-p)))) + ;; Define the Org-mode menus (easy-menu-define org-tbl-menu org-mode-map "Tbl menu" '("Tbl" @@ -19666,23 +19672,25 @@ See the individual commands for more information." "--" ["Jump" org-goto t]) ("Edit Structure" - ["Move Subtree Up" org-shiftmetaup (not (org-at-table-p))] - ["Move Subtree Down" org-shiftmetadown (not (org-at-table-p))] + ["Refile Subtree" org-refile (org-in-subtree-not-table-p)] + "--" + ["Move Subtree Up" org-shiftmetaup (org-in-subtree-not-table-p)] + ["Move Subtree Down" org-shiftmetadown (org-in-subtree-not-table-p)] "--" - ["Copy Subtree" org-copy-special (not (org-at-table-p))] - ["Cut Subtree" org-cut-special (not (org-at-table-p))] + ["Copy Subtree" org-copy-special (org-in-subtree-not-table-p)] + ["Cut Subtree" org-cut-special (org-in-subtree-not-table-p)] ["Paste Subtree" org-paste-special (not (org-at-table-p))] "--" ["Clone subtree, shift time" org-clone-subtree-with-time-shift t] "--" ["Copy visible text" org-copy-visible t] "--" - ["Promote Heading" org-metaleft (not (org-at-table-p))] - ["Promote Subtree" org-shiftmetaleft (not (org-at-table-p))] - ["Demote Heading" org-metaright (not (org-at-table-p))] - ["Demote Subtree" org-shiftmetaright (not (org-at-table-p))] + ["Promote Heading" org-metaleft (org-in-subtree-not-table-p)] + ["Promote Subtree" org-shiftmetaleft (org-in-subtree-not-table-p)] + ["Demote Heading" org-metaright (org-in-subtree-not-table-p)] + ["Demote Subtree" org-shiftmetaright (org-in-subtree-not-table-p)] "--" - ["Sort Region/Children" org-sort (not (org-at-table-p))] + ["Sort Region/Children" org-sort t] "--" ["Convert to odd levels" org-convert-to-odd-levels t] ["Convert to odd/even levels" org-convert-to-oddeven-levels t]) @@ -19693,11 +19701,11 @@ See the individual commands for more information." ["Footnote new/jump" org-footnote-action t] ["Footnote extra" (org-footnote-action t) :active t :keys "C-u C-c C-x f"]) ("Archive" - ["Archive (default method)" org-archive-subtree-default t] + ["Archive (default method)" org-archive-subtree-default (org-in-subtree-not-table-p)] "--" - ["Move Subtree to Archive file" org-advertized-archive-subtree t] - ["Toggle ARCHIVE tag" org-toggle-archive-tag t] - ["Move subtree to Archive sibling" org-archive-to-archive-sibling t] + ["Move Subtree to Archive file" org-advertized-archive-subtree (org-in-subtree-not-table-p)] + ["Toggle ARCHIVE tag" org-toggle-archive-tag (org-in-subtree-not-table-p)] + ["Move subtree to Archive sibling" org-archive-to-archive-sibling (org-in-subtree-not-table-p)] ) "--" ("Hyperlinks" @@ -19748,23 +19756,23 @@ See the individual commands for more information." ["Go to the inbox of a feed..." org-feed-goto-inbox t] ["Customize feeds" (customize-variable 'org-feed-alist) t]) ("TAGS and Properties" - ["Set Tags" org-set-tags-command t] + ["Set Tags" org-set-tags-command (not (org-before-first-heading-p))] ["Change tag in region" org-change-tag-in-region (org-region-active-p)] "--" - ["Set property" org-set-property t] + ["Set property" org-set-property (not (org-before-first-heading-p))] ["Column view of properties" org-columns t] ["Insert Column View DBlock" org-insert-columns-dblock t]) ("Dates and Scheduling" - ["Timestamp" org-time-stamp t] - ["Timestamp (inactive)" org-time-stamp-inactive t] + ["Timestamp" org-time-stamp (not (org-before-first-heading-p))] + ["Timestamp (inactive)" org-time-stamp-inactive (not (org-before-first-heading-p))] ("Change Date" - ["1 Day Later" org-shiftright t] - ["1 Day Earlier" org-shiftleft t] - ["1 ... Later" org-shiftup t] - ["1 ... Earlier" org-shiftdown t]) + ["1 Day Later" org-shiftright (org-at-timestamp-p)] + ["1 Day Earlier" org-shiftleft (org-at-timestamp-p)] + ["1 ... Later" org-shiftup (org-at-timestamp-p)] + ["1 ... Earlier" org-shiftdown (org-at-timestamp-p)]) ["Compute Time Range" org-evaluate-time-range t] - ["Schedule Item" org-schedule t] - ["Deadline" org-deadline t] + ["Schedule Item" org-schedule (not (org-before-first-heading-p))] + ["Deadline" org-deadline (not (org-before-first-heading-p))] "--" ["Custom time format" org-toggle-time-stamp-overlays :style radio :selected org-display-custom-times] |