emacs-devel
[Top][All Lists]
Advanced

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

`fit-window-to-buffer-as-displayed'?


From: Drew Adams
Subject: `fit-window-to-buffer-as-displayed'?
Date: Mon, 10 Jan 2011 13:46:09 -0800

`fit-window-to-buffer' uses `count-window-lines', which takes line display into
account.

In this it seems to be trying, at least somewhat, to fit the window not simply
to the buffer content (plain text, fixed-char size) but to the buffer as
actually displayed.

But it fails to take any other display stuff into account, besides visual lines.
Looking around, I haven't found any code that would help fit a window to the
buffer as it is actually displayed - to account for the size of what you
actually see: displayed images, `display' property effects, proportional text,
etc.

1. Am I missing something - is there something that would help with this?
Something that would give me the actual height and width of a buffer as
currently displayed (e.g. in pixels)?

2. If not, could that please be added to Emacs?  (I'll file an enhancement
request if it makes sense.)  Either a new function,
`fit-window-to-buffer-as-displayed' or (better, IMO) an enhancement to
`fit-window-to-buffer' that adds an optional parameter AS-DISPLAYED.

3. If such an optional parameter were added, then perhaps it should also allow a
value that did not `count-window-lines' but counted buffer lines - IOW, instead
of just the halfway house of respecting display only so far as visual line
display is concerned, have 3 possibilities:

(a) buffer content without regard to display,
(b) what we have now: sensitivity only to line display, and
(c) sensitivity to all display artefacts.

For (a), we would need some defined way of treating images (whether or not they
are displayed) - perhaps based on the length of the file-name or embedded-image
code (dunno).

Wrt #1, I did find a couple of things that seem a bit related, in addition to
`count-window-lines': `image-size' and the window `vscroll' and `hscroll'
properties.  But nothing that takes the display of a whole buffer into account.
(E.g., it seems that instead of fitting the window to the image-dired display
image-dired does the opposite: scales the images to fit the window size.)

Anticipating a possible response of "this is too hard...", let me add that even
a partial solution would be helpful.  IOW, even if we couldn't immediately or
easily treat the whole problem of calculating displayed buffer size, perhaps we
could make some progress, so that `fit-window-to-buffer' might do a better job
than just adapting to screen lines.

WDOT?




reply via email to

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