Subject: Re: bug#17346: 24.4.50; Why is the goal column limited to C-n and C-p ?

From: Dani Moncayo <[email-masked]>
Date: Thu, 9 Oct 2014 22:43:38 +0200

On Thu, Oct 9, 2014 at 6:57 PM, Stefan Monnier <[email-masked]> wrote:
>>> We could change that hardcoded list by replacing it with a symbol
>>> property `preserve-temporary-goal-column' and then add that property to
>>> recenter-top-bottom.
>> Sounds right to me.
>
> Patch welcome.

I currently lack the knowledge for making the change myself, sorry.

>> Note also that, as I said before in this thread, any command intended
>> for _vertical_ motion of the cursor (scroll-up-command,
>> scroll-down-command, scroll-bar-toolkit-scroll, mwheel-scroll, ...)
>> should try to preserve the goal column (whether semi-permanet or
>> temporary).
>
> If you want that, just set scroll-preserve-screen-position accordingly.

I don't see how that would solve the problem I'm reporting.  For example:

* emacs -Q
* Visit the COPYING file from the Emacs tree.
* (setq scroll-preserve-screen-position t)
* M-m
* Scroll down with C-v until point falls on an empty line, so that the
  point can't stay at the original column.
* Now try to continue your scrolling down, but now with C-n.

Observe then how the original column is lost, which is IMO an annoying
bug which makes harder for me the analysis of tabulated files.

> I think there's a remaining bug in that the scroll commands will
> use their own "temporary goal-column".  So, for example, if you're on
> column 70, then do C-n to an empty line and then do page-down you'll end
> up in column 0 because page-down did not pay attention to
> temporary-goal-column (and vice-versa when switching from scrolling to
> C-n/C-p).
> Patch welcome to fix this as well.

Exactly.  That is what I'm trying to explain: All commands that move
point *vertically* to another line of text, either directly (like
C-p/C-n) or indirectly as consequence of scrolling the buffer (like
C-v/M-v) should share a single "temporary goal column", which is the
column where point was after the last non-vertical scrolling command.

>> Therefore, `preserve-goal-column' would be a better name for the
>> property, since it would refer to both types of goal columns.
>
> Actually both types are temporary (as opposed to `goal-column' which is
> set typically once and for all by the major mode).

I'm lost here.  I was aware of only these two types of "goal columns":

1. Temporary: Set after every command which moves point, except for
   those commands intended for _vertical_ motion (C-p/C-n/C-v/M-v/...).

2. Semi-permanent: Set with the `set-goal-column' command.  When this
   goal column is defined, it prevails over the temporary one.

-- 
Dani Moncayo