Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

window-width, the terminal and linum-mode

17 views
Skip to first unread message

Hans-Peter Deifel

unread,
Dec 25, 2012, 5:33:33 AM12/25/12
to
Hi group,

I was looking in "(elisp) Window Sizes" for a function to give me the
width of the text area of a window and found `window-body-width'.
However, this function gives me different results in terminal and GUI
modes, when linum-mode is enabled.

In terminal emacs, `window-body-width' includes the width of the line
number, while in gui emacs it doesn't. In both cases, the line number
width is returned correctly by `(window-margins)'.

So the question is: How can I get the width of the text-area (meaning,
in my case, without the line-numbers). I'd also like to avoid having to
distinguish X and terminal mode explicitly.

Thanks,
HP

--
Hans-Peter Deifel
GNU Emacs 24.2.1 (x86_64-pc-linux-gnu, GTK+ Version 3.4.4)

Constantin Kulikov

unread,
Dec 25, 2012, 6:12:06 AM12/25/12
to Hans-Peter Deifel, help-gnu-emacs
Maybe try `(window-width)' ?

Eli Zaretskii

unread,
Dec 25, 2012, 12:39:15 PM12/25/12
to help-gn...@gnu.org
> From: Hans-Peter Deifel <hpde...@gmx.de>
> Date: Tue, 25 Dec 2012 11:33:33 +0100
>
> I was looking in "(elisp) Window Sizes" for a function to give me the
> width of the text area of a window and found `window-body-width'.
> However, this function gives me different results in terminal and GUI
> modes, when linum-mode is enabled.
>
> In terminal emacs, `window-body-width' includes the width of the line
> number, while in gui emacs it doesn't. In both cases, the line number
> width is returned correctly by `(window-margins)'.

It's a bug in window-body-width, now fixed in the development sources,
thanks to your report. It should exclude the display margins from the
width calculation on TTYs as well.


Hans-Peter Deifel

unread,
Dec 27, 2012, 11:22:37 AM12/27/12
to
On Di, Dez 25 2012, Eli Zaretskii wrote:
>> I was looking in "(elisp) Window Sizes" for a function to give me the
>> width of the text area of a window and found `window-body-width'.
>> However, this function gives me different results in terminal and GUI
>> modes, when linum-mode is enabled.
>>
>> In terminal emacs, `window-body-width' includes the width of the line
>> number, while in gui emacs it doesn't. In both cases, the line number
>> width is returned correctly by `(window-margins)'.
>
> It's a bug in window-body-width, now fixed in the development sources,
> thanks to your report. It should exclude the display margins from the
> width calculation on TTYs as well.

Very cool. Thank you very much.

HP
0 new messages