From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.devel Subject: Re: Pixel-based display functions Date: Sun, 01 Feb 2015 13:52:23 +0100 Message-ID: <54CE2187.9070003@gmx.at> References: <87k306pfi9.fsf@building.gnus.org> <87egqekrd7.fsf@building.gnus.org> <877fw53eat.fsf@building.gnus.org> <877fw4zsdv.fsf@building.gnus.org> <831tmcn4k4.fsf@gnu.org> <87386szq1w.fsf@building.gnus.org> <83wq44ljm9.fsf@gnu.org> <87vbjowlqv.fsf@building.gnus.org> <83oapglbx6.fsf@gnu.org> <83lhkkl23i.fsf@gnu.org> <83bnlgkl1s.fsf@gnu.org> <837fw3l7uz.fsf@gnu.org> <54CD4B27.4080201@gmx.at> <874mr6qvi5.fsf@building.gnus.org> <87sieqpfxh.fsf@building.gnus.org> <54CDE908.7050908@gmx.at> <87ioflq0dz.fsf@building.gnus.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1422795182 5876 80.91.229.3 (1 Feb 2015 12:53:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 1 Feb 2015 12:53:02 +0000 (UTC) Cc: Eli Zaretskii , Stefan Monnier , emacs-devel@gnu.org To: Lars Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Feb 01 13:53:00 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YHu1M-0004Ou-5p for ged-emacs-devel@m.gmane.org; Sun, 01 Feb 2015 13:53:00 +0100 Original-Received: from localhost ([::1]:50270 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YHu1L-00029S-FQ for ged-emacs-devel@m.gmane.org; Sun, 01 Feb 2015 07:52:59 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44393) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YHu19-00029L-7J for emacs-devel@gnu.org; Sun, 01 Feb 2015 07:52:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YHu18-0001Le-5R for emacs-devel@gnu.org; Sun, 01 Feb 2015 07:52:47 -0500 Original-Received: from mout.gmx.net ([212.227.15.15]:64280) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YHu14-0001L2-CI; Sun, 01 Feb 2015 07:52:42 -0500 Original-Received: from [88.117.59.199] ([88.117.59.199]) by mail.gmx.com (mrgmx002) with ESMTPSA (Nemesis) id 0MexFh-1Y2s8J1fa5-00OU2V; Sun, 01 Feb 2015 13:52:34 +0100 In-Reply-To: <87ioflq0dz.fsf@building.gnus.org> X-Provags-ID: V03:K0:afLCIgMnmVWTESXTtZqjUubHVNCfM2TgfYbe7gBqcphSOow9udu bls9lbPbP9UEmliK06XcRB5jyNZfpRXPsA1IBNWNQPI2pk+iNVmLxrD/inDmjlPw53+BK49 Q/q/MkdtkDna9Nj7uUQPB6dmVnfW+ztvxKE8hNnX30YwVWT69UfCaLYpT0I7W+gccYLxM3S FqgjiAEO5sUtOJSp21dLw== X-UI-Out-Filterresults: notjunk:1; X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 212.227.15.15 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:182173 Archived-At: > Yes, that's what I meant by "worked around somehow". :-) If the eww > buffer is visible in a window (and it usually should be), I can insert > text I want to know the width of there, call the function, and then > delete it again. > > However, if the eww buffer isn't visible, that approach won't be > possible... > > But the other things you mention here (default window faces and overlays > and stuff) doesn't apply to eww at all, But a general function would have to take care of these. > so it kinda sounds like I could > just do all this in a buffer that's even more likely to be associated > with a window, like the echo area. > > Or is that too hacky to contemplate? I think it might be... Simply do a `set-window-buffer' for some window on your frame and restore the previously shown buffer afterwards. A macro along these lines: (let ((old-buffer (window-buffer (frame-selected-window))) (old-start (window-start (frame-selected-window))) (old-point (window-point (frame-selected-window)))) (set-window-buffer (frame-selected-window) your-buffer) ... do your calculations .... (set-window-buffer (frame-selected-window) old-buffer) (set-window-point (frame-selected-window) old-point) (set-window-start (frame-selected-window) old-start)) Or yet simpler: Save the entire window configuration around your calculations. If redisplay doesn't run for some miraculous reason in between, nobody will notice. And if this is still too complicated for you, simply give `window-text-pixel-size' an additional argument which suppresses the buf = w->contents; CHECK_BUFFER (buf); b = XBUFFER (buf); if (b != current_buffer) { old_buffer = current_buffer; set_buffer_internal (b); } ... if (old_buffer) set_buffer_internal (old_buffer); sections. In that case it would be sufficient to make your temporary buffer current around the `window-text-pixel-size' call. martin