unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#44087: 27.1; Switching to term-char-mode appends newline
@ 2020-10-19 23:45 Jinwoo Lee
  2022-06-06 18:54 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Jinwoo Lee @ 2020-10-19 23:45 UTC (permalink / raw)
  To: 44087

[-- Attachment #1: Type: text/plain, Size: 4957 bytes --]

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))

[-- Attachment #2: Type: text/html, Size: 5520 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#44087: 27.1; Switching to term-char-mode appends newline
  2020-10-19 23:45 bug#44087: 27.1; Switching to term-char-mode appends newline Jinwoo Lee
@ 2022-06-06 18:54 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-06 18:54 UTC (permalink / raw)
  To: Jinwoo Lee; +Cc: 44087

Jinwoo Lee <jinwoo68@gmail.com> writes:

> 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 going through old bug reports that unfortunately weren't resolved
at the time.)

But the comment right above that indicates that the intention is to send
the string to the inferior process in `C-c C-k':

    ;; Send existing partial line to inferior (without newline).
    (let ((pmark (process-mark (get-buffer-process (current-buffer)))))
      (when (> (point) pmark)
	(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))))
    (term-update-mode-line)))

(term-send-string just breaks up the output into shorter blocks.)

And this is how Emacs used to work in Emacs 25, and again works in 27
and up.  So it seems (see bug#49186) that this is working as intended,
so in that bug report I just updated the doc string to document the
behaviour, and I'm closing this bug report.

(And like I said in that bug report, I'm not sure the behaviour here is
optimal, so perhaps a feature request to disable this (behind a user
option) might be appropriate, if somebody feels strongly enough about
this.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-06-06 18:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-19 23:45 bug#44087: 27.1; Switching to term-char-mode appends newline Jinwoo Lee
2022-06-06 18:54 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).