emacs-devel
[Top][All Lists]
Advanced

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

Re: [mentoring-done] a darkroom/writeroom mode for Emacs


From: martin rudalics
Subject: Re: [mentoring-done] a darkroom/writeroom mode for Emacs
Date: Mon, 15 Dec 2014 16:28:06 +0100

> Yes I got it: I can collect pixelwise statistics about the line
> lengths and then use window width. (with one problem I can circumvent:
> window-width does not count *existing* margins).

You can always get the margins of a window via (window-margins).
Multiply the result with (frame-char-width) and you get the pixels
(beware of a nil return value).

> But to do comparisons with column based variables like `fill-column',

`fill-column' might be a problem, indeed.  Do you really need it?

> I
> still need the character (assumed fixed) pixel width, which I need to
> extract like this.
>
>    (window-text-pixel-size (selected-window)
>                            (point-min) (1+ (point-min)))

This will fail miserably with variable character widths.

> This fails for empty buffers, but that case is negligible anyway.
>
> The code is much cleaner now, so thanks.
>
> Anyway, its a bit confusing that `window-width' can't take the font size
> in consideration, while `window-text-pixel-size' can.

It can't.  Nobody can, so far ... Eli might fix this eventually.

> Though it probably
> makes sense since a window can display chars of many widths. But then
> using it without PIXELWISE should be deprecated.

For a human being it's easier to think in terms of columns rather than
in pixels.

> It might *become* its intent, if you wish to explain what you had in
> mind.

I only thought that if you add/remove characters to/from the longest
line you might also consider recentering the entire text on the fly.

martin



reply via email to

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