Subject: Re: bug#17585: 24.4.50; vertical-motion erroneously adds points

From: Keith David Bershatsky <[email-masked]>
Date: Sat, 31 May 2014 12:00:59 -0700

Eli & Stefan:

My confusion regarding whether the fix for Bug#17585 had been implemented in the version of Emacs Trunk that I've been testing was due to the reason mentioned by Eli below.  Indeed, the arrow keys and scrolling with the mouse now work correctly when `visual-line-mode` and `linum-mode` are both active and the line of text (without any spaces) exceeds the `window-width`.

I've been using the following command line prior to building a new Emacs Trunk version, and I believe it gives me the most recent Emacs-24 branch:

bzr branch --stacked bzr://bzr.savannah.gnu.org/emacs/trunk emacs-trunk

`M-x emacs version` yields the following message:

GNU Emacs 24.4.50.1 (x86_64-apple-darwin10.8.0, NS apple-appkit-1038.36) of 2014-05-29 on MP.local

I am working on writing a custom library that draws a thin vertical line (i.e., "|") and a thin horizontal line (i.e., `underline`), which is compatible with `visual-line-mode` and `linum-mode`.  The visual effect is similar to the `crosshairs.el` library, except that mine is done with thin lines only -- i.e., no background highlighting.  One of my key functions uses (vertical-motion 1) for every line in the visible window.  To deal with the situation best described by Eli (below), I use the following immediately after each execution of (vertical-motion 1):

    (when (= (current-column) 2 )
        (move-to-column (+ (current-column) (- window-width 2))))

I have not yet done any experimentation with removing the line number overlays for purposes of calculating and placing my cross-hair overlays.  My best guess is that adding the line numbers after the cross-hairs have been placed would skew/break the vertical line.

Thanks again for implementing the bug fix.  It certainly nice to be able to effectively use the arrow keys and the mouse scroll when dealing with the situation described in the first paragraph above.

Keith

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

At Fri, 30 May 2014 12:21:58 -0400,
Stefan Monnier wrote:
> 
> > the Trunk as of May 29, 2014 at 11:18 P.S.T.  Approximately when, please,
> > should I expect to see the fix merged into the Trunk?
> 
> Please use the `emacs-24' branch instead, which is the one we're
> focusing on right now (and which does have this fix applied).
> 
> 
>         Stefan

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

> Date:  Thu, 29 May 2014 23:21:05 -0700
> From:  Keith David Bershatsky <[email-masked]>
> Cc:  [email-masked]
> 
> The `test` function yields the same result with Emacs built (--with-ns) from the Trunk as of May 29, 2014 at 11:18 P.S.T.  Approximately when, please, should I expect to see the fix merged into the Trunk?

It was merged to the trunk on May 26, as trunk revision 117154 (yes,
the same revision number as on the emacs-24 branch; it happens).

> I'm using macports / baazar:
> 
> /macports/bin/bzr branch --stacked bzr://bzr.savannah.gnu.org/emacs/trunk emacs-trunk

Do you have revision 117154 in your bzr trunk branch?  If you do, you
should see this entry in src/ChangeLog:

  2014-05-26  Eli Zaretskii  <[email-masked]>

	  * xdisp.c (move_it_in_display_line_to): Don't record wrap position
	  if we are iterating over an object that generates glyphs for
	  marginal areas.  (Bug#17585)

With the latest trunk, vertical motion in the foo.txt buffer created
by your recipe works OK interactively (i.e. by using arrow keys or
M-:); it didn't work correctly before.  Please try that after your
'test' function finishes.

Your test case, which uses vertical-motion non-interactively, indeed
still moves point horizontally as well, but that's because linum-mode
does its line number display in a post-command hook, so it defers the
initial display of the line numbers until _after_ vertical-motion did
its thing.  You can see that by inserting (sit-for 1) before each call
to vertical-motion.  So I think this is an unrelated problem; if it
gives you trouble in some real-life use case, please describe that use
case.