bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#44087: 27.1; Switching to term-char-mode appends newline


From: Lars Ingebrigtsen
Subject: bug#44087: 27.1; Switching to term-char-mode appends newline
Date: Mon, 06 Jun 2022 20:54:23 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]