Subject: 27.1; Switching to term-char-mode appends newline

From: Jinwoo Lee <[email-masked]>
Date: Mon, 19 Oct 2020 16:45:48 -0700

In term-mode, when switching from line-mode (C-c C-j) to char-mode (C-c
C-k), a newline is appended at the end, thus sending out the text that
was previously entered in line-mode to the shell right away. Most of the
time, that is not what I want. I usually want to edit further before
sending the command to the shell.

I looked at the 'term-char-mode' function and it seems to prevent the
newline by temporarily overriding 'term-input-sender' with
'term-send-string', but it doesn't seem to work as intended
somehow. This is the snippet of the code.

        (unwind-protect
            (progn
              (add-function :override term-input-sender #'term-send-string)
              (end-of-line)
              (term-send-input))
          (remove-function term-input-sender #'term-send-string))))

I'm not sure why this doesn't work.
And not sure whether this is new in 27.1 or pre-existing.

In GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20),
modified by Debian
Windowing system distributor 'The X.Org Foundation', version 11.0.12008000
System Description: Debian GNU/Linux rodete

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.

Configured using:
 'configure --build x86_64-linux-gnu --build x86_64-linux-gnu
 --prefix=/usr --sharedstatedir=/var/lib --libexecdir=/usr/lib
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --enable-libsystemd --with-pop=yes
 --enable-locallisppath=/etc/google-emacs:/usr/local/share/google-emacs/27.1+gg3+1.20200824.053401.rc115/site-lisp:/usr/local/share/google-emacs/site-lisp:/usr/share/google-emacs/27.1+gg3+1.20200824.053401.rc115/site-lisp:/usr/share/google-emacs/site-lisp
 --with-sound=alsa --without-gconf --with-mailutils
 --program-prefix=google- --disable-build-details --disable-silent-rules
 --with-modules GOOGLE_VERSION=27.1+gg3+1.20200824.053401.rc115
 --with-x=yes --with-x-toolkit=gtk3 --with-toolkit-scroll-bars
 build_alias=x86_64-linux-gnu 'CFLAGS=-g -O2
 -fdebug-prefix-map=/build/google-emacs-mI2SpO/google-emacs-27.1+gg3+1.20200824.053401.rc115=.
-fstack-protector-strong
 -Wformat -Werror=format-security -Wall' LDFLAGS=-Wl,-z,relro
 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' 'OBJCFLAGS=-g -O2
 -fdebug-prefix-map=/build/google-emacs-mI2SpO/google-emacs-27.1+gg3+1.20200824.053401.rc115=.
-fstack-protector-strong
 -Wformat -Werror=format-security''

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND GPM DBUS GSETTINGS GLIB NOTIFY INOTIFY
ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD JSON
PDUMPER LCMS2 GMP

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=fcitx
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-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-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
format-spec rfc822 mml mml-sec password-cache epa derived epg epg-config
gnus-util rmail rmail-loaddefs text-property-search time-date subr-x seq
byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs cl-lib
sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils term
disp-table easymenu comint ansi-color ehelp ring tooltip eldoc electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote threads dbusbind inotify lcms2 dynamic-setting
system-font-setting font-render-setting move-toolbar gtk x-toolkit x
multi-tty make-network-process emacs)

Memory information:
((conses 16 50862 11535)
 (symbols 48 6786 1)
 (strings 32 17486 2323)
 (string-bytes 1 576575)
 (vectors 16 11421)
 (vector-slots 8 145518 16770)
 (floats 8 19 45)
 (intervals 56 248 0)
 (buffers 1000 12))