all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: "'Stefan Monnier'" <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: RE: `fit-window-to-buffer-as-displayed'?
Date: Mon, 10 Jan 2011 16:35:01 -0800	[thread overview]
Message-ID: <365C578E37C14DC9AA3982C625EFC32E@us.oracle.com> (raw)
In-Reply-To: <jwvy66siaov.fsf-monnier+emacs@gnu.org>

> > 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)?
> 
> At the time fit-window-to-buffer-as-displayed is called, the 
> text might not be completely displayed yet.

Well obviously one would call `fit-window-to-buffer-as-displayed' only after
(one knew that) it was displayed. ;-)

And if it were called when not displayed then, in that situation, we could
either have it be a no-op or have it do what `fit-window-to-buffer' does now.

> > 2. If not, could that please be added to Emacs?  (I'll file 
> > an enhancement
> 
> Agreed, please.

Done - bug #7822.

> > 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.
> 
> No need for a new parameter: it's a bug-fix.

That means that you interpret `fit-window-to-buffer' as though it should
_always_ fit the window to the buffer _as displayed_.

I think there can be use cases for its current behavior.  And use cases for just
fitting to the buffer text, ignoring all display considerations (treating it as
plain, fixed-width text, no more).

> It's not trivial to fix, tho, and it's not clear which kind 
> of primitive the C code could/should provide in order to make
> it possible.

I figured it would not be trivial.

And I'm guessing the result might be only partially effective (correct).  That's
one reason why I think there should be the option (either via a parameter or a
separate function) to _not_ have it try to take into account all display
characteristics.

IOW, you should be able to have the window fit the buffer text in simpler ways,
including the way we fit it now.

> Maybe we could simply do something like a binary search, 
> where each loop iteration forces redisplay, then checks with
> posn-point if EOB is right at the end of the window.

I probably have nothing to offer wrt the implementation.  I do think though that
this is bound to be somewhat complex and success is likely to be partial and
conditional (works for some display artifacts in some situations, but is not
perfect).  There are a lot of different things one can do with display, even
just counting the `display' text/overlay property.  (And note that some of them
take place beyond buffer positions, so tests involving (point) won't necessarily
cut the mustard.)

For this reason I think the behavior (what it tries to do) should be under
programmer control.  We already have something that "works" for what it does.
Complicating the behavior to try to do better might make some situations better,
but someone might still want simpler behavior (e.g. what we have now) sometimes.

[I generally prefer to give users and programmers more control, _especially_
when faced with an all-encompassing wannbe-all-powerful DWIM. ;-)]




  reply	other threads:[~2011-01-11  0:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-10 21:46 `fit-window-to-buffer-as-displayed'? Drew Adams
2011-01-10 23:51 ` `fit-window-to-buffer-as-displayed'? Stefan Monnier
2011-01-11  0:35   ` Drew Adams [this message]
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

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

  git send-email \
    --in-reply-to=365C578E37C14DC9AA3982C625EFC32E@us.oracle.com \
    --to=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.