From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thomas Fitzsimmons Newsgroups: gmane.emacs.bugs Subject: bug#7426: 23.2; term.el: After running stty -opost, printing \n\r inserts trailing spaces Date: Sat, 20 Nov 2010 18:58:12 -0500 Message-ID: References: <87eiahp99z.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1290298480 29333 80.91.229.12 (21 Nov 2010 00:14:40 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 21 Nov 2010 00:14:40 +0000 (UTC) Cc: 7426@debbugs.gnu.org To: Chong Yidong Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Nov 21 01:14:35 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PJxZi-00084L-C3 for geb-bug-gnu-emacs@m.gmane.org; Sun, 21 Nov 2010 01:14:34 +0100 Original-Received: from localhost ([127.0.0.1]:35631 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PJxZh-00019s-52 for geb-bug-gnu-emacs@m.gmane.org; Sat, 20 Nov 2010 19:14:33 -0500 Original-Received: from [140.186.70.92] (port=53481 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PJxZc-00019d-Ku for bug-gnu-emacs@gnu.org; Sat, 20 Nov 2010 19:14:29 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PJxZa-0002eT-U5 for bug-gnu-emacs@gnu.org; Sat, 20 Nov 2010 19:14:28 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:34042) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PJxZa-0002eP-Px for bug-gnu-emacs@gnu.org; Sat, 20 Nov 2010 19:14:26 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1PJxEr-0007CF-MH; Sat, 20 Nov 2010 18:53:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Thomas Fitzsimmons Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 20 Nov 2010 23:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7426 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 7426-submit@debbugs.gnu.org id=B7426.129029712727657 (code B ref 7426); Sat, 20 Nov 2010 23:53:01 +0000 Original-Received: (at 7426) by debbugs.gnu.org; 20 Nov 2010 23:52:07 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PJxDz-0007C2-0y for submit@debbugs.gnu.org; Sat, 20 Nov 2010 18:52:07 -0500 Original-Received: from mail-iw0-f172.google.com ([209.85.214.172]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PJxDy-0007Bf-6U for 7426@debbugs.gnu.org; Sat, 20 Nov 2010 18:52:06 -0500 Original-Received: by iwn40 with SMTP id 40so6637950iwn.3 for <7426@debbugs.gnu.org>; Sat, 20 Nov 2010 15:57:16 -0800 (PST) Original-Received: by 10.231.13.136 with SMTP id c8mr4438219iba.19.1290297436110; Sat, 20 Nov 2010 15:57:16 -0800 (PST) Original-Received: from autumn (bas3-toronto06-2925098028.dsl.bell.ca [174.89.116.44]) by mx.google.com with ESMTPS id d21sm3371750ibg.21.2010.11.20.15.57.13 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 20 Nov 2010 15:57:14 -0800 (PST) In-Reply-To: <87eiahp99z.fsf@stupidchicken.com> (Chong Yidong's message of "Fri, 19 Nov 2010 11:28:56 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sat, 20 Nov 2010 18:53:01 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:41775 Archived-At: Chong Yidong writes: > Thomas Fitzsimmons writes: > >> term-vertical-motion expands to vertical-motion and it's that call that >> results in the spaces being inserted in the buffer. >> >> I worked around the issue by removing, after-the-fact, spaces inserted >> by the (vertical-motion 0) call. A more efficient solution would be to >> prevent vertical-motion from inserting the spaces in the first place, >> but that happens deep within Emacs somewhere. I'm hoping a terminal >> expert can suggest where to look. > > That's strange. vertical-motion should not affect the buffer contents; > it only moves point. I did some more tracing and it's not vertical-motion. Here's a simplified test case: /* M-x term (Run program: /bin/bash) RET C-c M-x eval-expression (setq show-trailing-whitespace t) $ gcc -o term-trailing-spaces term-trailing-spaces.c $ stty -opost $ ./term-trailing-spaces (trailing spaces shown in red) $ stty opost $ ./term-trailing-spaces (no trailing spaces) */ #include int main (int argc, char* argv[]) { printf ("\n"); return 0; } With stty -opost, the new test case produces (dots represent spaces): $ ./term-trailing-spaces ........................ ........................$. That matches gnome-terminal's visual output for the same test. I can't tell if it uses spaces to produce that output. I can eliminate the trailing spaces with this change: Index: term.el =================================================================== RCS file: /sources/emacs/emacs/lisp/term.el,v retrieving revision 1.115 diff -u -r1.115 term.el --- term.el 13 Mar 2009 01:43:03 -0000 1.115 +++ term.el 20 Nov 2010 23:28:57 -0000 @@ -2619,7 +2619,7 @@ (save-excursion (end-of-line) (setq point-at-eol (point))) - (move-to-column term-current-column t) + (move-to-column term-current-column) ;; If move-to-column extends the current line it will use the face ;; from the last character on the line, set the face for the chars ;; to default. But then the output is: $ ./term-trailing-spaces $. which doesn't match gnome-terminal visually, so I don't think that's a correct solution. When the terminal is in char mode the trailing spaces don't affect input. When the terminal is in line mode, input problems happen as a result of the trailing spaces. I think the reason it's a problem is explained in the term-pending-delete-marker comment: (defvar term-pending-delete-marker) ;; New user input in line mode needs to ;; be deleted, because it gets echoed by the inferior. ;; To reduce flicker, we defer the delete until the next output. Maybe the correct solution is whenever (move-to-column ... t) is called in line mode, term-pending-delete-marker needs to be used to delete the extra spaces.