[Top][All Lists]

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

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

From: João Távora
Subject: Re: [mentoring-done] a darkroom/writeroom mode for Emacs
Date: Mon, 15 Dec 2014 14:54:02 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (windows-nt)

martin rudalics <address@hidden> writes:

> The function `window-text-pixel-size' gives you the width of some block
> of text in pixels. The function `window-width' when called with
> PIXELWISE non-nil gives you the width of the window in pixels.  The
> difference of the two gives you the pixel width you can distribute.

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).

But to do comparisons with column based variables like `fill-column', 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 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. Though it probably
makes sense since a window can display chars of many widths. But then
using it without PIXELWISE should be deprecated.

> Presently we cannot resize margins pixelwise.  But we can set fringe
> sizes pixelwise.  If you prefer using the margins, you have to round the
> difference calculated above (which means that the text might not get
> centerd exactly by at most one frame character width minus one pixel).

That's OK in my book.

>> Indeed, this is not the intent of darkroom.el, at least in its current
>> state. I don't even understand what how such a feature would work or
>> feel like. Do you mean like "center paragraph", where a typing a word
>> alone on a line makes it occupy the horizontal center?
> If it's not the intent of darkroom then don't bother.

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


reply via email to

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