[Top][All Lists]

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

bug#24837: 26.0.50; term.el: In char mode, displayed and executed comman

From: Phil Sainty
Subject: bug#24837: 26.0.50; term.el: In char mode, displayed and executed commands can differ
Date: Tue, 01 Nov 2016 09:46:32 +1300
User-agent: Orcon Webmail

On 2016-11-01 03:10, Philipp Stephani wrote:
This is dangerous because a different command is executed than the one
that is visible in the buffer.
Either Emacs should make sure that after C-<backspace> the same command
that is displayed is sent to the shell, or it should disable
C-<backspace> in char mode altogether.

This is a duplicate of bug #21609 -- any command which directly
modifies the state of the terminal buffer can cause the apparent
state to be out of sync with the 'actual' state (i.e. the state
according to the inferior process).

In my own config I use the following, and something along these
lines might form a useful solution? It would be convenient if
there was a symbol property to identify standard commands which
should be disabled, but that may well be excessive/unworkable
in practice.

For killing and yanking text, many cases might be accounted for
by detecting the issue within `kill-region' and `insert-for-yank'
respectively. That isn't comprehensive (at minimum rectangles are
different), but might still be worth considering.

(eval-after-load "term"
     ;; Fix forward/backward word when (term-in-char-mode).
     (define-key term-raw-map (kbd "<C-left>")
       (lambda () (interactive) (term-send-raw-string "\eb")))
     (define-key term-raw-map (kbd "<M-left>")
       (lambda () (interactive) (term-send-raw-string "\eb")))
     (define-key term-raw-map (kbd "<C-right>")
       (lambda () (interactive) (term-send-raw-string "\ef")))
     (define-key term-raw-map (kbd "<M-right>")
       (lambda () (interactive) (term-send-raw-string "\ef")))
     ;; Disable killing and yanking in char mode (term-raw-map).
      (lambda (func)
        (eval `(define-key term-raw-map [remap ,func]
                 (lambda () (interactive) (ding)))))
        backward-kill-sentence backward-kill-sexp backward-kill-word
        bookmark-kill-line kill-backward-chars kill-backward-up-list
        kill-forward-chars kill-line kill-paragraph kill-rectangle
        kill-region kill-sentence kill-sexp kill-visual-line
        kill-whole-line kill-word subword-backward-kill subword-kill
        yank yank-pop yank-rectangle))))

reply via email to

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