* [Bug?] Mark subtrees and inline tasks @ 2010-10-21 9:36 Sébastien Vauban 2010-11-06 10:15 ` Nicolas Goaziou 0 siblings, 1 reply; 3+ messages in thread From: Sébastien Vauban @ 2010-10-21 9:36 UTC (permalink / raw) To: emacs-orgmode-mXXj517/zsQ #+TITLE: Mark subtree forgets about last line #+AUTHOR: Seb Vauban #+LANGUAGE: en_US * Selecting this subtree To select this subtree, I use =C-c @=. It does its job, except that it never selects the last line. OK; just C-x C-x, add a line, and that's it. Feature? Bug? * The next headline Same problem, though more problematic IMHO, with the inline tasks. *************** Check how the selection works I'd expect the END line to be selected as well. It's not. *************** END Best regards, Seb -- Sébastien Vauban _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode-mXXj517/zsQ@public.gmane.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Bug?] Mark subtrees and inline tasks 2010-10-21 9:36 [Bug?] Mark subtrees and inline tasks Sébastien Vauban @ 2010-11-06 10:15 ` Nicolas Goaziou 2010-11-06 10:28 ` Nicolas Goaziou 0 siblings, 1 reply; 3+ messages in thread From: Nicolas Goaziou @ 2010-11-06 10:15 UTC (permalink / raw) To: Sébastien Vauban; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 648 bytes --] Hello, >>>>> Sébastien Vauban writes: > To select this subtree, I use =C-c @=. > It does its job, except that it never selects the last line. OK; > just C-x C-x, add a line, and that's it. Feature? Bug? Feature. If you want to grab the last line too, use (org-end-of-subtree nil t) > Same problem, though more problematic IMHO, with the inline tasks. > *************** Check how the selection works > I'd expect the END line to be selected as well. It's not. > *************** END Here is a suggestion of patch creating a new function org-mark-subtree (and not using the outline one). Tell me if it works for you. Regards, -- Nicolas [-- Attachment #2: 0001-Handle-inline-tasks-when-marking-a-subtree.patch --] [-- Type: text/plain, Size: 3924 bytes --] From b2267d2e4ef40a0d0d6e8c9a789e835b5cde6036 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou <n.goaziou@gmail.com> Date: Sat, 6 Nov 2010 10:10:22 +0100 Subject: [PATCH] Handle inline tasks when marking a subtree * org-inlinetask.el (org-inlinetask-goto-beginning): new function * org-inlinetask.el (org-inlinetask-goto-end): new function * org.el (org-mark-subtree): new command * org.el (org-speed-commands-default, org-mode-map): make use of new command --- lisp/org-inlinetask.el | 24 ++++++++++++++++++++++++ lisp/org.el | 25 ++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletions(-) diff --git a/lisp/org-inlinetask.el b/lisp/org-inlinetask.el index c000999..fc0d932 100644 --- a/lisp/org-inlinetask.el +++ b/lisp/org-inlinetask.el @@ -147,6 +147,30 @@ If prefix arg NO-STATE is set, ignore `org-inlinetask-default-state'." (and (re-search-forward "^\\*+[ \t]+" nil t) (progn (beginning-of-line) (looking-at task-end-re))))))) +(defun org-inlinetask-goto-beginning () + "Go to the beginning of the inline task at point." + (end-of-line) + (re-search-backward (format "^\\*\\{%d,\\}" org-inlinetask-min-level) nil t) + (when (org-looking-at-p (format "^\\*\\{%d,\\} END" org-inlinetask-min-level)) + (re-search-backward + (format "^\\*\\{%d,\\}" org-inlinetask-min-level) nil t))) + +(defun org-inlinetask-goto-end () + "Go to the end of the inline task at point." + (cond + ((org-looking-at-p (format "^\\*\\{%d,\\} END" org-inlinetask-min-level)) + (forward-line 1)) + ((org-looking-at-p (format "^\\*\\{%d,\\} " org-inlinetask-min-level)) + (forward-line 1) + (when (org-inlinetask-in-task-p) + (re-search-forward + (format "^\\*\\{%d,\\} END" org-inlinetask-min-level) nil t) + (forward-line 1))) + (t + (re-search-forward + (format "^\\*\\{%d,\\} END" org-inlinetask-min-level) nil t) + (forward-line 1)))) + (defvar htmlp) ; dynamically scoped into the next function (defvar latexp) ; dynamically scoped into the next function (defun org-inlinetask-export-handler () diff --git a/lisp/org.el b/lisp/org.el index 201dd87..905fabc 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -16433,6 +16433,7 @@ BEG and END default to the buffer boundaries." (org-defkey org-mode-map "\C-c\C-xf" 'org-footnote-action) (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 (control ?*)] 'org-list-make-subtree) ;;(org-defkey org-mode-map [?\C-c (control ?-)] 'org-list-make-list-from-subtree) @@ -16506,7 +16507,7 @@ BEG and END default to the buffer boundaries." ("^" . org-sort) ("w" . org-refile) ("a" . org-archive-subtree-default-with-confirmation) - ("." . outline-mark-subtree) + ("." . org-mark-subtree) ("Clock Commands") ("I" . org-clock-in) ("O" . org-clock-out) @@ -18653,6 +18654,28 @@ 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 () + "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) + (let ((inline-task-p + (and (featurep 'org-inlinetask) + (org-inlinetask-in-task-p))) + (beg)) + (cond + (inline-task-p (org-inlinetask-goto-beginning)) + ((org-at-heading-p) (beginning-of-line)) + ;; else go back to previous heading + (t (outline-previous-visible-heading 1))) + (setq beg (point)) + (if inline-task-p + (org-inlinetask-goto-end) + (org-end-of-subtree)) + (push-mark (point) nil t) + (goto-char beg))) + ;;; Paragraph filling stuff. ;; We want this to be just right, so use the full arsenal. -- 1.7.3.2 [-- Attachment #3: Type: text/plain, Size: 201 bytes --] _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Bug?] Mark subtrees and inline tasks 2010-11-06 10:15 ` Nicolas Goaziou @ 2010-11-06 10:28 ` Nicolas Goaziou 0 siblings, 0 replies; 3+ messages in thread From: Nicolas Goaziou @ 2010-11-06 10:28 UTC (permalink / raw) To: Nicolas Goaziou; +Cc: Sébastien Vauban, emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 722 bytes --] Well, use this version instead. It will avoid compilation problems. >>>>> Sébastien Vauban writes: >> To select this subtree, I use =C-c @=. >> It does its job, except that it never selects the last line. OK; >> just C-x C-x, add a line, and that's it. Feature? Bug? > Feature. If you want to grab the last line too, use > (org-end-of-subtree nil t) >> Same problem, though more problematic IMHO, with the inline tasks. >> *************** Check how the selection works I'd expect the END >> line to be selected as well. It's not. *************** END > Here is a suggestion of patch creating a new function > org-mark-subtree (and not using the outline one). > Tell me if it works for you. Regards, -- Nicolas [-- Attachment #2: 0001-Handle-inline-tasks-when-marking-a-subtree.patch --] [-- Type: text/plain, Size: 4528 bytes --] From 8fcf73648f722e2aa8c539bdda433daab1edce6e Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou <n.goaziou@gmail.com> Date: Sat, 6 Nov 2010 10:10:22 +0100 Subject: [PATCH] Handle inline tasks when marking a subtree * org-inlinetask.el (org-inlinetask-goto-beginning): new function * org-inlinetask.el (org-inlinetask-goto-end): new function * org.el (org-mark-subtree): new command * org.el (org-speed-commands-default, org-mode-map): make use of new command --- lisp/org-inlinetask.el | 24 ++++++++++++++++++++++++ lisp/org.el | 29 ++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletions(-) diff --git a/lisp/org-inlinetask.el b/lisp/org-inlinetask.el index c000999..fc0d932 100644 --- a/lisp/org-inlinetask.el +++ b/lisp/org-inlinetask.el @@ -147,6 +147,30 @@ If prefix arg NO-STATE is set, ignore `org-inlinetask-default-state'." (and (re-search-forward "^\\*+[ \t]+" nil t) (progn (beginning-of-line) (looking-at task-end-re))))))) +(defun org-inlinetask-goto-beginning () + "Go to the beginning of the inline task at point." + (end-of-line) + (re-search-backward (format "^\\*\\{%d,\\}" org-inlinetask-min-level) nil t) + (when (org-looking-at-p (format "^\\*\\{%d,\\} END" org-inlinetask-min-level)) + (re-search-backward + (format "^\\*\\{%d,\\}" org-inlinetask-min-level) nil t))) + +(defun org-inlinetask-goto-end () + "Go to the end of the inline task at point." + (cond + ((org-looking-at-p (format "^\\*\\{%d,\\} END" org-inlinetask-min-level)) + (forward-line 1)) + ((org-looking-at-p (format "^\\*\\{%d,\\} " org-inlinetask-min-level)) + (forward-line 1) + (when (org-inlinetask-in-task-p) + (re-search-forward + (format "^\\*\\{%d,\\} END" org-inlinetask-min-level) nil t) + (forward-line 1))) + (t + (re-search-forward + (format "^\\*\\{%d,\\} END" org-inlinetask-min-level) nil t) + (forward-line 1)))) + (defvar htmlp) ; dynamically scoped into the next function (defvar latexp) ; dynamically scoped into the next function (defun org-inlinetask-export-handler () diff --git a/lisp/org.el b/lisp/org.el index 201dd87..515764a 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -3555,6 +3555,8 @@ Normal means no org-mode-specific context." "org-agenda" (&optional end)) (declare-function org-inlinetask-remove-END-maybe "org-inlinetask" ()) (declare-function org-inlinetask-in-task-p "org-inlinetask" ()) +(declare-function org-inlinetask-goto-beginning "org-inlinetask" ()) +(declare-function org-inlinetask-goto-end "org-inlinetask" ()) (declare-function org-indent-mode "org-indent" (&optional arg)) (declare-function parse-time-string "parse-time" (string)) (declare-function org-attach-reveal "org-attach" (&optional if-exists)) @@ -16433,6 +16435,7 @@ BEG and END default to the buffer boundaries." (org-defkey org-mode-map "\C-c\C-xf" 'org-footnote-action) (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 (control ?*)] 'org-list-make-subtree) ;;(org-defkey org-mode-map [?\C-c (control ?-)] 'org-list-make-list-from-subtree) @@ -16506,7 +16509,7 @@ BEG and END default to the buffer boundaries." ("^" . org-sort) ("w" . org-refile) ("a" . org-archive-subtree-default-with-confirmation) - ("." . outline-mark-subtree) + ("." . org-mark-subtree) ("Clock Commands") ("I" . org-clock-in) ("O" . org-clock-out) @@ -18653,6 +18656,30 @@ 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 () + "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) + (let ((inline-task-p + (and (featurep 'org-inlinetask) + (org-inlinetask-in-task-p))) + (beg)) + ;; Get beginning of subtree + (cond + (inline-task-p (org-inlinetask-goto-beginning)) + ((org-at-heading-p) (beginning-of-line)) + (t (outline-previous-visible-heading 1))) + (setq beg (point)) + ;; Get end of it + (if inline-task-p + (org-inlinetask-goto-end) + (org-end-of-subtree)) + ;; Mark zone + (push-mark (point) nil t) + (goto-char beg))) + ;;; Paragraph filling stuff. ;; We want this to be just right, so use the full arsenal. -- 1.7.3.2 [-- Attachment #3: Type: text/plain, Size: 201 bytes --] _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode ^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-11-06 10:28 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-10-21 9:36 [Bug?] Mark subtrees and inline tasks Sébastien Vauban 2010-11-06 10:15 ` Nicolas Goaziou 2010-11-06 10:28 ` Nicolas Goaziou
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.