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#19395: 25.0.50; Setting left fringe to 0 messes up window-width Date: Thu, 18 Dec 2014 18:15:36 +0200 Message-ID: <837fxpue6v.fsf@gnu.org> References: <87vblbnz2u.fsf@posteo.de> <83k31rwe55.fsf@gnu.org> <87lhm772o2.fsf@posteo.de> <83h9wvwbux.fsf@gnu.org> <87bnn39cpe.fsf@posteo.de> <83a92mwau9.fsf@gnu.org> <874msu9out.fsf@posteo.de> <83vblauoh6.fsf@gnu.org> <87wq5q864m.fsf@posteo.de> <83tx0uum88.fsf@gnu.org> <87a92lmxy3.fsf@posteo.de> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1418919388 22634 80.91.229.3 (18 Dec 2014 16:16:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 18 Dec 2014 16:16:28 +0000 (UTC) Cc: 19395@debbugs.gnu.org To: Titus von der Malsburg Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Dec 18 17:16:21 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1Y1dkQ-0005si-Jb for geb-bug-gnu-emacs@m.gmane.org; Thu, 18 Dec 2014 17:16:18 +0100 Original-Received: from localhost ([::1]:54620 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1dkP-0002XE-Lo for geb-bug-gnu-emacs@m.gmane.org; Thu, 18 Dec 2014 11:16:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57287) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1dkI-0002UA-7F for bug-gnu-emacs@gnu.org; Thu, 18 Dec 2014 11:16:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y1dkA-00061s-QX for bug-gnu-emacs@gnu.org; Thu, 18 Dec 2014 11:16:10 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:40935) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1dkA-00061o-OA for bug-gnu-emacs@gnu.org; Thu, 18 Dec 2014 11:16:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Y1dkA-00037t-HB for bug-gnu-emacs@gnu.org; Thu, 18 Dec 2014 11:16:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 18 Dec 2014 16:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19395 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 19395-submit@debbugs.gnu.org id=B19395.141891934911984 (code B ref 19395); Thu, 18 Dec 2014 16:16:02 +0000 Original-Received: (at 19395) by debbugs.gnu.org; 18 Dec 2014 16:15:49 +0000 Original-Received: from localhost ([127.0.0.1]:50300 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y1djw-00037E-Un for submit@debbugs.gnu.org; Thu, 18 Dec 2014 11:15:49 -0500 Original-Received: from mtaout20.012.net.il ([80.179.55.166]:40432) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y1dju-000375-35 for 19395@debbugs.gnu.org; Thu, 18 Dec 2014 11:15:47 -0500 Original-Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0NGS00000CYPZV00@a-mtaout20.012.net.il> for 19395@debbugs.gnu.org; Thu, 18 Dec 2014 18:15:45 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NGS000PDD65T780@a-mtaout20.012.net.il>; Thu, 18 Dec 2014 18:15:45 +0200 (IST) In-reply-to: <87a92lmxy3.fsf@posteo.de> X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x 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:97520 Archived-At: > From: Titus von der Malsburg > Cc: 19395@debbugs.gnu.org > Date: Wed, 17 Dec 2014 19:36:04 -0800 > > > But if we want this function to be more generally useful, it > > shouldn't be limited to the frame's canonical character size, and > > should at least take the face-remapping into account. Bonus points > > for accepting a face as an argument and using that face's font > > dimensions. > > This is more difficult than I thought. Below is a first sketch. Let me > know if you think this is going in the right direction and I'll polish > it and add the bonus feature. > > It appears that a font has to be rendered before Emacs can tell how wide > a character is. That's why we need the temporary buffer. Not elegant, > but I couldn't find a better way. `default-font-width' complements > `default-font-height' in simple.el. The other function would go into > window.el. Given the changes I pushed in commit b197822, you will no longer need all this complexity. Just (aref (font-info (face-font 'default)) 11) (For bullet-proof code, check that this is not zero, and if it is, use the 10th member instead; see the docs.) > (defun window-available-columns () > "Return the maximal number of characters that can be displayed > on one line. This function is different from `window-body-width' > in that it accounts for fringes (when at least one fringe has > zero width, one column is reserved for continuation characters) > and for the size of the default font (which may have been > adjusted using, e.g., `text-scale-increase')." > (let* ((window-width (window-body-width nil t)) > (font-width (default-font-width)) > (ncols (/ window-width font-width))) > (if (and (not (featurep 'xemacs)) > (display-graphic-p) > overflow-newline-into-fringe > (/= (frame-parameter nil 'left-fringe) 0) > (/= (frame-parameter nil 'right-fringe) 0)) > ncols > (1- (ncols))))) If we are going to put this in simple.el or subr.el, I don't think we need to worry about XEmacs. Thanks.