From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Allen Li Newsgroups: gmane.emacs.bugs Subject: bug#29118: 25.2.50; Undoing shell flush output results in weird state Date: Fri, 10 Nov 2017 23:20:36 -0800 Message-ID: References: <878tfe53fm.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1510384873 1610 195.159.176.226 (11 Nov 2017 07:21:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 11 Nov 2017 07:21:13 +0000 (UTC) Cc: 29118@debbugs.gnu.org To: Noam Postavsky Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Nov 11 08:21:08 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eDQ6E-0008Qw-JY for geb-bug-gnu-emacs@m.gmane.org; Sat, 11 Nov 2017 08:21:06 +0100 Original-Received: from localhost ([::1]:44686 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDQ6K-0006ho-Eu for geb-bug-gnu-emacs@m.gmane.org; Sat, 11 Nov 2017 02:21:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37409) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDQ6F-0006hf-4C for bug-gnu-emacs@gnu.org; Sat, 11 Nov 2017 02:21:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eDQ6A-0004Lj-62 for bug-gnu-emacs@gnu.org; Sat, 11 Nov 2017 02:21:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:54185) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eDQ6A-0004Lc-2O for bug-gnu-emacs@gnu.org; Sat, 11 Nov 2017 02:21:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eDQ69-00040D-L7 for bug-gnu-emacs@gnu.org; Sat, 11 Nov 2017 02:21:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Allen Li Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 11 Nov 2017 07:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29118 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 29118-submit@debbugs.gnu.org id=B29118.151038484415352 (code B ref 29118); Sat, 11 Nov 2017 07:21:01 +0000 Original-Received: (at 29118) by debbugs.gnu.org; 11 Nov 2017 07:20:44 +0000 Original-Received: from localhost ([127.0.0.1]:34633 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eDQ5r-0003zY-Op for submit@debbugs.gnu.org; Sat, 11 Nov 2017 02:20:43 -0500 Original-Received: from mail-qk0-f170.google.com ([209.85.220.170]:49885) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eDQ5q-0003zM-Cr for 29118@debbugs.gnu.org; Sat, 11 Nov 2017 02:20:42 -0500 Original-Received: by mail-qk0-f170.google.com with SMTP id w125so3668155qkb.6 for <29118@debbugs.gnu.org>; Fri, 10 Nov 2017 23:20:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=VYF2TSl5iu5+e5OF/MFAI4bjASFIOFS9giH1c8OJvbk=; b=sZZ8h4EG/HShzJHFQ20jyBUKTRvjadCLp0pxCd0NijFKv3zyB2Mi58kXRJo0jV1wew Khtl8afOVNppspITGLUEoOzF1WLdESbK092JAB7pegKSQxfCWmcKq038xGNaDxOdKli7 1E38kJsaqINDmAjabAjKByw+Pn4+MG8UQEXh507bCwRCqrUjk79HDq8Q1YFP8UgwXTuX Y1hChEqaXSngB8pePheOaOKRUo9hfMIFacx+Xm98VE7HRsI/KT1SEt1kGTn740/oyjfZ FVUbHxJ+QXKYvu1gtw3efjRXi5rGVYdi1tlmdxJLrAcQdnquV8CaMTD74fBzRwJr4cUS WfLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=VYF2TSl5iu5+e5OF/MFAI4bjASFIOFS9giH1c8OJvbk=; b=G7CVpMJ0pvO28sidrVSRzIyKZfGBwIT33iJYfICPUtptKeeIpwHS36Q7zeZL+ekcb2 t4gmtwmol4l9CjpP32HYsYJ3SU1tedek5req2kFEuot4W1oF3vSt1PHvaGhXhJ2VPGGK 1eUeZDGZFKJM6ylURiK7MzpP5PJHt/5t3s9VejpAdbpqTIvhC6nmsO1tma1Tgg5Ag/iV ChbZ3f2g2nEaWupOSQIic8Hi9zXmFD4gokagco1Il9LjmDh3ePYrqQCRg8t5i2ISej1g Sggbaez8OzKUjSyMLlukaYGJ4PQYbAMbrYf3LBES4Xb+3yhKAJVvAXzHWYzf6d+8CtZD TN+A== X-Gm-Message-State: AJaThX7pBCWn/Tmwx7voMlP+fYFDmfRCN7QYpuFzlr+8X36ke6NWobMu P4xF1PzjDBK1u3YDdrEemgjLIIJEyXIRQj7OWiE= X-Google-Smtp-Source: AGs4zMa2lvJuFA3AAh11Zwk2QH/OKQEUy8QoTaaG7dsesfkASIM9nvckAhpbIYRJwbvJDytsa5j+9puynakYhRufFiY= X-Received: by 10.55.122.135 with SMTP id v129mr4148560qkc.171.1510384837049; Fri, 10 Nov 2017 23:20:37 -0800 (PST) Original-Received: by 10.200.19.10 with HTTP; Fri, 10 Nov 2017 23:20:36 -0800 (PST) In-Reply-To: <878tfe53fm.fsf@users.sourceforge.net> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:139743 Archived-At: On Thu, Nov 9, 2017 at 5:26 PM, Noam Postavsky wrote: > found 29118 26.0.90 > tags 29118 + confirmed > quit > > Allen Li writes: > >> Repro: >> >> 1. emacs -Q >> 2. M-x shell RET >> 3. echo hi RET >> 4. C-c C-o >> 5. C-/ >> 6. echo bye RET >> >> The shell buffer ends up in a weird state that's hard to describe. > > The process mark ends up in the wrong place. That is, > > (process-mark (get-buffer-process (current-buffer))) > > gives a different answer after step 3 vs after step 5. Not really sure > why, debugging undo-list stuff is kind of a pain. Thanks. A couple of followup observations: 1. As a workaround, to fix the shell buffer, you can use comint-set-process-mark with point at where the end of the current prompt is. 2. Changing the process-mark insertion type before undoing prevents the bug: (set-marker-insertion-type (process-mark (get-buffer-process (current-buffer))) t) However, you need to set it back to nil after undoing or all user input will get inserted before process-mark. So one way to fix this would be to define a comint-undo that sets and resets the process-mark insertion type. That's probably not the most elegant solution. I think undo in general does not behave well with markers. undo will always rely on the insertion type of the markers, whereas the text to re-insert may well have been on either side of the marker. Perhaps undo should be improved to track which side of a marker deleted text was at. I think that might fix a whole class of undo-related bugs. However, this is very difficult to implement (I think, but I would be glad to be proven wrong).