unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: <emacs-devel@gnu.org>
Subject: `fit-window-to-buffer-as-displayed'?
Date: Mon, 10 Jan 2011 13:46:09 -0800	[thread overview]
Message-ID: <F6F5819E415C4203A9B55E561A0D4168@us.oracle.com> (raw)

`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	other threads:[~2011-01-10 21:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-10 21:46 Drew Adams [this message]
2011-01-10 23:51 ` `fit-window-to-buffer-as-displayed'? Stefan Monnier
2011-01-11  0:35   ` `fit-window-to-buffer-as-displayed'? Drew Adams
2011-01-11  5:30     ` `fit-window-to-buffer-as-displayed'? Stefan Monnier
  -- strict thread matches above, loose matches on Subject: below --
2011-01-11 17:47 `fit-window-to-buffer-as-displayed'? Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=F6F5819E415C4203A9B55E561A0D4168@us.oracle.com \
    --to=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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