emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Fix org-outline-overlay-data marker insertion-type
@ 2014-01-15  0:19 Sylvain Chouleur
  2014-01-18 17:27 ` Sylvain Chouleur
  0 siblings, 1 reply; 9+ messages in thread
From: Sylvain Chouleur @ 2014-01-15  0:19 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 755 bytes --]

Hi all,

here is a patch that fixes outline visibility saving.

The root issue I've found is that when you call org-babel-execute-subtree
on a folded outline, the result is shown visible so the visibility property
is not well kept.

The root cause is the markers used by org-outline-overlay-data to bound the
invisible area.
When org-babel-insert-result is called by org-babel-execute-subtree, text
is added from the position of marker that mark the end of invisible area.
As the insertion-type of the marker is by default nil, the marker stays
where it is but text is inserted after, so the inserted text becomes
visible.

I'm not sure about the fix, I'm fearing some side effect I can't see in my
usage so it's open to any comments

Thanks

-- 
Sylvain

[-- Attachment #1.2: Type: text/html, Size: 983 bytes --]

[-- Attachment #2: 0001-Fix-org-outline-overlay-data-marker-insertion-type.patch --]
[-- Type: text/x-patch, Size: 1409 bytes --]

From a4bb85d9577e0454e01abe596f92b152007c0d9f Mon Sep 17 00:00:00 2001
From: Sylvain Chouleur <sylvain.chouleur@intel.com>
Date: Wed, 15 Jan 2014 00:38:55 +0100
Subject: [PATCH] Fix org-outline-overlay-data marker insertion-type

* org.el: Set the insertion-type of bounds markers of
org-outline-overlay-data to t (means marker advances when you insert
text at it)

This is to conserve outline visibility property when changes are made
at the bounds of the data.
For example: try org-babel-execute-subtree on a folded outline:
The new result will be shown after the folded part of the outline
whereas the outline body should not be visible.
---
 lisp/org.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index a53597e477e2..fc0f0ccb7125 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -7191,8 +7191,12 @@ If USE-MARKERS is set, return the positions as markers."
 				end (overlay-end o))
 			  (and beg end (> end beg)
 			       (if use-markers
-				   (cons (move-marker (make-marker) beg)
-					 (move-marker (make-marker) end))
+				   (let ((bound
+					  (cons (move-marker (make-marker) beg)
+						(move-marker (make-marker) end))))
+				     (set-marker-insertion-type (car bound) t)
+				     (set-marker-insertion-type (cdr bound) t)
+				     bound)
 				 (cons beg end)))))
 		      (overlays-in (point-min) (point-max))))))))
 
-- 
1.8.5.2


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

* Re: [PATCH] Fix org-outline-overlay-data marker insertion-type
  2014-01-15  0:19 [PATCH] Fix org-outline-overlay-data marker insertion-type Sylvain Chouleur
@ 2014-01-18 17:27 ` Sylvain Chouleur
  2014-01-18 17:43   ` Nicolas Goaziou
  0 siblings, 1 reply; 9+ messages in thread
From: Sylvain Chouleur @ 2014-01-18 17:27 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1007 bytes --]

A little fix on my last patch:
set the insertion type to t only for the end bound of the overlay as only
this one should move on insertion

-- 
Sylvain


2014/1/15 Sylvain Chouleur <sylvain.chouleur@gmail.com>

> Hi all,
>
> here is a patch that fixes outline visibility saving.
>
> The root issue I've found is that when you call org-babel-execute-subtree
> on a folded outline, the result is shown visible so the visibility property
> is not well kept.
>
> The root cause is the markers used by org-outline-overlay-data to bound
> the invisible area.
> When org-babel-insert-result is called by org-babel-execute-subtree, text
> is added from the position of marker that mark the end of invisible area.
> As the insertion-type of the marker is by default nil, the marker stays
> where it is but text is inserted after, so the inserted text becomes
> visible.
>
> I'm not sure about the fix, I'm fearing some side effect I can't see in my
> usage so it's open to any comments
>
> Thanks
>
> --
> Sylvain
>

[-- Attachment #1.2: Type: text/html, Size: 1613 bytes --]

[-- Attachment #2: 0001-Fix-org-outline-overlay-data-marker-insertion-type.patch --]
[-- Type: text/x-patch, Size: 1409 bytes --]

From a4bb85d9577e0454e01abe596f92b152007c0d9f Mon Sep 17 00:00:00 2001
From: Sylvain Chouleur <sylvain.chouleur@intel.com>
Date: Wed, 15 Jan 2014 00:38:55 +0100
Subject: [PATCH] Fix org-outline-overlay-data marker insertion-type

* org.el: Set the insertion-type of bounds markers of
org-outline-overlay-data to t (means marker advances when you insert
text at it)

This is to conserve outline visibility property when changes are made
at the bounds of the data.
For example: try org-babel-execute-subtree on a folded outline:
The new result will be shown after the folded part of the outline
whereas the outline body should not be visible.
---
 lisp/org.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index a53597e477e2..fc0f0ccb7125 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -7191,8 +7191,12 @@ If USE-MARKERS is set, return the positions as markers."
 				end (overlay-end o))
 			  (and beg end (> end beg)
 			       (if use-markers
-				   (cons (move-marker (make-marker) beg)
-					 (move-marker (make-marker) end))
+				   (let ((bound
+					  (cons (move-marker (make-marker) beg)
+						(move-marker (make-marker) end))))
+				     (set-marker-insertion-type (car bound) t)
+				     (set-marker-insertion-type (cdr bound) t)
+				     bound)
 				 (cons beg end)))))
 		      (overlays-in (point-min) (point-max))))))))
 
-- 
1.8.5.2


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

* Re: [PATCH] Fix org-outline-overlay-data marker insertion-type
  2014-01-18 17:27 ` Sylvain Chouleur
@ 2014-01-18 17:43   ` Nicolas Goaziou
  2014-01-18 18:35     ` Sylvain Chouleur
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2014-01-18 17:43 UTC (permalink / raw)
  To: Sylvain Chouleur; +Cc: emacs-orgmode

Hello,

Sylvain Chouleur <sylvain.chouleur@gmail.com> writes:

> A little fix on my last patch:

Thanks for your patch. A small style comment.

> +				   (let ((bound
> +					  (cons (move-marker (make-marker) beg)
> +						(move-marker (make-marker) end))))
> +				     (set-marker-insertion-type (car bound) t)
> +				     (set-marker-insertion-type (cdr bound) t)
> +				     bound)

All of this is really a one-liner:

  (cons (copy-marker beg t) (copy-marker end t))


Regards,

-- 
Nicolas Goaziou

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

* Re: [PATCH] Fix org-outline-overlay-data marker insertion-type
  2014-01-18 17:43   ` Nicolas Goaziou
@ 2014-01-18 18:35     ` Sylvain Chouleur
  2014-01-18 19:57       ` Nicolas Goaziou
  0 siblings, 1 reply; 9+ messages in thread
From: Sylvain Chouleur @ 2014-01-18 18:35 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 830 bytes --]

But beg and end are positions, not markers, I am wrong?


2014/1/18 Nicolas Goaziou <n.goaziou@gmail.com>

> Hello,
>
> Sylvain Chouleur <sylvain.chouleur@gmail.com> writes:
>
> > A little fix on my last patch:
>
> Thanks for your patch. A small style comment.
>
> > +                                (let ((bound
> > +                                       (cons (move-marker (make-marker)
> beg)
> > +                                             (move-marker (make-marker)
> end))))
> > +                                  (set-marker-insertion-type (car
> bound) t)
> > +                                  (set-marker-insertion-type (cdr
> bound) t)
> > +                                  bound)
>
> All of this is really a one-liner:
>
>   (cons (copy-marker beg t) (copy-marker end t))
>
>
> Regards,
>
> --
> Nicolas Goaziou
>

[-- Attachment #2: Type: text/html, Size: 1356 bytes --]

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

* Re: [PATCH] Fix org-outline-overlay-data marker insertion-type
  2014-01-18 18:35     ` Sylvain Chouleur
@ 2014-01-18 19:57       ` Nicolas Goaziou
  2014-01-19 13:20         ` Sylvain Chouleur
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2014-01-18 19:57 UTC (permalink / raw)
  To: Sylvain Chouleur; +Cc: emacs-orgmode

Sylvain Chouleur <sylvain.chouleur@gmail.com> writes:

> But beg and end are positions, not markers, I am wrong?

BEG and END are positions, but `copy-marker' accepts an integer as its
first argument. See its docstring.


Regards,

-- 
Nicolas Goaziou

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

* Re: [PATCH] Fix org-outline-overlay-data marker insertion-type
  2014-01-18 19:57       ` Nicolas Goaziou
@ 2014-01-19 13:20         ` Sylvain Chouleur
  2014-01-19 19:38           ` Nicolas Goaziou
  0 siblings, 1 reply; 9+ messages in thread
From: Sylvain Chouleur @ 2014-01-19 13:20 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 393 bytes --]

Well seen,
here is the new patch, working as well.

Thanks
--
Sylvain


2014/1/18 Nicolas Goaziou <n.goaziou@gmail.com>

> Sylvain Chouleur <sylvain.chouleur@gmail.com> writes:
>
> > But beg and end are positions, not markers, I am wrong?
>
> BEG and END are positions, but `copy-marker' accepts an integer as its
> first argument. See its docstring.
>
>
> Regards,
>
> --
> Nicolas Goaziou
>

[-- Attachment #1.2: Type: text/html, Size: 931 bytes --]

[-- Attachment #2: 0001-Fix-org-outline-overlay-data-marker-insertion-type.patch --]
[-- Type: text/x-patch, Size: 1239 bytes --]

From a956097b88088422bbbf1aa06dc3921cebbe7ad9 Mon Sep 17 00:00:00 2001
From: Sylvain Chouleur <sylvain.chouleur@gmail.com>
Date: Sun, 19 Jan 2014 14:18:45 +0100
Subject: [PATCH] Fix org-outline-overlay-data marker insertion-type

* org.el: Set the insertion-type of end bound marker of
org-outline-overlay-data to t (means marker advances when you insert
text at it)

This is to conserve outline visibility property when changes are made
at the end bound of the data.
For example: try org-babel-execute-subtree on a folded outline:
The new result will be shown after the folded part of the outline
whereas the outline body should not be visible.
---
 lisp/org.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index a53597e477e2..50e652160566 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -7191,8 +7191,8 @@ If USE-MARKERS is set, return the positions as markers."
 				end (overlay-end o))
 			  (and beg end (> end beg)
 			       (if use-markers
-				   (cons (move-marker (make-marker) beg)
-					 (move-marker (make-marker) end))
+				   (cons (copy-marker beg)
+					 (copy-marker end t))
 				 (cons beg end)))))
 		      (overlays-in (point-min) (point-max))))))))
 
-- 
1.8.5.2


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

* Re: [PATCH] Fix org-outline-overlay-data marker insertion-type
  2014-01-19 13:20         ` Sylvain Chouleur
@ 2014-01-19 19:38           ` Nicolas Goaziou
  2014-01-19 19:46             ` Sylvain Chouleur
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2014-01-19 19:38 UTC (permalink / raw)
  To: Sylvain Chouleur; +Cc: emacs-orgmode

Hello,

Sylvain Chouleur <sylvain.chouleur@gmail.com> writes:

> Well seen,
> here is the new patch, working as well.

Thank you. If you haven't signed FSF papers, could you add "TINYCHANGE"
at the end of your commit message so I can apply it?


Regards,

-- 
Nicolas Goaziou

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

* Re: [PATCH] Fix org-outline-overlay-data marker insertion-type
  2014-01-19 19:38           ` Nicolas Goaziou
@ 2014-01-19 19:46             ` Sylvain Chouleur
  2014-01-19 21:06               ` Nicolas Goaziou
  0 siblings, 1 reply; 9+ messages in thread
From: Sylvain Chouleur @ 2014-01-19 19:46 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 357 bytes --]

Done


2014/1/19 Nicolas Goaziou <n.goaziou@gmail.com>

> Hello,
>
> Sylvain Chouleur <sylvain.chouleur@gmail.com> writes:
>
> > Well seen,
> > here is the new patch, working as well.
>
> Thank you. If you haven't signed FSF papers, could you add "TINYCHANGE"
> at the end of your commit message so I can apply it?
>
>
> Regards,
>
> --
> Nicolas Goaziou
>

[-- Attachment #1.2: Type: text/html, Size: 882 bytes --]

[-- Attachment #2: 0001-Fix-org-outline-overlay-data-marker-insertion-type.patch --]
[-- Type: text/x-patch, Size: 1251 bytes --]

From 96efa14d318550e002b1c43e94cdaab108ddb78c Mon Sep 17 00:00:00 2001
From: Sylvain Chouleur <sylvain.chouleur@gmail.com>
Date: Sun, 19 Jan 2014 14:18:45 +0100
Subject: [PATCH] Fix org-outline-overlay-data marker insertion-type

* org.el: Set the insertion-type of end bound marker of
org-outline-overlay-data to t (means marker advances when you insert
text at it)

This is to conserve outline visibility property when changes are made
at the end bound of the data.
For example: try org-babel-execute-subtree on a folded outline:
The new result will be shown after the folded part of the outline
whereas the outline body should not be visible.

TINYCHANGE
---
 lisp/org.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index a53597e477e2..50e652160566 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -7191,8 +7191,8 @@ If USE-MARKERS is set, return the positions as markers."
 				end (overlay-end o))
 			  (and beg end (> end beg)
 			       (if use-markers
-				   (cons (move-marker (make-marker) beg)
-					 (move-marker (make-marker) end))
+				   (cons (copy-marker beg)
+					 (copy-marker end t))
 				 (cons beg end)))))
 		      (overlays-in (point-min) (point-max))))))))
 
-- 
1.8.5.2


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

* Re: [PATCH] Fix org-outline-overlay-data marker insertion-type
  2014-01-19 19:46             ` Sylvain Chouleur
@ 2014-01-19 21:06               ` Nicolas Goaziou
  0 siblings, 0 replies; 9+ messages in thread
From: Nicolas Goaziou @ 2014-01-19 21:06 UTC (permalink / raw)
  To: Sylvain Chouleur; +Cc: emacs-orgmode

Sylvain Chouleur <sylvain.chouleur@gmail.com> writes:

> Done

Applied. Thank you.


Regards,

-- 
Nicolas Goaziou

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

end of thread, other threads:[~2014-01-19 21:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-15  0:19 [PATCH] Fix org-outline-overlay-data marker insertion-type Sylvain Chouleur
2014-01-18 17:27 ` Sylvain Chouleur
2014-01-18 17:43   ` Nicolas Goaziou
2014-01-18 18:35     ` Sylvain Chouleur
2014-01-18 19:57       ` Nicolas Goaziou
2014-01-19 13:20         ` Sylvain Chouleur
2014-01-19 19:38           ` Nicolas Goaziou
2014-01-19 19:46             ` Sylvain Chouleur
2014-01-19 21:06               ` Nicolas Goaziou

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).