unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* width of line numbers
@ 2020-12-22  9:23 Joost Kremers
  2020-12-22 10:06 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-22 10:12 ` Stephen Berman
  0 siblings, 2 replies; 6+ messages in thread
From: Joost Kremers @ 2020-12-22  9:23 UTC (permalink / raw)
  To: gnu-emacs-help

Hi all,

I was wondering if there's a way to find out the width of the current line
number display (with `display-line-number-mode`, not `linum-mode`).

Or, alternatively, get the window width without the line number. Both
`window-body-width` and `window-total-width` (why are there two functions, BTW?)
report the width of the text area without "dividers, scrollbars, margins,
fringes", but the line number display is still included.

TIA


-- 
Joost Kremers
Life has its moments



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: width of line numbers
  2020-12-22  9:23 width of line numbers Joost Kremers
@ 2020-12-22 10:06 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-22 10:46   ` Joost Kremers
  2020-12-22 10:12 ` Stephen Berman
  1 sibling, 1 reply; 6+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-12-22 10:06 UTC (permalink / raw)
  To: help-gnu-emacs

Joost Kremers wrote:

> I was wondering if there's a way to find out the width of
> the current line number display (with
> `display-line-number-mode`, not `linum-mode`).

A hard to spot typo, should be `display-line-numbers-mode'.

> Or, alternatively, get the window width without the
> line number.

(defun display-width ()
  (interactive)
  (message "%s" (- (window-width) (line-number-display-width))) )

> `window-body-width` and `window-total-width` (why are there
> two functions, BTW?)

Two functions? What about `window-width'? :P

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: width of line numbers
  2020-12-22  9:23 width of line numbers Joost Kremers
  2020-12-22 10:06 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-12-22 10:12 ` Stephen Berman
  2020-12-22 10:45   ` Joost Kremers
  2020-12-22 15:57   ` Eli Zaretskii
  1 sibling, 2 replies; 6+ messages in thread
From: Stephen Berman @ 2020-12-22 10:12 UTC (permalink / raw)
  To: Joost Kremers; +Cc: gnu-emacs-help

On Tue, 22 Dec 2020 10:23:26 +0100 Joost Kremers <joostkremers@fastmail.fm> wrote:

> Hi all,
>
> I was wondering if there's a way to find out the width of the current line
> number display (with `display-line-number-mode`, not `linum-mode`).

(line-number-display-width)

> Or, alternatively, get the window width without the line number.

This should do it:

(- (window-body-width) (line-number-display-width))

>                                                                  
>                                                                  Both
> `window-body-width` and `window-total-width` (why are there two functions, BTW?)
> report the width of the text area without "dividers, scrollbars, margins,
> fringes", but the line number display is still included.

Actually, window-total-width "includes the widths of WINDOW’s fringes,
margins, scroll bars and its right divider, if any."

Steve Berman



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: width of line numbers
  2020-12-22 10:12 ` Stephen Berman
@ 2020-12-22 10:45   ` Joost Kremers
  2020-12-22 15:57   ` Eli Zaretskii
  1 sibling, 0 replies; 6+ messages in thread
From: Joost Kremers @ 2020-12-22 10:45 UTC (permalink / raw)
  To: Stephen Berman; +Cc: help-gnu-emacs, gnu-emacs-help


On Tue, Dec 22 2020, Stephen Berman wrote:
> On Tue, 22 Dec 2020 10:23:26 +0100 Joost Kremers <joostkremers@fastmail.fm> wrote:
>
>> Hi all,
>>
>> I was wondering if there's a way to find out the width of the current line
>> number display (with `display-line-number-mode`, not `linum-mode`).
>
> (line-number-display-width)

Oh boy, this topic was covered extensively a while ago... I searched for
functions starting with `display-line-numbers`...

Thanks!

-- 
Joost Kremers
Life has its moments



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: width of line numbers
  2020-12-22 10:06 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-12-22 10:46   ` Joost Kremers
  0 siblings, 0 replies; 6+ messages in thread
From: Joost Kremers @ 2020-12-22 10:46 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: help-gnu-emacs


On Tue, Dec 22 2020, Emanuel Berg via Users list for the GNU Emacs text editor wrote:
>> `window-body-width` and `window-total-width` (why are there
>> two functions, BTW?)
>
> Two functions? What about `window-width'? :P

Well, at least `window-width` is just an alias for `window-body-width`. The
other two are separate functions.

-- 
Joost Kremers
Life has its moments



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: width of line numbers
  2020-12-22 10:12 ` Stephen Berman
  2020-12-22 10:45   ` Joost Kremers
@ 2020-12-22 15:57   ` Eli Zaretskii
  1 sibling, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2020-12-22 15:57 UTC (permalink / raw)
  To: Stephen Berman; +Cc: joostkremers, gnu-emacs-help

> From: Stephen Berman <stephen.berman@gmx.net>
> Date: Tue, 22 Dec 2020 11:12:14 +0100
> Cc: gnu-emacs-help@gnu.org
> 
> This should do it:
> 
> (- (window-body-width) (line-number-display-width))

I suggest

  (- (window-body-width) (line-number-display-width 'columns))
                                                    ^^^^^^^^
to make sure you don't subtract apples from oranges...



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-12-22 15:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-22  9:23 width of line numbers Joost Kremers
2020-12-22 10:06 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-22 10:46   ` Joost Kremers
2020-12-22 10:12 ` Stephen Berman
2020-12-22 10:45   ` Joost Kremers
2020-12-22 15:57   ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).