From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 03 22:43:39 2011 Received: (at submit) by debbugs.gnu.org; 4 Nov 2011 02:43:39 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RM9kp-0002jG-0U for submit@debbugs.gnu.org; Thu, 03 Nov 2011 22:43:39 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RM9aC-0002Ru-9f for submit@debbugs.gnu.org; Thu, 03 Nov 2011 22:32:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RM9Xi-0001HD-Ta for submit@debbugs.gnu.org; Thu, 03 Nov 2011 22:30:08 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,HTML_MESSAGE, RCVD_IN_DNSWL_LOW autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([140.186.70.17]:59950) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RM9Xi-0001GG-OF for submit@debbugs.gnu.org; Thu, 03 Nov 2011 22:30:06 -0400 Received: from eggs.gnu.org ([140.186.70.92]:35997) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RM9Xh-00013Y-32 for bug-gnu-emacs@gnu.org; Thu, 03 Nov 2011 22:30:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RM9Xf-0001Du-FZ for bug-gnu-emacs@gnu.org; Thu, 03 Nov 2011 22:30:04 -0400 Received: from mail-gy0-f169.google.com ([209.85.160.169]:48224) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RM9Xf-0001D0-Ag for bug-gnu-emacs@gnu.org; Thu, 03 Nov 2011 22:30:03 -0400 Received: by gyg10 with SMTP id 10so2322491gyg.0 for ; Thu, 03 Nov 2011 19:30:02 -0700 (PDT) Received: by 10.236.75.227 with SMTP id z63mr16873757yhd.46.1320373801092; Thu, 03 Nov 2011 19:30:01 -0700 (PDT) MIME-Version: 1.0 Received: by 10.236.108.11 with HTTP; Thu, 3 Nov 2011 19:29:40 -0700 (PDT) From: Josh Date: Thu, 3 Nov 2011 19:29:40 -0700 X-Google-Sender-Auth: ZZ389nS36s_RQ-HGunsVypxqS38 Message-ID: Subject: 24.0.91; window-width function does not take text-scale-mode-amount into account To: bug-gnu-emacs@gnu.org Content-Type: multipart/alternative; boundary=20cf300fb0b962886e04b0df7bd7 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -6.6 (------) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Thu, 03 Nov 2011 22:43:38 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.6 (------) --20cf300fb0b962886e04b0df7bd7 Content-Type: text/plain; charset=ISO-8859-1 The window-width function does not take text scale adjustments into account. This breaks code such as http://www.emacswiki.org/emacs/ErcFilling#toc2 which is meant to insert timestamps aligned to the right edge of the window. To reproduce starting from emacs -Q, 1) M-: (window-width) RET ; returns 80 here 2) C-x C-= ; window is now 70 characters wide 3) M-: (window-width) RET ; still returns 80 In GNU Emacs 24.0.91.1 (x86_64-apple-darwin, NS apple-appkit-1038.35) of 2011-10-30 on virtualmac.porkrind.org Windowing system distributor `Apple', version 10.3.1038 configured using `configure '--host=x86_64-apple-darwin' '--build=i686-apple-darwin' '--with-ns' 'build_alias=i686-apple-darwin' 'host_alias=x86_64-apple-darwin' 'CC=gcc -mmacosx-version-min=10.5'' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: en_US.US-ASCII value of $XMODIFIERS: nil locale-coding-system: us-ascii-unix default enable-multibyte-characters: t Major mode: Lisp Interaction Minor modes in effect: text-scale-mode: t tooltip-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Recent input: M-x e m a c s - v e r C-x 3 M-: ( w i n d o w - w i d t h ) C-x C-= C-x C-= M-: C-x 1 M-x r e p o r t - e m Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. GNU Emacs 24.0.91.1 (x86_64-apple-darwin, NS apple-appkit-1038.35) of 2011-10-30 on virtualmac.porkrind.org 37 (#o45, #x25) 37 (#o45, #x25) Load-path shadows: None found. Features: (shadow sort gnus-util mail-extr message format-spec rfc822 mml easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mailabbrev mail-utils gmm-utils mailheader emacsbug face-remap time-date tooltip ediff-hook vc-hooks lisp-float-type mwheel ns-win tool-bar dnd fontset image fringe lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer loaddefs button faces cus-face files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process ns multi-tty emacs) --20cf300fb0b962886e04b0df7bd7 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
The window-width function does not take text scale adjustments into=A0= account. =A0This breaks code such as=A0http://www.emacswiki.org/emacs/ErcFilling#toc2 w= hich is meant to insert=A0timestamps aligned to the right edge of the windo= w.

To reproduce starting from emacs -Q,
1) M-: (= window-width) RET =A0; returns 80 here
2) C-x C-=3D =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 ; window is now 70 characters wide
3) M-: (wi= ndow-width) RET =A0; still returns 80=A0



In GNU Emacs 24.0.91.1 (x= 86_64-apple-darwin, NS apple-appkit-1038.35)
=A0of 2011-10-30 on = virtualmac.porkrind.org
Windowing system distributor `Apple', version 10.3.1038
= configured using `configure =A0'--host=3Dx86_64-apple-darwin' '= --build=3Di686-apple-darwin' '--with-ns' 'build_alias=3Di68= 6-apple-darwin' 'host_alias=3Dx86_64-apple-darwin' 'CC=3Dgc= c -mmacosx-version-min=3D10.5''

Important settings:
=A0 value of $LC_ALL: nil=
=A0 value of $LC_COLLATE: nil
=A0 value of $LC_CTYPE: = nil
=A0 value of $LC_MESSAGES: nil
=A0 value of $LC_MON= ETARY: nil
=A0 value of $LC_NUMERIC: nil
=A0 value of $LC_TIME: nil
=A0 value of $LANG: en_US.US-ASCII
=A0 value of $XMODIFIER= S: nil
=A0 locale-coding-system: us-ascii-unix
=A0 defa= ult enable-multibyte-characters: t

Major mode: Lisp Interaction

M= inor modes in effect:
=A0 text-scale-mode: t
=A0 toolti= p-mode: t
=A0 mouse-wheel-mode: t
=A0 tool-bar-mode: t<= /div>
=A0 menu-bar-mode: t
=A0 file-name-shadow-mode: t
= =A0 global-font-lock-mode: t
=A0 font-lock-mode: t
=A0 = blink-cursor-mode: t
=A0 auto-composition-mode: t
=A0 a= uto-encryption-mode: t
=A0 auto-compression-mode: t
=A0 line-number-mode: t
=A0 transient-mark-mode: t

Recent input:
<= div>M-x e m a c s - v e r <tab> <return> C-x 3 M-: ( w=A0
=
i n d o w - w i d t h ) <return> C-x C-=3D C-x C-=3D M-:=A0
<up> <return> C-x 1 M-x r e p o r t - e m <tab> <r
eturn>

Recent messages:
For i= nformation about GNU Emacs and the GNU system, type C-h C-a.
GNU Emacs 24.0.91.1 (x86_64-apple-darwin, NS apple-appkit-1038.35) of = 2011-10-30 on virtualmac.porkrin= d.org
37 (#o45, #x25)
37 (#o45, #x25)

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr message format-spec = rfc822 mml easymenu
mml-sec mm-decode mm-bodies mm-encode mail-pa= rse rfc2231 rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mailabbrev mail-utils gmm-utils mailhead= er
emacsbug face-remap time-date tooltip ediff-hook vc-hooks
lisp-float-type mwheel ns-win tool-bar dnd fontset image fringe
lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cham geor= gian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao ko= rean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abb= rev
minibuffer loaddefs button faces cus-face files text-properti= es overlay
sha1 md5 base64 format env code-pages mule custom widget
has= htable-print-readable backquote make-network-process ns multi-tty
emacs)

--20cf300fb0b962886e04b0df7bd7-- From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 04 06:28:35 2011 Received: (at 9949) by debbugs.gnu.org; 4 Nov 2011 10:28:35 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RMH0l-0005an-4O for submit@debbugs.gnu.org; Fri, 04 Nov 2011 06:28:35 -0400 Received: from mtaout22.012.net.il ([80.179.55.172]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RMH0e-0005ab-UZ for 9949@debbugs.gnu.org; Fri, 04 Nov 2011 06:28:33 -0400 Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0LU400A00SFYID00@a-mtaout22.012.net.il> for 9949@debbugs.gnu.org; Fri, 04 Nov 2011 12:25:53 +0200 (IST) Received: from HOME-C4E4A596F7 ([84.228.70.69]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0LU4009A6SZ4V0B0@a-mtaout22.012.net.il>; Fri, 04 Nov 2011 12:25:53 +0200 (IST) Date: Fri, 04 Nov 2011 12:25:57 +0200 From: Eli Zaretskii Subject: Re: bug#9949: 24.0.91; window-width function does not take text-scale-mode-amount into account In-reply-to: X-012-Sender: halo1@inter.net.il To: Josh Message-id: <83r51okwui.fsf@gnu.org> References: X-Spam-Score: -2.0 (--) X-Debbugs-Envelope-To: 9949 Cc: 9949@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Reply-To: Eli Zaretskii List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.0 (--) > From: Josh > Date: Thu, 3 Nov 2011 19:29:40 -0700 > > The window-width function does not take text scale adjustments > into account. This breaks code such as > http://www.emacswiki.org/emacs/ErcFilling#toc2 which is meant to > insert timestamps aligned to the right edge of the window. > > To reproduce starting from emacs -Q, > 1) M-: (window-width) RET ; returns 80 here > 2) C-x C-= ; window is now 70 characters wide > 3) M-: (window-width) RET ; still returns 80 This is a problem with imprecise documentation and incorrect expectations that are caused by that. window-width and window-height report the window dimensions in frame's canonical units, i.e. for the frame's default face. Changing the font size does not, therefore, affect the values they return. AFAICS, this has been so since about forever. The code shown by the URL you cite should not use window-width. It should instead use posn-at-point after moving to the line end (e.g., with `end-of-visual-line'). I've updated the doc strings and the ELisp manual with this caveat and committed that as trunk revision 106283. If you are satisfied with this resolution, I will close the bug report. If not, then I think this should at best be tagged as "wishlist", and it should request a different set of functions to return the values you expected (because window-width and window-height are used too widely to be able to sustain such a significant change in functionality). For someone to be able to implement these new functions, you (or someone else) should come up with a specification of what they should return in the presence of different faces in the window. E.g., should the function that returns the line's width return values for a specific line, rather than for a window as a whole? should it count characters in that line or something else? etc., etc. From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 04 09:59:02 2011 Received: (at 9949) by debbugs.gnu.org; 4 Nov 2011 13:59:02 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RMKIQ-0002vG-2A for submit@debbugs.gnu.org; Fri, 04 Nov 2011 09:59:02 -0400 Received: from mailout-de.gmx.net ([213.165.64.23]) by debbugs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1RMKIN-0002ux-I7 for 9949@debbugs.gnu.org; Fri, 04 Nov 2011 09:59:00 -0400 Received: (qmail invoked by alias); 04 Nov 2011 13:56:23 -0000 Received: from 62-47-33-82.adsl.highway.telekom.at (EHLO [62.47.33.82]) [62.47.33.82] by mail.gmx.net (mp047) with SMTP; 04 Nov 2011 14:56:23 +0100 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX18whrc90kswplWjLuciro7NwIdJadOfEJp5nm9vQc hyGUZz7Hbev5bL Message-ID: <4EB3EF06.9060301@gmx.at> Date: Fri, 04 Nov 2011 14:56:22 +0100 From: martin rudalics User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 To: Josh Subject: Re: bug#9949: 24.0.91; window-width function does not take text-scale-mode-amount into account References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable X-Y-GMX-Trusted: 0 X-Spam-Score: -2.5 (--) X-Debbugs-Envelope-To: 9949 Cc: 9949@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.5 (--) > The window-width function does not take text scale adjustments > into account. This breaks code such as > http://www.emacswiki.org/emacs/ErcFilling#toc2 which is meant to > insert timestamps aligned to the right edge of the window. Recipe by courtesy of Johan Bockg=E5rd: (insert (propertize " " 'display '(space :align-to (- text 8))) "#123456") martin From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 04 12:05:23 2011 Received: (at 9949) by debbugs.gnu.org; 4 Nov 2011 16:05:23 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RMMGh-0005pq-LF for submit@debbugs.gnu.org; Fri, 04 Nov 2011 12:05:23 -0400 Received: from mtaout20.012.net.il ([80.179.55.166]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RMMGf-0005pi-98 for 9949@debbugs.gnu.org; Fri, 04 Nov 2011 12:05:22 -0400 Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0LU500H008FRIU00@a-mtaout20.012.net.il> for 9949@debbugs.gnu.org; Fri, 04 Nov 2011 18:02:24 +0200 (IST) Received: from HOME-C4E4A596F7 ([84.228.70.69]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0LU500HYJ8JZ3690@a-mtaout20.012.net.il>; Fri, 04 Nov 2011 18:02:24 +0200 (IST) Date: Fri, 04 Nov 2011 18:02:28 +0200 From: Eli Zaretskii Subject: Re: bug#9949: 24.0.91; window-width function does not take text-scale-mode-amount into account In-reply-to: To: Josh Message-id: <83ipmzlvu3.fsf@gnu.org> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: QUOTED-PRINTABLE X-012-Sender: halo1@inter.net.il References: <83r51okwui.fsf@gnu.org> X-Spam-Score: -2.0 (--) X-Debbugs-Envelope-To: 9949 Cc: 9949@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Reply-To: Eli Zaretskii List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.0 (--) [Please don't remove debbugs from the CC list.] > > The code shown by the URL you cite should not use window-width. = It > > should instead use posn-at-point after moving to the line end (e.= g., > > with `end-of-visual-line'). > > >=20 > In the common case, lines are shorter than the window width, so aft= er > moving to end-of-visual-line, posn-at-point would contain the lengt= h of the > current line and not the window width. I don't see how this approa= ch could > work without modifying the buffer. I don't really understand what the code on the page you pointed to wants to do, so perhaps my suggestion was incorrect. An alternative is what Martin suggested: > Recipe by courtesy of Johan Bockg=E5rd: >=20 > (insert (propertize > " " 'display > '(space :align-to (- text 8))) "#123456") > (defun scaled-window-width () > (destructuring-bind (left top right bottom) (window-inside-pixel-= edges) > (/ (- right left) (face-pixel-width)))) >=20 > Unfortunately, I could not find anything like face-pixel-width. Is= this > information exposed somehow or could it be made so? You could move point by 1 character and subtract pixel coordinates returned by posn-at-point. > For someone to be able to implement these new functions, you (or > > someone else) should come up with a specification of what they sh= ould > > return in the presence of different faces in the window. E.g., s= hould > > the function that returns the line's width return values for a > > specific line, rather than for a window as a whole? should it co= unt > > characters in that line or something else? etc., etc. > > >=20 > Basing the result on the width of the face at point seems reasonabl= e, with > a caveat in the docstring about windows having faces of different w= idths. But given that a line can have characters of different width, even fo= r the same face (think proportional fonts), what good will this kind of functionality be? From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 04 14:33:10 2011 Received: (at 9949) by debbugs.gnu.org; 4 Nov 2011 18:33:10 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RMOZh-0001WQ-Md for submit@debbugs.gnu.org; Fri, 04 Nov 2011 14:33:10 -0400 Received: from mail-gy0-f172.google.com ([209.85.160.172]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RMOZf-0001WJ-Id for 9949@debbugs.gnu.org; Fri, 04 Nov 2011 14:33:08 -0400 Received: by gye5 with SMTP id 5so2698811gye.3 for <9949@debbugs.gnu.org>; Fri, 04 Nov 2011 11:30:31 -0700 (PDT) Received: by 10.236.75.227 with SMTP id z63mr22285682yhd.46.1320431431162; Fri, 04 Nov 2011 11:30:31 -0700 (PDT) MIME-Version: 1.0 Received: by 10.236.108.11 with HTTP; Fri, 4 Nov 2011 11:30:10 -0700 (PDT) In-Reply-To: <83ipmzlvu3.fsf@gnu.org> References: <83r51okwui.fsf@gnu.org> <83ipmzlvu3.fsf@gnu.org> From: Josh Date: Fri, 4 Nov 2011 11:30:10 -0700 X-Google-Sender-Auth: phbAdI9bkiPTlgrQVJbuLwUAWAQ Message-ID: Subject: Re: bug#9949: 24.0.91; window-width function does not take text-scale-mode-amount into account To: Eli Zaretskii Content-Type: multipart/alternative; boundary=20cf300fb0b9679bc304b0ece6a5 X-Spam-Score: -5.1 (-----) X-Debbugs-Envelope-To: 9949 Cc: 9949@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.6 (----) --20cf300fb0b9679bc304b0ece6a5 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Fri, Nov 4, 2011 at 9:02 AM, Eli Zaretskii wrote: > [Please don't remove debbugs from the CC list.] Oops, sorry. > > > The code shown by the URL you cite should not use window-width. It > > > should instead use posn-at-point after moving to the line end (e.g., > > > with `end-of-visual-line'). > > > > > > > In the common case, lines are shorter than the window width, so after > > moving to end-of-visual-line, posn-at-point would contain the length of > the > > current line and not the window width. I don't see how this approach > could > > work without modifying the buffer. > > I don't really understand what the code on the page you pointed to > wants to do, so perhaps my suggestion was incorrect. An alternative > is what Martin suggested: It's trying to set the ERC fill column such that there will be room to insert a timestamp aligned to the right edge of the window. That code was only an example to show how incorrect window-width can break things. I really want a version of window-width that behaves as I described. > Recipe by courtesy of Johan Bockg=E5rd: > > > > (insert (propertize > > " " 'display > > '(space :align-to (- text 8))) "#123456") > > > > (defun scaled-window-width () > > (destructuring-bind (left top right bottom) (window-inside-pixel-edge= s) > > (/ (- right left) (face-pixel-width)))) > > > > Unfortunately, I could not find anything like face-pixel-width. Is thi= s > > information exposed somehow or could it be made so? > > You could move point by 1 character and subtract pixel coordinates > returned by posn-at-point. I'd prefer to avoid the save-excursion-and-move-point dance so I could avoid checking conditions like being at start or end of buffer, whether forward-char actually moved horizontally or did it go to the next line, etc. This approach also wouldn't work in buffers that were empty, for example in a find-file-hook on a new file, because we can't move the point without modifying the buffer. It would be much simpler and more reliable to expose faces' pixel widths. > > For someone to be able to implement these new functions, you (or > > > someone else) should come up with a specification of what they should > > > return in the presence of different faces in the window. E.g., shoul= d > > > the function that returns the line's width return values for a > > > specific line, rather than for a window as a whole? should it count > > > characters in that line or something else? etc., etc. > > > > > > > Basing the result on the width of the face at point seems reasonable, > with > > a caveat in the docstring about windows having faces of different width= s. > > But given that a line can have characters of different width, even for > the same face (think proportional fonts), what good will this kind of > functionality be? > window-width already returns incorrect results for the exceptions you mentioned. A variant that accounts for text scaling would be correct in all the cases window-width is correct, plus the case where text scaling has been applied to a fixed width font. All that is needed is for someone to expose the pixel width of a face and my scaled-window-width function above will work. --20cf300fb0b9679bc304b0ece6a5 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On Fri, Nov 4, 2011 at 9:02 AM, Eli Zaretskii <eliz@gnu.org> wrote:
[Please don't remove debbugs from the CC list.]

Oops, sorry.
=A0
> > The code shown by the URL you cite should not use window-width. = =A0It
> > should instead use posn-at-point after moving to the line end (e.= g.,
> > with `end-of-visual-line').
> >
>
> In the common case, lines are shorter than the window width, so after<= br> > moving to end-of-visual-line, posn-at-point would contain the length o= f the
> current line and not the window width. =A0I don't see how this app= roach could
> work without modifying the buffer.

I don't really understand what the code on the page you pointed t= o
wants to do, so perhaps my suggestion was incorrect. =A0An alternative
is what Martin suggested:

It's trying t= o set the ERC fill column such that there will be room to insert a timestam= p aligned to the right edge of the window. =A0That code was only an example= to show how incorrect window-width can break things. =A0I really want a ve= rsion of window-width that behaves as I described.

> Recipe by courtesy of Johan Bockg=E5rd:
>
> (insert (propertize
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 " " 'display
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 '(space :align-to (- text 8))) "#= 123456")


> (defun scaled-window-width ()
> =A0 (destructuring-bind (left top right bottom) (window-inside-pixel-e= dges)
> =A0 =A0 (/ (- right left) (face-pixel-width))))
>
> Unfortunately, I could not find anything like face-pixel-width. =A0Is = this
> information exposed somehow or could it be made so?

You could move point by 1 character and subtract pixel coordinates returned by posn-at-point.

I'd prefer t= o avoid the save-excursion-and-move-point dance so I could avoid checking c= onditions like being at start or end of buffer, whether forward-char actual= ly moved horizontally or did it go to the next line, etc. =A0This approach = also wouldn't work in buffers that were empty, for example in a find-fi= le-hook on a new file, because we can't move the point without modifyin= g the buffer. =A0It would be much simpler and more reliable to expose faces= ' pixel widths.
=A0
> For someone to be able to implement these new functions, you (or
> > someone else) should come up with a specification of what they sh= ould
> > return in the presence of different faces in the window. =A0E.g.,= should
> > the function that returns the line's width return values for = a
> > specific line, rather than for a window as a whole? =A0should it = count
> > characters in that line or something else? =A0etc., etc.
> >
>
> Basing the result on the width of the face at point seems reasonable, = with
> a caveat in the docstring about windows having faces of different widt= hs.

But given that a line can have characters of different width, even fo= r
the same face (think proportional fonts), what good will this kind of
functionality be?

window-width already returns incorrect results = for the exceptions you mentioned. =A0A variant that accounts for text scali= ng would be correct in all the cases window-width is correct, plus the case= where text scaling has been applied to a fixed width font. =A0All that is = needed is for someone to expose the pixel width of a face and my scaled-win= dow-width function above will work.
--20cf300fb0b9679bc304b0ece6a5-- From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 04 16:01:26 2011 Received: (at 9949) by debbugs.gnu.org; 4 Nov 2011 20:01:26 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RMPx8-0003Yo-9W for submit@debbugs.gnu.org; Fri, 04 Nov 2011 16:01:26 -0400 Received: from mailout-de.gmx.net ([213.165.64.22]) by debbugs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1RMPx6-0003Yg-9I for 9949@debbugs.gnu.org; Fri, 04 Nov 2011 16:01:25 -0400 Received: (qmail invoked by alias); 04 Nov 2011 19:58:46 -0000 Received: from 62-47-38-79.adsl.highway.telekom.at (EHLO [62.47.38.79]) [62.47.38.79] by mail.gmx.net (mp072) with SMTP; 04 Nov 2011 20:58:46 +0100 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX19+Zalbzdx+3eH6q8c91LK5zhtK0kFiV9cxTG02O/ cR2WfFA3yhuVsv Message-ID: <4EB443F4.9070605@gmx.at> Date: Fri, 04 Nov 2011 20:58:44 +0100 From: martin rudalics User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 To: Josh Subject: Re: bug#9949: 24.0.91; window-width function does not take text-scale-mode-amount into account References: <83r51okwui.fsf@gnu.org> <83ipmzlvu3.fsf@gnu.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Spam-Score: -2.5 (--) X-Debbugs-Envelope-To: 9949 Cc: 9949@debbugs.gnu.org, Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.5 (--) > window-width already returns incorrect results for the exceptions you > mentioned. A variant that accounts for text scaling would be correct in > all the cases window-width is correct, plus the case where text scaling has > been applied to a fixed width font. All that is needed is for someone to > expose the pixel width of a face and my scaled-window-width function above > will work. You really should leave this job to the display-engine. Doing your calculations based on window-width means you'd have to add a function to `window-configuration-change-hook' and/or `window-size-change-functions' and recalculate the position of your stamps when a window changes size. Moreover, a solution based on window-width will fail when you display the same buffer in two windows of different width. And another benefit of using :align-to would be the additional experience whether it does its job as expected. martin From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 04 16:14:42 2011 Received: (at 9949-done) by debbugs.gnu.org; 4 Nov 2011 20:14:42 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RMQ9x-0003rp-Rj for submit@debbugs.gnu.org; Fri, 04 Nov 2011 16:14:42 -0400 Received: from mtaout23.012.net.il ([80.179.55.175]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RMQ9v-0003rh-93 for 9949-done@debbugs.gnu.org; Fri, 04 Nov 2011 16:14:40 -0400 Received: from conversion-daemon.a-mtaout23.012.net.il by a-mtaout23.012.net.il (HyperSendmail v2007.08) id <0LU500A00JWT2C00@a-mtaout23.012.net.il> for 9949-done@debbugs.gnu.org; Fri, 04 Nov 2011 22:12:02 +0200 (IST) Received: from HOME-C4E4A596F7 ([84.228.70.69]) by a-mtaout23.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0LU500AKHK402K00@a-mtaout23.012.net.il>; Fri, 04 Nov 2011 22:12:01 +0200 (IST) Date: Fri, 04 Nov 2011 22:12:06 +0200 From: Eli Zaretskii Subject: Re: bug#9949: 24.0.91; window-width function does not take text-scale-mode-amount into account In-reply-to: X-012-Sender: halo1@inter.net.il To: Josh Message-id: <838vnvlka1.fsf@gnu.org> References: <83r51okwui.fsf@gnu.org> <83ipmzlvu3.fsf@gnu.org> X-Spam-Score: -1.7 (-) X-Debbugs-Envelope-To: 9949-done Cc: 9949-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Reply-To: Eli Zaretskii List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.7 (-) > From: Josh > Date: Fri, 4 Nov 2011 11:30:10 -0700 > Cc: 9949@debbugs.gnu.org > > > > (defun scaled-window-width () > > > (destructuring-bind (left top right bottom) (window-inside-pixel-edges) > > > (/ (- right left) (face-pixel-width)))) > > > > > > Unfortunately, I could not find anything like face-pixel-width. Is this > > > information exposed somehow or could it be made so? > > > > You could move point by 1 character and subtract pixel coordinates > > returned by posn-at-point. > > > I'd prefer to avoid the save-excursion-and-move-point dance so I could > avoid checking conditions like being at start or end of buffer, whether > forward-char actually moved horizontally or did it go to the next line, > etc. This approach also wouldn't work in buffers that were empty, for > example in a find-file-hook on a new file, because we can't move the point > without modifying the buffer. It would be much simpler and more reliable > to expose faces' pixel widths. I suggest to ask for advice on help-gnu-emacs or emacs-devel, then. > > But given that a line can have characters of different width, even for > > the same face (think proportional fonts), what good will this kind of > > functionality be? > > > > window-width already returns incorrect results for the exceptions you > mentioned. A variant that accounts for text scaling would be correct in > all the cases window-width is correct, plus the case where text scaling has > been applied to a fixed width font. All that is needed is for someone to > expose the pixel width of a face and my scaled-window-width function above > will work. Feel free to file a feature-request bug about that. I'm closing this one. From unknown Sat Aug 09 14:04:57 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 03 Dec 2011 12:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 05 16:08:16 2012 Received: (at control) by debbugs.gnu.org; 5 Dec 2012 21:08:16 +0000 Received: from localhost ([127.0.0.1]:55330 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TgMCW-0001xy-5J for submit@debbugs.gnu.org; Wed, 05 Dec 2012 16:08:16 -0500 Received: from fencepost.gnu.org ([208.118.235.10]:53642) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TgMCU-0001xq-7x for control@debbugs.gnu.org; Wed, 05 Dec 2012 16:08:14 -0500 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1TgMCK-0000t1-UO for control@debbugs.gnu.org; Wed, 05 Dec 2012 16:08:04 -0500 Date: Wed, 05 Dec 2012 16:08:04 -0500 Message-Id: Subject: control message for bug 13073 To: X-Mailer: mail (GNU Mailutils 2.1) From: Glenn Morris X-Spam-Score: -4.2 (----) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.2 (----) unarchive 9949 forcemerge 9949 13073 From unknown Sat Aug 09 14:04:57 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 03 Jan 2013 12:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator