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: Eli Zaretskii
Subject: Re: Problems with move_it_in_display_line_to X when tabs exist.
Date: Mon, 15 Jan 2018 14:06:35 +0200

> Date:  Sun, 14 Jan 2018 21:48:12 -0800
> From:  Keith David Bershatsky <address@hidden>
> Cc:  address@hidden
> 
> I am still working on troubleshooting how the value of it->pixel_width is 
> determined.  In the current fact pattern, I am using the following settings:
> 
>   (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)
> 
> I am placing a tab at flush-left and some text following the tab, such as:
> 
>       Hello-world.
> 
> I am calling interactively (scroll-left 1) to temporarily scroll the text to 
> the left 1 column at a time.
> 
> I believe that x_produce_glyphs sets the it->pixel-width of the stretch tab 
> incorrectly (while scrolling 2 or more columns to the left), which affects 
> the ability to properly move by it.pixel_width when calling 
> move_it_in_display_line_to.  As far as I can tell, this problem _only_ 
> happens when displaying native line numbers.

As previously, please provide a complete recipe, with text that needs
to be inserted into a buffer, and the commands that show why you think
the pixel_width is calculated incorrectly.  The above Lisp snippet is
a good start, but the main part, i.e. the text to insert, the commands
to perform, and the values you see produced -- that part is missing.

> QUESTION:  Is this line of code:
> 
>   int next_tab_x = ((1 + x + tab_width - 1) / tab_width) * tab_width;
> 
> the same thing as:
> 
>   int next_tab_x = x + tab_width;

No, it isn't, see below.

> If we add 1 and then subtract 1, we did not do anything meaningful.

True.  The code does that to make more explicitly clear how the value
of 'x + tab_width' was arrived to.  Omitting the two 1's could leave
the reader wondering where did those one-pixel adjustment disappear.

> If we divide something by tab_width and then multiply it by tab_width, then 
> we are back again at where we started.
> 
> EXAMPLE #1:  (1 + 11 + 77 - 1) / 77) * 77 = 88

No, this is integer division, so 88/77 yields 1, and the overall
result is 77, not 88.



reply via email to

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