* [reveal-mode] Hiding short expressions
@ 2004-07-02 21:05 Ralf Angeli
2004-07-02 21:37 ` Stefan
0 siblings, 1 reply; 11+ messages in thread
From: Ralf Angeli @ 2004-07-02 21:05 UTC (permalink / raw)
Hello,
currently I am trying to make use of reveal-mode for hiding and
revealing \footnote{...} expressions in Emacs. Now the problem is
that visible expressions under the control of reveal-mode only get
hidden if the cursor moves before the beginning of the line with the
expression or past its end. If you have short expressions within a
line it would be nice if the expression became invisible as soon as
the cursor moves out of it.
Are there any reasons why this is not handled like this in reveal.el
and would it be possible to change it if there aren't any? (A patch
would be to replace the `save-excursion' statements around line 119 in
reveal.el by the `overlay-start' or `overlay-end' statements already
defined there.)
--
Ralf
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [reveal-mode] Hiding short expressions
2004-07-02 21:05 [reveal-mode] Hiding short expressions Ralf Angeli
@ 2004-07-02 21:37 ` Stefan
2004-07-03 12:07 ` Ralf Angeli
0 siblings, 1 reply; 11+ messages in thread
From: Stefan @ 2004-07-02 21:37 UTC (permalink / raw)
> currently I am trying to make use of reveal-mode for hiding and
> revealing \footnote{...} expressions in Emacs. Now the problem is
> that visible expressions under the control of reveal-mode only get
> hidden if the cursor moves before the beginning of the line with the
> expression or past its end. If you have short expressions within a
> line it would be nice if the expression became invisible as soon as
> the cursor moves out of it.
> Are there any reasons why this is not handled like this in reveal.el
> and would it be possible to change it if there aren't any? (A patch
> would be to replace the `save-excursion' statements around line 119 in
> reveal.el by the `overlay-start' or `overlay-end' statements already
> defined there.)
The current behavior of reveal-mode was designed while using it with
outline-minor-mode in elisp buffers. It is tuned for such a context and
might indeed need different tuning in a different context.
The behavior you seem to want is actually simpler than the current
behavior (in other words, I first implemented the behavior you want and
then added code to keep the overlays open even after the cursor moves out
of the overlay), and it should be easy to change the code such that you can
choose between different behaviors.
But please don't just remove the code that implements the current behavior.
Stefan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [reveal-mode] Hiding short expressions
2004-07-02 21:37 ` Stefan
@ 2004-07-03 12:07 ` Ralf Angeli
2004-07-03 17:01 ` Stefan
0 siblings, 1 reply; 11+ messages in thread
From: Ralf Angeli @ 2004-07-03 12:07 UTC (permalink / raw)
* Stefan (2004-07-02) writes:
>> currently I am trying to make use of reveal-mode for hiding and
>> revealing \footnote{...} expressions in Emacs. Now the problem is
>> that visible expressions under the control of reveal-mode only get
>> hidden if the cursor moves before the beginning of the line with the
>> expression or past its end. If you have short expressions within a
>> line it would be nice if the expression became invisible as soon as
>> the cursor moves out of it.
>
>> Are there any reasons why this is not handled like this in reveal.el
>> and would it be possible to change it if there aren't any?
[...]
> The behavior you seem to want is actually simpler than the current
> behavior (in other words, I first implemented the behavior you want and
> then added code to keep the overlays open even after the cursor moves out
> of the overlay), and it should be easy to change the code such that you can
> choose between different behaviors.
One could add a variable which lets you choose what behavior is used.
But if you wanted to use outline-minor-mode and hiding of footnotes at
the same time in a latex-mode or LaTeX-mode buffer, it would probably
be better to choose the behavior depending on a special attribute of
the overlays. This could be done e.g. by adding a 'reveal-close
attribute to the 'category property of the overlay:
(put 'some-category 'reveal-close 'on-cursor-out)
(overlay-put ov 'category 'some-category)
Then this gets checked in reveal.el:
--8<---------------cut here---------------start------------->8---
--- /usr/local/share/emacs/21.3.50/lisp/reveal.el 2004-07-02 22:08:23.000000000 +0200
+++ reveal.el 2004-07-03 12:44:47.000000000 +0200
@@ -116,12 +116,20 @@
(dolist (ol old-ols)
(when (and (eq (current-buffer) (overlay-buffer ol))
(not (rassq ol reveal-open-spots)))
- (if (and (>= (point) (save-excursion
- (goto-char (overlay-start ol))
- (line-beginning-position 1)))
- (<= (point) (save-excursion
- (goto-char (overlay-end ol))
- (line-beginning-position 2))))
+ (if (and (>= (point)
+ (if (eq (get (overlay-get ol 'category) 'reveal-close)
+ 'on-cursor-out)
+ (overlay-start ol)
+ (save-excursion
+ (goto-char (overlay-start ol))
+ (line-beginning-position 1))))
+ (<= (point)
+ (if (eq (get (overlay-get ol 'category) 'reveal-close)
+ 'on-cursor-out)
+ (overlay-end ol)
+ (save-excursion
+ (goto-char (overlay-end ol))
+ (line-beginning-position 2)))))
;; Still near the overlay: keep it open.
(push (cons (selected-window) ol) reveal-open-spots)
;; Really close it.
--8<---------------cut here---------------end--------------->8---
How does this look like?
I am considering to add some code to AUCTeX in order to support hiding
of LaTeX macros with reveal-mode. (This hasn't been discussed yet on
the AUCTeX mailing list, though.) So it would be nice if the above or
something similar could be integrated into Emacs.
--
Ralf
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [reveal-mode] Hiding short expressions
2004-07-03 12:07 ` Ralf Angeli
@ 2004-07-03 17:01 ` Stefan
2004-07-03 18:03 ` Ralf Angeli
0 siblings, 1 reply; 11+ messages in thread
From: Stefan @ 2004-07-03 17:01 UTC (permalink / raw)
>> The behavior you seem to want is actually simpler than the current
>> behavior (in other words, I first implemented the behavior you want and
>> then added code to keep the overlays open even after the cursor moves out
>> of the overlay), and it should be easy to change the code such that you can
>> choose between different behaviors.
> One could add a variable which lets you choose what behavior is used.
> But if you wanted to use outline-minor-mode and hiding of footnotes at
> the same time in a latex-mode or LaTeX-mode buffer, it would probably
> be better to choose the behavior depending on a special attribute of
> the overlays. This could be done e.g. by adding a 'reveal-close
> attribute to the 'category property of the overlay:
Indeed, I think it should be decided on an overlay basis rather than for the
whole buffer. But I don't like forcing an indirection through `category',
so I'd just do (overlay-get ol 'reveal-close) which also obeys the
`category' prop if present. Also I expect that a heuristic such as "is
there a linefeed within the overlay" would provide a pretty good
starting point without needing any extra tag on the overlays.
The rationale for it is that the behavior that "keeps overlay opened when
point is on same line" is mostly useful to allow the user to use C-p and
C-n without spuriously closing the overlay because the C-p jumps to just
a bit before the beginning. At least that was my experience when working
on it.
Stefan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [reveal-mode] Hiding short expressions
2004-07-03 17:01 ` Stefan
@ 2004-07-03 18:03 ` Ralf Angeli
2004-07-03 18:56 ` Stefan
2004-07-06 19:07 ` Kevin Rodgers
0 siblings, 2 replies; 11+ messages in thread
From: Ralf Angeli @ 2004-07-03 18:03 UTC (permalink / raw)
* Stefan (2004-07-03) writes:
> Indeed, I think it should be decided on an overlay basis rather than for the
> whole buffer. But I don't like forcing an indirection through `category',
> so I'd just do (overlay-get ol 'reveal-close) which also obeys the
> `category' prop if present.
This would be fine with me. I'd use the symbol 'reveal-on-cursor-out,
though.
> Also I expect that a heuristic such as "is
> there a linefeed within the overlay" would provide a pretty good
> starting point without needing any extra tag on the overlays.
>
> The rationale for it is that the behavior that "keeps overlay opened when
> point is on same line" is mostly useful to allow the user to use C-p and
> C-n without spuriously closing the overlay because the C-p jumps to just
> a bit before the beginning. At least that was my experience when working
> on it.
So you want to achieve that if you have a paragraph of text and the
cursor moves downward into an empty line while the paragraph and
therefore the overlay ends at the end of the line before, the overlay
does not get collapsed. For the downward case you could probably do
it like this (I don't know if there even is a problem with the upward
case):
--8<---------------cut here---------------start------------->8---
--- /usr/local/share/emacs/21.3.50/lisp/reveal.el 2004-07-02 22:08:23.000000000 +0200
+++ reveal.el 2004-07-03 19:42:46.000000000 +0200
@@ -116,12 +116,10 @@
(dolist (ol old-ols)
(when (and (eq (current-buffer) (overlay-buffer ol))
(not (rassq ol reveal-open-spots)))
- (if (and (>= (point) (save-excursion
- (goto-char (overlay-start ol))
- (line-beginning-position 1)))
- (<= (point) (save-excursion
- (goto-char (overlay-end ol))
- (line-beginning-position 2))))
+ (if (and (>= (point) (overlay-start ol))
+ (<= (point) (if (= (overlay-end ol) (line-end-position))
+ (line-beginning-position 2)
+ (overlay-end ol))))
;; Still near the overlay: keep it open.
(push (cons (selected-window) ol) reveal-open-spots)
;; Really close it.
--8<---------------cut here---------------end--------------->8---
But wouldn't it be cleaner to extend the respective overlay by this
one character instead of trying to code around it with a trickery
like above (which includes the code already inside of reveal.el)?
Additionally a heuristic based on the presence of line breaks in the
overlay may easily produce a wrong result for an overlay inside of a
paragraph of text which coincidently ends at the end of a line. You
would have to add further logic to cater for these cases. So
personally I'd prefer working with additional properties or even
better, extending the overlays which would get collapsed too early.
--
Ralf
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [reveal-mode] Hiding short expressions
2004-07-03 18:03 ` Ralf Angeli
@ 2004-07-03 18:56 ` Stefan
2004-07-03 19:26 ` Ralf Angeli
2004-07-06 19:07 ` Kevin Rodgers
1 sibling, 1 reply; 11+ messages in thread
From: Stefan @ 2004-07-03 18:56 UTC (permalink / raw)
>> The rationale for it is that the behavior that "keeps overlay opened when
>> point is on same line" is mostly useful to allow the user to use C-p and
>> C-n without spuriously closing the overlay because the C-p jumps to just
>> a bit before the beginning. At least that was my experience when working
>> on it.
> So you want to achieve that if you have a paragraph of text and the
> cursor moves downward into an empty line while the paragraph and
> therefore the overlay ends at the end of the line before, the overlay
> does not get collapsed.
No, I want that if you have
foo bar baz \footnote{blabla
toto titi tutu
tata} hello there
and point is between `titi' and `tutu' hitting C-p or C-n does not close
the overlay, so that you can go from where you are to `blabla' without
the overlay being closed&reopened which takes time and flashes annoyingly.
Stefan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [reveal-mode] Hiding short expressions
2004-07-03 18:56 ` Stefan
@ 2004-07-03 19:26 ` Ralf Angeli
0 siblings, 0 replies; 11+ messages in thread
From: Ralf Angeli @ 2004-07-03 19:26 UTC (permalink / raw)
* Stefan (2004-07-03) writes:
> No, I want that if you have
>
> foo bar baz \footnote{blabla
> toto titi tutu
> tata} hello there
>
> and point is between `titi' and `tutu' hitting C-p or C-n does not close
> the overlay, so that you can go from where you are to `blabla' without
> the overlay being closed&reopened which takes time and flashes annoyingly.
Ah, okay, now I got it. Personally I don't mind the flashing, but I
favor that the overlay gets collapsed as soon as the cursor moves out
of it. So I think using a special property for such overlays as
proposed in a former mail would be an adequate way to allow
configuration of different behaviors.
In case you want to add this configuration possibility to reveal.el,
should I send an appropriate patch to be checked in?
--
Ralf
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [reveal-mode] Hiding short expressions
2004-07-03 18:03 ` Ralf Angeli
2004-07-03 18:56 ` Stefan
@ 2004-07-06 19:07 ` Kevin Rodgers
2004-07-06 19:34 ` Ralf Angeli
1 sibling, 1 reply; 11+ messages in thread
From: Kevin Rodgers @ 2004-07-06 19:07 UTC (permalink / raw)
Ralf Angeli wrote:
> * Stefan (2004-07-03) writes:
>>Indeed, I think it should be decided on an overlay basis rather than for the
>>whole buffer. But I don't like forcing an indirection through `category',
>>so I'd just do (overlay-get ol 'reveal-close) which also obeys the
>>`category' prop if present.
>
> This would be fine with me. I'd use the symbol 'reveal-on-cursor-out,
> though.
Emacs generally uses the term point instead of cursor, e.g. the
point-entered and point-left text properties. So how about
reveal-point-left or reveal-when-point-left?
--
Kevin Rodgers
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [reveal-mode] Hiding short expressions
2004-07-06 19:07 ` Kevin Rodgers
@ 2004-07-06 19:34 ` Ralf Angeli
2004-07-06 19:56 ` David Kastrup
2004-07-07 13:32 ` Stefan
0 siblings, 2 replies; 11+ messages in thread
From: Ralf Angeli @ 2004-07-06 19:34 UTC (permalink / raw)
* Kevin Rodgers (2004-07-06) writes:
> Ralf Angeli wrote:
> > * Stefan (2004-07-03) writes:
> >>Indeed, I think it should be decided on an overlay basis rather
> >>than for the whole buffer. But I don't like forcing an
> >>indirection through `category', so I'd just do (overlay-get ol
> >>'reveal-close) which also obeys the `category' prop if present.
> >
> > This would be fine with me. I'd use the symbol 'reveal-on-cursor-out,
> > though.
>
> Emacs generally uses the term point instead of cursor, e.g. the
> point-entered and point-left text properties. So how about
> reveal-point-left or reveal-when-point-left?
One remark: If I am the only one who requested/needed such a feature,
please don't bother anymore.
While I was working with reveal.el I found that I cannot use the
'invisible property of overlays which has to be set with reveal.el.
If there are invisible overlays, `move-to-column' will not look at the
content covered by the overlay but at the overlay itself. Now when
you fill a paragraph with short overlays covering some longer text
passages and delete the overlays afterwards, there will most likely be
overfull lines. Therefore I cannot use reveal.el in its totality
anyway and I am not in need of it testing for a special property
anymore.
--
Ralf
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [reveal-mode] Hiding short expressions
2004-07-06 19:34 ` Ralf Angeli
@ 2004-07-06 19:56 ` David Kastrup
2004-07-07 13:32 ` Stefan
1 sibling, 0 replies; 11+ messages in thread
From: David Kastrup @ 2004-07-06 19:56 UTC (permalink / raw)
Ralf Angeli <angeli@iwi.uni-sb.de> writes:
> * Kevin Rodgers (2004-07-06) writes:
>
> > Ralf Angeli wrote:
> > > * Stefan (2004-07-03) writes:
> > >>Indeed, I think it should be decided on an overlay basis rather
> > >>than for the whole buffer. But I don't like forcing an
> > >>indirection through `category', so I'd just do (overlay-get ol
> > >>'reveal-close) which also obeys the `category' prop if present.
> > >
> > > This would be fine with me. I'd use the symbol 'reveal-on-cursor-out,
> > > though.
> >
> > Emacs generally uses the term point instead of cursor, e.g. the
> > point-entered and point-left text properties. So how about
> > reveal-point-left or reveal-when-point-left?
>
> One remark: If I am the only one who requested/needed such a feature,
> please don't bother anymore.
>
> While I was working with reveal.el I found that I cannot use the
> 'invisible property of overlays which has to be set with reveal.el.
> If there are invisible overlays, `move-to-column' will not look at
> the content covered by the overlay but at the overlay itself. Now
> when you fill a paragraph with short overlays covering some longer
> text passages and delete the overlays afterwards, there will most
> likely be overfull lines. Therefore I cannot use reveal.el in its
> totality anyway and I am not in need of it testing for a special
> property anymore.
If you would need reveal's functionality triggered on a different
property, it should be reasonably straightforward to make the
'invisible which reveal.el looks at configurable.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [reveal-mode] Hiding short expressions
2004-07-06 19:34 ` Ralf Angeli
2004-07-06 19:56 ` David Kastrup
@ 2004-07-07 13:32 ` Stefan
1 sibling, 0 replies; 11+ messages in thread
From: Stefan @ 2004-07-07 13:32 UTC (permalink / raw)
> If there are invisible overlays, `move-to-column' will not look at the
> content covered by the overlay but at the overlay itself. Now when
If the invisible text is replaced by ellipsis (see
add-to-invisibility-spec), then move-to-column will ignore the invisibility
property (i.e. will not ignore the text).
Stefan
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2004-07-07 13:32 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-02 21:05 [reveal-mode] Hiding short expressions Ralf Angeli
2004-07-02 21:37 ` Stefan
2004-07-03 12:07 ` Ralf Angeli
2004-07-03 17:01 ` Stefan
2004-07-03 18:03 ` Ralf Angeli
2004-07-03 18:56 ` Stefan
2004-07-03 19:26 ` Ralf Angeli
2004-07-06 19:07 ` Kevin Rodgers
2004-07-06 19:34 ` Ralf Angeli
2004-07-06 19:56 ` David Kastrup
2004-07-07 13:32 ` Stefan
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.