From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Titus von der Malsburg Newsgroups: gmane.emacs.bugs Subject: bug#19395: 25.0.50; Setting left fringe to 0 messes up window-width Date: Sun, 21 Dec 2014 23:04:51 +0100 Message-ID: <87ppbc3bi4.fsf@posteo.de> 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> <837fxpue6v.fsf@gnu.org> <87oaqyz85s.fsf@posteo.de> <83388as2oy.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: ger.gmane.org 1419199588 26886 80.91.229.3 (21 Dec 2014 22:06:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 21 Dec 2014 22:06:28 +0000 (UTC) Cc: 19395@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Dec 21 23:06: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 1Y2odl-0008W5-Nu for geb-bug-gnu-emacs@m.gmane.org; Sun, 21 Dec 2014 23:06:17 +0100 Original-Received: from localhost ([::1]:38447 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y2odk-0003aB-SK for geb-bug-gnu-emacs@m.gmane.org; Sun, 21 Dec 2014 17:06:16 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55076) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y2odc-0003Zs-2P for bug-gnu-emacs@gnu.org; Sun, 21 Dec 2014 17:06:13 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y2odW-0001ss-Pl for bug-gnu-emacs@gnu.org; Sun, 21 Dec 2014 17:06:08 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:44715) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y2odW-0001so-Mx for bug-gnu-emacs@gnu.org; Sun, 21 Dec 2014 17:06:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Y2odW-0000xE-6E for bug-gnu-emacs@gnu.org; Sun, 21 Dec 2014 17:06:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Titus von der Malsburg Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 21 Dec 2014 22:06: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.14191995053600 (code B ref 19395); Sun, 21 Dec 2014 22:06:02 +0000 Original-Received: (at 19395) by debbugs.gnu.org; 21 Dec 2014 22:05:05 +0000 Original-Received: from localhost ([127.0.0.1]:54081 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y2oca-0000w0-Du for submit@debbugs.gnu.org; Sun, 21 Dec 2014 17:05:04 -0500 Original-Received: from mx02.posteo.de ([89.146.194.165]:40970) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y2ocT-0000vQ-II for 19395@debbugs.gnu.org; Sun, 21 Dec 2014 17:05:01 -0500 Original-Received: from dovecot03.posteo.de (unknown [185.67.36.28]) by mx02.posteo.de (Postfix) with ESMTPS id 7E80225ACC5E; Sun, 21 Dec 2014 23:04:56 +0100 (CET) Original-Received: from mail.posteo.de (localhost [127.0.0.1]) by dovecot03.posteo.de (Postfix) with ESMTPSA id 3k5Ht01Q6Xz5vN2; Sun, 21 Dec 2014 23:04:55 +0100 (CET) In-reply-to: <83388as2oy.fsf@gnu.org> 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:97658 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On 2014-12-20 Sat 17:31, Eli Zaretskii wrote: >> From: Titus von der Malsburg >> Cc: 19395@debbugs.gnu.org >> Date: Sat, 20 Dec 2014 15:51:27 +0100 >>=20 >> > (aref (font-info (face-font 'default)) 11) >>=20 >> Great, thanks for adding this. Below the updated version of my solution >> to the original problem: > > Looks good to me. A few comments about the doc strings: Eli, I fixed the doc strings following your suggestions and added the function `window-char-height' analogous to `window-char-width' (see code below). If there are no objections, I'll go ahead and submit a patch (after reading the relevant guidelines). Thanks for your input. I learned a lot about fonts and faces in Emacs. Titus (defun default-font-width () "Return the width in pixels of the current buffer's default face font. If the default font is remapped (see `face-remapping-alist'), the function returns the width of the remapped face." (let* ((info (font-info (face-font 'default))) (width (aref info 11))) (if (> width 0) width (aref info 10)))) (defun window-char-width (&optional window face) "Return average character width for the font of FACE used in WINDOW. WINDOW must be a live window and defaults to the selected one. If FACE is nil or omitted, the default face is used. If FACE is remapped (see `face-remapping-alist'), the function returns the information for the remapped face." (with-selected-window (window-normalize-window window t) (let* ((face (if face face 'default)) (info (font-info (face-font face))) (width (aref info 11))) (if (> width 0) width (aref info 10))))) (defun window-char-height (&optional window face) "Return character height for the font of FACE used in WINDOW. WINDOW must be a live window and defaults to the selected one. If FACE is nil or omitted, the default face is used. If FACE is remapped (see `face-remapping-alist'), the function returns the information for the remapped face." (with-selected-window (window-normalize-window window t) (let* ((face (if face face 'default)) (info (font-info (face-font face)))) (aref info 3)))) (defun window-max-characters-per-line (&optional window face) "Return the number of characters that can be displayed on one line in WIN= DOW. WINDOW must be a live window and defaults to the selected one. The character width of FACE is used for the calculation. If FACE is nil or omitted, the default face is used. If FACE is remapped (see `face-remapping-alist'), the function uses the remapped face. This function is different from `window-body-width' in two ways. First, it accounts for the portions of the line reserved for the continuation glyph. Second, it accounts for the size of the font, which may have been adjusted, e.g., using `text-scale-increase')." (with-selected-window (window-normalize-window window t) (let* ((window-width (window-body-width window t)) (font-width (window-char-width window face)) (ncols (/ window-width font-width))) (if (and (display-graphic-p) overflow-newline-into-fringe (/=3D (frame-parameter nil 'left-fringe) 0) (/=3D (frame-parameter nil 'right-fringe) 0)) ncols (1- ncols))))) =20=20 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJUl0QEAAoJEK40WfPGE2idjvMH/13bYvhG3PU5bLKV/ovkwQ7H Rk3DrqhA3lIz56UUSJTjxIr8Pi7/T8CUJnyYLM6yHi3b8LH5Ym0zyGarBGUw5oyO wXEAXKEfB88w7dyxF/jqHdUlh82FyTt2K0w+WqenN5iDSKZEUuupigJTaJ6/6XO7 fPh5YG0oxdFj+SRUmAV851dyyt9CDrLUYxlgCJmKzv99evXnh9kWU5LL8M54fhK4 07bdwa4cxeQQ7QCGSFmXJ6rkkN/lQGdru+LnVyevk0fIBnAI0mxvn0VdHqlUydH4 DhK/ndEWYu1Ah3dbQa2s6oyVk+0e3rXwrhanQr0sXh2CAOtiYzEz1rG1nYo8xd8= =tfZ3 -----END PGP SIGNATURE----- --=-=-=--