From unknown Sun Aug 10 16:50:31 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#24837 <24837@debbugs.gnu.org> To: bug#24837 <24837@debbugs.gnu.org> Subject: Status: 26.0.50; term.el: In char mode, displayed and executed commands can differ Reply-To: bug#24837 <24837@debbugs.gnu.org> Date: Sun, 10 Aug 2025 23:50:31 +0000 retitle 24837 26.0.50; term.el: In char mode, displayed and executed comman= ds can differ reassign 24837 emacs submitter 24837 Philipp Stephani severity 24837 important thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 31 10:10:51 2016 Received: (at submit) by debbugs.gnu.org; 31 Oct 2016 14:10:51 +0000 Received: from localhost ([127.0.0.1]:38164 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c1DIZ-0005hS-6S for submit@debbugs.gnu.org; Mon, 31 Oct 2016 10:10:51 -0400 Received: from eggs.gnu.org ([208.118.235.92]:41507) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c1DIX-0005hD-Ua for submit@debbugs.gnu.org; Mon, 31 Oct 2016 10:10:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1DIR-0001pL-GC for submit@debbugs.gnu.org; Mon, 31 Oct 2016 10:10:44 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: * X-Spam-Status: No, score=1.1 required=5.0 tests=BAYES_50, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:40922) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c1DIR-0001pC-Cc for submit@debbugs.gnu.org; Mon, 31 Oct 2016 10:10:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60687) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1DIN-0006mg-1I for bug-gnu-emacs@gnu.org; Mon, 31 Oct 2016 10:10:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1DIL-0001mg-CI for bug-gnu-emacs@gnu.org; Mon, 31 Oct 2016 10:10:39 -0400 Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]:37353) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c1DIL-0001lO-4F for bug-gnu-emacs@gnu.org; Mon, 31 Oct 2016 10:10:37 -0400 Received: by mail-wm0-x229.google.com with SMTP id t79so52339614wmt.0 for ; Mon, 31 Oct 2016 07:10:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=SxMVmaXCX0m8v01swFCFmAmpG6eewyDAt4NTAKWVwaM=; b=RjjHAkAZYCC73N6OOHgCCEeAc7nMvw/XMrSsetG7uLWqikopBkJkt1c513hUkcEIVz uAbkMWIlva5DyQg0gsw/n6GCT/DrJWDX7taFomfD5yHW5NF4r7/9H7XcH/pmzLrR6umn aF+M5/R8qSsp/tvry/EsXjjSl8fVk42/2gUmxmBhEsD7Kn0nb/3fpRdVka/YNyZeilzh fpa+hjNea2GFfM6QmrEkqaaj7WUXWZ6Wu8ZsivwXTIVyrcMUnYTRSgj3f+O3O7RrYQmt JWAgDt2QSeHEPTfXGlopvf1oB96CQKN56yXfTLBb5uY2hKE0JCLdLMpudUNmLBAukzbX PcDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=SxMVmaXCX0m8v01swFCFmAmpG6eewyDAt4NTAKWVwaM=; b=a/zjQJli1whUYyT3gHU+nkbes/JiJqfWt5+jktMNSCIcvtYQxKLIt0Epr5KR6ke6Ua tZnfqDLsURl5TBr0Aemx7tMgcu3lgMIYPL5i6WEWrOpDxXmm1J3aAGMCSD+kdc+UbITr xi5/TGHdwk9txhOdx2icfyysOHY+zXz8PaX74/s1DeUTvxZsq8BLT5dH7JRRvpHvQu1L HdENBWNv1Dnb3fx+ePaxVoLC2HN1N8j9qxfHWv66A1wM/BvaZjTsal4jGg7xVlgB2jXG GPpbQpAxupMnhCzwJfoy1L0trbR2UAd1+hijdcozI7ZCdr9ZprgULZNNn2MP618LRQRV Bd3Q== X-Gm-Message-State: ABUngvcqtbXiPZP2qLiYXvxkWzJRjfcuZDivHWqgkgapSyOvAAhPDJGLw5y2X1aZ/9aT0Q== X-Received: by 10.194.86.201 with SMTP id r9mr22187404wjz.5.1477923035309; Mon, 31 Oct 2016 07:10:35 -0700 (PDT) Received: from a.muc.corp.google.com ([2a00:79e0:15:4:98eb:fd1c:3b72:75f8]) by smtp.gmail.com with ESMTPSA id xq9sm30163647wjb.35.2016.10.31.07.10.34 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 31 Oct 2016 07:10:34 -0700 (PDT) From: Philipp Stephani To: bug-gnu-emacs@gnu.org Subject: 26.0.50; term.el: In char mode, displayed and executed commands can differ Date: Mon, 31 Oct 2016 15:10:28 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -3.8 (---) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.8 (---) emacs -Q M-x term RET RET Make sure the terminal is in char mode. Enter foo-bar C- RET The string "foo-" is now shown in the term buffer, but "foo-bar" has been sent to the shell. Typical output is "foo-bar: command not found". 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- the same command that is displayed is sent to the shell, or it should disable C- in char mode altogether. In GNU Emacs 26.0.50.14 (x86_64-unknown-linux-gnu, GTK+ Version 3.10.8) of 2016-10-31 built on localhost Repository revision: 8e7b1af1d708dcf41695cf3fbeff9d35cdb8e5b6 Windowing system distributor 'The X.Org Foundation', version 11.0.11501000 System Description: Ubuntu 14.04 LTS Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Configured using: 'configure --with-modules --enable-checking --enable-check-lisp-object-type 'CFLAGS=3D-ggdb3 -O0'' Configured features: XPM JPEG TIFF GIF PNG SOUND GSETTINGS NOTIFY GNUTLS FREETYPE XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 MODULES Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Term Minor modes in effect: tooltip-mode: t global-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 subr-x puny seq byte-opt gv bytecomp byte-compile cl-extra help-mode cconv cl-loaddefs pcase cl-lib dired dired-loaddefs format-spec rfc822 mml mml-sec password-cache epa derived epg epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils term disp-table easymenu ehelp ring time-date mule-util 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 newcomment elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame 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 charscript case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer 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 inotify dynamic-setting system-font-setting font-render-setting move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 101998 8071) (symbols 48 20928 0) (miscs 40 339 145) (strings 32 19121 4563) (string-bytes 1 622106) (vectors 16 15237) (vector-slots 8 465841 4221) (floats 8 185 39) (intervals 56 269 0) (buffers 976 13) (heap 1024 47494 1043)) --=20 Google Germany GmbH Erika-Mann-Stra=C3=9Fe 33 80636 M=C3=BCnchen Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Gesch=C3=A4ftsf=C3=BChrer: Matthew Scott Sucherman, Paul Terence Manicle Diese E-Mail ist vertraulich. Wenn Sie nicht der richtige Adressat sind, leiten Sie diese bitte nicht weiter, informieren Sie den Absender und l=C3= =B6schen Sie die E-Mail und alle Anh=C3=A4nge. Vielen Dank. This e-mail is confidential. If you are not the right addressee please do = not forward it, please inform the sender, and please erase this e-mail including any attachments. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 31 14:35:48 2016 Received: (at control) by debbugs.gnu.org; 31 Oct 2016 18:35:49 +0000 Received: from localhost ([127.0.0.1]:38294 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c1HQy-0003Tf-Of for submit@debbugs.gnu.org; Mon, 31 Oct 2016 14:35:48 -0400 Received: from eggs.gnu.org ([208.118.235.92]:60639) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c1HQw-0003TT-Vm for control@debbugs.gnu.org; Mon, 31 Oct 2016 14:35:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1HQq-0004Qp-VN for control@debbugs.gnu.org; Mon, 31 Oct 2016 14:35:41 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:52059) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1HQq-0004Qg-SS for control@debbugs.gnu.org; Mon, 31 Oct 2016 14:35:40 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1c1HQq-0003f6-I7 for control@debbugs.gnu.org; Mon, 31 Oct 2016 14:35:40 -0400 Subject: control message for bug 24837 To: X-Mailer: mail (GNU Mailutils 2.99.98) Message-Id: From: Glenn Morris Date: Mon, 31 Oct 2016 14:35:40 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -7.7 (-------) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -7.7 (-------) severity 24837 important From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 31 14:35:56 2016 Received: (at control) by debbugs.gnu.org; 31 Oct 2016 18:35:56 +0000 Received: from localhost ([127.0.0.1]:38297 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c1HR5-0003U3-Vz for submit@debbugs.gnu.org; Mon, 31 Oct 2016 14:35:56 -0400 Received: from eggs.gnu.org ([208.118.235.92]:60707) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c1HR4-0003Tm-3t for control@debbugs.gnu.org; Mon, 31 Oct 2016 14:35:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1HQy-0004Tg-Do for control@debbugs.gnu.org; Mon, 31 Oct 2016 14:35:49 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:52065) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1HQy-0004Ta-Aq for control@debbugs.gnu.org; Mon, 31 Oct 2016 14:35:48 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1c1HQx-0003gp-Sp for control@debbugs.gnu.org; Mon, 31 Oct 2016 14:35:48 -0400 Subject: control message for bug 24655 To: X-Mailer: mail (GNU Mailutils 2.99.98) Message-Id: From: Glenn Morris Date: Mon, 31 Oct 2016 14:35:47 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -7.7 (-------) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -7.7 (-------) block 24655 by 24837 From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 31 16:46:41 2016 Received: (at 24837) by debbugs.gnu.org; 31 Oct 2016 20:46:41 +0000 Received: from localhost ([127.0.0.1]:38359 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c1JTd-0008VL-HM for submit@debbugs.gnu.org; Mon, 31 Oct 2016 16:46:41 -0400 Received: from [219.88.242.59] (port=38669 helo=mail.orcon.net.nz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c1JTb-0008V8-9v for 24837@debbugs.gnu.org; Mon, 31 Oct 2016 16:46:40 -0400 Received: from webmail-1.orcon.net.nz ([10.253.37.40]) by mail.orcon.net.nz (8.14.3/8.14.3/Debian-9.4) with ESMTP id u9VKkWSa046494; Tue, 1 Nov 2016 09:46:32 +1300 Received: from mail.orcon.net.nz (localhost [IPv6:::1]) by webmail-1.orcon.net.nz (Postfix) with ESMTP id 3DE8F201F0B0; Tue, 1 Nov 2016 09:46:32 +1300 (NZDT) Received: from wlg-office-ffw.catalyst.net.nz ([202.78.240.7]) via [10.253.37.253] by mail.orcon.net.nz with HTTP (HTTP/1.1 POST); Tue, 01 Nov 2016 09:46:32 +1300 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 01 Nov 2016 09:46:32 +1300 From: Phil Sainty To: Philipp Stephani Subject: Re: bug#24837: 26.0.50; term.el: In char mode, displayed and executed commands can differ In-Reply-To: References: Message-ID: X-Sender: psainty@orcon.net.nz User-Agent: Orcon Webmail X-Bayes-Prob: 0.0001 (Score 0: No Bayes scoring rules defined, tokens from: outbound) X-Spam-Score: -3.00 () [Hold at 3.00] FREEMAIL_FROM:0.001,CC(NZ:-3) X-CanIt-Geo: ip=202.78.240.7; country=NZ; latitude=-41.0000; longitude=174.0000; http://maps.google.com/maps?q=-41.0000,174.0000&z=6 X-CanItPRO-Stream: base:outbound X-Canit-Stats-ID: 02S2kKwce - 3939be640f2e - 20161101 (trained as not-spam) X-Scanned-By: CanIt (www . roaringpenguin . com) on 10.250.8.6 X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 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- the same command > that is displayed is sent to the shell, or it should disable > C- in char mode altogether. [...] Content analysis details: (1.3 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (psainty[at]orcon.net.nz) 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Debbugs-Envelope-To: 24837 Cc: 24837@debbugs.gnu.org, bug-gnu-emacs X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 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- the same command > that is displayed is sent to the shell, or it should disable > C- in char mode altogether. [...] Content analysis details: (1.3 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (psainty[at]orcon.net.nz) 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS 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- the same command > that is displayed is sent to the shell, or it should disable > C- 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" '(progn ;; Fix forward/backward word when (term-in-char-mode). (define-key term-raw-map (kbd "") (lambda () (interactive) (term-send-raw-string "\eb"))) (define-key term-raw-map (kbd "") (lambda () (interactive) (term-send-raw-string "\eb"))) (define-key term-raw-map (kbd "") (lambda () (interactive) (term-send-raw-string "\ef"))) (define-key term-raw-map (kbd "") (lambda () (interactive) (term-send-raw-string "\ef"))) ;; Disable killing and yanking in char mode (term-raw-map). (mapc (lambda (func) (eval `(define-key term-raw-map [remap ,func] (lambda () (interactive) (ding))))) '(backward-kill-paragraph 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)))) From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 31 20:33:36 2016 Received: (at control) by debbugs.gnu.org; 1 Nov 2016 00:33:36 +0000 Received: from localhost ([127.0.0.1]:38412 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c1N1E-00083B-9H for submit@debbugs.gnu.org; Mon, 31 Oct 2016 20:33:36 -0400 Received: from mail-oi0-f52.google.com ([209.85.218.52]:36746) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c1N1C-00082w-W1 for control@debbugs.gnu.org; Mon, 31 Oct 2016 20:33:35 -0400 Received: by mail-oi0-f52.google.com with SMTP id v84so102669520oie.3 for ; Mon, 31 Oct 2016 17:33:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=4uci9ledQRBmHHK6l/zao2DqNjK3y52+H075/FDcjOs=; b=tskcNrS5hjsJJqSpzEx9VVCODhYpEXfwMyWVWeLpdTgDQZvF/z71YLLyp88r28LXES o9KR+fu+NMJRBqkKfJg36dCKngltAj09KK+mGqoUzHkrFrfLTu1sHnghFLA4y9gAOeDe vjnt2Km4P0/8R753Z1A36Vj6pOUZC1ypWoNoDnne9M21dQBnBEX3IOWmwIW63eGibs4y Fyl/EvBq//RKaCp6lzSfEXzbUeZlgqVvw1I5l+ywc0XcMN9DJC+KtRt0iyM3RxhvMB6K mz1Kjh41iu3wzedbVy6jXqVXJRf1RZ2WnYwcjLtDRDZg8hwDqpTeAlu7/XNoc3wgyRan X9Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=4uci9ledQRBmHHK6l/zao2DqNjK3y52+H075/FDcjOs=; b=Yr8OUP2kG+sGZrZe4DD/7EfTMELvXftxbG7UtkEgbAKKtps59kPIrlWqX+K+egHkIS T8hjpkysTYTKelGgpbKTJG3sa9aEuJQobxTEgFxbADuZ1EPUgGhHytC+rK2O5jYiecnf 5ZE1MZQsevxWfQwKgvCpZSHDqvU+B/CBRBRg02ljKslPnC6Evm2tdtjdna8JtEynWXcL dk3NH/jhDL7gx/pskdw4UnoE5KHeLBJRbyPTBcfKLQwoH6CYX1452HACybNjGA/ZVWEn 2RicG+lrt8jpCBVz4Mt1FUW/NgyMXN4WZsf8z5gnYf8KwfNa29hsC0H1aV4kS3UbN8P0 uQvQ== X-Gm-Message-State: ABUngvfk8kfkFW3xtTzFarDOg7NyULUYNImwvmeqEDY7F7oeX9kQC/za0iI9YUzqXM2ysg== X-Received: by 10.107.3.223 with SMTP id e92mr5548499ioi.113.1477960409485; Mon, 31 Oct 2016 17:33:29 -0700 (PDT) Received: from zony ([45.2.7.130]) by smtp.googlemail.com with ESMTPSA id k123sm12864527ita.2.2016.10.31.17.33.28 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 31 Oct 2016 17:33:29 -0700 (PDT) From: npostavs@users.sourceforge.net To: control@debbugs.gnu.org Subject: Re: bug#24837: 26.0.50; term.el: In char mode, displayed and executed commands can differ References: Date: Mon, 31 Oct 2016 20:34:11 -0400 In-Reply-To: (Phil Sainty's message of "Tue, 01 Nov 2016 09:46:32 +1300") Message-ID: <87zilkox6k.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) forcemerge 24837 21609 quit Phil Sainty writes: > 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- the same command >> that is displayed is sent to the shell, or it should disable >> C- 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). From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 23 14:44:47 2016 Received: (at 24837) by debbugs.gnu.org; 23 Nov 2016 19:44:47 +0000 Received: from localhost ([127.0.0.1]:39568 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c9dTL-0002ht-7F for submit@debbugs.gnu.org; Wed, 23 Nov 2016 14:44:47 -0500 Received: from mail-wm0-f53.google.com ([74.125.82.53]:35415) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c9dTJ-0002hd-1p; Wed, 23 Nov 2016 14:44:45 -0500 Received: by mail-wm0-f53.google.com with SMTP id a197so91621670wmd.0; Wed, 23 Nov 2016 11:44:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HV9PUsve+EVr0f58ya03+Pv/CM196WMP1by8sh9deWk=; b=DIqrJ2FWUiOQSWWpMG3jUSoj81wR14nNYF2Fg+0Uzzqu4CT+UAcBU9nVDqxM+M3xA4 ei9/Q9aNfMOEjr/4Fn8hYbRQhrKHdsDj9SuKogVAnpWXwFrKT6bI+n6B8RNjZyxkG8lm 4MBKjibmBtZLfvPaH0a/Nqs8gm6zbttxhXn2cwJcrHO2CErX/mtOwUUssyGRB2Owo8p5 VlLKJiypDq6jx/dakrsT5jpgRapG0zhbFWth5zjnVqX1q5pBJsj5VKXrT7zumROzBIMz Fmw7IpXHgAEOTygHYzKnFUxTSz0ebhqdJ0/jdTrzx7KjC+bjnoOzpgWyPw5sUmRoxLAx JOOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HV9PUsve+EVr0f58ya03+Pv/CM196WMP1by8sh9deWk=; b=cJF2jGIpCO3AFD55Dd8AiOZ0Go19FzNeC/XISzT6VNGW1ocLQZv0gRWCp4IJ7xmd/H OSxajc3+Q43Kiyt8fjQgRBSenqUr1tsg2NtMxuLmZgxCDcijyKFP60Cfp1B9gXJcPoQp zAsMF4rLMV9H8HPcJ7i1gVa7NAnR41F00sPaPe5eNX5V5ZJ5xSp4pehUGjc9tKwHRwGY SoI+Alp58/Y22XpyHoTP5zAochak7XqUxbfwjQgxQPclT8sfOJj2cmeqioWSwd6odObV 7SqF9W7RRcKSzUFKYgi2Ns2VrKZ2djAkk9sxhAve8YLSG5J70OYFVeZukHxXyO/qjtnX l+4Q== X-Gm-Message-State: AKaTC010Uu12pvRJslf6GjFQp/0QP+qnXcBPrO6kM0anoYSSkeMqybyKPF+06JkXRwanZH/c6gd5yi68wV1DGQ== X-Received: by 10.28.129.81 with SMTP id c78mr5037645wmd.94.1479930279326; Wed, 23 Nov 2016 11:44:39 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Philipp Stephani Date: Wed, 23 Nov 2016 19:44:29 +0000 Message-ID: Subject: Re: bug#24837: 26.0.50; term.el: In char mode, displayed and executed commands can differ To: Phil Sainty Content-Type: multipart/alternative; boundary=001a1142426297781c0541fd1e70 X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: 24837 Cc: 24837@debbugs.gnu.org, 21609@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.7 (/) --001a1142426297781c0541fd1e70 Content-Type: text/plain; charset=UTF-8 Phil Sainty schrieb am Mo., 31. Okt. 2016 um 21:46 Uhr: > 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- the same command > > that is displayed is sent to the shell, or it should disable > > C- 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). > Should maybe terminal buffers in char-mode be read-only? The process filter could then use inhibit-read-only. --001a1142426297781c0541fd1e70 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


Phil S= ainty <psainty@orcon.net.nz&= gt; schrieb am Mo., 31. Okt. 2016 um 21:46=C2=A0Uhr:
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).

Should maybe terminal buffers in char-mode= be read-only? The process filter could then use inhibit-read-only.
--001a1142426297781c0541fd1e70-- From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 23 15:09:07 2016 Received: (at 24837) by debbugs.gnu.org; 23 Nov 2016 20:09:07 +0000 Received: from localhost ([127.0.0.1]:39581 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c9dqt-0003GY-II for submit@debbugs.gnu.org; Wed, 23 Nov 2016 15:09:07 -0500 Received: from [219.88.242.52] (port=41818 helo=mail.orcon.net.nz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c9dqq-0003GK-PS; Wed, 23 Nov 2016 15:09:05 -0500 Received: from [192.168.20.100] ([150.107.172.103]) (authenticated bits=0) by mail.orcon.net.nz (8.14.3/8.14.3/Debian-9.4) with ESMTP id uANK90Dd027754; Thu, 24 Nov 2016 09:09:01 +1300 Subject: Re: bug#24837: 26.0.50; term.el: In char mode, displayed and executed commands can differ To: Philipp Stephani References: From: Phil Sainty Message-ID: <08c3b161-174d-1fb7-5df4-bbf7f7d47ee9@orcon.net.nz> Date: Thu, 24 Nov 2016 09:08:59 +1300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Bayes-Prob: 0.0001 (Score 0: No Bayes scoring rules defined, tokens from: outbound) X-Spam-Score: -1.73 () [Hold at 3.00] FREEMAIL_FROM:0.001, RDNS_NONE:1.274, CC(NZ:-3) X-CanIt-Geo: ip=150.107.172.103; country=NZ; region=Bay of Plenty Region; city=Tauranga; latitude=-37.6686; longitude=176.2664; http://maps.google.com/maps?q=-37.6686,176.2664&z=6 X-CanItPRO-Stream: base:outbound X-Canit-Stats-ID: 02Sbw908P - 71052bd00dcb - 20161124 X-Scanned-By: CanIt (www . roaringpenguin . com) X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: On 24/11/16 08:44, Philipp Stephani wrote: > Phil Sainty schrieb am Mo., 31. Okt. 2016 um >> 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). > > Should maybe terminal buffers in char-mode be read-only? The process > filter could then use inhibit-read-only. [...] Content analysis details: (1.3 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (psainty[at]orcon.net.nz) 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Debbugs-Envelope-To: 24837 Cc: 24837@debbugs.gnu.org, 21609@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: On 24/11/16 08:44, Philipp Stephani wrote: > Phil Sainty schrieb am Mo., 31. Okt. 2016 um >> 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). > > Should maybe terminal buffers in char-mode be read-only? The process > filter could then use inhibit-read-only. [...] Content analysis details: (1.3 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (psainty[at]orcon.net.nz) 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS On 24/11/16 08:44, Philipp Stephani wrote: > Phil Sainty schrieb am Mo., 31. Okt. 2016 um >> 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). > > Should maybe terminal buffers in char-mode be read-only? The process > filter could then use inhibit-read-only. That's an interesting thought, and may be worth investigating (offhand I've no idea whether it's workable), but note that it's not sufficient to deal with all cases -- any Emacs command which moves point can create an inconsistent state without modifying the buffer contents. From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 23 15:22:14 2016 Received: (at 24837) by debbugs.gnu.org; 23 Nov 2016 20:22:14 +0000 Received: from localhost ([127.0.0.1]:39619 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c9e3a-0003cC-6i for submit@debbugs.gnu.org; Wed, 23 Nov 2016 15:22:14 -0500 Received: from mail-wj0-f181.google.com ([209.85.210.181]:36132) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c9e3Y-0003bu-9y; Wed, 23 Nov 2016 15:22:12 -0500 Received: by mail-wj0-f181.google.com with SMTP id qp4so16745252wjc.3; Wed, 23 Nov 2016 12:22:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MJjT6s1TSvffjhcHXj5JQmXzJE0WFD7nBkUgtk77b9I=; b=GTv8+F+L5C6Qil3oaGQp5laLFIHjfK4+eNiO7Ds7LA41+JKk4x5vveF2ui9USWh9BO cVaNYXWhL1MSehJthWsK2sg9M/id51fh0sag4R2X5CiYf7B7yGc12B4qMrAJmVrJjj+e I18WdERLcN9nJBp2R3JrmLcUc+SSPZ608FpazM+t81XdfgzBdmaQS+4sMu4GfQUWSOEZ v9PP7b3ukQMbo6hqOgOgSC9VkZboCwmoam139cfS3dsiRx2E1n016HcqoCGA0XwwVur0 BYLgen0ejx7Un39Ocnk7BRpmauikuf0Ccpy7ED1CGxes5llNp+nd8GSjyRAjtT86/cy7 dN0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MJjT6s1TSvffjhcHXj5JQmXzJE0WFD7nBkUgtk77b9I=; b=g8+EguP0mqspz8n5ZuBCe6+n58aKbH+padoGGlsYCg7AXUXv2oVUl+2yJG5vvWhnM5 0VVhU3UUalSvtB04+kU2WY/wgzrF1CGYWIu3NqwQQ/srOELZ6CktBUj0cIkp6VZGz3/F OZeMorVpOnFhlmvow+84tK3jT3GD1Lj5V6klA78tCeL9eTAO8dAbPoYSDcrrn6XT5m/C szkxyMVLmbY0+lhdN2sR+pfogRWZBqU2DC5YduEPEtv20iMEBtqUJDKgrD+VgiHgOmTU BRwuAT+V1Wmj73uq8nZE97My3W/nYCyhyz4zRyj+2fu//POzHUZtZrTp1KUQraqx7/l0 yKFw== X-Gm-Message-State: AKaTC02wcF3n/kh2YFhznHpPYbmSWjZVO0/q4Qp+phy89DI5ErTwFG3DofFQjBcZCAgZuwd1urmrYlBcAZIR/A== X-Received: by 10.194.95.35 with SMTP id dh3mr5208106wjb.141.1479932526525; Wed, 23 Nov 2016 12:22:06 -0800 (PST) MIME-Version: 1.0 References: <08c3b161-174d-1fb7-5df4-bbf7f7d47ee9@orcon.net.nz> In-Reply-To: <08c3b161-174d-1fb7-5df4-bbf7f7d47ee9@orcon.net.nz> From: Philipp Stephani Date: Wed, 23 Nov 2016 20:21:56 +0000 Message-ID: Subject: Re: bug#24837: 26.0.50; term.el: In char mode, displayed and executed commands can differ To: Phil Sainty Content-Type: multipart/alternative; boundary=047d7bb0405089021a0541fda476 X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: 24837 Cc: 24837@debbugs.gnu.org, 21609@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.7 (/) --047d7bb0405089021a0541fda476 Content-Type: text/plain; charset=UTF-8 Phil Sainty schrieb am Mi., 23. Nov. 2016 um 21:09 Uhr: > On 24/11/16 08:44, Philipp Stephani wrote: > > Phil Sainty schrieb am Mo., 31. Okt. 2016 um > >> 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). > > > > Should maybe terminal buffers in char-mode be read-only? The process > > filter could then use inhibit-read-only. > > That's an interesting thought, and may be worth investigating (offhand > I've no idea whether it's workable), but note that it's not sufficient > to deal with all cases -- any Emacs command which moves point can create > an inconsistent state without modifying the buffer contents. > > Hmm, then maybe the entire buffer also needs to be made intangible, except for the actual position of the terminal cursor? --047d7bb0405089021a0541fda476 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


Phil S= ainty <psainty@orcon.net.nz&= gt; schrieb am Mi., 23. Nov. 2016 um 21:09=C2=A0Uhr:
On 24/11/16 08:44, Philipp Stephani wrote:
> Phil Sainty <psainty@orcon.net.nz> schrieb am Mo., 31. Ok= t. 2016 um
>> 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).
>
> Should maybe terminal buffers in char-mode be read-only? The process > filter could then use inhibit-read-only.

That's an interesting thought, and may be worth investigating (offhand<= br class=3D"gmail_msg"> I've no idea whether it's workable), but note that it's not suf= ficient
to deal with all cases -- any Emacs command which moves point can create an inconsistent state without modifying the buffer contents.


Hmm, then maybe th= e entire buffer also needs to be made intangible, except for the actual pos= ition of the terminal cursor?=C2=A0
--047d7bb0405089021a0541fda476-- From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 02 10:15:00 2017 Received: (at 24837) by debbugs.gnu.org; 2 Sep 2017 14:15:00 +0000 Received: from localhost ([127.0.0.1]:43540 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1do9CN-0003QO-QT for submit@debbugs.gnu.org; Sat, 02 Sep 2017 10:15:00 -0400 Received: from eggs.gnu.org ([208.118.235.92]:32793) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1do9CM-0003QA-RH for 24837@debbugs.gnu.org; Sat, 02 Sep 2017 10:14:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1do9CD-0004xI-86 for 24837@debbugs.gnu.org; Sat, 02 Sep 2017 10:14:53 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_20,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:50670) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1do9C2-0004qY-SO; Sat, 02 Sep 2017 10:14:38 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2283 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1do9C1-0001Rl-SS; Sat, 02 Sep 2017 10:14:38 -0400 Date: Sat, 02 Sep 2017 17:14:27 +0300 Message-Id: <83val1xk58.fsf@gnu.org> From: Eli Zaretskii To: Philipp Stephani In-reply-to: (message from Philipp Stephani on Wed, 23 Nov 2016 20:21:56 +0000) Subject: Re: bug#24837: 26.0.50; term.el: In char mode, displayed and executed commands can differ References: <08c3b161-174d-1fb7-5df4-bbf7f7d47ee9@orcon.net.nz> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 24837 Cc: psainty@orcon.net.nz, 24837@debbugs.gnu.org, 21609@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > From: Philipp Stephani > Date: Wed, 23 Nov 2016 20:21:56 +0000 > Cc: 24837@debbugs.gnu.org, 21609@debbugs.gnu.org > > Phil Sainty schrieb am Mi., 23. Nov. 2016 um 21:09 Uhr: > > On 24/11/16 08:44, Philipp Stephani wrote: > > Phil Sainty schrieb am Mo., 31. Okt. 2016 um > >> 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). > > > > Should maybe terminal buffers in char-mode be read-only? The process > > filter could then use inhibit-read-only. > > That's an interesting thought, and may be worth investigating (offhand > I've no idea whether it's workable), but note that it's not sufficient > to deal with all cases -- any Emacs command which moves point can create > an inconsistent state without modifying the buffer contents. > > Hmm, then maybe the entire buffer also needs to be made intangible, except for the actual position of the > terminal cursor? This bug is currently one of those marked to block the release of Emacs 26.1. Given that it existed for quite some time, I tend to remove the blocking status, but if someone has practical ideas how to fix this, I think we should do that now. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 02 22:58:38 2017 Received: (at 24837) by debbugs.gnu.org; 3 Sep 2017 02:58:38 +0000 Received: from localhost ([127.0.0.1]:44413 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1doL7O-0001nb-4a for submit@debbugs.gnu.org; Sat, 02 Sep 2017 22:58:38 -0400 Received: from smtp-1.orcon.net.nz ([60.234.4.34]:49270) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1doL7M-0001nH-9S; Sat, 02 Sep 2017 22:58:37 -0400 Received: from [150.107.172.82] (port=13875 helo=[192.168.20.102]) by smtp-1.orcon.net.nz with esmtpa (Exim 4.86_2) (envelope-from ) id 1doL7A-0002Nt-4j; Sun, 03 Sep 2017 14:58:28 +1200 Subject: Re: bug#24837: 26.0.50; term.el: In char mode, displayed and executed commands can differ To: Eli Zaretskii , Philipp Stephani References: <08c3b161-174d-1fb7-5df4-bbf7f7d47ee9@orcon.net.nz> <83val1xk58.fsf@gnu.org> From: Phil Sainty Message-ID: Date: Sun, 3 Sep 2017 14:58:23 +1200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <83val1xk58.fsf@gnu.org> Content-Type: multipart/mixed; boundary="------------B35E7E1C9200B0EC0FA052D9" Content-Language: en-US X-GeoIP: NZ X-Spam_score: -2.9 X-Spam_score_int: -28 X-Spam_bar: -- X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 24837 Cc: 24837@debbugs.gnu.org, 21609@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) This is a multi-part message in MIME format. --------------B35E7E1C9200B0EC0FA052D9 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 03/09/17 02:14, Eli Zaretskii wrote: > This bug is currently one of those marked to block the release of > Emacs 26.1. Given that it existed for quite some time, I tend to > remove the blocking status, but if someone has practical ideas how > to fix this, I think we should do that now. Well here's a starter for discussion. I've performed only cursory testing, but at first glance this seems to do the trick, so I'll see what other people think... Firstly I'm using Philipp Stephani's suggestion that the buffer be read-only in `term-char-mode' (and removing that in `term-line-mode'; this code doesn't attempt to remember the pre-existing states if the user had changed it manually). The default term process filter `term-emulate-terminal' then binds `buffer-read-only' to nil. Secondly, I've added a local `post-command-hook' function in `term-char-mode' which simply moves point back to the local process mark position. Might such a simple approach be usable? I'm not very familiar with the code, so maybe there are glaring holes that I'm not seeing. -Phil --------------B35E7E1C9200B0EC0FA052D9 Content-Type: text/x-patch; name="0001-Avoid-creating-inconsistent-buffer-states-in-term-ch.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Avoid-creating-inconsistent-buffer-states-in-term-ch.pa"; filename*1="tch" >From edeb0ae7ae6fefe15f277029792617da030c5a9b Mon Sep 17 00:00:00 2001 From: Phil Sainty Date: Sun, 3 Sep 2017 14:30:18 +1200 Subject: [PATCH] Avoid creating inconsistent buffer states in `term-char-mode'. * lisp/term.el (term-char-mode, term-line-mode, term-emulate-terminal): Make buffer read-only in `term-char-mode' except for the process filter, and use post-command-hook function `term-goto-process-mark' to avoid unexpected changes to point. (term-goto-process-mark): New function. --- lisp/term.el | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lisp/term.el b/lisp/term.el index 12a37ca..3ba6ee7 100644 --- a/lisp/term.el +++ b/lisp/term.el @@ -1246,6 +1246,11 @@ term-char-mode (easy-menu-add term-terminal-menu) (easy-menu-add term-signals-menu) + ;; Don't allow changes to the buffer or to point which are not + ;; caused by the process filter. + (read-only-mode 1) + (add-hook 'post-command-hook #'term-goto-process-mark nil t) + ;; Send existing partial line to inferior (without newline). (let ((pmark (process-mark (get-buffer-process (current-buffer)))) (save-input-sender term-input-sender)) @@ -1265,6 +1270,8 @@ term-line-mode you type \\[term-send-input] which sends the current line to the inferior." (interactive) (when (term-in-char-mode) + (read-only-mode 0) + (remove-hook 'post-command-hook #'term-goto-process-mark t) (use-local-map term-old-mode-map) (term-update-mode-line))) @@ -2711,6 +2718,7 @@ term-emulate-terminal count-bytes ; number of bytes decoded-substring save-point save-marker old-point temp win + buffer-read-only (buffer-undo-list t) (selected (selected-window)) last-win @@ -3109,6 +3117,14 @@ term-emulate-terminal (when (get-buffer-window (current-buffer)) (redisplay)))) +(defun term-goto-process-mark () + "Move point to the current process-mark for the term buffer process. + +Used as a buffer-local `post-command-hook' in `term-char-mode' to +prevent commands from putting the buffer into an inconsistent +state by unexpectedly moving point." + (goto-char (process-mark (get-buffer-process (current-buffer))))) + (defun term-handle-deferred-scroll () (let ((count (- (term-current-row) term-height))) (when (>= count 0) -- 2.8.3 --------------B35E7E1C9200B0EC0FA052D9-- From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 02 23:09:41 2017 Received: (at 24837) by debbugs.gnu.org; 3 Sep 2017 03:09:41 +0000 Received: from localhost ([127.0.0.1]:44425 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1doLI5-00023l-EU for submit@debbugs.gnu.org; Sat, 02 Sep 2017 23:09:41 -0400 Received: from smtp-1.orcon.net.nz ([60.234.4.34]:39739) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1doLI3-00023S-SA; Sat, 02 Sep 2017 23:09:40 -0400 Received: from [150.107.172.82] (port=50489 helo=[192.168.20.102]) by smtp-1.orcon.net.nz with esmtpa (Exim 4.86_2) (envelope-from ) id 1doLHs-0002yD-IY; Sun, 03 Sep 2017 15:09:28 +1200 Subject: Re: bug#21609: bug#24837: 26.0.50; term.el: In char mode, displayed and executed commands can differ From: Phil Sainty To: Eli Zaretskii , Philipp Stephani References: <08c3b161-174d-1fb7-5df4-bbf7f7d47ee9@orcon.net.nz> <83val1xk58.fsf@gnu.org> Message-ID: <5087b7b4-21e5-090a-5363-a72647c7cd33@orcon.net.nz> Date: Sun, 3 Sep 2017 15:09:28 +1200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-GeoIP: NZ X-Spam_score: -2.9 X-Spam_score_int: -28 X-Spam_bar: -- X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 24837 Cc: 24837@debbugs.gnu.org, 21609@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On 03/09/17 14:58, Phil Sainty wrote: > Firstly I'm using Philipp Stephani's suggestion that the buffer be > read-only in `term-char-mode' [...] The default term process filter > `term-emulate-terminal' then binds `buffer-read-only' to nil. In fact Philipp actually suggested binding `inhibit-read-only' in the process filter, which is presumably preferable. From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 04 05:56:12 2017 Received: (at 24837) by debbugs.gnu.org; 4 Sep 2017 09:56:13 +0000 Received: from localhost ([127.0.0.1]:47718 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1doo72-0002DC-MO for submit@debbugs.gnu.org; Mon, 04 Sep 2017 05:56:12 -0400 Received: from smtp-4.orcon.net.nz ([60.234.4.59]:53229) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1doo70-0002Cm-PZ; Mon, 04 Sep 2017 05:56:11 -0400 Received: from [150.107.172.28] (port=10839 helo=[192.168.20.102]) by smtp-4.orcon.net.nz with esmtpa (Exim 4.86_2) (envelope-from ) id 1doo6o-0004d7-9j; Mon, 04 Sep 2017 21:55:58 +1200 Subject: Re: bug#21609: bug#24837: 26.0.50; term.el: In char mode, displayed and executed commands can differ From: Phil Sainty To: Eli Zaretskii , Philipp Stephani References: <08c3b161-174d-1fb7-5df4-bbf7f7d47ee9@orcon.net.nz> <83val1xk58.fsf@gnu.org> Message-ID: Date: Mon, 4 Sep 2017 21:55:57 +1200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-GeoIP: NZ X-Spam_score: -2.9 X-Spam_score_int: -28 X-Spam_bar: -- X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 24837 Cc: 24837@debbugs.gnu.org, 21609@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On 03/09/17 14:58, Phil Sainty wrote: > Secondly, I've added a local `post-command-hook' function in > `term-char-mode' which simply moves point back to the local process > mark position. > > Might such a simple approach be usable? I'm not very familiar with > the code, so maybe there are glaring holes that I'm not seeing. I've realised that one such glaring hole is mouse input, as clicking then tends to create a selection between where you click and (forcibly) the mark position at (most likely) the end of the buffer. I'm not sure whether that's a deal breaker, or something which is essentially incompatible with any solution to the problem and should perhaps be disabled when in term-char-mode? Inhibiting mouse events (or similar) sounds a little bit drastic; however if unimpeded mouse selection is possible, and this allows the user a way to move point from the process mark, then that just seems contradictory to what we're trying to achieve in the first place, which is to keep the state of the buffer (including point) consistent with what the terminal process believes it to be. We could automatically switch to term-line-mode upon mouse clicks, but offhand I don't see how we could switch back automatically without simply triggering the initial problem, and requiring the user to manually switch back doesn't seem so user-friendly. -Phil From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 04 06:11:00 2017 Received: (at 24837) by debbugs.gnu.org; 4 Sep 2017 10:11:00 +0000 Received: from localhost ([127.0.0.1]:47737 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dooLM-0002Yg-9T for submit@debbugs.gnu.org; Mon, 04 Sep 2017 06:11:00 -0400 Received: from smtp-4.orcon.net.nz ([60.234.4.59]:51836) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dooLK-0002YN-M1; Mon, 04 Sep 2017 06:10:59 -0400 Received: from [150.107.172.28] (port=4604 helo=[192.168.20.102]) by smtp-4.orcon.net.nz with esmtpa (Exim 4.86_2) (envelope-from ) id 1dooL7-0005Bs-PV; Mon, 04 Sep 2017 22:10:45 +1200 Subject: Re: bug#24837: bug#21609: bug#24837: 26.0.50; term.el: In char mode, displayed and executed commands can differ From: Phil Sainty To: Eli Zaretskii , Philipp Stephani References: <08c3b161-174d-1fb7-5df4-bbf7f7d47ee9@orcon.net.nz> <83val1xk58.fsf@gnu.org> Message-ID: <6916916c-2f04-b377-7825-b5e7e98136c1@orcon.net.nz> Date: Mon, 4 Sep 2017 22:10:45 +1200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-GeoIP: NZ X-Spam_score: -2.9 X-Spam_score_int: -28 X-Spam_bar: -- X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 24837 Cc: 24837@debbugs.gnu.org, 21609@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On 04/09/17 21:55, Phil Sainty wrote: > We could automatically switch to term-line-mode upon mouse clicks, > but offhand I don't see how we could switch back automatically > without simply triggering the initial problem Maybe switching to line mode and temporarily shifting the post-command hook to pre-command, such that nothing happens post-command for the mouse events, but afterwards, at pre-command, any keyboard events first trigger a move to the process mark (at which point we could shift the behaviour back to post-command again). (All speculation; I'm not sure if that would actually work.) From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 04 07:59:24 2017 Received: (at 24837) by debbugs.gnu.org; 4 Sep 2017 11:59:24 +0000 Received: from localhost ([127.0.0.1]:47848 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1doq2G-0006yN-3G for submit@debbugs.gnu.org; Mon, 04 Sep 2017 07:59:24 -0400 Received: from smtp-4.orcon.net.nz ([60.234.4.59]:44856) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1doq2D-0006y4-Jo; Mon, 04 Sep 2017 07:59:22 -0400 Received: from [150.107.172.28] (port=42725 helo=[192.168.20.102]) by smtp-4.orcon.net.nz with esmtpa (Exim 4.86_2) (envelope-from ) id 1doq20-0001Pu-FB; Mon, 04 Sep 2017 23:59:08 +1200 Subject: Re: bug#21609: bug#24837: bug#21609: bug#24837: 26.0.50; term.el: In char mode, displayed and executed commands can differ From: Phil Sainty To: Eli Zaretskii , Philipp Stephani References: <08c3b161-174d-1fb7-5df4-bbf7f7d47ee9@orcon.net.nz> <83val1xk58.fsf@gnu.org> <6916916c-2f04-b377-7825-b5e7e98136c1@orcon.net.nz> Message-ID: Date: Mon, 4 Sep 2017 23:59:08 +1200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <6916916c-2f04-b377-7825-b5e7e98136c1@orcon.net.nz> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-GeoIP: NZ X-Spam_score: -2.9 X-Spam_score_int: -28 X-Spam_bar: -- X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 24837 Cc: 24837@debbugs.gnu.org, 21609@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On 04/09/17 21:55, Phil Sainty wrote: > We could automatically switch to term-line-mode upon mouse clicks, Actually, that's probably a non-starter -- if you paste via the mouse whilst in char mode, it is reasonable (and perhaps necessary) that the paste will execute in char mode. However the simpler approach of using the following for both pre-command and post-command hooks whilst in char mode doesn't seem awful: (unless (mouse-event-p last-command-event) (term-goto-process-mark)) Mouse events aren't inhibited, but as soon as the keyboard is involved we jump to where we're supposed to be. Potentially that's a reasonable compromise. -Phil From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 24 06:59:32 2017 Received: (at 24837) by debbugs.gnu.org; 24 Sep 2017 10:59:32 +0000 Received: from localhost ([127.0.0.1]:55221 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dw4dH-0002Rw-Vt for submit@debbugs.gnu.org; Sun, 24 Sep 2017 06:59:32 -0400 Received: from mail-oi0-f43.google.com ([209.85.218.43]:45610) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dw4dG-0002Rf-6X; Sun, 24 Sep 2017 06:59:30 -0400 Received: by mail-oi0-f43.google.com with SMTP id z73so3571687oia.2; Sun, 24 Sep 2017 03:59:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IhoWhYntowlchCaSu09kVl1SgQgImS2P/yoyCvF0ZGI=; b=Kjp/Ea0s70bqCzVoJRmy89UjXEw9j23PSBO4zH06J5sBy3ZDb7HTGsNSOTMnOxLA1n ocVVCaWuboZJscr1dgR51HNWxNq2h650pR1wSU8+5cCHzzdxufTBHXFanJ3JszTbSQyB 3A0TGJIOSlgsxxWmvfEZY7TdgQ+38CZHFVEte/8m15uXfscRsX9CrneW+jNRHTTcJ+wq 5bl7xGZoBXRrx7/IOnDQGS5R1lfRDWWLIXxjXN0tmOkr8DHm+IZGMt+HvK3Jh8tP2KYl XpCeGZZsaBWtZxiEbcScFPT9je8azJ+Uxk8/syxqSjesXdgQzulTKhU1pTwiuSryeF+H ufNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=IhoWhYntowlchCaSu09kVl1SgQgImS2P/yoyCvF0ZGI=; b=rSMNafXHlJRWwARLtp3CTd47hPvjMK4AB3GRfGibi+rW8dzU9WP8wZ7Nuwn1tPA1S9 FSMi1VSU9G0wD8164nWJZjLqv2dRqRNbvuqbbwIazaH1gHPGp+wvYS2kAx2hNbeeYaUy N6pss7HQCRyPvMcqmBelrL+ktPbAJqomTL073yP3iwGtyryHqlPYa2h577O0SYlATqlc kmDdZio4oBRfMUEd58Wd47rD+rrf9M0SNS/rSv6Utz1Wdm+3fUoLaWFSHOthUAzwh9lG 3actmK2bJztobE92wU6hZQlnTxAXQsFdL2XvAjs9SlnPi0mY0mFuOD3VsoDvvfkoOuNm T08Q== X-Gm-Message-State: AHPjjUgM+7+ojSqbaNPde3od97yh6cYCdi79hrlL2OSojx+Fytx1olae 4A2gZWZLwBxB2nb4hi497RLRpL9w5j42ULtcf+U= X-Google-Smtp-Source: AOwi7QBXJ3WbNsZQV4WD8hSv8dVJU9/C8BR5kfWe1bg9IxYGu7bBe+3GSslOldRLRy7VlNDFVN94dP9PALkwd+cZtZk= X-Received: by 10.157.15.208 with SMTP id m16mr7377otd.256.1506250764319; Sun, 24 Sep 2017 03:59:24 -0700 (PDT) MIME-Version: 1.0 References: <08c3b161-174d-1fb7-5df4-bbf7f7d47ee9@orcon.net.nz> <83val1xk58.fsf@gnu.org> In-Reply-To: From: Philipp Stephani Date: Sun, 24 Sep 2017 10:59:13 +0000 Message-ID: Subject: Re: bug#24837: 26.0.50; term.el: In char mode, displayed and executed commands can differ To: Phil Sainty , Eli Zaretskii Content-Type: multipart/alternative; boundary="001a114147d4c002ce0559ed55dc" X-Spam-Score: -2.0 (--) X-Debbugs-Envelope-To: 24837 Cc: 24837@debbugs.gnu.org, 21609@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.0 (--) --001a114147d4c002ce0559ed55dc Content-Type: text/plain; charset="UTF-8" Phil Sainty schrieb am So., 3. Sep. 2017 um 04:58 Uhr: > On 03/09/17 02:14, Eli Zaretskii wrote: > > This bug is currently one of those marked to block the release of > > Emacs 26.1. Given that it existed for quite some time, I tend to > > remove the blocking status, but if someone has practical ideas how > > to fix this, I think we should do that now. > > Well here's a starter for discussion. > > I've performed only cursory testing, but at first glance this seems > to do the trick, so I'll see what other people think... > > Firstly I'm using Philipp Stephani's suggestion that the buffer be > read-only in `term-char-mode' (and removing that in `term-line-mode'; > this code doesn't attempt to remember the pre-existing states if > the user had changed it manually). The default term process filter > `term-emulate-terminal' then binds `buffer-read-only' to nil. > > Secondly, I've added a local `post-command-hook' function in > `term-char-mode' which simply moves point back to the local process > mark position. > > Might such a simple approach be usable? I'm not very familiar with > the code, so maybe there are glaring holes that I'm not seeing. > > I haven't checked the code in detail, but it seems to be reasonable. Since nobody complained in weeks, maybe just push it to the release branch and see whether it breaks anything. --001a114147d4c002ce0559ed55dc Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


Phil S= ainty <psainty@orcon.net.nz&= gt; schrieb am So., 3. Sep. 2017 um 04:58=C2=A0Uhr:
On 03/09/17 02:14, Eli Zaretskii wrote:
> This bug is currently one of those marked to block the release of
> Emacs 26.1.=C2=A0 Given that it existed for quite some time, I tend to=
> remove the blocking status, but if someone has practical ideas how
> to fix this, I think we should do that now.

Well here's a starter for discussion.

I've performed only cursory testing, but at first glance this seems
to do the trick, so I'll see what other people think...

Firstly I'm using Philipp Stephani's suggestion that the buffer be<= br> read-only in `term-char-mode' (and removing that in `term-line-mode'= ;;
this code doesn't attempt to remember the pre-existing states if
the user had changed it manually).=C2=A0 The default term process filter `term-emulate-terminal' then binds `buffer-read-only' to nil.

Secondly, I've added a local `post-command-hook' function in
`term-char-mode' which simply moves point back to the local process
mark position.

Might such a simple approach be usable?=C2=A0 I'm not very familiar wit= h
the code, so maybe there are glaring holes that I'm not seeing.


I haven't checked the code in deta= il, but it seems to be reasonable. Since nobody complained in weeks, maybe = just push it to the release branch and see whether it breaks anything.=C2= =A0
--001a114147d4c002ce0559ed55dc-- From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 24 20:49:11 2017 Received: (at 24837) by debbugs.gnu.org; 25 Sep 2017 00:49:12 +0000 Received: from localhost ([127.0.0.1]:56869 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dwHaB-0002PR-9N for submit@debbugs.gnu.org; Sun, 24 Sep 2017 20:49:11 -0400 Received: from smtp-3.orcon.net.nz ([60.234.4.44]:36020) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dwHa8-0002P4-Lx; Sun, 24 Sep 2017 20:49:09 -0400 Received: from [150.107.172.67] (port=32313 helo=[192.168.20.102]) by smtp-3.orcon.net.nz with esmtpa (Exim 4.86_2) (envelope-from ) id 1dwHZx-0007JP-PM; Mon, 25 Sep 2017 13:49:03 +1300 Subject: Re: bug#24837: 26.0.50; term.el: In char mode, displayed and executed commands can differ To: Philipp Stephani , Eli Zaretskii References: <08c3b161-174d-1fb7-5df4-bbf7f7d47ee9@orcon.net.nz> <83val1xk58.fsf@gnu.org> From: Phil Sainty Message-ID: <1f3ce5dd-e8b0-6aee-1614-bbe0200baa95@orcon.net.nz> Date: Mon, 25 Sep 2017 13:48:57 +1300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------90934D436BADF0CC42BF6F8B" Content-Language: en-GB X-GeoIP: NZ X-Spam_score: -2.9 X-Spam_score_int: -28 X-Spam_bar: -- X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 24837 Cc: 24837@debbugs.gnu.org, 21609@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) This is a multi-part message in MIME format. --------------90934D436BADF0CC42BF6F8B Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 24/09/17 23:59, Philipp Stephani wrote: > I haven't checked the code in detail, but it seems to be reasonable. > Since nobody complained in weeks, maybe just push it to the release > branch and see whether it breaks anything. Before we do that, here's a revised patch based on my own follow-ups to my initial patch. Changes to that version are as follows: I've switched the `buffer-read-only' let-binding to `inhibit-read-only', as you had originally suggested. It looks like programatically calling `read-only-mode' was incorrect on my part, so I'm now setting `buffer-read-only' instead. I've added a `read-only-mode-hook' function to track when the user toggles the read-only state, however, so that if the user happens to enable `read-only-mode' in line mode, toggling to and from char mode will not revert their selected read-only state. Lastly I'm trying to avoid messing with mouse selection in char mode, by *not* moving point back to the process mark if the last command input event was a mouse event. So keyboard events cannot leave point in the wrong position; and while mouse events can do so, as soon as the keyboard is involved again we jump to where we're supposed to be. This still happens in post-command-hook only. Question: Is there a reason to additionally do this in pre-command-hook? I initially thought I'd need to do so, due to it now being possible for a (mouse) command to leave point in the wrong position; however I think it's probably still fine to limit this to post-command-hook? IIRC the main danger of leaving point in the wrong position is mitigated by the buffer being read-only, which ensures that the user cannot make inconsistent changes to the buffer state in char mode; and I'm assuming that inferior process output is guaranteed to happen at the process mark. (The user could invoke a command which uses inhibit-read-only to update the buffer, but that's going to introduce inconsistencies no matter where point is at the time, so I think that's out of scope.) The user might also wish to invoke a keyboard command that acts upon the mouse-selected region, so limiting ourselves to post-command-hook means we won't interfere with such a command. New patch is attached. -Phil --------------90934D436BADF0CC42BF6F8B Content-Type: text/x-patch; name="0001-Avoid-creating-inconsistent-buffer-states-in-term-ch.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Avoid-creating-inconsistent-buffer-states-in-term-ch.pa"; filename*1="tch" >From 2476e0a6aed6ba9760651df707b814046ffe45ca Mon Sep 17 00:00:00 2001 From: Phil Sainty Date: Sun, 3 Sep 2017 14:30:18 +1200 Subject: [PATCH] Avoid creating inconsistent buffer states in term-char-mode (bug#24837) * lisp/term.el (term-mode, term-char-mode, term-line-mode) (term-emulate-terminal): Make buffer read-only in `term-char-mode', except for the process filter's output. Use `read-only-mode-hook' to track and restore the user-set state of `buffer-read-only' for `term-line-mode'. term-line-mode-buffer-read-only: New variable. (term-line-mode-buffer-read-only-update): New function. (term-char-mode, term-line-mode): Use `term-goto-process-mark-maybe' in post-command-hook to counter-act unexpected changes to point. (term-goto-process-mark-maybe): New function. (term-goto-process-mark): New function. --- lisp/term.el | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/lisp/term.el b/lisp/term.el index c748c45..31c78af 100644 --- a/lisp/term.el +++ b/lisp/term.el @@ -427,6 +427,8 @@ term-old-mode-map (defvar term-old-mode-line-format) ; Saves old mode-line-format while paging. (defvar term-pager-old-local-map nil "Saves old keymap while paging.") (defvar term-pager-old-filter) ; Saved process-filter while paging. +(defvar-local term-line-mode-buffer-read-only nil + "The `buffer-read-only' state to set in `term-line-mode'.") (defcustom explicit-shell-file-name nil "If non-nil, is file name to use for explicitly requested inferior shell." @@ -1105,6 +1107,8 @@ term-mode (term-reset-size (cdr size) (car size))) size)) + (add-hook 'read-only-mode-hook #'term-line-mode-buffer-read-only-update nil t) + (easy-menu-add term-terminal-menu) (easy-menu-add term-signals-menu) (or term-input-ring @@ -1246,6 +1250,11 @@ term-char-mode (easy-menu-add term-terminal-menu) (easy-menu-add term-signals-menu) + ;; Don't allow changes to the buffer or to point which are not + ;; caused by the process filter. + (setq buffer-read-only 1) + (add-hook 'post-command-hook #'term-goto-process-mark-maybe nil t) + ;; Send existing partial line to inferior (without newline). (let ((pmark (process-mark (get-buffer-process (current-buffer)))) (save-input-sender term-input-sender)) @@ -1265,9 +1274,16 @@ term-line-mode you type \\[term-send-input] which sends the current line to the inferior." (interactive) (when (term-in-char-mode) + (setq buffer-read-only term-line-mode-buffer-read-only) + (remove-hook 'post-command-hook #'term-goto-process-mark-maybe t) (use-local-map term-old-mode-map) (term-update-mode-line))) +(defun term-line-mode-buffer-read-only-update () + "Update the user-set state of `buffer-read-only' in `term-line-mode'." + (when (term-in-line-mode) + (setq term-line-mode-buffer-read-only buffer-read-only))) + (defun term-update-mode-line () (let ((term-mode (if (term-in-char-mode) @@ -2711,6 +2727,7 @@ term-emulate-terminal count-bytes ; number of bytes decoded-substring save-point save-marker old-point temp win + (inhibit-read-only t) (buffer-undo-list t) (selected (selected-window)) last-win @@ -3109,6 +3126,21 @@ term-emulate-terminal (when (get-buffer-window (current-buffer)) (redisplay)))) +(defun term-goto-process-mark-maybe () + "Move point to the term buffer's process-mark upon keyboard input. + +Used as a buffer-local `post-command-hook' function in +`term-char-mode' to prevent commands from putting the buffer into +an inconsistent state by unexpectedly moving point. + +Mouse events are ignored so that mouse selection is unimpeded." + (unless (mouse-event-p last-command-event) + (term-goto-process-mark))) + +(defun term-goto-process-mark () + "Move point to the current process-mark for the term buffer process." + (goto-char (process-mark (get-buffer-process (current-buffer))))) + (defun term-handle-deferred-scroll () (let ((count (- (term-current-row) term-height))) (when (>= count 0) -- 2.8.3 --------------90934D436BADF0CC42BF6F8B-- From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 24 23:09:29 2017 Received: (at 24837) by debbugs.gnu.org; 25 Sep 2017 03:09:29 +0000 Received: from localhost ([127.0.0.1]:56974 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dwJlx-00007d-7j for submit@debbugs.gnu.org; Sun, 24 Sep 2017 23:09:29 -0400 Received: from smtp-2.orcon.net.nz ([60.234.4.43]:36052) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dwJlv-00007R-Ex; Sun, 24 Sep 2017 23:09:28 -0400 Received: from [10.253.37.70] (port=49730 helo=webmail.orcon.net.nz) by smtp-2.orcon.net.nz with esmtpa (Exim 4.86_2) (envelope-from ) id 1dwJlq-0006HT-5C; Mon, 25 Sep 2017 16:09:22 +1300 Received: from wlgwil-nat-office.catalyst.net.nz ([202.78.240.7]) via [10.253.37.253] by webmail.orcon.net.nz with HTTP (HTTP/1.1 POST); Mon, 25 Sep 2017 16:09:22 +1300 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 25 Sep 2017 16:09:22 +1300 From: Phil Sainty To: Philipp Stephani , Eli Zaretskii Subject: Re: bug#24837: 26.0.50; term.el: In char mode, displayed and executed commands can differ In-Reply-To: <1f3ce5dd-e8b0-6aee-1614-bbe0200baa95@orcon.net.nz> References: <08c3b161-174d-1fb7-5df4-bbf7f7d47ee9@orcon.net.nz> <83val1xk58.fsf@gnu.org> <1f3ce5dd-e8b0-6aee-1614-bbe0200baa95@orcon.net.nz> Message-ID: X-Sender: psainty@orcon.net.nz User-Agent: Orcon Webmail X-GeoIP: -- X-Spam_score: -2.9 X-Spam_score_int: -28 X-Spam_bar: -- X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 24837 Cc: 24837@debbugs.gnu.org, 21609@debbugs.gnu.org, bug-gnu-emacs X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On 2017-09-25 13:48, Phil Sainty wrote: > So keyboard events cannot leave point in the wrong position; and while > mouse events can do so, as soon as the keyboard is involved again we > jump to where we're supposed to be. Thinking on this further, it might be even better to use pre-command-hook to establish whether the pre-command position of point is equal to the process mark, and then act conditionally on that in post-command-hook, so that if the pre-command point did not already match the process mark, we do *not* forcibly move it to the process mark afterwards. The intention being that in term-char-mode: 1. Unless mouse activity takes place, a command cannot leave point in an inconsistent position. 2. The user *can* still use the mouse in char mode (e.g. to move point and/or select a region). 3. Once the user has used the mouse to move point, they may continue to invoke arbitrary commands without it being forced back to the process mark (so exchange-point-and-mark would do what they expected, for example). The buffer will still be read-only of course. 4. Upon process output, point would move back to the process mark as normal. When this happens (or if the user manually moves point to that position) the user would need to use the mouse once more to move point elsewhere. Obviously they can switch to term-line-mode at any time and do anything to the buffer, but the above would give some ability to the mouse and certain keybindings in char mode as well. -Phil From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 29 04:38:28 2017 Received: (at 24837) by debbugs.gnu.org; 29 Sep 2017 08:38:28 +0000 Received: from localhost ([127.0.0.1]:37560 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dxqoW-000730-76 for submit@debbugs.gnu.org; Fri, 29 Sep 2017 04:38:28 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57229) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dxqoU-00072e-Ka for 24837@debbugs.gnu.org; Fri, 29 Sep 2017 04:38:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxqoO-0005it-LQ for 24837@debbugs.gnu.org; Fri, 29 Sep 2017 04:38:21 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_05,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:58199) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxqo6-0005Y4-QH; Fri, 29 Sep 2017 04:38:02 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1067 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1dxqo5-0000dm-8v; Fri, 29 Sep 2017 04:38:02 -0400 Date: Fri, 29 Sep 2017 11:37:48 +0300 Message-Id: <83y3ox99yb.fsf@gnu.org> From: Eli Zaretskii To: Phil Sainty In-reply-to: (message from Phil Sainty on Mon, 25 Sep 2017 16:09:22 +1300) Subject: Re: bug#24837: 26.0.50; term.el: In char mode, displayed and executed commands can differ References: <08c3b161-174d-1fb7-5df4-bbf7f7d47ee9@orcon.net.nz> <83val1xk58.fsf@gnu.org> <1f3ce5dd-e8b0-6aee-1614-bbe0200baa95@orcon.net.nz> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 24837 Cc: p.stephani2@gmail.com, 24837@debbugs.gnu.org, 21609@debbugs.gnu.org, bug-gnu-emacs-bounces+psainty=orcon.net.nz@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > Date: Mon, 25 Sep 2017 16:09:22 +1300 > From: Phil Sainty > Cc: 24837@debbugs.gnu.org, 21609@debbugs.gnu.org, bug-gnu-emacs > > > On 2017-09-25 13:48, Phil Sainty wrote: > > So keyboard events cannot leave point in the wrong position; and while > > mouse events can do so, as soon as the keyboard is involved again we > > jump to where we're supposed to be. > > Thinking on this further, it might be even better to use > pre-command-hook > to establish whether the pre-command position of point is equal to the > process mark, and then act conditionally on that in post-command-hook, > so that if the pre-command point did not already match the process mark, > we do *not* forcibly move it to the process mark afterwards. Do you have a patch along these lines? Thanks. From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 08 08:39:59 2017 Received: (at 24837) by debbugs.gnu.org; 8 Oct 2017 12:39:59 +0000 Received: from localhost ([127.0.0.1]:55568 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1AsA-0000WE-Kx for submit@debbugs.gnu.org; Sun, 08 Oct 2017 08:39:58 -0400 Received: from smtp-3.orcon.net.nz ([60.234.4.44]:37061) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1As8-0000Vu-Kx; Sun, 08 Oct 2017 08:39:57 -0400 Received: from [150.107.172.119] (port=11199 helo=[192.168.20.102]) by smtp-3.orcon.net.nz with esmtpa (Exim 4.86_2) (envelope-from ) id 1e1Aru-0001xm-KH; Mon, 09 Oct 2017 01:39:51 +1300 Subject: Re: bug#24837: 26.0.50; term.el: In char mode, displayed and executed commands can differ To: Eli Zaretskii References: <08c3b161-174d-1fb7-5df4-bbf7f7d47ee9@orcon.net.nz> <83val1xk58.fsf@gnu.org> <1f3ce5dd-e8b0-6aee-1614-bbe0200baa95@orcon.net.nz> <83y3ox99yb.fsf@gnu.org> From: Phil Sainty Message-ID: Date: Mon, 9 Oct 2017 01:39:41 +1300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <83y3ox99yb.fsf@gnu.org> Content-Type: multipart/mixed; boundary="------------53C53F9169A2406B41D1F93B" Content-Language: en-GB X-GeoIP: NZ X-Spam_score: -2.9 X-Spam_score_int: -28 X-Spam_bar: -- X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 24837 Cc: p.stephani2@gmail.com, 24837@debbugs.gnu.org, 21609@debbugs.gnu.org, bug-gnu-emacs-bounces+psainty=orcon.net.nz@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) This is a multi-part message in MIME format. --------------53C53F9169A2406B41D1F93B Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 29/09/17 21:37, Eli Zaretskii wrote: >> On 2017-09-25 13:48, Phil Sainty wrote: >> Thinking on this further, it might be even better to use >> pre-command-hook >> to establish whether the pre-command position of point is equal to the >> process mark, and then act conditionally on that in post-command-hook, >> so that if the pre-command point did not already match the process mark, >> we do *not* forcibly move it to the process mark afterwards. > > Do you have a patch along these lines? I've found a little time to work on this some more. New patch attached, with the aforementioned changes. I think the remaining task would be to add user options to disable the new behaviours, as some users might object to them? -Phil --------------53C53F9169A2406B41D1F93B Content-Type: text/x-patch; name="0001-Avoid-creating-inconsistent-buffer-states-in-term-ch.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Avoid-creating-inconsistent-buffer-states-in-term-ch.pa"; filename*1="tch" >From 01ebb45b5e6bc22a5db55343bb6084d9a1800f2e Mon Sep 17 00:00:00 2001 From: Phil Sainty Date: Sun, 3 Sep 2017 14:30:18 +1200 Subject: [PATCH] Avoid creating inconsistent buffer states in term-char-mode (bug#24837) * lisp/term.el (term-mode, term-char-mode, term-line-mode) (term-emulate-terminal): Make buffer read-only in `term-char-mode', except for the process filter's output. Use `read-only-mode-hook' to track and restore the user-set state of `buffer-read-only' for `term-line-mode'. term-line-mode-buffer-read-only: New variable. (term-line-mode-buffer-read-only-update): New function. (term-char-mode, term-line-mode): Use `term-set-goto-process-mark' in pre-command-hook, and `term-goto-process-mark-maybe' in post-command-hook to counter-act unexpected changes to point. term-goto-process-mark: New buffer-local variable. (term-set-goto-process-mark): New function. (term-goto-process-mark-maybe): New function. (term-process-mark): New function. --- lisp/term.el | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/lisp/term.el b/lisp/term.el index c748c45..32dcb5a 100644 --- a/lisp/term.el +++ b/lisp/term.el @@ -427,6 +427,8 @@ term-old-mode-map (defvar term-old-mode-line-format) ; Saves old mode-line-format while paging. (defvar term-pager-old-local-map nil "Saves old keymap while paging.") (defvar term-pager-old-filter) ; Saved process-filter while paging. +(defvar-local term-line-mode-buffer-read-only nil + "The `buffer-read-only' state to set in `term-line-mode'.") (defcustom explicit-shell-file-name nil "If non-nil, is file name to use for explicitly requested inferior shell." @@ -1105,6 +1107,8 @@ term-mode (term-reset-size (cdr size) (car size))) size)) + (add-hook 'read-only-mode-hook #'term-line-mode-buffer-read-only-update nil t) + (easy-menu-add term-terminal-menu) (easy-menu-add term-signals-menu) (or term-input-ring @@ -1246,6 +1250,12 @@ term-char-mode (easy-menu-add term-terminal-menu) (easy-menu-add term-signals-menu) + ;; Don't allow changes to the buffer or to point which are not + ;; caused by the process filter. + (setq buffer-read-only 1) + (add-hook 'pre-command-hook #'term-set-goto-process-mark nil t) + (add-hook 'post-command-hook #'term-goto-process-mark-maybe nil t) + ;; Send existing partial line to inferior (without newline). (let ((pmark (process-mark (get-buffer-process (current-buffer)))) (save-input-sender term-input-sender)) @@ -1265,9 +1275,17 @@ term-line-mode you type \\[term-send-input] which sends the current line to the inferior." (interactive) (when (term-in-char-mode) + (setq buffer-read-only term-line-mode-buffer-read-only) + (remove-hook 'pre-command-hook #'term-set-goto-process-mark t) + (remove-hook 'post-command-hook #'term-goto-process-mark-maybe t) (use-local-map term-old-mode-map) (term-update-mode-line))) +(defun term-line-mode-buffer-read-only-update () + "Update the user-set state of `buffer-read-only' in `term-line-mode'." + (when (term-in-line-mode) + (setq term-line-mode-buffer-read-only buffer-read-only))) + (defun term-update-mode-line () (let ((term-mode (if (term-in-char-mode) @@ -2711,6 +2729,7 @@ term-emulate-terminal count-bytes ; number of bytes decoded-substring save-point save-marker old-point temp win + (inhibit-read-only t) (buffer-undo-list t) (selected (selected-window)) last-win @@ -3109,6 +3128,39 @@ term-emulate-terminal (when (get-buffer-window (current-buffer)) (redisplay)))) +(defvar-local term-goto-process-mark t + "Whether to reset point to the current process mark after each command. + +Set in `pre-command-hook' by `term-set-goto-process-mark'.") + +(defun term-set-goto-process-mark () + "Sets `term-goto-process-mark'. Called during `pre-command-hook'. + +Ensures that when point is equal to the process mark at the +pre-command stage, it will be returned to the process mark at the +post-command stage. See also `term-goto-process-mark-maybe'." + (setq term-goto-process-mark + (eq (point) (marker-position (term-process-mark))))) + +(defun term-goto-process-mark-maybe () + "Move point to the term buffer's process mark upon keyboard input. + +Used as a buffer-local `post-command-hook' function in +`term-char-mode' to prevent commands from putting the buffer into +an inconsistent state by unexpectedly moving point. + +Only acts when the pre-command position of point was equal to the +current process mark. + +Mouse events are ignored so that mouse selection is unimpeded." + (unless (mouse-event-p last-command-event) + (when term-goto-process-mark + (goto-char (term-process-mark))))) + +(defun term-process-mark () + "The current process-mark for the term buffer process." + (process-mark (get-buffer-process (current-buffer)))) + (defun term-handle-deferred-scroll () (let ((count (- (term-current-row) term-height))) (when (>= count 0) -- 2.8.3 --------------53C53F9169A2406B41D1F93B-- From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 09 10:04:37 2017 Received: (at 24837) by debbugs.gnu.org; 9 Oct 2017 14:04:37 +0000 Received: from localhost ([127.0.0.1]:58400 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1Yfa-0003rF-Oy for submit@debbugs.gnu.org; Mon, 09 Oct 2017 10:04:35 -0400 Received: from smtp-3.orcon.net.nz ([60.234.4.44]:55463) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1YfY-0003r0-6d; Mon, 09 Oct 2017 10:04:33 -0400 Received: from [150.107.172.82] (port=24761 helo=[192.168.20.102]) by smtp-3.orcon.net.nz with esmtpa (Exim 4.86_2) (envelope-from ) id 1e1YfQ-00047q-P7; Tue, 10 Oct 2017 03:04:29 +1300 Subject: Re: bug#24837: 26.0.50; term.el: In char mode, displayed and executed commands can differ From: Phil Sainty To: Eli Zaretskii References: <08c3b161-174d-1fb7-5df4-bbf7f7d47ee9@orcon.net.nz> <83val1xk58.fsf@gnu.org> <1f3ce5dd-e8b0-6aee-1614-bbe0200baa95@orcon.net.nz> <83y3ox99yb.fsf@gnu.org> Message-ID: <33aed754-b4cf-a75d-837d-14ee596613b1@orcon.net.nz> Date: Tue, 10 Oct 2017 03:04:24 +1300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------E919497974743E6A325BF413" Content-Language: en-GB X-GeoIP: NZ X-Spam_score: -2.9 X-Spam_score_int: -28 X-Spam_bar: -- X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 24837 Cc: p.stephani2@gmail.com, 24837@debbugs.gnu.org, 21609@debbugs.gnu.org, bug-gnu-emacs-bounces+psainty=orcon.net.nz@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) This is a multi-part message in MIME format. --------------E919497974743E6A325BF413 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 09/10/17 01:39, Phil Sainty wrote: > I think the remaining task would be to add user options to disable > the new behaviours, as some users might object to them? This is now done, and rebased onto the emacs-26 branch. The new user options are enabled by default, and a NEWS entry added. New patch is attached; please review. -Phil --------------E919497974743E6A325BF413 Content-Type: text/x-patch; name="0001-Avoid-creating-inconsistent-buffer-states-in-term-ch.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Avoid-creating-inconsistent-buffer-states-in-term-ch.pa"; filename*1="tch" >From ecd56a565bd4260bcd88e63b0f99cd7eeec71714 Mon Sep 17 00:00:00 2001 From: Phil Sainty Date: Sun, 3 Sep 2017 14:30:18 +1200 Subject: [PATCH] Avoid creating inconsistent buffer states in term-char-mode (bug#24837) * lisp/term.el (term-mode, term-char-mode, term-line-mode) (term-emulate-terminal): Make buffer read-only in `term-char-mode', except for the process filter's output. Use `read-only-mode-hook' to track and restore the user-set state of `buffer-read-only' for `term-line-mode'. term-char-mode-buffer-read-only: New user option. term-line-mode-buffer-read-only: New buffer-local variable. (term-line-mode-buffer-read-only-update): New function. (term-char-mode, term-line-mode): Use `term-set-goto-process-mark' in pre-command-hook, and `term-goto-process-mark-maybe' in post-command-hook to counter-act unexpected changes to point when using `term-char-mode'. term-char-mode-point-at-process-mark: New user option. term-goto-process-mark: New buffer-local variable. (term-set-goto-process-mark): New function. (term-goto-process-mark-maybe): New function. (term-process-mark): New function. * etc/NEWS: Mention the new user options. --- etc/NEWS | 12 ++++++++ lisp/term.el | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) diff --git a/etc/NEWS b/etc/NEWS index a9a4bc6..2149829 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1148,6 +1148,18 @@ languages. (Version 2.1.0 or later of Enchant is required.) +++ *** Emacs no longer prompts the user before killing Flymake processes on exit. +** Term + ++++ +*** New user options `term-char-mode-buffer-read-only' and +`term-char-mode-point-at-process-mark' are enabled by default to avoid +buffer states being created in `term-char-mode' which are inconsistent +with the terminal state expected by the inferior process. + +Respectively, these options prevent buffer changes which are not +caused by the process filter, and counter-act movements of point away +from the process mark (with the exception of mouse events). + * New Modes and Packages in Emacs 26.1 diff --git a/lisp/term.el b/lisp/term.el index c748c45..ffd0e92 100644 --- a/lisp/term.el +++ b/lisp/term.el @@ -427,6 +427,8 @@ term-old-mode-map (defvar term-old-mode-line-format) ; Saves old mode-line-format while paging. (defvar term-pager-old-local-map nil "Saves old keymap while paging.") (defvar term-pager-old-filter) ; Saved process-filter while paging. +(defvar-local term-line-mode-buffer-read-only nil + "The `buffer-read-only' state to set in `term-line-mode'.") (defcustom explicit-shell-file-name nil "If non-nil, is file name to use for explicitly requested inferior shell." @@ -487,6 +489,36 @@ term-input-ring-file-name :type 'boolean :group 'term) +(defcustom term-char-mode-buffer-read-only t + "If non-nil, only the process filter may modify the buffer in char mode. + +This makes the buffer read-only in char mode (except for the +process filter), to prevent editing commands from causing a +buffer state which is inconsistent with the state understood by +the inferior process." + :type 'boolean + :group 'term) + +(defcustom term-char-mode-point-at-process-mark t + "If non-nil, keep point at the process mark in char mode. + +This prevents commands that move point from causing a buffer +state which is inconsistent with the state understood by the +inferior process. + +Takes effect during `post-command-hook', provided that the +pre-command point position was also at the process mark. + +Mouse selection and other mouse events are ignored, so moving +point is still possible in char mode via the mouse, and other +commands can then be invoked at the mouse-selected point or +region, until the process filter (or user) moves point to the +process mark once again. + +This option has no effect in line mode." + :type 'boolean + :group 'term) + (defcustom term-scroll-to-bottom-on-output nil "Controls whether interpreter output causes window to scroll. If nil, then do not scroll. If t or `all', scroll all windows showing buffer. @@ -1105,6 +1137,8 @@ term-mode (term-reset-size (cdr size) (car size))) size)) + (add-hook 'read-only-mode-hook #'term-line-mode-buffer-read-only-update nil t) + (easy-menu-add term-terminal-menu) (easy-menu-add term-signals-menu) (or term-input-ring @@ -1246,6 +1280,13 @@ term-char-mode (easy-menu-add term-terminal-menu) (easy-menu-add term-signals-menu) + ;; Don't allow changes to the buffer or to point which are not + ;; caused by the process filter. + (when term-char-mode-buffer-read-only + (setq buffer-read-only t)) + (add-hook 'pre-command-hook #'term-set-goto-process-mark nil t) + (add-hook 'post-command-hook #'term-goto-process-mark-maybe nil t) + ;; Send existing partial line to inferior (without newline). (let ((pmark (process-mark (get-buffer-process (current-buffer)))) (save-input-sender term-input-sender)) @@ -1265,9 +1306,20 @@ term-line-mode you type \\[term-send-input] which sends the current line to the inferior." (interactive) (when (term-in-char-mode) + (when term-char-mode-buffer-read-only + (setq buffer-read-only term-line-mode-buffer-read-only)) + (remove-hook 'pre-command-hook #'term-set-goto-process-mark t) + (remove-hook 'post-command-hook #'term-goto-process-mark-maybe t) (use-local-map term-old-mode-map) (term-update-mode-line))) +(defun term-line-mode-buffer-read-only-update () + "Update the user-set state of `buffer-read-only' in `term-line-mode'. + +Called as a buffer-local `read-only-mode-hook' function." + (when (term-in-line-mode) + (setq term-line-mode-buffer-read-only buffer-read-only))) + (defun term-update-mode-line () (let ((term-mode (if (term-in-char-mode) @@ -2711,6 +2763,7 @@ term-emulate-terminal count-bytes ; number of bytes decoded-substring save-point save-marker old-point temp win + (inhibit-read-only t) (buffer-undo-list t) (selected (selected-window)) last-win @@ -3109,6 +3162,46 @@ term-emulate-terminal (when (get-buffer-window (current-buffer)) (redisplay)))) +(defvar-local term-goto-process-mark t + "Whether to reset point to the current process mark after this command. + +Set in `pre-command-hook' in char mode by `term-set-goto-process-mark'.") + +(defun term-set-goto-process-mark () + "Sets `term-goto-process-mark'. + +Always set to nil if `term-char-mode-point-at-process-mark' is nil. + +Called as a buffer-local `pre-command-hook' function in +`term-char-mode' so that when point is equal to the process mark +at the pre-command stage, we know to restore point to the process +mark at the post-command stage. + +See also `term-goto-process-mark-maybe'." + (setq term-goto-process-mark + (and term-char-mode-point-at-process-mark + (eq (point) (marker-position (term-process-mark)))))) + +(defun term-goto-process-mark-maybe () + "Move point to the term buffer's process mark upon keyboard input. + +Called as a buffer-local `post-command-hook' function in +`term-char-mode' to prevent commands from putting the buffer into +an inconsistent state by unexpectedly moving point. + +Mouse events are ignored so that mouse selection is unimpeded. + +Only acts when the pre-command position of point was equal to the +process mark, and the `term-char-mode-point-at-process-mark' +option is enabled. See `term-set-goto-process-mark'." + (when term-goto-process-mark + (unless (mouse-event-p last-command-event) + (goto-char (term-process-mark))))) + +(defun term-process-mark () + "The current `process-mark' for the term buffer process." + (process-mark (get-buffer-process (current-buffer)))) + (defun term-handle-deferred-scroll () (let ((count (- (term-current-row) term-height))) (when (>= count 0) -- 2.8.3 --------------E919497974743E6A325BF413-- From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 09 11:33:29 2017 Received: (at 24837) by debbugs.gnu.org; 9 Oct 2017 15:33:29 +0000 Received: from localhost ([127.0.0.1]:58455 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1a3c-00069H-Jj for submit@debbugs.gnu.org; Mon, 09 Oct 2017 11:33:28 -0400 Received: from eggs.gnu.org ([208.118.235.92]:52700) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1a3b-000691-98 for 24837@debbugs.gnu.org; Mon, 09 Oct 2017 11:33:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1a3R-0003gA-MS for 24837@debbugs.gnu.org; Mon, 09 Oct 2017 11:33:22 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:60300) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1a3F-0003ZF-Cy; Mon, 09 Oct 2017 11:33:05 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1075 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1e1a3E-00070K-QZ; Mon, 09 Oct 2017 11:33:05 -0400 Date: Mon, 09 Oct 2017 18:32:49 +0300 Message-Id: <83r2ucqqu6.fsf@gnu.org> From: Eli Zaretskii To: Phil Sainty In-reply-to: <33aed754-b4cf-a75d-837d-14ee596613b1@orcon.net.nz> (message from Phil Sainty on Tue, 10 Oct 2017 03:04:24 +1300) Subject: Re: bug#24837: 26.0.50; term.el: In char mode, displayed and executed commands can differ References: <08c3b161-174d-1fb7-5df4-bbf7f7d47ee9@orcon.net.nz> <83val1xk58.fsf@gnu.org> <1f3ce5dd-e8b0-6aee-1614-bbe0200baa95@orcon.net.nz> <83y3ox99yb.fsf@gnu.org> <33aed754-b4cf-a75d-837d-14ee596613b1@orcon.net.nz> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 24837 Cc: p.stephani2@gmail.com, 24837@debbugs.gnu.org, 21609@debbugs.gnu.org, bug-gnu-emacs-bounces+psainty=orcon.net.nz@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > From: Phil Sainty > Cc: p.stephani2@gmail.com, 24837@debbugs.gnu.org, 21609@debbugs.gnu.org, > bug-gnu-emacs-bounces+psainty=orcon.net.nz@gnu.org > Date: Tue, 10 Oct 2017 03:04:24 +1300 > > This is now done, and rebased onto the emacs-26 branch. The new user > options are enabled by default, and a NEWS entry added. New patch is > attached; please review. Thanks, see below. > --- a/etc/NEWS > +++ b/etc/NEWS > @@ -1148,6 +1148,18 @@ languages. (Version 2.1.0 or later of Enchant is required.) > +++ > *** Emacs no longer prompts the user before killing Flymake processes on exit. > > +** Term > + > ++++ This indication means the change is already described in the manual. But since the patch doesn't include any doc changes except NEWS, I presume you decided this shouldn't be mentioned in the manual (and I agree), so the indication should be "---" instead. > +*** New user options `term-char-mode-buffer-read-only' and > +`term-char-mode-point-at-process-mark' are enabled by default to avoid > +buffer states being created in `term-char-mode' which are inconsistent > +with the terminal state expected by the inferior process. > + > +Respectively, these options prevent buffer changes which are not > +caused by the process filter, and counter-act movements of point away > +from the process mark (with the exception of mouse events). I have a difficulty understanding why the user would like to change the values of these options from their defaults. How about revising this text to describe (a) the default behavior, and (b) when would someone want to change that by tweaking these options? > +(defcustom term-char-mode-buffer-read-only t > + "If non-nil, only the process filter may modify the buffer in char mode. > + > +This makes the buffer read-only in char mode (except for the > +process filter), to prevent editing commands from causing a > +buffer state which is inconsistent with the state understood by > +the inferior process." > + :type 'boolean > + :group 'term) > + > +(defcustom term-char-mode-point-at-process-mark t > + "If non-nil, keep point at the process mark in char mode. Same comment about the doc strings of these options. Also, please add a :version tag to these options. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Tue Oct 10 07:11:24 2017 Received: (at 24837) by debbugs.gnu.org; 10 Oct 2017 11:11:24 +0000 Received: from localhost ([127.0.0.1]:59298 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1sRY-0004jL-8y for submit@debbugs.gnu.org; Tue, 10 Oct 2017 07:11:24 -0400 Received: from smtp-3.orcon.net.nz ([60.234.4.44]:41069) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1sRV-0004j4-P7; Tue, 10 Oct 2017 07:11:22 -0400 Received: from [150.107.172.99] (port=4241 helo=[192.168.20.102]) by smtp-3.orcon.net.nz with esmtpa (Exim 4.86_2) (envelope-from ) id 1e1sRS-0006YU-5j; Wed, 11 Oct 2017 00:11:18 +1300 Subject: Re: bug#21609: bug#24837: 26.0.50; term.el: In char mode, displayed and executed commands can differ To: Eli Zaretskii References: <08c3b161-174d-1fb7-5df4-bbf7f7d47ee9@orcon.net.nz> <83val1xk58.fsf@gnu.org> <1f3ce5dd-e8b0-6aee-1614-bbe0200baa95@orcon.net.nz> <83y3ox99yb.fsf@gnu.org> <33aed754-b4cf-a75d-837d-14ee596613b1@orcon.net.nz> <83r2ucqqu6.fsf@gnu.org> From: Phil Sainty Message-ID: Date: Wed, 11 Oct 2017 00:11:17 +1300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <83r2ucqqu6.fsf@gnu.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-GeoIP: NZ X-Spam_score: -2.9 X-Spam_score_int: -28 X-Spam_bar: -- X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 24837 Cc: p.stephani2@gmail.com, 24837@debbugs.gnu.org, 21609@debbugs.gnu.org, bug-gnu-emacs-bounces+psainty=orcon.net.nz@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On 10/10/17 04:32, Eli Zaretskii wrote: >> +*** New user options `term-char-mode-buffer-read-only' and >> +`term-char-mode-point-at-process-mark' > I have a difficulty understanding why the user would like to change > the values of these options from their defaults. How about revising > this text to describe (a) the default behavior, and (b) when would > someone want to change that by tweaking these options? I'm likewise not sure whether users will *actually* want to do this. I just wanted to make sure that they had the ability to do so, in case these changes somehow interfered with their workflows (given that these are notable changes to some long-standing behaviour). I could 'demote' them to plain defvars, if we think that their use is so unlikely that they don't actually warrant being included in the customize group? In any case I'll see if I can improve the wording... -Phil From debbugs-submit-bounces@debbugs.gnu.org Tue Oct 10 08:36:22 2017 Received: (at 24837) by debbugs.gnu.org; 10 Oct 2017 12:36:22 +0000 Received: from localhost ([127.0.0.1]:59381 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1tlm-0000JC-AO for submit@debbugs.gnu.org; Tue, 10 Oct 2017 08:36:22 -0400 Received: from eggs.gnu.org ([208.118.235.92]:52274) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1tlk-0000J0-Jy for 24837@debbugs.gnu.org; Tue, 10 Oct 2017 08:36:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1tlZ-0001mL-Oh for 24837@debbugs.gnu.org; Tue, 10 Oct 2017 08:36:15 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:53033) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1tlF-0000rr-0q; Tue, 10 Oct 2017 08:35:49 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2086 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1e1tlE-0002KN-Bf; Tue, 10 Oct 2017 08:35:48 -0400 Date: Tue, 10 Oct 2017 15:35:33 +0300 Message-Id: <8360bnqiy2.fsf@gnu.org> From: Eli Zaretskii To: Phil Sainty In-reply-to: (message from Phil Sainty on Wed, 11 Oct 2017 00:11:17 +1300) Subject: Re: bug#21609: bug#24837: 26.0.50; term.el: In char mode, displayed and executed commands can differ References: <08c3b161-174d-1fb7-5df4-bbf7f7d47ee9@orcon.net.nz> <83val1xk58.fsf@gnu.org> <1f3ce5dd-e8b0-6aee-1614-bbe0200baa95@orcon.net.nz> <83y3ox99yb.fsf@gnu.org> <33aed754-b4cf-a75d-837d-14ee596613b1@orcon.net.nz> <83r2ucqqu6.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 24837 Cc: p.stephani2@gmail.com, 24837@debbugs.gnu.org, 21609@debbugs.gnu.org, bug-gnu-emacs-bounces+psainty=orcon.net.nz@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > Cc: p.stephani2@gmail.com, 24837@debbugs.gnu.org, 21609@debbugs.gnu.org, > bug-gnu-emacs-bounces+psainty=orcon.net.nz@gnu.org > From: Phil Sainty > Date: Wed, 11 Oct 2017 00:11:17 +1300 > > On 10/10/17 04:32, Eli Zaretskii wrote: > >> +*** New user options `term-char-mode-buffer-read-only' and > >> +`term-char-mode-point-at-process-mark' > > > I have a difficulty understanding why the user would like to change > > the values of these options from their defaults. How about revising > > this text to describe (a) the default behavior, and (b) when would > > someone want to change that by tweaking these options? > > I'm likewise not sure whether users will *actually* want to do this. In that case, the text should say something like Customize these options to nil if you want the previous behavior. > In any case I'll see if I can improve the wording... Thanks. From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 12 06:54:59 2017 Received: (at 24837) by debbugs.gnu.org; 12 Oct 2017 10:54:59 +0000 Received: from localhost ([127.0.0.1]:34917 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e2b8k-0001YG-JK for submit@debbugs.gnu.org; Thu, 12 Oct 2017 06:54:59 -0400 Received: from smtp-2.orcon.net.nz ([60.234.4.43]:60494) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e2b8i-0001Y1-9E; Thu, 12 Oct 2017 06:54:57 -0400 Received: from [150.107.172.86] (port=16747 helo=[192.168.20.102]) by smtp-2.orcon.net.nz with esmtpa (Exim 4.86_2) (envelope-from ) id 1e2b8V-00081R-3H; Thu, 12 Oct 2017 23:54:52 +1300 Subject: Re: bug#24837: bug#21609: bug#24837: 26.0.50; term.el: In char mode, displayed and executed commands can differ To: Eli Zaretskii References: <08c3b161-174d-1fb7-5df4-bbf7f7d47ee9@orcon.net.nz> <83val1xk58.fsf@gnu.org> <1f3ce5dd-e8b0-6aee-1614-bbe0200baa95@orcon.net.nz> <83y3ox99yb.fsf@gnu.org> <33aed754-b4cf-a75d-837d-14ee596613b1@orcon.net.nz> <83r2ucqqu6.fsf@gnu.org> <8360bnqiy2.fsf@gnu.org> From: Phil Sainty Message-ID: <3b8cac2b-4cd6-b0ef-e42a-01ef58975a01@orcon.net.nz> Date: Thu, 12 Oct 2017 23:54:42 +1300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <8360bnqiy2.fsf@gnu.org> Content-Type: multipart/mixed; boundary="------------16DAF5E862BF155606080916" Content-Language: en-GB X-GeoIP: NZ X-Spam_score: -2.9 X-Spam_score_int: -28 X-Spam_bar: -- X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 24837 Cc: p.stephani2@gmail.com, 24837@debbugs.gnu.org, 21609@debbugs.gnu.org, bug-gnu-emacs-bounces+psainty=orcon.net.nz@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) This is a multi-part message in MIME format. --------------16DAF5E862BF155606080916 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 11/10/17 01:35, Eli Zaretskii wrote: > In that case, the text should say something like > Customize these options to nil if you want the previous behavior. > >> In any case I'll see if I can improve the wording... I've revised the text for the NEWS entry and both user options. --------------16DAF5E862BF155606080916 Content-Type: text/x-patch; name="0001-Avoid-creating-inconsistent-buffer-states-in-term-ch.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Avoid-creating-inconsistent-buffer-states-in-term-ch.pa"; filename*1="tch" >From c0c1cb126dfc68a44be2b8d4b4a9350823d3d47c Mon Sep 17 00:00:00 2001 From: Phil Sainty Date: Sun, 3 Sep 2017 14:30:18 +1200 Subject: [PATCH] Avoid creating inconsistent buffer states in term-char-mode (bug#24837) * lisp/term.el (term-mode, term-char-mode, term-line-mode) (term-emulate-terminal): Make buffer read-only in `term-char-mode', except for the process filter's output. Use `read-only-mode-hook' to track and restore the user-set state of `buffer-read-only' for `term-line-mode'. term-char-mode-buffer-read-only: New user option. term-line-mode-buffer-read-only: New buffer-local variable. (term-line-mode-buffer-read-only-update): New function. (term-char-mode, term-line-mode): Use `term-set-goto-process-mark' in pre-command-hook, and `term-goto-process-mark-maybe' in post-command-hook to counter-act unexpected changes to point when using `term-char-mode'. term-char-mode-point-at-process-mark: New user option. term-goto-process-mark: New buffer-local variable. (term-set-goto-process-mark): New function. (term-goto-process-mark-maybe): New function. (term-process-mark): New function. * etc/NEWS: Mention the new behaviour and user options. --- etc/NEWS | 17 +++++++++++ lisp/term.el | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) diff --git a/etc/NEWS b/etc/NEWS index 87a82de..6b26a69 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1164,6 +1164,23 @@ provided. The old Flymake behaviour is preserved in the so-called "legacy backend", which has been updated to benefit from the new UI features. +** Term + +--- +*** `term-char-mode' now avoids buffer states which are inconsistent +with the state of the terminal understood by the inferior process. + +The buffer is made read-only to prevent changes from being made by +anything other than the process filter; and movements of point away +from the process mark are counter-acted so that the cursor is in the +correct position after each command. + +New user options `term-char-mode-buffer-read-only' and +`term-char-mode-point-at-process-mark' control these behaviours, and +are enabled by default. Customize these options to nil if you want +the previous behaviours. + + * New Modes and Packages in Emacs 26.1 diff --git a/lisp/term.el b/lisp/term.el index c748c45..2046578 100644 --- a/lisp/term.el +++ b/lisp/term.el @@ -427,6 +427,8 @@ term-old-mode-map (defvar term-old-mode-line-format) ; Saves old mode-line-format while paging. (defvar term-pager-old-local-map nil "Saves old keymap while paging.") (defvar term-pager-old-filter) ; Saved process-filter while paging. +(defvar-local term-line-mode-buffer-read-only nil + "The `buffer-read-only' state to set in `term-line-mode'.") (defcustom explicit-shell-file-name nil "If non-nil, is file name to use for explicitly requested inferior shell." @@ -487,6 +489,41 @@ term-input-ring-file-name :type 'boolean :group 'term) +(defcustom term-char-mode-buffer-read-only t + "If non-nil, only the process filter may modify the buffer in char mode. + +A non-nil value makes the buffer read-only in `term-char-mode', +which prevents editing commands from making the buffer state +inconsistent with the state of the terminal understood by the +inferior process. Only the process filter is allowed to make +changes to the buffer. + +Customize this option to nil if you want the previous behaviour." + :version "26.1" + :type 'boolean + :group 'term) + +(defcustom term-char-mode-point-at-process-mark t + "If non-nil, keep point at the process mark in char mode. + +A non-nil value causes point to be moved to the current process +mark after each command in `term-char-mode' (provided that the +pre-command point position was also at the process mark). This +prevents commands that move point from making the buffer state +inconsistent with the state of the terminal understood by the +inferior process. + +Mouse events are not affected, so moving point and selecting text +is still possible in char mode via the mouse, after which other +commands can be invoked on the mouse-selected point or region, +until the process filter (or user) moves point to the process +mark once again. + +Customize this option to nil if you want the previous behaviour." + :version "26.1" + :type 'boolean + :group 'term) + (defcustom term-scroll-to-bottom-on-output nil "Controls whether interpreter output causes window to scroll. If nil, then do not scroll. If t or `all', scroll all windows showing buffer. @@ -1105,6 +1142,8 @@ term-mode (term-reset-size (cdr size) (car size))) size)) + (add-hook 'read-only-mode-hook #'term-line-mode-buffer-read-only-update nil t) + (easy-menu-add term-terminal-menu) (easy-menu-add term-signals-menu) (or term-input-ring @@ -1246,6 +1285,13 @@ term-char-mode (easy-menu-add term-terminal-menu) (easy-menu-add term-signals-menu) + ;; Don't allow changes to the buffer or to point which are not + ;; caused by the process filter. + (when term-char-mode-buffer-read-only + (setq buffer-read-only t)) + (add-hook 'pre-command-hook #'term-set-goto-process-mark nil t) + (add-hook 'post-command-hook #'term-goto-process-mark-maybe nil t) + ;; Send existing partial line to inferior (without newline). (let ((pmark (process-mark (get-buffer-process (current-buffer)))) (save-input-sender term-input-sender)) @@ -1265,9 +1311,20 @@ term-line-mode you type \\[term-send-input] which sends the current line to the inferior." (interactive) (when (term-in-char-mode) + (when term-char-mode-buffer-read-only + (setq buffer-read-only term-line-mode-buffer-read-only)) + (remove-hook 'pre-command-hook #'term-set-goto-process-mark t) + (remove-hook 'post-command-hook #'term-goto-process-mark-maybe t) (use-local-map term-old-mode-map) (term-update-mode-line))) +(defun term-line-mode-buffer-read-only-update () + "Update the user-set state of `buffer-read-only' in `term-line-mode'. + +Called as a buffer-local `read-only-mode-hook' function." + (when (term-in-line-mode) + (setq term-line-mode-buffer-read-only buffer-read-only))) + (defun term-update-mode-line () (let ((term-mode (if (term-in-char-mode) @@ -2711,6 +2768,7 @@ term-emulate-terminal count-bytes ; number of bytes decoded-substring save-point save-marker old-point temp win + (inhibit-read-only t) (buffer-undo-list t) (selected (selected-window)) last-win @@ -3109,6 +3167,46 @@ term-emulate-terminal (when (get-buffer-window (current-buffer)) (redisplay)))) +(defvar-local term-goto-process-mark t + "Whether to reset point to the current process mark after this command. + +Set in `pre-command-hook' in char mode by `term-set-goto-process-mark'.") + +(defun term-set-goto-process-mark () + "Sets `term-goto-process-mark'. + +Always set to nil if `term-char-mode-point-at-process-mark' is nil. + +Called as a buffer-local `pre-command-hook' function in +`term-char-mode' so that when point is equal to the process mark +at the pre-command stage, we know to restore point to the process +mark at the post-command stage. + +See also `term-goto-process-mark-maybe'." + (setq term-goto-process-mark + (and term-char-mode-point-at-process-mark + (eq (point) (marker-position (term-process-mark)))))) + +(defun term-goto-process-mark-maybe () + "Move point to the term buffer's process mark upon keyboard input. + +Called as a buffer-local `post-command-hook' function in +`term-char-mode' to prevent commands from putting the buffer into +an inconsistent state by unexpectedly moving point. + +Mouse events are ignored so that mouse selection is unimpeded. + +Only acts when the pre-command position of point was equal to the +process mark, and the `term-char-mode-point-at-process-mark' +option is enabled. See `term-set-goto-process-mark'." + (when term-goto-process-mark + (unless (mouse-event-p last-command-event) + (goto-char (term-process-mark))))) + +(defun term-process-mark () + "The current `process-mark' for the term buffer process." + (process-mark (get-buffer-process (current-buffer)))) + (defun term-handle-deferred-scroll () (let ((count (- (term-current-row) term-height))) (when (>= count 0) -- 2.8.3 --------------16DAF5E862BF155606080916-- From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 12 08:05:05 2017 Received: (at 24837) by debbugs.gnu.org; 12 Oct 2017 12:05:05 +0000 Received: from localhost ([127.0.0.1]:34970 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e2cEa-0005F6-PL for submit@debbugs.gnu.org; Thu, 12 Oct 2017 08:05:04 -0400 Received: from eggs.gnu.org ([208.118.235.92]:34838) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e2cEZ-0005EM-MY for 24837@debbugs.gnu.org; Thu, 12 Oct 2017 08:05:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2cER-00049p-Cs for 24837@debbugs.gnu.org; Thu, 12 Oct 2017 08:04:58 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:41508) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2cED-00046F-Lq; Thu, 12 Oct 2017 08:04:41 -0400 Received: from [176.228.60.248] (port=1816 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1e2cED-0005mT-2O; Thu, 12 Oct 2017 08:04:41 -0400 Date: Thu, 12 Oct 2017 15:04:31 +0300 Message-Id: <838tggmv1s.fsf@gnu.org> From: Eli Zaretskii To: Phil Sainty In-reply-to: <3b8cac2b-4cd6-b0ef-e42a-01ef58975a01@orcon.net.nz> (message from Phil Sainty on Thu, 12 Oct 2017 23:54:42 +1300) Subject: Re: bug#24837: bug#21609: bug#24837: 26.0.50; term.el: In char mode, displayed and executed commands can differ References: <08c3b161-174d-1fb7-5df4-bbf7f7d47ee9@orcon.net.nz> <83val1xk58.fsf@gnu.org> <1f3ce5dd-e8b0-6aee-1614-bbe0200baa95@orcon.net.nz> <83y3ox99yb.fsf@gnu.org> <33aed754-b4cf-a75d-837d-14ee596613b1@orcon.net.nz> <83r2ucqqu6.fsf@gnu.org> <8360bnqiy2.fsf@gnu.org> <3b8cac2b-4cd6-b0ef-e42a-01ef58975a01@orcon.net.nz> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 24837 Cc: p.stephani2@gmail.com, 24837@debbugs.gnu.org, 21609@debbugs.gnu.org, bug-gnu-emacs-bounces+psainty=orcon.net.nz@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > Cc: p.stephani2@gmail.com, 24837@debbugs.gnu.org, 21609@debbugs.gnu.org, > bug-gnu-emacs-bounces+psainty=orcon.net.nz@gnu.org > From: Phil Sainty > Date: Thu, 12 Oct 2017 23:54:42 +1300 > > I've revised the text for the NEWS entry and both user options. Thanks, this is fine with me, but please in the future use the US English spelling of words such as "behavior". (No need to send another patch with that fixed this time.) I will look into pushing this in a few days, if no objections or comments surface. From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 21 04:21:27 2017 Received: (at 24837-done) by debbugs.gnu.org; 21 Oct 2017 08:21:27 +0000 Received: from localhost ([127.0.0.1]:53048 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e5p27-0005Yd-6L for submit@debbugs.gnu.org; Sat, 21 Oct 2017 04:21:27 -0400 Received: from eggs.gnu.org ([208.118.235.92]:58250) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e5p24-0005YL-RL for 24837-done@debbugs.gnu.org; Sat, 21 Oct 2017 04:21:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5p1w-0001YB-Mp for 24837-done@debbugs.gnu.org; Sat, 21 Oct 2017 04:21:19 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:51329) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5p1l-0001Sd-Bf; Sat, 21 Oct 2017 04:21:05 -0400 Received: from [176.228.60.248] (port=3468 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1e5p1k-00077I-50; Sat, 21 Oct 2017 04:21:04 -0400 Date: Sat, 21 Oct 2017 11:20:57 +0300 Message-Id: <83y3o4c3o6.fsf@gnu.org> From: Eli Zaretskii To: Phil Sainty In-reply-to: <3b8cac2b-4cd6-b0ef-e42a-01ef58975a01@orcon.net.nz> (message from Phil Sainty on Thu, 12 Oct 2017 23:54:42 +1300) Subject: Re: bug#24837: bug#21609: bug#24837: 26.0.50; term.el: In char mode, displayed and executed commands can differ References: <08c3b161-174d-1fb7-5df4-bbf7f7d47ee9@orcon.net.nz> <83val1xk58.fsf@gnu.org> <1f3ce5dd-e8b0-6aee-1614-bbe0200baa95@orcon.net.nz> <83y3ox99yb.fsf@gnu.org> <33aed754-b4cf-a75d-837d-14ee596613b1@orcon.net.nz> <83r2ucqqu6.fsf@gnu.org> <8360bnqiy2.fsf@gnu.org> <3b8cac2b-4cd6-b0ef-e42a-01ef58975a01@orcon.net.nz> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 24837-done Cc: p.stephani2@gmail.com, bug-gnu-emacs-bounces+psainty=orcon.net.nz@gnu.org, 24837-done@debbugs.gnu.org, 21609@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > Cc: p.stephani2@gmail.com, 24837@debbugs.gnu.org, 21609@debbugs.gnu.org, > bug-gnu-emacs-bounces+psainty=orcon.net.nz@gnu.org > From: Phil Sainty > Date: Thu, 12 Oct 2017 23:54:42 +1300 > > On 11/10/17 01:35, Eli Zaretskii wrote: > > In that case, the text should say something like > > Customize these options to nil if you want the previous behavior. > > > >> In any case I'll see if I can improve the wording... > > I've revised the text for the NEWS entry and both user options. Thanks, pushed to the release branch. From unknown Sun Aug 10 16:50:31 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 18 Nov 2017 12:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator