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#17303: On tty or -nw, (window-body-width) is one column too big. Date: Mon, 21 Apr 2014 09:56:01 +0300 Message-ID: <83a9bfdvcu.fsf@gnu.org> References: <20140420170343.GA4058@acm.acm> <83ha5neqv7.fsf@gnu.org> <20140420203904.GA3580@acm.acm> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1398063446 4132 80.91.229.3 (21 Apr 2014 06:57:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 21 Apr 2014 06:57:26 +0000 (UTC) Cc: 17303@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Apr 21 08:57:19 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 1Wc8AG-0005DO-MC for geb-bug-gnu-emacs@m.gmane.org; Mon, 21 Apr 2014 08:57:16 +0200 Original-Received: from localhost ([::1]:47783 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wc8AG-0002fR-8P for geb-bug-gnu-emacs@m.gmane.org; Mon, 21 Apr 2014 02:57:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38630) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wc8A8-0002fK-GT for bug-gnu-emacs@gnu.org; Mon, 21 Apr 2014 02:57:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wc8A3-0001kZ-Do for bug-gnu-emacs@gnu.org; Mon, 21 Apr 2014 02:57:08 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:45559) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wc8A3-0001kV-A3 for bug-gnu-emacs@gnu.org; Mon, 21 Apr 2014 02:57:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Wc8A2-0004XR-Ag for bug-gnu-emacs@gnu.org; Mon, 21 Apr 2014 02:57:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 21 Apr 2014 06:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 17303 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 17303-submit@debbugs.gnu.org id=B17303.139806338017357 (code B ref 17303); Mon, 21 Apr 2014 06:57:02 +0000 Original-Received: (at 17303) by debbugs.gnu.org; 21 Apr 2014 06:56:20 +0000 Original-Received: from localhost ([127.0.0.1]:53716 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wc89L-0004Vq-8C for submit@debbugs.gnu.org; Mon, 21 Apr 2014 02:56:19 -0400 Original-Received: from mtaout20.012.net.il ([80.179.55.166]:48461) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wc89F-0004VX-D0 for 17303@debbugs.gnu.org; Mon, 21 Apr 2014 02:56:15 -0400 Original-Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0N4D00200CEBQN00@a-mtaout20.012.net.il> for 17303@debbugs.gnu.org; Mon, 21 Apr 2014 09:56:11 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0N4D002PRCLNA860@a-mtaout20.012.net.il>; Mon, 21 Apr 2014 09:56:11 +0300 (IDT) In-reply-to: <20140420203904.GA3580@acm.acm> 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:88179 Archived-At: > Date: Sun, 20 Apr 2014 20:39:04 +0000 > Cc: 17303@debbugs.gnu.org > From: Alan Mackenzie > > > No, it's because the last character in the continued like is in column > > 78 on a TTY, but in column 79 in a GUI session. Emacs counts columns > > in continuation lines starting from the last column in the previous > > line, as you'd expect. IOW, the continued line is treated as one long > > line, and all its columns counted contiguously. > > Yes, this is true, but it's (window-body-width) which is inconsistent > between GUI and tty. > > > It is true that the "\" character on a TTY takes up one column, and > > thus leaves only 79 columns for text, but what else can Emacs do? > > Tell me that (window-body-width) is 79, not 80. It can't. It's not designed for what you need. You should use different APIs for what you want; see below. > > current-column is it. Please tell why it doesn't fit your needs. > > current-column provides the "logical" column (e.g. 79). I need the > "visual" column (e.g. 0). Then what you want is '(car (posn-col-row (posn-at-point)))'. But see below. > I'm working on getting follow-mode's scrolling working properly. I have > a situation where: > o - point is at Col 79, this being at the start of a continuation line. > o - this position is one line below the bottom of the window > o - (but hasn't been redisplayed yet). > o - set-window-start has NOT been called with a nil NOFORCE parameter. > > If I were to allow the redisplay without further action, redisplay would > scroll the window back upwards to ensure point is displayed. This would > negate the purpose of the scrolling. I want to move point back into the > window before the redisplay. So I attempt the following: > o - (setq dest-col (Determine-the-visual-column-point-is-in)) > o - (vertical-motion -1) > o - (move-to-column dest-col) > > However this last action becomes, on a tty, (move-to-column 79) putting > point back where it started. :-( I think you just need to use pos-visible-in-window-p instead of all that complexity: if that function returns an indication that point is not visible, move it back until it is. There's also the new pre-redisplay-function hook that you might find useful. Don't try to outsmart redisplay; instead, ask redisplay to tell you what it already knows. The functions I mentioned are interfaces exposed by redisplay for this very purpose. So can we close this bug report?