From unknown Mon Aug 18 11:33:07 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15494: [PATCH] 24.3.50; Processes running under TRAMP can't cleanly write to the middle of a buffer Resent-From: Dima Kogan Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 30 Sep 2013 07:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 15494 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 15494@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.13805265443494 (code B ref -1); Mon, 30 Sep 2013 07:36:01 +0000 Received: (at submit) by debbugs.gnu.org; 30 Sep 2013 07:35:44 +0000 Received: from localhost ([127.0.0.1]:45543 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VQY14-0000u9-OH for submit@debbugs.gnu.org; Mon, 30 Sep 2013 03:35:43 -0400 Received: from eggs.gnu.org ([208.118.235.92]:34022) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VQY0x-0000tx-Dn for submit@debbugs.gnu.org; Mon, 30 Sep 2013 03:35:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VQY0q-0000Ko-BJ for submit@debbugs.gnu.org; Mon, 30 Sep 2013 03:35:30 -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,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:60569) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQY0q-0000Ki-6U for submit@debbugs.gnu.org; Mon, 30 Sep 2013 03:35:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35702) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQY0j-0004kT-Gd for bug-gnu-emacs@gnu.org; Mon, 30 Sep 2013 03:35:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VQY0d-0000B6-9i for bug-gnu-emacs@gnu.org; Mon, 30 Sep 2013 03:35:17 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:50551) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQY0d-0008V7-5W for bug-gnu-emacs@gnu.org; Mon, 30 Sep 2013 03:35:11 -0400 Received: from compute5.internal (compute5.nyi.mail.srv.osa [10.202.2.45]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id BD0E220F54 for ; Mon, 30 Sep 2013 03:35:06 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute5.internal (MEProxy); Mon, 30 Sep 2013 03:35:06 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=secretsauce.net; h=from:to:subject:date:message-id:mime-version:content-type; s= mesmtp; bh=uGdP8kGC3pfvK94fPQwTInaQ5y8=; b=np9YlPvIKJDp3qmPyy2Tj tQUpZVPvtFu0MS/NVF0Sw5Bzrl2YOD7YJ20v3zCtMw4nQeZOZf2frbhLfEsfBsH0 beipZy2UbKVlV649njeBQXCHe/PiA9WjE3oeJUKImLYzrXnIMiqnvg+veL7lwAgv R6rU+ILmGgWB1sasvqWjMg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=from:to:subject:date:message-id :mime-version:content-type; s=smtpout; bh=uGdP8kGC3pfvK94fPQwTIn aQ5y8=; b=Cgr0+e/S8yVoFZhiSM+gqVRHoas9ZzMIW10AWChiKhgcWGcgt3gu/5 hsJqeZLprB5Q0xxyopH0BWF9MTbFC0nZmDaagn8C+WJUUhv27oiXPCFdfiM5XGpe oDk3jAm5oA4nDFz1yyvMJM4Zmkq/LqXFC9Mha2s4UU75waBqz5LYk= X-Sasl-enc: K4BkmpeOtBldIHXi/nWp12a/NgopMg4GtC8RtdFMl3FC 1380526506 Received: from shorty.local (unknown [76.169.247.77]) by mail.messagingengine.com (Postfix) with ESMTPA id 82CE0C00E91 for ; Mon, 30 Sep 2013 03:35:06 -0400 (EDT) Received: from dima by shorty.local with local (Exim 4.80) (envelope-from ) id 1VQY0X-00007Q-1B for bug-gnu-emacs@gnu.org; Mon, 30 Sep 2013 00:35:05 -0700 From: Dima Kogan Date: Mon, 30 Sep 2013 00:35:04 -0700 Message-ID: <871u467oev.fsf@secretsauce.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 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: -5.0 (-----) --=-=-= Content-Type: text/plain Hi. I am observing that processes running over TRAMP overwrite all the buffer contents after (point). This is irrelevant in the usual case where the process output is going to the end of the buffer (there's nothing after the point in that case). This is also something that works fine with local (i.e. non-TRAMP) processes. To be clear, an example emacs invocation appears below. This populates the *scratch* buffer with a b c 1 2 3 Then moves the point to the begging of the "1 2 3" line, and runs a TRAMP process to insert the text "inserted". I would expect the *scratch* buffer to end up with a b c inserted 1 2 3 If the process runs without TRAMP, this is indeed what happens. With TRAMP, however, I get a b c inserted Note that with TRAMP the "1 2 3" line got deleted. The example invocation: $ emacs -Q \ --eval \ '(defun test-filter(process output) (with-current-buffer (process-buffer process) (insert output)))' \ --eval \ '(defun test-sentinel(process event) )' \ --eval \ '(progn (insert "a b c\n1 2 3\n") (forward-line -1) (cd "/sudo::/tmp") (let ((process (start-file-process "echo" (get-buffer "*scratch*") "echo" "inserted"))) (set-process-sentinel process `test-sentinel) (set-process-filter process `test-filter)))' This creates a process filter that simply inserts the process output, and a sentinel that does nothing. The (cd "/sudo::/tmp") form is there to force the process to run with TRAMP. Every TRAMP-based path I've tried tickles this bug for me. Removing that form makes the process run without TRAMP, and I do not see the buggy behavior then. I'm observing this issue with the latest emacs24 release and with the latest emacs built from the sources as of 2013/09/30. Emacs 23.4.1 appears to NOT have this bug. This is on a machine running Debian. I'm attaching a patch that fixes this issue for me. The cause appears to be a bit of code that deletes the system prompt from the TRAMP output. There's a bug in that code that deletes more than just the prompt in the case described above. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-TRAMP-processes-no-longer-delete-their-buffer-conten.patch >From 4af06390facb39fba2d150da296b6ede96c8cef4 Mon Sep 17 00:00:00 2001 From: Dima Kogan Date: Mon, 30 Sep 2013 00:30:28 -0700 Subject: [PATCH] TRAMP processes no longer delete their buffer contents after (point) --- lisp/net/tramp-sh.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 4bc836b..96cf9d2 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -2730,9 +2730,10 @@ the result will be a local, non-Tramp, filename." ;; We call `tramp-maybe-open-connection', in order ;; to cleanup the prompt afterwards. (catch 'suppress - (tramp-maybe-open-connection v) - (widen) - (delete-region mark (point)) + (let ((point-prompt-start (point))) + (tramp-maybe-open-connection v) + (widen) + (delete-region point-prompt-start (point))) (narrow-to-region (point-max) (point-max)) ;; Now do it. (if command -- 1.8.3.2 --=-=-=-- From unknown Mon Aug 18 11:33:07 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15494: Improved patch References: <871u467oev.fsf@secretsauce.net> In-Reply-To: <871u467oev.fsf@secretsauce.net> Resent-From: Dima Kogan Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 30 Sep 2013 07:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15494 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 15494@debbugs.gnu.org Received: via spool by 15494-submit@debbugs.gnu.org id=B15494.13805275415040 (code B ref 15494); Mon, 30 Sep 2013 07:53:01 +0000 Received: (at 15494) by debbugs.gnu.org; 30 Sep 2013 07:52:21 +0000 Received: from localhost ([127.0.0.1]:45557 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VQYHE-0001JD-SA for submit@debbugs.gnu.org; Mon, 30 Sep 2013 03:52:21 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:43712) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VQYHB-0001J4-L1 for 15494@debbugs.gnu.org; Mon, 30 Sep 2013 03:52:18 -0400 Received: from compute2.internal (compute2.nyi.mail.srv.osa [10.202.2.42]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id 8E29520E43 for <15494@debbugs.gnu.org>; Mon, 30 Sep 2013 03:52:16 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute2.internal (MEProxy); Mon, 30 Sep 2013 03:52:16 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=secretsauce.net; h=from:to:subject:date:message-id:mime-version:content-type; s= mesmtp; bh=X9gHdMspZg97E21jc3ainQMSquM=; b=S9V2Dqy0iGZr8dKuu8B1T 8B/0LuGnXaEtpEGvsBhoWxSjkP8SmxGAN72bDiWuNS4tUKCFb9ptJLtGdvhcDBSe a0oQrONJKPPDn9zbGvTk3CYcEF/dUkW4V4+cFB9sNszNwpPGPMJM3sLRrzZ8oaeD KPjBig/M0DGmoeXJkW4dyU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=from:to:subject:date:message-id :mime-version:content-type; s=smtpout; bh=X9gHdMspZg97E21jc3ainQ MSquM=; b=LLQhYIV93RGX3JxPelRxIR5EiUsV6ug6cOJIMSE43kyz0XZyjI5ui1 QlAVPmGeqcL0ob20kt9LQdzHazKyqVJMoORquSzaAOIYppIBxiMbx5yjQ4gDlMG/ U3H0QnYd0IblZwxqx1mUkihpOxb0BpbA0Xzbi2AizEcoaFLY/mhqs= X-Sasl-enc: XHK6+llRJeSHIgiFV4UAvxt1q/sYunC5T7m8Yf+Vqhjh 1380527536 Received: from shorty.local (unknown [76.169.247.77]) by mail.messagingengine.com (Postfix) with ESMTPA id 507D06800EA for <15494@debbugs.gnu.org>; Mon, 30 Sep 2013 03:52:16 -0400 (EDT) Received: from dima by shorty.local with local (Exim 4.80) (envelope-from ) id 1VQYH8-0000GA-T6 for 15494@debbugs.gnu.org; Mon, 30 Sep 2013 00:52:14 -0700 From: Dima Kogan User-agent: mu4e 0.9.9.5; emacs 24.3.50.1 Date: Mon, 30 Sep 2013 00:52:14 -0700 Message-ID: <87zjqu691t.fsf@secretsauce.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 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 (/) --=-=-= Content-Type: text/plain I'm attaching a smaller patch that solves this in a somewhat cleaner way. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-TRAMP-processes-no-longer-delete-their-buffer-conten.patch >From 5fd5f6f5fed3d5736c7a4267d2487c2dd2861d08 Mon Sep 17 00:00:00 2001 From: Dima Kogan Date: Mon, 30 Sep 2013 00:30:28 -0700 Subject: [PATCH] TRAMP processes no longer delete their buffer contents after (point) --- lisp/net/tramp-sh.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 4bc836b..81f0c97 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -2724,7 +2724,7 @@ the result will be a local, non-Tramp, filename." ;; `verify-visited-file-modtime'. (let ((buffer-undo-list t) (buffer-read-only nil) - (mark (point))) + (point-prompt-start (point-max))) (clear-visited-file-modtime) (narrow-to-region (point-max) (point-max)) ;; We call `tramp-maybe-open-connection', in order @@ -2732,7 +2732,7 @@ the result will be a local, non-Tramp, filename." (catch 'suppress (tramp-maybe-open-connection v) (widen) - (delete-region mark (point)) + (delete-region point-prompt-start (point)) (narrow-to-region (point-max) (point-max)) ;; Now do it. (if command -- 1.8.3.2 --=-=-=-- From unknown Mon Aug 18 11:33:07 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15494: [PATCH] 24.3.50; Processes running under TRAMP can't cleanly write to the middle of a buffer Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 24 Feb 2016 04:08:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15494 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Dima Kogan Cc: 15494@debbugs.gnu.org, Michael Albinus Received: via spool by 15494-submit@debbugs.gnu.org id=B15494.145628686114260 (code B ref 15494); Wed, 24 Feb 2016 04:08:01 +0000 Received: (at 15494) by debbugs.gnu.org; 24 Feb 2016 04:07:41 +0000 Received: from localhost ([127.0.0.1]:42115 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aYQjl-0003hw-L5 for submit@debbugs.gnu.org; Tue, 23 Feb 2016 23:07:41 -0500 Received: from hermes.netfonds.no ([80.91.224.195]:40033) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aYQjk-0003hp-9K for 15494@debbugs.gnu.org; Tue, 23 Feb 2016 23:07:40 -0500 Received: from cpe-60-225-211-161.nsw.bigpond.net.au ([60.225.211.161] helo=mouse) by hermes.netfonds.no with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1aYQjM-00088N-Lu; Wed, 24 Feb 2016 05:07:17 +0100 From: Lars Ingebrigtsen References: <871u467oev.fsf@secretsauce.net> Date: Wed, 24 Feb 2016 15:07:12 +1100 In-Reply-To: <871u467oev.fsf@secretsauce.net> (Dima Kogan's message of "Mon, 30 Sep 2013 00:35:04 -0700") Message-ID: <87ziuqiwen.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-MailScanner-ID: 1aYQjM-00088N-Lu X-Netfonds-MailScanner: Found to be clean X-Netfonds-MailScanner-From: larsi@gnus.org MailScanner-NULL-Check: 1456891637.43377@fPgreX2dqG3HUfc/sgaKcA X-Spam-Status: No X-Spam-Score: 0.0 (/) 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.0 (/) Dima Kogan writes: > Hi. > > I am observing that processes running over TRAMP overwrite all the > buffer contents after (point). This is irrelevant in the usual case > where the process output is going to the end of the buffer (there's > nothing after the point in that case). This is also something that works > fine with local (i.e. non-TRAMP) processes. > > To be clear, an example emacs invocation appears below. This populates > the *scratch* buffer with > > a b c > 1 2 3 > > Then moves the point to the begging of the "1 2 3" line, and runs a > TRAMP process to insert the text "inserted". I would expect the > *scratch* buffer to end up with > > a b c > inserted > 1 2 3 > > If the process runs without TRAMP, this is indeed what happens. With > TRAMP, however, I get > > a b c > inserted > > Note that with TRAMP the "1 2 3" line got deleted. The example invocation: > > $ emacs -Q \ > --eval \ > '(defun test-filter(process output) > (with-current-buffer (process-buffer process) (insert output)))' \ > --eval \ > '(defun test-sentinel(process event) > )' \ > --eval \ > '(progn > (insert "a b c\n1 2 3\n") > (forward-line -1) > (cd "/sudo::/tmp") > (let ((process (start-file-process "echo" (get-buffer "*scratch*") "echo" "inserted"))) > (set-process-sentinel process `test-sentinel) > (set-process-filter process `test-filter)))' > > This creates a process filter that simply inserts the process output, > and a sentinel that does nothing. The (cd "/sudo::/tmp") form is there > to force the process to run with TRAMP. Every TRAMP-based path I've > tried tickles this bug for me. Removing that form makes the process run > without TRAMP, and I do not see the buggy behavior then. > > I'm observing this issue with the latest emacs24 release and with the > latest emacs built from the sources as of 2013/09/30. Emacs 23.4.1 > appears to NOT have this bug. This is on a machine running Debian. > > I'm attaching a patch that fixes this issue for me. The cause appears to > be a bit of code that deletes the system prompt from the TRAMP output. > There's a bug in that code that deletes more than just the prompt in the > case described above. The patch makes sense to me. Michael? -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Mon Aug 18 11:33:07 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Dima Kogan Subject: bug#15494: closed (Re: bug#15494: [PATCH] 24.3.50; Processes running under TRAMP can't cleanly write to the middle of a buffer) Message-ID: References: <87povmtx5s.fsf@gmx.de> <871u467oev.fsf@secretsauce.net> X-Gnu-PR-Message: they-closed 15494 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 15494@debbugs.gnu.org Date: Wed, 24 Feb 2016 06:56:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1456296962-17056-1" This is a multi-part message in MIME format... ------------=_1456296962-17056-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #15494: [PATCH] 24.3.50; Processes running under TRAMP can't cleanly write = to the middle of a buffer which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 15494@debbugs.gnu.org. --=20 15494: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D15494 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1456296962-17056-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 15494-done) by debbugs.gnu.org; 24 Feb 2016 06:55:47 +0000 Received: from localhost ([127.0.0.1]:42391 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aYTMN-0004Qd-B4 for submit@debbugs.gnu.org; Wed, 24 Feb 2016 01:55:47 -0500 Received: from mout.gmx.net ([212.227.15.15]:64505) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aYTMI-0004QM-8H for 15494-done@debbugs.gnu.org; Wed, 24 Feb 2016 01:55:42 -0500 Received: from detlef.gmx.de ([87.146.60.250]) by mail.gmx.com (mrgmx002) with ESMTPSA (Nemesis) id 0M70Td-1Zkkr61l8n-00wo3F; Wed, 24 Feb 2016 07:55:29 +0100 From: Michael Albinus To: Lars Ingebrigtsen Subject: Re: bug#15494: [PATCH] 24.3.50; Processes running under TRAMP can't cleanly write to the middle of a buffer References: <871u467oev.fsf@secretsauce.net> <87ziuqiwen.fsf@gnus.org> Date: Wed, 24 Feb 2016 07:55:27 +0100 In-Reply-To: <87ziuqiwen.fsf@gnus.org> (Lars Ingebrigtsen's message of "Wed, 24 Feb 2016 15:07:12 +1100") Message-ID: <87povmtx5s.fsf@gmx.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K0:18aNW+YOH/h/nRdxPbgGpi2C6D4tQ3Joi6SBPdDREbLiG6CS0A7 2spfRaqc9IQQgZzA76MGzXsVyOje2tpG8iKvlfY6CNQslu9LiaSW6qb1jwdKgGZczK19LBl Yl+urudX7K75EvzGy2zI7FGoL38kOWyy5XA2bg9zMMtvvnZ0sq7SUibhvoug8lWYx6B2ubH 9Qjm0FEG57bvm//tLJ3fg== X-UI-Out-Filterresults: notjunk:1;V01:K0:MX2tUAxQ+No=:+FanUUshQATCuen2VMcF9x NLLaD+JM1DWBsOy+OAuZc+Jj6dvxVFd2qi2b/yrD7fm/oZwl7hRwm0cq2JC4MZTjqtB11etm9 XThF0TpYbmdIyH5unAps+M6CzPVOVVb11GXFFaBXYF7idFqe7ZxQKYGLXZ6BbAMzYdF1fCLky 3/BG7kSZL6cURqQ/4leCNh5mfMVP88B5BevZRVwvqzK3dPUwwMmAhjsD/6j2O8Slfx4zjhQrd pXB0lyG7+VYijTM+aNBfBZp6Ir+Ht7ZunoNlBY+Erw2ExPcISkeP54hSL6UBLqc3C7Fsm9D9W SzsNgoREaJIIOeQX86EAJSoIV3jpD2oGKdjxqmi853qkf5ARK4YY9IyLZlezwfuNUVK9LnvbK 0WPhd9bRDaLVSM6HANxBwP+irE3Td9eRzxYyJ8UcIQ+O3vp40R6QowEE5QezHNfAj9NNXPBOo GsRA/mHFcHUpaU6KYQev0z6FSG+DpdbIlzG1t7zpu/yvz7fakF8a1gFOpdWx3sn9yQytl93vG 04uYcm4hbFNwU9ZK50C8T9M7Jgt8ZONWnHu782qVwT05VQNjaKsbo7f7ehYTXteG1hUN/K8qs W6nIKORcgRvUi3wVeBo5Ut860+kAM/8KkHMLDaRbPOo6mxtkRWkNjH696JP6xD++cr/nEdykJ qzQqJUhaaR2oUdah4fXCHVmTIVz+pXtX0QMwS0uPJTexy/os9WXb8UK8JCbi15PahAUrFlzVv VKYV4pkethKFDqD+VoZM1hhARzaUWFJq8+sfVCUxmUJdm/FXjXHs/6K3MMd3gmxAxVsiwhidE GJafbdS X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 15494-done Cc: 15494-done@debbugs.gnu.org, Dima Kogan 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 (/) Lars Ingebrigtsen writes: Hi, >> I'm attaching a patch that fixes this issue for me. The cause appears to >> be a bit of code that deletes the system prompt from the TRAMP output. >> There's a bug in that code that deletes more than just the prompt in the >> case described above. > > The patch makes sense to me. Michael? I'm very sorry, but I've overlooked this bug report completely :-( Fortunately, there was another bug report #16120, which speaks about the same problem. And the solution is identical to what Dima proposed. It was merged into the Emacs sources back in February 2014. I'm closing this bug. Best regards, Michael. ------------=_1456296962-17056-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 30 Sep 2013 07:35:44 +0000 Received: from localhost ([127.0.0.1]:45543 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VQY14-0000u9-OH for submit@debbugs.gnu.org; Mon, 30 Sep 2013 03:35:43 -0400 Received: from eggs.gnu.org ([208.118.235.92]:34022) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VQY0x-0000tx-Dn for submit@debbugs.gnu.org; Mon, 30 Sep 2013 03:35:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VQY0q-0000Ko-BJ for submit@debbugs.gnu.org; Mon, 30 Sep 2013 03:35:30 -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,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:60569) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQY0q-0000Ki-6U for submit@debbugs.gnu.org; Mon, 30 Sep 2013 03:35:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35702) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQY0j-0004kT-Gd for bug-gnu-emacs@gnu.org; Mon, 30 Sep 2013 03:35:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VQY0d-0000B6-9i for bug-gnu-emacs@gnu.org; Mon, 30 Sep 2013 03:35:17 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:50551) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQY0d-0008V7-5W for bug-gnu-emacs@gnu.org; Mon, 30 Sep 2013 03:35:11 -0400 Received: from compute5.internal (compute5.nyi.mail.srv.osa [10.202.2.45]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id BD0E220F54 for ; Mon, 30 Sep 2013 03:35:06 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute5.internal (MEProxy); Mon, 30 Sep 2013 03:35:06 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=secretsauce.net; h=from:to:subject:date:message-id:mime-version:content-type; s= mesmtp; bh=uGdP8kGC3pfvK94fPQwTInaQ5y8=; b=np9YlPvIKJDp3qmPyy2Tj tQUpZVPvtFu0MS/NVF0Sw5Bzrl2YOD7YJ20v3zCtMw4nQeZOZf2frbhLfEsfBsH0 beipZy2UbKVlV649njeBQXCHe/PiA9WjE3oeJUKImLYzrXnIMiqnvg+veL7lwAgv R6rU+ILmGgWB1sasvqWjMg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=from:to:subject:date:message-id :mime-version:content-type; s=smtpout; bh=uGdP8kGC3pfvK94fPQwTIn aQ5y8=; b=Cgr0+e/S8yVoFZhiSM+gqVRHoas9ZzMIW10AWChiKhgcWGcgt3gu/5 hsJqeZLprB5Q0xxyopH0BWF9MTbFC0nZmDaagn8C+WJUUhv27oiXPCFdfiM5XGpe oDk3jAm5oA4nDFz1yyvMJM4Zmkq/LqXFC9Mha2s4UU75waBqz5LYk= X-Sasl-enc: K4BkmpeOtBldIHXi/nWp12a/NgopMg4GtC8RtdFMl3FC 1380526506 Received: from shorty.local (unknown [76.169.247.77]) by mail.messagingengine.com (Postfix) with ESMTPA id 82CE0C00E91 for ; Mon, 30 Sep 2013 03:35:06 -0400 (EDT) Received: from dima by shorty.local with local (Exim 4.80) (envelope-from ) id 1VQY0X-00007Q-1B for bug-gnu-emacs@gnu.org; Mon, 30 Sep 2013 00:35:05 -0700 From: Dima Kogan To: bug-gnu-emacs@gnu.org Subject: [PATCH] 24.3.50; Processes running under TRAMP can't cleanly write to the middle of a buffer Date: Mon, 30 Sep 2013 00:35:04 -0700 Message-ID: <871u467oev.fsf@secretsauce.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 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: -5.0 (-----) --=-=-= Content-Type: text/plain Hi. I am observing that processes running over TRAMP overwrite all the buffer contents after (point). This is irrelevant in the usual case where the process output is going to the end of the buffer (there's nothing after the point in that case). This is also something that works fine with local (i.e. non-TRAMP) processes. To be clear, an example emacs invocation appears below. This populates the *scratch* buffer with a b c 1 2 3 Then moves the point to the begging of the "1 2 3" line, and runs a TRAMP process to insert the text "inserted". I would expect the *scratch* buffer to end up with a b c inserted 1 2 3 If the process runs without TRAMP, this is indeed what happens. With TRAMP, however, I get a b c inserted Note that with TRAMP the "1 2 3" line got deleted. The example invocation: $ emacs -Q \ --eval \ '(defun test-filter(process output) (with-current-buffer (process-buffer process) (insert output)))' \ --eval \ '(defun test-sentinel(process event) )' \ --eval \ '(progn (insert "a b c\n1 2 3\n") (forward-line -1) (cd "/sudo::/tmp") (let ((process (start-file-process "echo" (get-buffer "*scratch*") "echo" "inserted"))) (set-process-sentinel process `test-sentinel) (set-process-filter process `test-filter)))' This creates a process filter that simply inserts the process output, and a sentinel that does nothing. The (cd "/sudo::/tmp") form is there to force the process to run with TRAMP. Every TRAMP-based path I've tried tickles this bug for me. Removing that form makes the process run without TRAMP, and I do not see the buggy behavior then. I'm observing this issue with the latest emacs24 release and with the latest emacs built from the sources as of 2013/09/30. Emacs 23.4.1 appears to NOT have this bug. This is on a machine running Debian. I'm attaching a patch that fixes this issue for me. The cause appears to be a bit of code that deletes the system prompt from the TRAMP output. There's a bug in that code that deletes more than just the prompt in the case described above. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-TRAMP-processes-no-longer-delete-their-buffer-conten.patch >From 4af06390facb39fba2d150da296b6ede96c8cef4 Mon Sep 17 00:00:00 2001 From: Dima Kogan Date: Mon, 30 Sep 2013 00:30:28 -0700 Subject: [PATCH] TRAMP processes no longer delete their buffer contents after (point) --- lisp/net/tramp-sh.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 4bc836b..96cf9d2 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -2730,9 +2730,10 @@ the result will be a local, non-Tramp, filename." ;; We call `tramp-maybe-open-connection', in order ;; to cleanup the prompt afterwards. (catch 'suppress - (tramp-maybe-open-connection v) - (widen) - (delete-region mark (point)) + (let ((point-prompt-start (point))) + (tramp-maybe-open-connection v) + (widen) + (delete-region point-prompt-start (point))) (narrow-to-region (point-max) (point-max)) ;; Now do it. (if command -- 1.8.3.2 --=-=-=-- ------------=_1456296962-17056-1--