From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Guerry Subject: [Accepted] [O,3/3] Promote and demote inline tasks Date: Sun, 6 Mar 2011 09:30:58 +0100 (CET) Message-ID: <20110306083058.03EE56A2C@myhost.localdomain> References: <1299084964-26440-3-git-send-email-n.goaziou@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from [140.186.70.92] (port=52416 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pw9Mz-0003hk-I5 for emacs-orgmode@gnu.org; Sun, 06 Mar 2011 03:31:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pw9My-0005Kt-2y for emacs-orgmode@gnu.org; Sun, 06 Mar 2011 03:31:17 -0500 Received: from mail-wy0-f169.google.com ([74.125.82.169]:37591) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pw9Mw-0005Kk-Gz for emacs-orgmode@gnu.org; Sun, 06 Mar 2011 03:31:16 -0500 Received: by wyi11 with SMTP id 11so3881270wyi.0 for ; Sun, 06 Mar 2011 00:31:13 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Patch 645 (http://patchwork.newartisans.com/patch/645/) is now "Accepted". Maintainer comment: none This relates to the following submission: http://mid.gmane.org/%3C1299084964-26440-3-git-send-email-n.goaziou%40gmail.com%3E Here is the original message containing the patch: > Content-Type: text/plain; charset="utf-8" > MIME-Version: 1.0 > Content-Transfer-Encoding: 7bit > Subject: [O,3/3] Promote and demote inline tasks > Date: Wed, 02 Mar 2011 21:56:04 -0000 > From: Nicolas Goaziou > X-Patchwork-Id: 645 > Message-Id: <1299084964-26440-3-git-send-email-n.goaziou@gmail.com> > To: Org mode list > Cc: Nicolas Goaziou > > * lisp/org-inlinetask.el (org-inlinetask-promote, > org-inlinetask-demote): new functions. > > * lisp/org.el (org-metaleft, org-metaright): when point is at an > inline task, promote or demote it. > > --- > lisp/org-inlinetask.el | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ > lisp/org.el | 28 +++++++++++++++++--------- > 2 files changed, 67 insertions(+), 10 deletions(-) > > diff --git a/lisp/org-inlinetask.el b/lisp/org-inlinetask.el > index 6bf38df..42ba7a4 100644 > --- a/lisp/org-inlinetask.el > +++ b/lisp/org-inlinetask.el > @@ -252,6 +252,55 @@ This assumes the point is inside an inline task." > (re-search-backward (org-inlinetask-outline-regexp) nil t) > (- (match-end 1) (match-beginning 1)))) > > +(defun org-inlinetask-promote () > + "Promote the inline task at point. > +If the task has an end part, promote it. Also, prevents level from > +going below `org-inlinetask-min-level'." > + (interactive) > + (if (not (org-inlinetask-in-task-p)) > + (error "Not in an inline task") > + (save-excursion > + (let* ((lvl (org-inlinetask-get-task-level)) > + (next-lvl (org-get-valid-level lvl -1)) > + (diff (- next-lvl lvl)) > + (down-task (concat (make-string next-lvl ?*))) > + beg) > + (if (< next-lvl org-inlinetask-min-level) > + (error "Cannot promote an inline task at minimum level") > + (org-inlinetask-goto-beginning) > + (setq beg (point)) > + (replace-match down-task nil t nil 1) > + (org-inlinetask-goto-end) > + (if (eobp) (beginning-of-line) (forward-line -1)) > + (unless (= (point) beg) > + (replace-match down-task nil t nil 1) > + (when org-adapt-indentation > + (goto-char beg) > + (org-fixup-indentation diff)))))))) > + > +(defun org-inlinetask-demote () > + "Demote the inline task at point. > +If the task has an end part, also demote it." > + (interactive) > + (if (not (org-inlinetask-in-task-p)) > + (error "Not in an inline task") > + (save-excursion > + (let* ((lvl (org-inlinetask-get-task-level)) > + (next-lvl (org-get-valid-level lvl 1)) > + (diff (- next-lvl lvl)) > + (down-task (concat (make-string next-lvl ?*))) > + beg) > + (org-inlinetask-goto-beginning) > + (setq beg (point)) > + (replace-match down-task nil t nil 1) > + (org-inlinetask-goto-end) > + (if (eobp) (beginning-of-line) (forward-line -1)) > + (unless (= (point) beg) > + (replace-match down-task nil t nil 1) > + (when org-adapt-indentation > + (goto-char beg) > + (org-fixup-indentation diff))))))) > + > (defvar org-export-current-backend) ; dynamically bound in org-exp.el > (defun org-inlinetask-export-handler () > "Handle headlines with level larger or equal to `org-inlinetask-min-level'. > diff --git a/lisp/org.el b/lisp/org.el > index 8ae5e6f..c528707 100644 > --- a/lisp/org.el > +++ b/lisp/org.el > @@ -17042,13 +17042,17 @@ See the individual commands for more information." > (cond > ((run-hook-with-args-until-success 'org-metaleft-hook)) > ((org-at-table-p) (org-call-with-arg 'org-table-move-column 'left)) > - ((or (org-on-heading-p) > - (and (org-region-active-p) > - (save-excursion > - (goto-char (region-beginning)) > - (org-on-heading-p)))) > + ((org-with-limited-levels > + (or (org-on-heading-p) > + (and (org-region-active-p) > + (save-excursion > + (goto-char (region-beginning)) > + (org-on-heading-p))))) > (when (org-check-for-hidden 'headlines) (org-hidden-tree-error)) > (call-interactively 'org-do-promote)) > + ;; At an inline task. > + ((org-on-heading-p) > + (call-interactively 'org-inlinetask-promote)) > ((or (org-at-item-p) > (and (org-region-active-p) > (save-excursion > @@ -17067,13 +17071,17 @@ See the individual commands for more information." > (cond > ((run-hook-with-args-until-success 'org-metaright-hook)) > ((org-at-table-p) (call-interactively 'org-table-move-column)) > - ((or (org-on-heading-p) > - (and (org-region-active-p) > - (save-excursion > - (goto-char (region-beginning)) > - (org-on-heading-p)))) > + ((org-with-limited-levels > + (or (org-on-heading-p) > + (and (org-region-active-p) > + (save-excursion > + (goto-char (region-beginning)) > + (org-on-heading-p))))) > (when (org-check-for-hidden 'headlines) (org-hidden-tree-error)) > (call-interactively 'org-do-demote)) > + ;; At an inline task. > + ((org-on-heading-p) > + (call-interactively 'org-inlinetask-demote)) > ((or (org-at-item-p) > (and (org-region-active-p) > (save-excursion >