From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#9949: 24.0.91; window-width function does not take text-scale-mode-amount into account Date: Fri, 04 Nov 2011 22:12:06 +0200 Message-ID: <838vnvlka1.fsf@gnu.org> References: <83r51okwui.fsf@gnu.org> <83ipmzlvu3.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1320437559 28797 80.91.229.12 (4 Nov 2011 20:12:39 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 4 Nov 2011 20:12:39 +0000 (UTC) Cc: 9949-done@debbugs.gnu.org To: Josh Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Nov 04 21:12:33 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RMQ7r-0008Pr-U8 for geb-bug-gnu-emacs@m.gmane.org; Fri, 04 Nov 2011 21:12:32 +0100 Original-Received: from localhost ([::1]:44004 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RMQ7r-0000aD-7W for geb-bug-gnu-emacs@m.gmane.org; Fri, 04 Nov 2011 16:12:31 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:37107) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RMQ7n-0000a0-DW for bug-gnu-emacs@gnu.org; Fri, 04 Nov 2011 16:12:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RMQ7m-0006Zm-EE for bug-gnu-emacs@gnu.org; Fri, 04 Nov 2011 16:12:27 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:39812) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RMQ7m-0006Zf-CO for bug-gnu-emacs@gnu.org; Fri, 04 Nov 2011 16:12:26 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1RMQAI-0003sr-Bn for bug-gnu-emacs@gnu.org; Fri, 04 Nov 2011 16:15:02 -0400 Resent-From: Eli Zaretskii Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Fri, 04 Nov 2011 20:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 9949 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Mail-Followup-To: 9949@debbugs.gnu.org, eliz@gnu.org Original-Received: via spool by 9949-done@debbugs.gnu.org id=D9949.132043768214875 (code D ref 9949); Fri, 04 Nov 2011 20:15:02 +0000 Original-Received: (at 9949-done) by debbugs.gnu.org; 4 Nov 2011 20:14:42 +0000 Original-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 Original-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 Original-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) Original-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) In-reply-to: X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Fri, 04 Nov 2011 16:15:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:53529 Archived-At: > 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.