emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems with move_it_in_display_line_to X when tabs exist.


From: Keith David Bershatsky
Subject: Re: Problems with move_it_in_display_line_to X when tabs exist.
Date: Mon, 15 Jan 2018 20:41:52 -0800

Thank you, Eli, for teaching me about "integer division".  I have added that 
concept to my learning "todo list" and anticipate having a handle on that in 
the next couple of days.

GOAL:  The goal is to interactively call (scroll-left 1) -- one or more times 
in a row -- and obtain the beginning _visible_ X and HPOS of the STRETCH tab; 
and, also obtain its _visible_ pixel-width.

The following screenshots with stderr results were obtained by calling the 
function debug-tab-pixel-width, which is contained in the attached patch.diff.  
I saw that x_produce_glyphs is able to achieve the correct it->pixel_width for 
the STRETCH tab when x0 >= it->lnum_pixel_width; however, it is run subsequent 
in time to when we call move_it_in_display_line_to.


0.  Opening screenshot -- just setting up the test buffer.

  https://www.lawlist.com/images/tab_width_bug_00.png


1.  Place the cursor on the line that begins with a tab, and press the f5 key 
once.

  https://www.lawlist.com/images/tab_width_bug_01.png

  OBSERVATIONS (w->hscroll == 1):  The expected result is that the STRETCH tab 
will have an it.pixel_width of 42.  The third (3rd) iteration/loop has the 
wrong value; i.e., 49.  The fourth (4th) iteration/loop has the correct value; 
i.e., 42.  x_produce_glyphs runs subsequent in time and contains the desired 
value of 42 when x0 >= it->lnum_pixel_width.


2.  With the cursor still on the line that began with a tab, Press the f5 key 
once.

  https://www.lawlist.com/images/tab_width_bug_02.png

  OBSERVATIONS (w->hscroll == 2):  The expected result is that the STRETCH tab 
will have an it.pixel_width of 35; however, it has a value of 49 instead.  
x_produce_glyphs runs subsequent in time and contains the desired value of 35 
when x0 >= it->lnum_pixel_width.


3. With the cursor still on the line that began with a tab, Press the f5 key 
once.

  https://www.lawlist.com/images/tab_width_bug_03.png

  OBSERVATIONS (w->hscroll == 3):  The expected result is that the STRETCH tab 
will have an it.pixel_width of 28; however, it has a value of 49 instead.  
x_produce_glyphs runs subsequent in time and contains the desired value of 28 
when x0 >= it->lnum_pixel_width.


LISP CODE (buffer-local):

(setq display-line-numbers t)
(setq buffer-display-table (make-display-table))
(aset buffer-display-table
      ?\t
      (vector (make-glyph-code ?\u00BB 'font-lock-warning-face)
              (make-glyph-code ?\t 'highlight)))
(setq tab-width 8)
(global-set-key [f5] (lambda () (interactive) (debug-tab-pixel-width)))


TEST TEXT (a tab, followed by some arbitrary letters such Hello-world) -- the 
text begins on line 13:

        Hello-world.


C CODE:  Apply the attached patch.diff to Emacs 26 as of 01/15/2018 bearing 
last commit 9f22b7d2317eff65897355dcf68ba10d521cfa5a.


Attachment: patch.diff
Description: application/diff


reply via email to

[Prev in Thread] Current Thread [Next in Thread]