emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH 1/3] Fix bug when narrowing to subtree with point at an inline task
@ 2011-03-02 16:56 Nicolas Goaziou
  2011-03-02 16:56 ` [PATCH 2/3] When demoting a subtree, don't change level of inline tasks within Nicolas Goaziou
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Nicolas Goaziou @ 2011-03-02 16:56 UTC (permalink / raw)
  To: Org mode list; +Cc: Nicolas Goaziou

* lisp/org.el (org-narrow-to-subtree): ensure `org-back-to-heading'
  will move point to a real heading and not an inline task by wraping
  function into a org-with-limited-levels macro.
---
 lisp/org.el |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index a26a3ca..6e1be76 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -7566,11 +7566,12 @@ If yes, remember the marker and the distance to BEG."
   (interactive)
   (save-excursion
     (save-match-data
-      (narrow-to-region
-       (progn (org-back-to-heading t) (point))
-       (progn (org-end-of-subtree t t)
-	      (if (and (org-on-heading-p) (not (eobp))) (backward-char 1))
-	      (point))))))
+      (org-with-limited-levels
+       (narrow-to-region
+	(progn (org-back-to-heading t) (point))
+	(progn (org-end-of-subtree t t)
+	       (if (and (org-on-heading-p) (not (eobp))) (backward-char 1))
+	       (point)))))))
 
 (defun org-narrow-to-block ()
   "Narrow buffer to the current block."
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] When demoting a subtree, don't change level of inline tasks within
  2011-03-02 16:56 [PATCH 1/3] Fix bug when narrowing to subtree with point at an inline task Nicolas Goaziou
@ 2011-03-02 16:56 ` Nicolas Goaziou
  2011-03-06  8:30   ` [Accepted] [O, " Bastien Guerry
  2011-03-02 16:56 ` [PATCH 3/3] Promote and demote inline tasks Nicolas Goaziou
  2011-03-06  8:29 ` [Accepted] [O, 1/3] Fix bug when narrowing to subtree with point at an inline task Bastien Guerry
  2 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2011-03-02 16:56 UTC (permalink / raw)
  To: Org mode list; +Cc: Nicolas Goaziou

* lisp/org.el (org-demote-subtree,org-promote-subtree): wrap
  org-map-tree into org-with-limited-levels macro, so it avoids
  operating on inline tasks.
---
 lisp/org.el |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 6e1be76..8ae5e6f 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -7002,7 +7002,7 @@ When a subtree is being promoted, the hook will be called for each node.")
 See also `org-promote'."
   (interactive)
   (save-excursion
-    (org-map-tree 'org-promote))
+    (org-with-limited-levels (org-map-tree 'org-promote)))
   (org-fix-position-after-promote))
 
 (defun org-demote-subtree ()
@@ -7010,7 +7010,7 @@ See also `org-promote'."
 See also `org-promote'."
   (interactive)
   (save-excursion
-    (org-map-tree 'org-demote))
+    (org-with-limited-levels (org-map-tree 'org-demote)))
   (org-fix-position-after-promote))
 
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] Promote and demote inline tasks
  2011-03-02 16:56 [PATCH 1/3] Fix bug when narrowing to subtree with point at an inline task Nicolas Goaziou
  2011-03-02 16:56 ` [PATCH 2/3] When demoting a subtree, don't change level of inline tasks within Nicolas Goaziou
@ 2011-03-02 16:56 ` Nicolas Goaziou
  2011-03-06  8:30   ` [Accepted] [O,3/3] " Bastien Guerry
  2011-03-06  8:29 ` [Accepted] [O, 1/3] Fix bug when narrowing to subtree with point at an inline task Bastien Guerry
  2 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2011-03-02 16:56 UTC (permalink / raw)
  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
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Accepted] [O, 1/3] Fix bug when narrowing to subtree with point at an inline task
  2011-03-02 16:56 [PATCH 1/3] Fix bug when narrowing to subtree with point at an inline task Nicolas Goaziou
  2011-03-02 16:56 ` [PATCH 2/3] When demoting a subtree, don't change level of inline tasks within Nicolas Goaziou
  2011-03-02 16:56 ` [PATCH 3/3] Promote and demote inline tasks Nicolas Goaziou
@ 2011-03-06  8:29 ` Bastien Guerry
  2 siblings, 0 replies; 6+ messages in thread
From: Bastien Guerry @ 2011-03-06  8:29 UTC (permalink / raw)
  To: emacs-orgmode

Patch 643 (http://patchwork.newartisans.com/patch/643/) is now "Accepted".

Maintainer comment: none

This relates to the following submission:

http://mid.gmane.org/%3C1299084964-26440-1-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,
> 	1/3] Fix bug when narrowing to subtree with point at an inline task
> Date: Wed, 02 Mar 2011 21:56:02 -0000
> From: Nicolas Goaziou <n.goaziou@gmail.com>
> X-Patchwork-Id: 643
> Message-Id: <1299084964-26440-1-git-send-email-n.goaziou@gmail.com>
> To: Org mode list <emacs-orgmode@gnu.org>
> Cc: Nicolas Goaziou <n.goaziou@gmail.com>
> 
> * lisp/org.el (org-narrow-to-subtree): ensure `org-back-to-heading'
>   will move point to a real heading and not an inline task by wraping
>   function into a org-with-limited-levels macro.
> 
> ---
> lisp/org.el |   11 ++++++-----
>  1 files changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/lisp/org.el b/lisp/org.el
> index a26a3ca..6e1be76 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -7566,11 +7566,12 @@ If yes, remember the marker and the distance to BEG."
>    (interactive)
>    (save-excursion
>      (save-match-data
> -      (narrow-to-region
> -       (progn (org-back-to-heading t) (point))
> -       (progn (org-end-of-subtree t t)
> -	      (if (and (org-on-heading-p) (not (eobp))) (backward-char 1))
> -	      (point))))))
> +      (org-with-limited-levels
> +       (narrow-to-region
> +	(progn (org-back-to-heading t) (point))
> +	(progn (org-end-of-subtree t t)
> +	       (if (and (org-on-heading-p) (not (eobp))) (backward-char 1))
> +	       (point)))))))
>  
>  (defun org-narrow-to-block ()
>    "Narrow buffer to the current block."
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Accepted] [O, 2/3] When demoting a subtree, don't change level of inline tasks within
  2011-03-02 16:56 ` [PATCH 2/3] When demoting a subtree, don't change level of inline tasks within Nicolas Goaziou
@ 2011-03-06  8:30   ` Bastien Guerry
  0 siblings, 0 replies; 6+ messages in thread
From: Bastien Guerry @ 2011-03-06  8:30 UTC (permalink / raw)
  To: emacs-orgmode

Patch 644 (http://patchwork.newartisans.com/patch/644/) is now "Accepted".

Maintainer comment: none

This relates to the following submission:

http://mid.gmane.org/%3C1299084964-26440-2-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, 2/3] When demoting a subtree,
> 	don't change level of inline tasks within
> Date: Wed, 02 Mar 2011 21:56:03 -0000
> From: Nicolas Goaziou <n.goaziou@gmail.com>
> X-Patchwork-Id: 644
> Message-Id: <1299084964-26440-2-git-send-email-n.goaziou@gmail.com>
> To: Org mode list <emacs-orgmode@gnu.org>
> Cc: Nicolas Goaziou <n.goaziou@gmail.com>
> 
> * lisp/org.el (org-demote-subtree,org-promote-subtree): wrap
>   org-map-tree into org-with-limited-levels macro, so it avoids
>   operating on inline tasks.
> 
> ---
> lisp/org.el |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lisp/org.el b/lisp/org.el
> index 6e1be76..8ae5e6f 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -7002,7 +7002,7 @@ When a subtree is being promoted, the hook will be called for each node.")
>  See also `org-promote'."
>    (interactive)
>    (save-excursion
> -    (org-map-tree 'org-promote))
> +    (org-with-limited-levels (org-map-tree 'org-promote)))
>    (org-fix-position-after-promote))
>  
>  (defun org-demote-subtree ()
> @@ -7010,7 +7010,7 @@ See also `org-promote'."
>  See also `org-promote'."
>    (interactive)
>    (save-excursion
> -    (org-map-tree 'org-demote))
> +    (org-with-limited-levels (org-map-tree 'org-demote)))
>    (org-fix-position-after-promote))
>  
>  
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Accepted] [O,3/3] Promote and demote inline tasks
  2011-03-02 16:56 ` [PATCH 3/3] Promote and demote inline tasks Nicolas Goaziou
@ 2011-03-06  8:30   ` Bastien Guerry
  0 siblings, 0 replies; 6+ messages in thread
From: Bastien Guerry @ 2011-03-06  8:30 UTC (permalink / raw)
  To: emacs-orgmode

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 <n.goaziou@gmail.com>
> X-Patchwork-Id: 645
> Message-Id: <1299084964-26440-3-git-send-email-n.goaziou@gmail.com>
> To: Org mode list <emacs-orgmode@gnu.org>
> Cc: Nicolas Goaziou <n.goaziou@gmail.com>
> 
> * 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
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-03-06  8:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-02 16:56 [PATCH 1/3] Fix bug when narrowing to subtree with point at an inline task Nicolas Goaziou
2011-03-02 16:56 ` [PATCH 2/3] When demoting a subtree, don't change level of inline tasks within Nicolas Goaziou
2011-03-06  8:30   ` [Accepted] [O, " Bastien Guerry
2011-03-02 16:56 ` [PATCH 3/3] Promote and demote inline tasks Nicolas Goaziou
2011-03-06  8:30   ` [Accepted] [O,3/3] " Bastien Guerry
2011-03-06  8:29 ` [Accepted] [O, 1/3] Fix bug when narrowing to subtree with point at an inline task Bastien Guerry

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).