unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Daniel Pittman <slippycheeze@google.com>
To: Michael Albinus <michael.albinus@gmx.de>
Cc: 28139@debbugs.gnu.org
Subject: bug#28139: 25.2; TRAMP vs bash 4.4 / readline 7.0 "bracketed paste" mode
Date: Mon, 13 Nov 2017 14:41:30 -0500	[thread overview]
Message-ID: <CAC45yQvcfPQRX5jHfXSCrwuypSz1yZaKD6Eb=_CVxAEOYO2UVQ@mail.gmail.com> (raw)
In-Reply-To: <87fu9srj1p.fsf@gmx.de>


[-- Attachment #1.1: Type: text/plain, Size: 1983 bytes --]

Michael, you are completely right that my previous change was not
necessary.  I blame my prehistoric knowledge of Emacs here, as I wasn't
aware of the change to use INSIDE_EMACS.  On testing, it seems that EMACS=t
just happened to work in bash (for legacy reasons, probably other dinosaurs
like me), and INSIDE_EMACS also disables editing, and fixes my problem.

You are also quite correct that INSIDE_EMACS was being set by tramp.  The
problem was that it was set at the wrong time: we need it set *before* we
start the shell, to disable readline bracketed paste (and other advanced
features) before we start, for example, interrogating the remote system for
the running version with `uname` during `tramp-open-shell`.

I have attached a patch that moves two variables, TERM and INSIDE_EMACS,
out of `tramp-remote-process-environment`, and instead, handles setting
them prior to shell execution.

This has two advantages:

First, INSIDE_EMACS is visible to the shell we are about to probe for
usability, which fixes my own problem with bracketed paste support in
libreadline / bash breaking, and which makes it uniformly available on the
remote host.

Second, changes to `tramp-terminal-type` (and the TRAMP version) are now
handled correctly without having to recompute the value of
`tramp-remote-process-environment`; previously this was not done, and a
restart or user intervention would be required to correct them.

Hopefully this meets with approval, so I append both the patch, and what I
think is the appropriate changelog entry for this, to be manually added:

2017-11-13  Daniel Pittman  <slippycheeze@google.com>

* tramp-sh.el: Set TERM and INSIDE_EMACS environment earlier.
(tramp-remote-process-environment): Remove TERM and INSIDE_EMACS.
(tramp-remote-process-environment): Document their special handling.
(tramp-open-shell): Set TERM and INSIDE_EMACS prior to starting the
initial remote shell, so that it is also aware of the environment
in which it is operating.

[-- Attachment #1.2: Type: text/html, Size: 3052 bytes --]

[-- Attachment #2: emacs-tramp-no-editing.patch --]
[-- Type: application/octet-stream, Size: 2265 bytes --]

--- 26.0.90/lisp/net/tramp-sh.el.orig	2017-11-13 13:59:24.000000000 -0500
+++ 26.0.90/lisp/net/tramp-sh.el	2017-11-13 14:38:06.000000000 -0500
@@ -533,9 +533,7 @@
 
 ;;;###tramp-autoload
 (defcustom tramp-remote-process-environment
-  `("ENV=''" "TMOUT=0" "LC_CTYPE=''"
-    ,(format "TERM=%s" tramp-terminal-type)
-    ,(format "INSIDE_EMACS='%s,tramp:%s'" emacs-version tramp-version)
+  '("ENV=''" "TMOUT=0" "LC_CTYPE=''"
     "CDPATH=" "HISTORY=" "MAIL=" "MAILCHECK=" "MAILPATH=" "PAGER=cat"
     "autocorrect=" "correct=")
   "List of environment variables to be set on the remote host.
@@ -544,8 +542,15 @@
 entry ENVVARNAME= disables the corresponding environment variable,
 which might have been set in the init files like ~/.profile.
 
-Special handling is applied to the PATH environment, which should
-not be set here. Instead, it should be set via `tramp-remote-path'."
+Special handling is applied to some environment variables,
+which should not be set here:
+
+The PATH environment variable should be set via `tramp-remote-path'.
+
+The TERM environment variable should be set via `tramp-terminal-type'.
+
+The INSIDE_EMACS environment variable will automatically be set
+based on the TRAMP and Emacs versions, and should not be set here."
   :group 'tramp
   :version "26.1"
   :type '(repeat string)
@@ -3942,9 +3947,15 @@
       ;; file clobbering $PS1.  $PROMPT_COMMAND is another way to set
       ;; the prompt in /bin/bash, it must be discarded as well.
       ;; $HISTFILE is set according to `tramp-histfile-override'.
+      ;; TERM and INSIDE_EMACS set here to ensure they have the
+      ;; correct values when the shell starts, not just processes
+      ;; run within the shell. (Which processes include our
+      ;; initial probes to ensure the remote shell is usable.)
       (tramp-send-command
        vec (format
-	    "exec env ENV=%s %s PROMPT_COMMAND='' PS1=%s PS2='' PS3='' %s %s"
+	    "exec env TERM='%s' INSIDE_EMACS='%s,tramp:%s' ENV=%s %s PROMPT_COMMAND='' PS1=%s PS2='' PS3='' %s %s"
+            tramp-terminal-type
+            emacs-version tramp-version  ; INSIDE_EMACS
             (or (getenv-internal "ENV" tramp-remote-process-environment) "")
 	    (if (stringp tramp-histfile-override)
 		(format "HISTFILE=%s"

  reply	other threads:[~2017-11-13 19:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-18 15:22 bug#28139: 25.2; TRAMP vs bash 4.4 / readline 7.0 "bracketed paste" mode Daniel Pittman
2017-08-19 17:59 ` Michael Albinus
2017-08-21 15:19   ` Daniel Pittman
2017-08-21 15:45     ` Michael Albinus
2017-08-21 16:01       ` Daniel Pittman
2017-08-21 16:17         ` Michael Albinus
2017-08-24 19:52           ` Daniel Pittman
2017-08-25  7:31             ` Michael Albinus
2017-10-31 20:40               ` Daniel Pittman
2017-11-05 12:45                 ` Michael Albinus
2017-11-13 19:41                   ` Daniel Pittman [this message]
2017-11-14 10:44                     ` Michael Albinus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAC45yQvcfPQRX5jHfXSCrwuypSz1yZaKD6Eb=_CVxAEOYO2UVQ@mail.gmail.com' \
    --to=slippycheeze@google.com \
    --cc=28139@debbugs.gnu.org \
    --cc=michael.albinus@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).