emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Scrolling down after Shift-TAB ?
@ 2012-01-23 23:39 François Pinard
  2012-01-24  0:45 ` Nick Dokos
  0 siblings, 1 reply; 6+ messages in thread
From: François Pinard @ 2012-01-23 23:39 UTC (permalink / raw)
  To: emacs-orgmode

Hi again.

Very, very often, after a Shift-TAB that collapses all entries, a few
lines in the vicinity of the cursor are shown at the top of the window,
which is mainly empty for its reminder; we contemplate the vacuum
*after* the file.  As my Org files are such that all the top level lines
usually fit in one window, I then invariably scroll down so see it all.

I wonder if this could be automated, yet it is a bit uneasy to exactly
define what would be the ideal.  Let me try an initial suggestion:

- If the whole Org file could be displayed at once, scrolling should
  automatically occur so the first line of the window displays the
  beginning of the Org file.

- Otherwise, if the last line of the window would be *outside* the Org
  file, scrolling should automatically occur so the last line of the
  window displays the end of the Org file.

- If neither of the above holds, do not automatically scroll.

Maybe others could improve on this with better ideas or algorithms ?

François

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

* Re: Scrolling down after Shift-TAB ?
  2012-01-23 23:39 Scrolling down after Shift-TAB ? François Pinard
@ 2012-01-24  0:45 ` Nick Dokos
  2012-01-24  2:02   ` François Pinard
  0 siblings, 1 reply; 6+ messages in thread
From: Nick Dokos @ 2012-01-24  0:45 UTC (permalink / raw)
  To: =?utf-8?Q?Fran=C3=A7ois?= Pinard; +Cc: nicholas.dokos, emacs-orgmode

François Pinard <pinard@iro.umontreal.ca> wrote:

> Hi again.
> 
> Very, very often, after a Shift-TAB that collapses all entries, a few
> lines in the vicinity of the cursor are shown at the top of the window,
> which is mainly empty for its reminder; we contemplate the vacuum
> *after* the file.  As my Org files are such that all the top level lines
> usually fit in one window, I then invariably scroll down so see it all.
> 
> I wonder if this could be automated, yet it is a bit uneasy to exactly
> define what would be the ideal.  Let me try an initial suggestion:
> 
> - If the whole Org file could be displayed at once, scrolling should
>   automatically occur so the first line of the window displays the
>   beginning of the Org file.
> 
> - Otherwise, if the last line of the window would be *outside* the Org
>   file, scrolling should automatically occur so the last line of the
>   window displays the end of the Org file.
> 
> - If neither of the above holds, do not automatically scroll.
> 
> Maybe others could improve on this with better ideas or algorithms ?
> 

You'd need to code it somewhat carefully sp that you wouldn't lose the
property that after a couple of S-TABs, the buffer looks the same as
when you started and point has not moved: that's useful in order to zoom
out and orient yourself in the larger context and then zoom in again to
continue working.

Have you tried C-l after the collapse? S-TAB C-l doesn't do quite what
you specified, but perhaps it's enough: it shrinks the vacuum after the
file, maybe to nothing, and it does not shift point. If you like
the behavior, you can always advise org-cycle so that it always calls
recenter afterwards:

--8<---------------cut here---------------start------------->8---
(defadvice  org-cycle (after org-cycle-recenter)
  "Recenter after org-cycle)"
  (recenter))

(ad-activate 'org-cycle)
--8<---------------cut here---------------end--------------->8---

Nick

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

* Re: Scrolling down after Shift-TAB ?
  2012-01-24  0:45 ` Nick Dokos
@ 2012-01-24  2:02   ` François Pinard
  2012-01-24  2:33     ` Nick Dokos
  0 siblings, 1 reply; 6+ messages in thread
From: François Pinard @ 2012-01-24  2:02 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: emacs-orgmode

Nick Dokos <nicholas.dokos@hp.com> writes:
> François Pinard <pinard@iro.umontreal.ca> wrote:

>> Very, very often, after a Shift-TAB that collapses all entries, [...]
>> I [...] scroll down so see it all.

> You'd need to code it somewhat carefully sp that you wouldn't lose the
> property that after a couple of S-TABs, the buffer looks the same as
> when you started and point has not moved: that's useful in order to zoom
> out and orient yourself in the larger context and then zoom in again to
> continue working.

That's a nice property indeed.  Thanks for your patience with me!  :-)

> Have you tried C-l after the collapse?

It usually does not do the proper thing alone, but `C-l C-l C-l' is
closer to what I want.

> If you like the behavior, you can always advise org-cycle so that it
> always calls recenter afterwards:

> (defadvice  org-cycle (after org-cycle-recenter)
>   "Recenter after org-cycle)"
>   (recenter))

> (ad-activate 'org-cycle)

This was a good hint, thanks.  Starting from your idea, I ended up with:

(defun fp-org-cycle-recenter (type)
  "Recenter after global collapsing."
  (when (eq type 'overview)
    (recenter (1- (window-body-height)))))

(add-hook 'org-cycle-hook 'fp-org-cycle-recenter)

When returning to a more expanded view, the original line is recovered
at the center of the window instead of at its precise previous position,
which is quite acceptable to me.  From there, another full cycle of
course leaves the impression that the position did not move.

François

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

* Re: Scrolling down after Shift-TAB ?
  2012-01-24  2:02   ` François Pinard
@ 2012-01-24  2:33     ` Nick Dokos
  2012-01-24 12:14       ` François Pinard
  2012-01-24 12:15       ` François Pinard
  0 siblings, 2 replies; 6+ messages in thread
From: Nick Dokos @ 2012-01-24  2:33 UTC (permalink / raw)
  To: =?utf-8?Q?Fran=C3=A7ois?= Pinard; +Cc: nicholas.dokos, emacs-orgmode

François Pinard <pinard@iro.umontreal.ca> wrote:


> It usually does not do the proper thing alone, but `C-l C-l C-l' is
> closer to what I want.
> 

Well, the proper thing is very much in the eye of the beholder :-)

Also, I never noticed the binding change: I've been living my life thinking
that C-l *is* recenter... Thanks for the wake-up call.

Nick

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

* Re: Scrolling down after Shift-TAB ?
  2012-01-24  2:33     ` Nick Dokos
@ 2012-01-24 12:14       ` François Pinard
  2012-01-24 12:15       ` François Pinard
  1 sibling, 0 replies; 6+ messages in thread
From: François Pinard @ 2012-01-24 12:14 UTC (permalink / raw)
  To: emacs-orgmode

Nick Dokos <nicholas.dokos@hp.com> writes:

> Well, the proper thing is very much in the eye of the beholder :-)

My mother, who was a musician and a painter, used to say:

  "Des goûts et des couleurs, on ne discute pas...
   Mais il y en a de meilleurs que d'autres!"

The sentence is soft and spicy all at once!  A bit hard to translate,
though:

  "It's not fruitful to compare tastes and colors...
   Yet, some have it better than others!"

The fun thing is that the standard proverb stops at the ellipsis.  What
follows slightly contradicts what precedes!

And the lesson, for me, is to use some bits of courage at proposing or
evaluating aspects of things which, being more on the subjective side
than the objective side, might be prone to subtler debates.

François

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

* Re: Scrolling down after Shift-TAB ?
  2012-01-24  2:33     ` Nick Dokos
  2012-01-24 12:14       ` François Pinard
@ 2012-01-24 12:15       ` François Pinard
  1 sibling, 0 replies; 6+ messages in thread
From: François Pinard @ 2012-01-24 12:15 UTC (permalink / raw)
  To: emacs-orgmode

Nick Dokos <nicholas.dokos@hp.com> writes:

> Well, the proper thing is very much in the eye of the beholder :-)

My mother, who was a musician and a painter, used to say:

  "Des goûts et des couleurs, on ne discute pas...
   Mais il y en a de meilleurs que d'autres!"

The sentence is soft and spicy all at once!  A bit hard to translate,
though:

  "It's not fruitful to compare tastes and colors...
   Yet, some have it better than others!"

The fun thing is that the standard proverb stops at the ellipsis.  What
follows slightly contradicts what precedes!

And the lesson, for me, is to use some bits of courage at proposing or
evaluating aspects of things which, being more on the subjective side
than the objective side, might be prone to subtler debates.

François

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

end of thread, other threads:[~2012-01-24 12:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-23 23:39 Scrolling down after Shift-TAB ? François Pinard
2012-01-24  0:45 ` Nick Dokos
2012-01-24  2:02   ` François Pinard
2012-01-24  2:33     ` Nick Dokos
2012-01-24 12:14       ` François Pinard
2012-01-24 12:15       ` François Pinard

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