From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#17303: On tty or -nw, (window-body-width) is one column too big. Date: Sun, 20 Apr 2014 20:39:04 +0000 Message-ID: <20140420203904.GA3580@acm.acm> References: <20140420170343.GA4058@acm.acm> <83ha5neqv7.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1398026670 28595 80.91.229.3 (20 Apr 2014 20:44:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 20 Apr 2014 20:44:30 +0000 (UTC) Cc: 17303@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Apr 20 22:44:18 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 1Wbyb4-0000mC-7m for geb-bug-gnu-emacs@m.gmane.org; Sun, 20 Apr 2014 22:44:18 +0200 Original-Received: from localhost ([::1]:46606 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wbyb3-0003FS-P5 for geb-bug-gnu-emacs@m.gmane.org; Sun, 20 Apr 2014 16:44:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49310) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wbyav-0003FG-Q2 for bug-gnu-emacs@gnu.org; Sun, 20 Apr 2014 16:44:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wbyap-0004FU-2l for bug-gnu-emacs@gnu.org; Sun, 20 Apr 2014 16:44:09 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:45412) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wbyao-0004FQ-Vj for bug-gnu-emacs@gnu.org; Sun, 20 Apr 2014 16:44:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Wbyao-0000vs-5A for bug-gnu-emacs@gnu.org; Sun, 20 Apr 2014 16:44:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 20 Apr 2014 20:44: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.13980265883479 (code B ref 17303); Sun, 20 Apr 2014 20:44:02 +0000 Original-Received: (at 17303) by debbugs.gnu.org; 20 Apr 2014 20:43:08 +0000 Original-Received: from localhost ([127.0.0.1]:53569 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WbyZv-0000u2-8I for submit@debbugs.gnu.org; Sun, 20 Apr 2014 16:43:07 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:63092 helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WbyZq-0000tY-GX for 17303@debbugs.gnu.org; Sun, 20 Apr 2014 16:43:03 -0400 Original-Received: (qmail 98964 invoked by uid 3782); 20 Apr 2014 20:43:01 -0000 Original-Received: from acm.muc.de (pD951961C.dip0.t-ipconnect.de [217.81.150.28]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 20 Apr 2014 22:42:59 +0200 Original-Received: (qmail 3656 invoked by uid 1000); 20 Apr 2014 20:39:04 -0000 Content-Disposition: inline In-Reply-To: <83ha5neqv7.fsf@gnu.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de 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:88173 Archived-At: Hi, Eli. On Sun, Apr 20, 2014 at 10:35:24PM +0300, Eli Zaretskii wrote: > > Date: Sun, 20 Apr 2014 17:03:43 +0000 > > From: Alan Mackenzie > > I'm doing something at the moment involving scrolling of windows, and I > > need to know at what "visual" column point is in. So, naturally, I do > > (% (current-column) (window-body-width)) > > . At the start of the first continuation line, this formula (correctly) > > returns 0 on a GUI, but (e.g.) 79 on a tty or in emacs -nw. > You mean, it says 80 in a GUI session, not 0, right? Er, no. It says 0 in a GUI session. In the GUI, (window-body-width) is the number of characters which fit on the line. In a tty, (window-body-width) is ONE MORE than that number. > > This is caused by emacs counting the "\" character in the right margin as > > part of the body-width. > 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. > > This seems like a bad idea. I think it's also a bug. > What would you like Emacs to do instead, given what I just explained? See above. > > So, is there a better method of determining the "visual" column point is > > in? > 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). 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. :-( It is (Determine-the-visual-column-..) which gives me trouble. On a GUI, I can use (% (current-column) (window-body-width)) , but this fails on a tty, as noted above. -- Alan Mackenzie (Nuremberg, Germany).