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: Wed, 17 Nov 2010 15:00:57 -0500 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1290024871 32105 80.91.229.12 (17 Nov 2010 20:14:31 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 17 Nov 2010 20:14:31 +0000 (UTC) To: 7426@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Nov 17 21:14:26 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 1PIoOe-0001pu-W1 for geb-bug-gnu-emacs@m.gmane.org; Wed, 17 Nov 2010 21:14:26 +0100 Original-Received: from localhost ([127.0.0.1]:49187 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PIoOd-0003pV-UX for geb-bug-gnu-emacs@m.gmane.org; Wed, 17 Nov 2010 15:14:23 -0500 Original-Received: from [140.186.70.92] (port=43961 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PIoOX-0003np-Ah for bug-gnu-emacs@gnu.org; Wed, 17 Nov 2010 15:14:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PIoOW-0002LW-48 for bug-gnu-emacs@gnu.org; Wed, 17 Nov 2010 15:14:17 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:36713) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PIoOW-0002LG-0a for bug-gnu-emacs@gnu.org; Wed, 17 Nov 2010 15:14:16 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1PIoAl-0004Ve-Pc; Wed, 17 Nov 2010 15:00:03 -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: 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: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.129002394817302 (code B ref -1); Wed, 17 Nov 2010 20:00:03 +0000 Original-Received: (at submit) by debbugs.gnu.org; 17 Nov 2010 19:59:08 +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 1PIo9s-0004V1-8O for submit@debbugs.gnu.org; Wed, 17 Nov 2010 14:59:08 -0500 Original-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 Original-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 Original-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 Original-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 Original-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 Original-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 Original-Received: by gxk7 with SMTP id 7so1663971gxk.0 for ; Wed, 17 Nov 2010 11:59:40 -0800 (PST) Original-Received: by 10.150.186.1 with SMTP id j1mr11447099ybf.147.1290023980642; Wed, 17 Nov 2010 11:59:40 -0800 (PST) Original-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) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Wed, 17 Nov 2010 15:00:03 -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:41709 Archived-At: 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=at om -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)