all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Thomas Fitzsimmons <fitzsim@fitzsim.org>
To: Chong Yidong <cyd@stupidchicken.com>
Cc: 7426@debbugs.gnu.org
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	[thread overview]
Message-ID: <m3hbfbbl9n.fsf@fitzsim.org> (raw)
In-Reply-To: <87eiahp99z.fsf@stupidchicken.com> (Chong Yidong's message of "Fri, 19 Nov 2010 11:28:56 -0500")

Chong Yidong <cyd@stupidchicken.com> writes:

> Thomas Fitzsimmons <fitzsim@fitzsim.org> 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 <stdio.h>

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.





  parent reply	other threads:[~2010-11-20 23:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-17 20:00 bug#7426: 23.2; term.el: After running stty -opost, printing \n\r inserts trailing spaces Thomas Fitzsimmons
2010-11-19 16:28 ` Chong Yidong
2010-11-19 19:22   ` Thomas Fitzsimmons
2010-11-20 23:58   ` Thomas Fitzsimmons [this message]
2013-03-23 16:37   ` Thomas Fitzsimmons
2015-09-13  0:26     ` Thomas Fitzsimmons

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3hbfbbl9n.fsf@fitzsim.org \
    --to=fitzsim@fitzsim.org \
    --cc=7426@debbugs.gnu.org \
    --cc=cyd@stupidchicken.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.