* tab widths with a remapped default face
@ 2008-06-06 5:19 Miles Bader
2008-06-06 5:53 ` Stefan Monnier
0 siblings, 1 reply; 8+ messages in thread
From: Miles Bader @ 2008-06-06 5:19 UTC (permalink / raw)
To: emacs-devel
The following patch seems to fix the bad tab rendering when the default
face is altered using face remapping. Any objections?
It will also change the way tabs are computed for explicit faces (and
other implicit faces such as the region), but I think it's probably
usually the right thing to do for those cases too.
Thanks,
-Miles
--- orig/src/xdisp.c
+++ mod/src/xdisp.c
@@ -21125,14 +21125,14 @@
}
else if (it->char_to_display == '\t')
{
- int tab_width = it->tab_width * FRAME_SPACE_WIDTH (it->f);
+ int tab_width = it->tab_width * font->space_width;
int x = it->current_x + it->continuation_lines_width;
int next_tab_x = ((1 + x + tab_width - 1) / tab_width) * tab_width;
/* If the distance from the current position to the next tab
stop is less than a space character width, use the
tab stop after that. */
- if (next_tab_x - x < FRAME_SPACE_WIDTH (it->f))
+ if (next_tab_x - x < font->space_width)
next_tab_x += tab_width;
it->pixel_width = next_tab_x - x;
--
Year, n. A period of three hundred and sixty-five disappointments.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: tab widths with a remapped default face
2008-06-06 5:19 tab widths with a remapped default face Miles Bader
@ 2008-06-06 5:53 ` Stefan Monnier
2008-06-06 7:26 ` Miles Bader
0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2008-06-06 5:53 UTC (permalink / raw)
To: Miles Bader; +Cc: emacs-devel
> The following patch seems to fix the bad tab rendering when the default
> face is altered using face remapping. Any objections?
> It will also change the way tabs are computed for explicit faces (and
> other implicit faces such as the region), but I think it's probably
> usually the right thing to do for those cases too.
IIUC your patch changes the TAB size to depend on the face applied to
the TAB. The current code was consciously not doing that, IIRC, tho
I can't quite remember the reason for it.
Could we make it use the space_width of the font used for the
default face?
Stefan
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: tab widths with a remapped default face
2008-06-06 5:53 ` Stefan Monnier
@ 2008-06-06 7:26 ` Miles Bader
2008-06-06 7:53 ` Stefan Monnier
2008-06-06 8:08 ` Miles Bader
0 siblings, 2 replies; 8+ messages in thread
From: Miles Bader @ 2008-06-06 7:26 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> IIUC your patch changes the TAB size to depend on the face applied to
> the TAB. The current code was consciously not doing that, IIRC, tho
> I can't quite remember the reason for it.
>
> Could we make it use the space_width of the font used for the
> default face?
It would be a bit more code, not sure if it would be a speed problem or
not.
Using the TAB face for tab-width calculation seems much likely to
preserve the local integrity of indentation (using the default face
means that mixed space and tab indentation will often not be the same as
space-only indentation). It seems a bit more intuitive to me as well.
However, if there is a significant case where using the default face for
calculations is better, it would be good to know it, but it seems a bit
silly to make decisions based on vague recollections.
-Miles
--
Absurdity, n. A statement or belief manifestly inconsistent with one's own
opinion.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: tab widths with a remapped default face
2008-06-06 7:26 ` Miles Bader
@ 2008-06-06 7:53 ` Stefan Monnier
2008-06-06 19:34 ` Gerd Möllmann
2008-06-06 8:08 ` Miles Bader
1 sibling, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2008-06-06 7:53 UTC (permalink / raw)
To: Miles Bader; +Cc: Gerd Moellmann, emacs-devel
> Using the TAB face for tab-width calculation seems much likely to
> preserve the local integrity of indentation (using the default face
> means that mixed space and tab indentation will often not be the same as
> space-only indentation). It seems a bit more intuitive to me as well.
> However, if there is a significant case where using the default face for
> calculations is better, it would be good to know it, but it seems a bit
> silly to make decisions based on vague recollections.
I think the issue was vertical alignment of elements on different lines,
using different faces. E.g. a first (header) line in one face,
followed by various lines in some other face.
OTOH, you can usually add a `default' face to the TABs to impose the use
of a uniform tab size, so maybe it's not a real problem.
Maybe Gerd remembers?
Stefan
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: tab widths with a remapped default face
2008-06-06 7:53 ` Stefan Monnier
@ 2008-06-06 19:34 ` Gerd Möllmann
0 siblings, 0 replies; 8+ messages in thread
From: Gerd Möllmann @ 2008-06-06 19:34 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Gerd Moellmann, emacs-devel, Miles Bader
On 06.06.2008, at 09:53, Stefan Monnier wrote:
>> Using the TAB face for tab-width calculation seems much likely to
>> preserve the local integrity of indentation (using the default face
>> means that mixed space and tab indentation will often not be the
>> same as
>> space-only indentation). It seems a bit more intuitive to me as
>> well.
>
>> However, if there is a significant case where using the default
>> face for
>> calculations is better, it would be good to know it, but it seems a
>> bit
>> silly to make decisions based on vague recollections.
>
> I think the issue was vertical alignment of elements on different
> lines,
> using different faces. E.g. a first (header) line in one face,
> followed by various lines in some other face.
>
> OTOH, you can usually add a `default' face to the TABs to impose the
> use
> of a uniform tab size, so maybe it's not a real problem.
> Maybe Gerd remembers?
I'm afraid I don't remember that. Maybe I thought it was more compatible
with how previous Emacs versions worked.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: tab widths with a remapped default face
2008-06-06 7:26 ` Miles Bader
2008-06-06 7:53 ` Stefan Monnier
@ 2008-06-06 8:08 ` Miles Bader
2008-06-06 19:13 ` Stefan Monnier
1 sibling, 1 reply; 8+ messages in thread
From: Miles Bader @ 2008-06-06 8:08 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
BTW, I assume the case you're remembering probably has to do with trying
to preserve column alignment across regions which using different faces.
E.g. if the `region' face scales the text by 0.5 and you select some
lines of code, then:
* Using the global face for tab calculation would roughly preserve
line-initial indendation (compared to the non-selected text) that
uses tabs even though the text all shrinks greatly. Of course,
non-line-initial column alignments will be completely screwed up,
and even line-initial indendation will be wrong to the extent it
uses spaces as well as tabs.
* Using the tab's face for tab calculation would mean that
line-initial indentation would shrink along with the text, but would
remain correct (locally, not compared to the non-selected text).
Non-line-initial column alignments would remain correct (locally).
I suppose which of these is "correct" can be argued, but personally the
latter seems the least objectionable to me, especially for displaying
source code.
-Miles
--
Dawn, n. When men of reason go to bed.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: tab widths with a remapped default face
2008-06-06 8:08 ` Miles Bader
@ 2008-06-06 19:13 ` Stefan Monnier
2008-06-06 21:41 ` Miles Bader
0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2008-06-06 19:13 UTC (permalink / raw)
To: Miles Bader; +Cc: emacs-devel
> I suppose which of these is "correct" can be argued, but personally the
> latter seems the least objectionable to me, especially for displaying
> source code.
Yes, I think it's a lose-lose situation, so we may as well use the
simpler solution.
Stefan
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: tab widths with a remapped default face
2008-06-06 19:13 ` Stefan Monnier
@ 2008-06-06 21:41 ` Miles Bader
0 siblings, 0 replies; 8+ messages in thread
From: Miles Bader @ 2008-06-06 21:41 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> I suppose which of these is "correct" can be argued, but personally the
>> latter seems the least objectionable to me, especially for displaying
>> source code.
>
> Yes, I think it's a lose-lose situation, so we may as well use the
> simpler solution.
Ok.
If there are tons of complaints, at least there will then be more
concrete info about what behavior people rely on.
-Miles
--
Hers, pron. His.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-06-06 21:41 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-06 5:19 tab widths with a remapped default face Miles Bader
2008-06-06 5:53 ` Stefan Monnier
2008-06-06 7:26 ` Miles Bader
2008-06-06 7:53 ` Stefan Monnier
2008-06-06 19:34 ` Gerd Möllmann
2008-06-06 8:08 ` Miles Bader
2008-06-06 19:13 ` Stefan Monnier
2008-06-06 21:41 ` Miles Bader
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.