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: Mon, 21 Apr 2014 15:43:35 +0000 Message-ID: <20140421154335.GB4266@acm.acm> References: <20140420170343.GA4058@acm.acm> <83ha5neqv7.fsf@gnu.org> <20140420203904.GA3580@acm.acm> <83a9bfdvcu.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 1398095306 23556 80.91.229.3 (21 Apr 2014 15:48:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 21 Apr 2014 15:48:26 +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 Mon Apr 21 17:48: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 1WcGS8-0003KK-Pr for geb-bug-gnu-emacs@m.gmane.org; Mon, 21 Apr 2014 17:48:17 +0200 Original-Received: from localhost ([::1]:49952 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcGS8-0000oM-Eh for geb-bug-gnu-emacs@m.gmane.org; Mon, 21 Apr 2014 11:48:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45251) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcGRz-0000nR-Rb for bug-gnu-emacs@gnu.org; Mon, 21 Apr 2014 11:48:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WcGRu-0006Vr-Oz for bug-gnu-emacs@gnu.org; Mon, 21 Apr 2014 11:48:07 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:46107) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcGRu-0006Vl-LW for bug-gnu-emacs@gnu.org; Mon, 21 Apr 2014 11:48:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WcGRu-0000xb-2H for bug-gnu-emacs@gnu.org; Mon, 21 Apr 2014 11:48: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: Mon, 21 Apr 2014 15:48:01 +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.13980952553632 (code B ref 17303); Mon, 21 Apr 2014 15:48:01 +0000 Original-Received: (at 17303) by debbugs.gnu.org; 21 Apr 2014 15:47:35 +0000 Original-Received: from localhost ([127.0.0.1]:54264 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WcGRR-0000wV-UE for submit@debbugs.gnu.org; Mon, 21 Apr 2014 11:47:34 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:36888 helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WcGRO-0000wJ-Oz for 17303@debbugs.gnu.org; Mon, 21 Apr 2014 11:47:31 -0400 Original-Received: (qmail 78125 invoked by uid 3782); 21 Apr 2014 15:47:30 -0000 Original-Received: from acm.muc.de (pD9519BAA.dip0.t-ipconnect.de [217.81.155.170]) by colin.muc.de (tmda-ofmipd) with ESMTP; Mon, 21 Apr 2014 17:47:29 +0200 Original-Received: (qmail 5199 invoked by uid 1000); 21 Apr 2014 15:43:35 -0000 Content-Disposition: inline In-Reply-To: <83a9bfdvcu.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:88187 Archived-At: Hi, Eli. On Mon, Apr 21, 2014 at 09:56:01AM +0300, Eli Zaretskii wrote: > > Date: Sun, 20 Apr 2014 20:39:04 +0000 > > Cc: 17303@debbugs.gnu.org > > From: Alan Mackenzie > > > 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. OK. > > > 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. posn-at-point only works when point is inside a window. What I ended up using is (- (current-column) (progn (vertical-motion 0) (current-column))) (with a save-excursion at a strategic surrounding point). > > 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. pos-visible-in-window-p unfortunately doesn't reveal whether pos is above or below the window, it just returns nil. > There's also the new pre-redisplay-function hook that you might find > useful. OK, I'll look at this sometime. > 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. follow-mode is about nothing else but outsmarting redisplay. ;-) As its original author recently discussed with you, it would be nice if there were more support for it inside redisplay, but that means Somebody (tm) stepping up to the plate and implementing it. > So can we close this bug report? I've just closed it. Thanks for all the help! -- Alan Mackenzie (Nuremberg, Germany).