From unknown Sat Aug 16 19:17:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7426: 23.2; term.el: After running stty -opost, printing \n\r inserts trailing spaces 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: Wed, 17 Nov 2010 20:00:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 7426 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 7426@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.129002394817302 (code B ref -1); Wed, 17 Nov 2010 20:00:03 +0000 Received: (at submit) by debbugs.gnu.org; 17 Nov 2010 19:59:08 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PIo9s-0004V1-8O for submit@debbugs.gnu.org; Wed, 17 Nov 2010 14:59:08 -0500 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PIo9q-0004Uf-DK for submit@debbugs.gnu.org; Wed, 17 Nov 2010 14:59:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PIoEc-0007yC-Cd for submit@debbugs.gnu.org; Wed, 17 Nov 2010 15:04:09 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:43462) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PIoEc-0007y1-8q for submit@debbugs.gnu.org; Wed, 17 Nov 2010 15:04:02 -0500 Received: from [140.186.70.92] (port=39618 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PIoET-0006pQ-U9 for bug-gnu-emacs@gnu.org; Wed, 17 Nov 2010 15:04:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PIoAQ-0005kK-KB for bug-gnu-emacs@gnu.org; Wed, 17 Nov 2010 15:00:50 -0500 Received: from mail-gx0-f169.google.com ([209.85.161.169]:36511) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PIoAQ-0005iH-7O for bug-gnu-emacs@gnu.org; Wed, 17 Nov 2010 14:59:42 -0500 Received: by gxk7 with SMTP id 7so1663971gxk.0 for ; Wed, 17 Nov 2010 11:59:40 -0800 (PST) Received: by 10.150.186.1 with SMTP id j1mr11447099ybf.147.1290023980642; Wed, 17 Nov 2010 11:59:40 -0800 (PST) Received: from autumn (bas3-toronto06-2925098028.dsl.bell.ca [174.89.116.44]) by mx.google.com with ESMTPS id 66sm604957yhl.2.2010.11.17.11.59.37 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 17 Nov 2010 11:59:38 -0800 (PST) From: Thomas Fitzsimmons Date: Wed, 17 Nov 2010 15:00:57 -0500 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Spam-Score: -6.6 (------) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.6 (------) This bug report will be sent to the Free Software Foundation, not to your local site managers! Please write in English if possible, because the Emacs maintainers usually do not have translators to read other languages for them. Your bug report will be posted to the bug-gnu-emacs@gnu.org mailing list, and to the gnu.emacs.bug news group. Please describe exactly what actions triggered the bug and the precise symptoms of the bug. If you can, give a recipe starting from `emacs -Q': $ emacs -Q Create term-trailing-spaces.c: #include int main (int argc, char* argv[]) { int i = 0; while (i < 10) { printf ("aaaaaaaaaaaaaaaaaaaaaaa\n\rbbbbbbbbbbbb\n\r"); i++; } return 0; } 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 are shown in red. $ stty opost $ ./term-trailing-spaces No trailing spaces are shown. I'm using serial-term to connect to an embedded Linux board's serial console. During Linux boot the terminal doesn't post-process output (equivalent to stty -opost) so long-line/shorter-line combinations like in the test case result in spaces being appended to the end of the buffer. This is OK in char mode but in line mode the spaces stack up at the end of the buffer and interfere with terminal I/O. If I accidentally leave term-mode in line mode during boot I have to kill the buffer and restart serial-term. I traced through term-emulate-terminal to: ((eq char ?\r) ;; (terminfo: cr) (term-vertical-motion 0) (setq term-current-column term-start-line-column)) 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. If Emacs crashed, and you have the Emacs process in the gdb debugger, please include the output from the following gdb commands: `bt full' and `xbacktrace'. For information about debugging Emacs, please read the file /usr/share/emacs/23.2/etc/DEBUG. In GNU Emacs 23.2.1 (i386-redhat-linux-gnu, GTK+ Version 2.20.1) of 2010-06-03 on x86-07.phx2.fedoraproject.org Windowing system distributor `Fedora Project', version 11.0.10800000 configured using `configure '--build=i386-redhat-linux-gnu' '--host=i386-redhat-linux-gnu' '--program-prefix=' '--disable-dependency-tracking' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/var/lib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--with-dbus' '--with-gif' '--with-jpeg' '--with-png' '--with-rsvg' '--with-tiff' '--with-xft' '--with-xpm' '--with-x-toolkit=gtk' 'build_alias=i386-redhat-linux-gnu' 'host_alias=i386-redhat-linux-gnu' 'CFLAGS=-DMAIL_USE_LOCKF -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables'' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: en_US.utf8 value of $XMODIFIERS: @im=none locale-coding-system: utf-8-unix default enable-multibyte-characters: t Major mode: Term Minor modes in effect: tooltip-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Recent input: o C-g M-x t e r m C-c M-x C-g C-x o C-x C-c C-g C-g C-x k C-g C-c M-x M-p C-k s w i t k i l l - b u y e s C-g C-g M-x t e r m C-c M-x e v a l - e x p ( s e t q SPC s h o w - t r a i l i n g - s h i w w h i t e s p a c e SPC t ) g c c SPC - o SPC t e r m - t r a i l i n g - s p a c e s SPC t e r m - t r a i l i n g - s p a C-a C-k c d SPC s o u t e r m g c c SPC - o SPC t e r m - t r a i l i SPC t e r m - t r a i l i . c s t t y SPC - o p o s t . / t e r m - t r a i l i s t t y SPC o p o s t . / t e r m - t r a i l i n g - s p a . / t e r m - t r a i l i C-c M-x r e p o r t - e m Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Quit [5 times] t Load-path shadows: /usr/share/emacs/site-lisp/flim/md4 hides /usr/share/emacs/23.2/lisp/md4 /usr/share/emacs/site-lisp/flim/sha1 hides /usr/share/emacs/23.2/lisp/sha1 /usr/share/emacs/site-lisp/flim/hex-util hides /usr/share/emacs/23.2/lisp/hex-util /usr/share/emacs/site-lisp/flim/ntlm hides /usr/share/emacs/23.2/lisp/net/ntlm /usr/share/emacs/site-lisp/flim/sasl-ntlm hides /usr/share/emacs/23.2/lisp/net/sasl-ntlm /usr/share/emacs/site-lisp/flim/hmac-def hides /usr/share/emacs/23.2/lisp/net/hmac-def /usr/share/emacs/site-lisp/flim/hmac-md5 hides /usr/share/emacs/23.2/lisp/net/hmac-md5 /usr/share/emacs/site-lisp/flim/sasl-digest hides /usr/share/emacs/23.2/lisp/net/sasl-digest /usr/share/emacs/site-lisp/flim/sasl-cram hides /usr/share/emacs/23.2/lisp/net/sasl-cram /usr/share/emacs/site-lisp/flim/sasl hides /usr/share/emacs/23.2/lisp/net/sasl Features: (shadow sort mail-extr message idna sendmail regexp-opt ecomplete rfc822 mml easymenu mml-sec password-cache mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231 rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util netrc time-date mm-util mail-prsvr gmm-utils wid-edit mailheader canlock sha1 sha1-el hex-util hashcash mail-utils emacsbug term disp-table ehelp electric ring tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd font-setting tool-bar dnd fontset image fringe lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar mldrag mouse jit-lock font-lock syntax facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev loaddefs button minibuffer faces cus-face files text-properties overlay md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process dbusbind system-font-setting font-render-setting gtk x-toolkit x multi-tty emacs) From unknown Sat Aug 16 19:17:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7426: 23.2; term.el: After running stty -opost, printing \n\r inserts trailing spaces Resent-From: Chong Yidong Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 19 Nov 2010 16:24: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: To: Thomas Fitzsimmons Cc: 7426@debbugs.gnu.org Received: via spool by 7426-submit@debbugs.gnu.org id=B7426.129018383032116 (code B ref 7426); Fri, 19 Nov 2010 16:24:01 +0000 Received: (at 7426) by debbugs.gnu.org; 19 Nov 2010 16:23:50 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PJTkb-0008Lx-9k for submit@debbugs.gnu.org; Fri, 19 Nov 2010 11:23:49 -0500 Received: from pantheon-po42.its.yale.edu ([130.132.50.101]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PJTka-0008Ls-CC for 7426@debbugs.gnu.org; Fri, 19 Nov 2010 11:23:48 -0500 Received: from furball (dhcp128036014113.central.yale.edu [128.36.14.113]) (authenticated bits=0) by pantheon-po42.its.yale.edu (8.12.11.20060308/8.12.11) with ESMTP id oAJGStJb022758 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 19 Nov 2010 11:28:55 -0500 Received: by furball (Postfix, from userid 1000) id 397CD160854; Fri, 19 Nov 2010 11:28:56 -0500 (EST) From: Chong Yidong References: Date: Fri, 19 Nov 2010 11:28:56 -0500 In-Reply-To: (Thomas Fitzsimmons's message of "Wed, 17 Nov 2010 15:00:57 -0500") Message-ID: <87eiahp99z.fsf@stupidchicken.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-YaleITSMailFilter: Version 1.2c (attachment(s) not renamed) X-Spam-Score: -2.7 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.7 (--) 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. From unknown Sat Aug 16 19:17:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7426: 23.2; term.el: After running stty -opost, printing \n\r inserts trailing spaces 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: Fri, 19 Nov 2010 19:16: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: To: Chong Yidong Cc: 7426@debbugs.gnu.org Received: via spool by 7426-submit@debbugs.gnu.org id=B7426.12901941519992 (code B ref 7426); Fri, 19 Nov 2010 19:16:01 +0000 Received: (at 7426) by debbugs.gnu.org; 19 Nov 2010 19:15:51 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PJWR4-0002b7-TC for submit@debbugs.gnu.org; Fri, 19 Nov 2010 14:15:51 -0500 Received: from mail-qy0-f172.google.com ([209.85.216.172]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PJWR1-0002av-Pq for 7426@debbugs.gnu.org; Fri, 19 Nov 2010 14:15:48 -0500 Received: by qyk7 with SMTP id 7so5163qyk.3 for <7426@debbugs.gnu.org>; Fri, 19 Nov 2010 11:20:55 -0800 (PST) Received: by 10.224.45.130 with SMTP id e2mr1233115qaf.22.1290194455330; Fri, 19 Nov 2010 11:20:55 -0800 (PST) Received: from autumn (bas3-toronto06-2925098028.dsl.bell.ca [174.89.116.44]) by mx.google.com with ESMTPS id l14sm1168123qck.17.2010.11.19.11.20.53 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 19 Nov 2010 11:20:53 -0800 (PST) From: Thomas Fitzsimmons In-Reply-To: <87eiahp99z.fsf@stupidchicken.com> (Chong Yidong's message of "Fri, 19 Nov 2010 11:28:56 -0500") References: <87eiahp99z.fsf@stupidchicken.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) Date: Fri, 19 Nov 2010 14:22:20 -0500 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -4.6 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.9 (---) 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. Yeah, it is strange. Were you able to replicate on your setup the behavior I described? From unknown Sat Aug 16 19:17:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7426: 23.2; term.el: After running stty -opost, printing \n\r inserts trailing spaces 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: To: Chong Yidong Cc: 7426@debbugs.gnu.org Received: via spool by 7426-submit@debbugs.gnu.org id=B7426.129029712727657 (code B ref 7426); Sat, 20 Nov 2010 23:53:01 +0000 Received: (at 7426) by debbugs.gnu.org; 20 Nov 2010 23:52:07 +0000 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 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 Received: by iwn40 with SMTP id 40so6637950iwn.3 for <7426@debbugs.gnu.org>; Sat, 20 Nov 2010 15:57:16 -0800 (PST) Received: by 10.231.13.136 with SMTP id c8mr4438219iba.19.1290297436110; Sat, 20 Nov 2010 15:57:16 -0800 (PST) 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) From: Thomas Fitzsimmons References: <87eiahp99z.fsf@stupidchicken.com> Date: Sat, 20 Nov 2010 18:58:12 -0500 In-Reply-To: <87eiahp99z.fsf@stupidchicken.com> (Chong Yidong's message of "Fri, 19 Nov 2010 11:28:56 -0500") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -3.6 (---) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.4 (---) 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. From unknown Sat Aug 16 19:17:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7426: 23.2; term.el: After running stty -opost, printing \n\r inserts trailing spaces Resent-From: Thomas Fitzsimmons Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 24 Mar 2013 03:59:02 +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: To: Chong Yidong Cc: 7426@debbugs.gnu.org Received: via spool by 7426-submit@debbugs.gnu.org id=B7426.136409748531929 (code B ref 7426); Sun, 24 Mar 2013 03:59:02 +0000 Received: (at 7426) by debbugs.gnu.org; 24 Mar 2013 03:58:05 +0000 Received: from localhost ([127.0.0.1]:42767 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UJc4K-0008It-Co for submit@debbugs.gnu.org; Sat, 23 Mar 2013 23:58:04 -0400 Received: from mail-ie0-f176.google.com ([209.85.223.176]:63048) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UJRU3-0007uk-9H for 7426@debbugs.gnu.org; Sat, 23 Mar 2013 12:39:59 -0400 Received: by mail-ie0-f176.google.com with SMTP id x14so5966322ief.35 for <7426@debbugs.gnu.org>; Sat, 23 Mar 2013 09:37:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=BF7GNDu631tg3/PUp5rpLCW3UMEnamqhLoVggs3BiCE=; b=LG5LlqkYZzeJVKM77KyiunBiaPWoA8SqDT6NWaYQycHPZxHTI3DvNsZXKJk+6uPIw1 5/VoA7Ti/CQOfAxOLcCbUCgTn87bkWnU4IN7+x9NJ1vxJR1W+oR54Q6t42/auRkVCsZi fNbYTUoGfETTGN8Yk/DpQYscbK83cgb7RoBCSvQqIunnJpoBtUqLxgkMM1PNaPbxI/07 Cg0zfJLdiGnSmxzVIlHf9Fp4HuSF2Sn0OvAo5i4uehfOwKSg/Jko1agbDb4TWBUaecXp Ghl2v8g7RItt1FeuX3iyf3lFpRcawoXr0SL1XXowYtjM8Xx5V2H43GmxYjvVKIshHv5H araw== X-Received: by 10.50.149.233 with SMTP id ud9mr3957646igb.92.1364056671509; Sat, 23 Mar 2013 09:37:51 -0700 (PDT) Received: from ducky.fitzsim.org (69-165-165-189.dsl.teksavvy.com. [69.165.165.189]) by mx.google.com with ESMTPS id px9sm15449440igc.0.2013.03.23.09.37.50 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 23 Mar 2013 09:37:50 -0700 (PDT) From: Thomas Fitzsimmons References: <87eiahp99z.fsf@stupidchicken.com> Date: Sat, 23 Mar 2013 12:37:48 -0400 In-Reply-To: <87eiahp99z.fsf@stupidchicken.com> (Chong Yidong's message of "Fri, 19 Nov 2010 11:28:56 -0500") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.1 (/) X-Mailman-Approved-At: Sat, 23 Mar 2013 23:58:03 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) This issue affected me when I was working with the RedBoot bootloader. The boards I'm currently working on instead use the U-Boot bootloader. I re-tested booting a U-Boot board under serial-term in line mode, and I didn't see the terminal-trashing trailing spaces. So I think this was a bad interaction between RedBoot's terminal handling and term.el. It's pretty obscure, and it's not affecting my day-to-day work anymore, so I would be fine with this bug being closed as wontfix. From unknown Sat Aug 16 19:17:03 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.503 (Entity 5.503) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Thomas Fitzsimmons Subject: bug#7426: closed (Re: bug#7426: 23.2; term.el: After running stty -opost, printing \n\r inserts trailing spaces) Message-ID: References: X-Gnu-PR-Message: they-closed 7426 X-Gnu-PR-Package: emacs Reply-To: 7426@debbugs.gnu.org Date: Sun, 13 Sep 2015 00:27:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1442104022-3425-1" This is a multi-part message in MIME format... ------------=_1442104022-3425-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #7426: 23.2; term.el: After running stty -opost, printing \n\r inserts trai= ling spaces which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 7426@debbugs.gnu.org. --=20 7426: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D7426 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1442104022-3425-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 7426-done) by debbugs.gnu.org; 13 Sep 2015 00:26:16 +0000 Received: from localhost ([127.0.0.1]:58590 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zav7Y-0000sE-CX for submit@debbugs.gnu.org; Sat, 12 Sep 2015 20:26:16 -0400 Received: from mail-ig0-f179.google.com ([209.85.213.179]:33668) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zav7W-0000s4-0H for 7426-done@debbugs.gnu.org; Sat, 12 Sep 2015 20:26:14 -0400 Received: by igbkq10 with SMTP id kq10so68485200igb.0 for <7426-done@debbugs.gnu.org>; Sat, 12 Sep 2015 17:26:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=FgwKg5+W7igirky9akjMm5EYVMPsFOc4NNvIQL4f+7Y=; b=Jd9z0JYKQl5JZN9g9rlz6G9lKJYp5J815it0gm8kIt+Is5zPQtNh6fM37vOuYAL5Ux BMvE4HipLxC1utxJEtMDIBe8f/c0qsHjMb9M6XY6iVeNdvFHDQsVhcfgAx0+9ui3zZza Qg8obNY8NH35k9zXDyaW/G2BdiN/5MbV4htaXCUmZAUwITBe+vbpqA25IQozZwrXITsY nsLMgoct6dR34Im+ovJt4/IudugBZcx5980Uw69hchHBetj7/QmP2OjSnj0y2rG3hXmo 4XNHU3k4ehDQIXU9hqHwzAAT4K42jnfarXEvc/6NkgL6aqyLd07t382+jBbjJbYn8p15 Le8g== X-Gm-Message-State: ALoCoQniIVkIuXNacwbUXWGmzIvZMVJ3CCgyy4TAQ64zeVXpXTgEhfO0JEVDliJmYODY09AO7/BC X-Received: by 10.50.2.68 with SMTP id 4mr7200318igs.7.1442103973328; Sat, 12 Sep 2015 17:26:13 -0700 (PDT) Received: from hp-dv5t (69-165-165-189.dsl.teksavvy.com. [69.165.165.189]) by smtp.gmail.com with ESMTPSA id x1sm2738250igl.14.2015.09.12.17.26.12 for <7426-done@debbugs.gnu.org> (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 12 Sep 2015 17:26:12 -0700 (PDT) From: Thomas Fitzsimmons To: 7426-done@debbugs.gnu.org Subject: Re: bug#7426: 23.2; term.el: After running stty -opost, printing \n\r inserts trailing spaces References: <87eiahp99z.fsf@stupidchicken.com> Date: Sat, 12 Sep 2015 20:26:12 -0400 In-Reply-To: (Thomas Fitzsimmons's message of "Sat, 23 Mar 2013 12:37:48 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 7426-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) tags 7426 wontfix thanks Tagging wontfix and closing. Thomas ------------=_1442104022-3425-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 17 Nov 2010 19:59:08 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PIo9s-0004V1-8O for submit@debbugs.gnu.org; Wed, 17 Nov 2010 14:59:08 -0500 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PIo9q-0004Uf-DK for submit@debbugs.gnu.org; Wed, 17 Nov 2010 14:59:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PIoEc-0007yC-Cd for submit@debbugs.gnu.org; Wed, 17 Nov 2010 15:04:09 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:43462) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PIoEc-0007y1-8q for submit@debbugs.gnu.org; Wed, 17 Nov 2010 15:04:02 -0500 Received: from [140.186.70.92] (port=39618 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PIoET-0006pQ-U9 for bug-gnu-emacs@gnu.org; Wed, 17 Nov 2010 15:04:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PIoAQ-0005kK-KB for bug-gnu-emacs@gnu.org; Wed, 17 Nov 2010 15:00:50 -0500 Received: from mail-gx0-f169.google.com ([209.85.161.169]:36511) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PIoAQ-0005iH-7O for bug-gnu-emacs@gnu.org; Wed, 17 Nov 2010 14:59:42 -0500 Received: by gxk7 with SMTP id 7so1663971gxk.0 for ; Wed, 17 Nov 2010 11:59:40 -0800 (PST) Received: by 10.150.186.1 with SMTP id j1mr11447099ybf.147.1290023980642; Wed, 17 Nov 2010 11:59:40 -0800 (PST) Received: from autumn (bas3-toronto06-2925098028.dsl.bell.ca [174.89.116.44]) by mx.google.com with ESMTPS id 66sm604957yhl.2.2010.11.17.11.59.37 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 17 Nov 2010 11:59:38 -0800 (PST) From: Thomas Fitzsimmons To: bug-gnu-emacs@gnu.org Subject: 23.2; term.el: After running stty -opost, printing \n\r inserts trailing spaces Date: Wed, 17 Nov 2010 15:00:57 -0500 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Spam-Score: -6.6 (------) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.6 (------) This bug report will be sent to the Free Software Foundation, not to your local site managers! Please write in English if possible, because the Emacs maintainers usually do not have translators to read other languages for them. Your bug report will be posted to the bug-gnu-emacs@gnu.org mailing list, and to the gnu.emacs.bug news group. Please describe exactly what actions triggered the bug and the precise symptoms of the bug. If you can, give a recipe starting from `emacs -Q': $ emacs -Q Create term-trailing-spaces.c: #include int main (int argc, char* argv[]) { int i = 0; while (i < 10) { printf ("aaaaaaaaaaaaaaaaaaaaaaa\n\rbbbbbbbbbbbb\n\r"); i++; } return 0; } 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 are shown in red. $ stty opost $ ./term-trailing-spaces No trailing spaces are shown. I'm using serial-term to connect to an embedded Linux board's serial console. During Linux boot the terminal doesn't post-process output (equivalent to stty -opost) so long-line/shorter-line combinations like in the test case result in spaces being appended to the end of the buffer. This is OK in char mode but in line mode the spaces stack up at the end of the buffer and interfere with terminal I/O. If I accidentally leave term-mode in line mode during boot I have to kill the buffer and restart serial-term. I traced through term-emulate-terminal to: ((eq char ?\r) ;; (terminfo: cr) (term-vertical-motion 0) (setq term-current-column term-start-line-column)) 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. If Emacs crashed, and you have the Emacs process in the gdb debugger, please include the output from the following gdb commands: `bt full' and `xbacktrace'. For information about debugging Emacs, please read the file /usr/share/emacs/23.2/etc/DEBUG. In GNU Emacs 23.2.1 (i386-redhat-linux-gnu, GTK+ Version 2.20.1) of 2010-06-03 on x86-07.phx2.fedoraproject.org Windowing system distributor `Fedora Project', version 11.0.10800000 configured using `configure '--build=i386-redhat-linux-gnu' '--host=i386-redhat-linux-gnu' '--program-prefix=' '--disable-dependency-tracking' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/var/lib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--with-dbus' '--with-gif' '--with-jpeg' '--with-png' '--with-rsvg' '--with-tiff' '--with-xft' '--with-xpm' '--with-x-toolkit=gtk' 'build_alias=i386-redhat-linux-gnu' 'host_alias=i386-redhat-linux-gnu' 'CFLAGS=-DMAIL_USE_LOCKF -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables'' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: en_US.utf8 value of $XMODIFIERS: @im=none locale-coding-system: utf-8-unix default enable-multibyte-characters: t Major mode: Term Minor modes in effect: tooltip-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Recent input: o C-g M-x t e r m C-c M-x C-g C-x o C-x C-c C-g C-g C-x k C-g C-c M-x M-p C-k s w i t k i l l - b u y e s C-g C-g M-x t e r m C-c M-x e v a l - e x p ( s e t q SPC s h o w - t r a i l i n g - s h i w w h i t e s p a c e SPC t ) g c c SPC - o SPC t e r m - t r a i l i n g - s p a c e s SPC t e r m - t r a i l i n g - s p a C-a C-k c d SPC s o u t e r m g c c SPC - o SPC t e r m - t r a i l i SPC t e r m - t r a i l i . c s t t y SPC - o p o s t . / t e r m - t r a i l i s t t y SPC o p o s t . / t e r m - t r a i l i n g - s p a . / t e r m - t r a i l i C-c M-x r e p o r t - e m Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Quit [5 times] t Load-path shadows: /usr/share/emacs/site-lisp/flim/md4 hides /usr/share/emacs/23.2/lisp/md4 /usr/share/emacs/site-lisp/flim/sha1 hides /usr/share/emacs/23.2/lisp/sha1 /usr/share/emacs/site-lisp/flim/hex-util hides /usr/share/emacs/23.2/lisp/hex-util /usr/share/emacs/site-lisp/flim/ntlm hides /usr/share/emacs/23.2/lisp/net/ntlm /usr/share/emacs/site-lisp/flim/sasl-ntlm hides /usr/share/emacs/23.2/lisp/net/sasl-ntlm /usr/share/emacs/site-lisp/flim/hmac-def hides /usr/share/emacs/23.2/lisp/net/hmac-def /usr/share/emacs/site-lisp/flim/hmac-md5 hides /usr/share/emacs/23.2/lisp/net/hmac-md5 /usr/share/emacs/site-lisp/flim/sasl-digest hides /usr/share/emacs/23.2/lisp/net/sasl-digest /usr/share/emacs/site-lisp/flim/sasl-cram hides /usr/share/emacs/23.2/lisp/net/sasl-cram /usr/share/emacs/site-lisp/flim/sasl hides /usr/share/emacs/23.2/lisp/net/sasl Features: (shadow sort mail-extr message idna sendmail regexp-opt ecomplete rfc822 mml easymenu mml-sec password-cache mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231 rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util netrc time-date mm-util mail-prsvr gmm-utils wid-edit mailheader canlock sha1 sha1-el hex-util hashcash mail-utils emacsbug term disp-table ehelp electric ring tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd font-setting tool-bar dnd fontset image fringe lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar mldrag mouse jit-lock font-lock syntax facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev loaddefs button minibuffer faces cus-face files text-properties overlay md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process dbusbind system-font-setting font-render-setting gtk x-toolkit x multi-tty emacs) ------------=_1442104022-3425-1--