unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#51426: 29.0.50; [PATCH] Should 'comint-term-environment' be connection-aware?
@ 2021-10-26 22:54 Jim Porter
  2021-10-27  8:20 ` Michael Albinus
  0 siblings, 1 reply; 10+ messages in thread
From: Jim Porter @ 2021-10-26 22:54 UTC (permalink / raw)
  To: 51426

[-- Attachment #1: Type: text/plain, Size: 1316 bytes --]

`comint-term-environment' consults `system-uses-terminfo' to determine 
how to set environment variables to indicate comint's terminal 
capabilities. However, `system-uses-terminfo' describes whether the host 
system running Emacs uses terminfo, not whether the remote system uses 
it. Similarly for `comint-terminfo-terminal'.

If `comint-term-environment' were aware of connection-local variables, 
it would be possible to create a connection-local profile to configure 
this for remote hosts, e.g.:

   (connection-local-set-profile-variables
    'remote-terminfo
    '((system-uses-terminfo . t)
      (comint-terminfo-terminal . "dumb-emacs-ansi")))

   (connection-local-set-profiles
    '(:application tramp :machine "foo")
    'remote-terminfo))

(Note: "dumb-emacs-ansi" comes from the ncurses-term package[1] in 
Debian, and should be a good value to represent comint's capabilities.)

This lets the user pass a terminfo-friendly value for TERM to the remote 
system, even if the local system doesn't use terminfo. Then programs on 
the remote system can consult terminfo to their hearts' content.

I've attached a patch that does this, assuming the reasoning above makes 
sense. Perhaps it also warrants an entry in NEWS? I wasn't sure...

[1] https://packages.debian.org/buster/all/ncurses-term/filelist

[-- Attachment #2: 0001-lisp-comint.el-comint-term-environment-Make-it-conne.patch --]
[-- Type: text/plain, Size: 1383 bytes --]

From f2d247b5201da01a19b87e3b17a90891a19c4c60 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Tue, 26 Oct 2021 15:18:43 -0700
Subject: [PATCH] * lisp/comint.el (comint-term-environment): Make it
 connection-aware.

---
 lisp/comint.el | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/lisp/comint.el b/lisp/comint.el
index e925b3a4b6..04e39edc42 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -889,12 +889,13 @@ comint-term-environment
   ;; and there is no way for us to define it here.
   ;; Some programs that use terminfo get very confused
   ;; if TERM is not a valid terminal type.
-  (if (and (boundp 'system-uses-terminfo) system-uses-terminfo)
-      (list (format "TERM=%s" comint-terminfo-terminal)
-            "TERMCAP="
-            (format "COLUMNS=%d" (window-width)))
-    (list "TERM=emacs"
-          (format "TERMCAP=emacs:co#%d:tc=unknown:" (window-width)))))
+  (with-connection-local-variables
+   (if (and (boundp 'system-uses-terminfo) system-uses-terminfo)
+       (list (format "TERM=%s" comint-terminfo-terminal)
+             "TERMCAP="
+             (format "COLUMNS=%d" (window-width)))
+     (list "TERM=emacs"
+           (format "TERMCAP=emacs:co#%d:tc=unknown:" (window-width))))))
 
 (defun comint-nonblank-p (str)
   "Return non-nil if STR contains non-whitespace syntax."
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* bug#51426: 29.0.50; [PATCH] Should 'comint-term-environment' be connection-aware?
  2021-10-26 22:54 bug#51426: 29.0.50; [PATCH] Should 'comint-term-environment' be connection-aware? Jim Porter
@ 2021-10-27  8:20 ` Michael Albinus
  2021-10-28  0:45   ` Jim Porter
  0 siblings, 1 reply; 10+ messages in thread
From: Michael Albinus @ 2021-10-27  8:20 UTC (permalink / raw)
  To: Jim Porter; +Cc: 51426

Jim Porter <jporterbugs@gmail.com> writes:

Hi Jim,

> `comint-term-environment' consults `system-uses-terminfo' to determine
> how to set environment variables to indicate comint's terminal
> capabilities. However, `system-uses-terminfo' describes whether the
> host system running Emacs uses terminfo, not whether the remote system
> uses it. Similarly for `comint-terminfo-terminal'.
>
> If `comint-term-environment' were aware of connection-local variables,
> it would be possible to create a connection-local profile to configure
> this for remote hosts, e.g.:
>
>   (connection-local-set-profile-variables
>    'remote-terminfo
>    '((system-uses-terminfo . t)
>      (comint-terminfo-terminal . "dumb-emacs-ansi")))
>
>   (connection-local-set-profiles
>    '(:application tramp :machine "foo")
>    'remote-terminfo))
>
> (Note: "dumb-emacs-ansi" comes from the ncurses-term package[1] in
> Debian, and should be a good value to represent comint's
> capabilities.)
>
> This lets the user pass a terminfo-friendly value for TERM to the
> remote system, even if the local system doesn't use terminfo. Then
> programs on the remote system can consult terminfo to their hearts'
> content.

Looks good to me. However, this technique must be documented
anywhere. Likely in the Emacs manual, node "Shell Options"
(file doc/emacs/misc.texi).

> I've attached a patch that does this, assuming the reasoning above
> makes sense. Perhaps it also warrants an entry in NEWS? I wasn't
> sure...

Yes, it should be said in etc/NEWS.

> diff --git a/lisp/comint.el b/lisp/comint.el
> index e925b3a4b6..04e39edc42 100644
> --- a/lisp/comint.el
> +++ b/lisp/comint.el
> @@ -889,12 +889,13 @@ comint-term-environment
>    ;; and there is no way for us to define it here.
>    ;; Some programs that use terminfo get very confused
>    ;; if TERM is not a valid terminal type.
> -  (if (and (boundp 'system-uses-terminfo) system-uses-terminfo)
> -      (list (format "TERM=%s" comint-terminfo-terminal)
> -            "TERMCAP="
> -            (format "COLUMNS=%d" (window-width)))
> -    (list "TERM=emacs"
> -          (format "TERMCAP=emacs:co#%d:tc=unknown:" (window-width)))))
> +  (with-connection-local-variables
> +   (if (and (boundp 'system-uses-terminfo) system-uses-terminfo)

According to git log, the variable system-uses-terminfo exists since

--8<---------------cut here---------------start------------->8---
commit 07c57952d8364663eb2abd979457cc880b7fd855
Author: Karl Heuer <kwzh@gnu.org>
Date:   Fri Apr 8 06:59:55 1994 +0000

    (system_uses_terminfo): New variable.
    (syms_of_term): New function, to initialize it.
--8<---------------cut here---------------end--------------->8---

I guess it is save to get rid of "(and (boundp 'system-uses-terminfo)".

Best regards, Michael.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#51426: 29.0.50; [PATCH] Should 'comint-term-environment' be connection-aware?
  2021-10-27  8:20 ` Michael Albinus
@ 2021-10-28  0:45   ` Jim Porter
  2021-10-28  8:02     ` Michael Albinus
  0 siblings, 1 reply; 10+ messages in thread
From: Jim Porter @ 2021-10-28  0:45 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 51426

[-- Attachment #1: Type: text/plain, Size: 806 bytes --]

On 10/27/2021 1:20 AM, Michael Albinus wrote:
> Looks good to me. However, this technique must be documented
> anywhere. Likely in the Emacs manual, node "Shell Options"
> (file doc/emacs/misc.texi).

Thanks. I've expanded the section about `comint-terminfo-terminal' in 
the manual to include information about how `system-uses-terminfo' works 
as well as mentioning that these variables can be declared as 
connection-local.

> Yes, it should be said in etc/NEWS.

I added a new entry too.

>> +  (with-connection-local-variables
>> +   (if (and (boundp 'system-uses-terminfo) system-uses-terminfo)
> 
> According to git log, the variable system-uses-terminfo exists since [1994.]
> I guess it is save to get rid of "(and (boundp 'system-uses-terminfo)".

Removed this.

Thanks for taking a look.

- Jim

[-- Attachment #2: 0001-Support-setting-comint-terminal-connection-locally.patch --]
[-- Type: text/plain, Size: 3545 bytes --]

From 00cb9929f6e8d97531c7a9956b451619f4ff642b Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Wed, 27 Oct 2021 14:41:54 -0700
Subject: [PATCH] Support setting comint terminal connection-locally

* lisp/comint.el (comint-term-environment): Make it connection-aware.
* doc/emacs/misc.texi (Shell Options): Document the above change, and
explain how this interacts with 'system-uses-terminfo'.
* etc/NEWS: Announce the above change.
---
 doc/emacs/misc.texi | 12 +++++++++---
 etc/NEWS            |  8 ++++++++
 lisp/comint.el      | 13 +++++++------
 3 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi
index 5123a716dc..3f8fba2155 100644
--- a/doc/emacs/misc.texi
+++ b/doc/emacs/misc.texi
@@ -1497,14 +1497,20 @@ Shell Options
 underlying shell, of course.
 
 @vindex comint-terminfo-terminal
+@vindex system-uses-terminfo
 @vindex TERM@r{, environment variable, in sub-shell}
 Comint mode sets the @env{TERM} environment variable to a safe default
 value, but this value disables some useful features.  For example,
 color is disabled in applications that use @env{TERM} to determine if
 color is supported.  Therefore, Emacs provides an option
-@code{comint-terminfo-terminal}, which you can set to a terminal that
-is present in your system's terminfo database, in order to take
-advantage of advanced features of that terminal.
+@code{comint-terminfo-terminal} to let you choose a terminal with more
+advanced features, as defined in your system's terminfo database.
+When @code{system-uses-terminfo} is non-nil, Emacs will use this
+option as the value for @env{TERM}.
+
+Both @code{comint-terminfo-terminal} and @code{system-uses-terminfo}
+can be declared as connection-local to adjust these options to match
+what a remote system expects (@pxref{Connection Variables}).
 
 @node Terminal emulator
 @subsection Emacs Terminal Emulator
diff --git a/etc/NEWS b/etc/NEWS
index c1b8adc511..2a8a3f08e7 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -183,6 +183,14 @@ To improve security, if an sql product has ':password-in-comint' set
 to t, a password supplied via the minibuffer will be sent in-process,
 as opposed to via the command-line.
 
+** Comint
+
++++
+*** 'comint-term-environment' is now aware of connection-local variables.
+The option 'comint-terminfo-terminal' and variable
+'system-uses-terminfo' can now be set as connection-local variables to
+change the terminal used on a remote host.
+
 \f
 * New Modes and Packages in Emacs 29.1
 
diff --git a/lisp/comint.el b/lisp/comint.el
index e925b3a4b6..c114bdf758 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -889,12 +889,13 @@ comint-term-environment
   ;; and there is no way for us to define it here.
   ;; Some programs that use terminfo get very confused
   ;; if TERM is not a valid terminal type.
-  (if (and (boundp 'system-uses-terminfo) system-uses-terminfo)
-      (list (format "TERM=%s" comint-terminfo-terminal)
-            "TERMCAP="
-            (format "COLUMNS=%d" (window-width)))
-    (list "TERM=emacs"
-          (format "TERMCAP=emacs:co#%d:tc=unknown:" (window-width)))))
+  (with-connection-local-variables
+   (if system-uses-terminfo
+       (list (format "TERM=%s" comint-terminfo-terminal)
+             "TERMCAP="
+             (format "COLUMNS=%d" (window-width)))
+     (list "TERM=emacs"
+           (format "TERMCAP=emacs:co#%d:tc=unknown:" (window-width))))))
 
 (defun comint-nonblank-p (str)
   "Return non-nil if STR contains non-whitespace syntax."
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* bug#51426: 29.0.50; [PATCH] Should 'comint-term-environment' be connection-aware?
  2021-10-28  0:45   ` Jim Porter
@ 2021-10-28  8:02     ` Michael Albinus
  2021-10-28 15:49       ` Jim Porter
  0 siblings, 1 reply; 10+ messages in thread
From: Michael Albinus @ 2021-10-28  8:02 UTC (permalink / raw)
  To: Jim Porter; +Cc: 51426

Jim Porter <jporterbugs@gmail.com> writes:

Hi Jim,

> Thanks. I've expanded the section about `comint-terminfo-terminal' in
> the manual to include information about how `system-uses-terminfo'
> works as well as mentioning that these variables can be declared as
> connection-local.

LGTM. Just one nit:

>  color is supported.  Therefore, Emacs provides an option
> -@code{comint-terminfo-terminal}, which you can set to a terminal that
> -is present in your system's terminfo database, in order to take
> -advantage of advanced features of that terminal.
> +@code{comint-terminfo-terminal} to let you choose a terminal with more
> +advanced features, as defined in your system's terminfo database.
> +When @code{system-uses-terminfo} is non-nil, Emacs will use this
> +option as the value for @env{TERM}.

"this option" sounds like Emacs uses system-uses-terminfo for TERM, at
least in my ears. Could you pls rephrase it a little bit?

Otherwise, it is OK. If nobody else objects, I would push it in your
name to the master branch, when you have reworded it.

> Thanks for taking a look.
>
> - Jim

Best regards, Michael.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#51426: 29.0.50; [PATCH] Should 'comint-term-environment' be connection-aware?
  2021-10-28  8:02     ` Michael Albinus
@ 2021-10-28 15:49       ` Jim Porter
  2021-10-28 16:48         ` Michael Albinus
  0 siblings, 1 reply; 10+ messages in thread
From: Jim Porter @ 2021-10-28 15:49 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 51426

[-- Attachment #1: Type: text/plain, Size: 556 bytes --]

On 10/28/2021 1:02 AM, Michael Albinus wrote:
>> +@code{comint-terminfo-terminal} to let you choose a terminal with more
>> +advanced features, as defined in your system's terminfo database.
>> +When @code{system-uses-terminfo} is non-nil, Emacs will use this
>> +option as the value for @env{TERM}.
> 
> "this option" sounds like Emacs uses system-uses-terminfo for TERM, at
> least in my ears. Could you pls rephrase it a little bit?

Looking at it again, I definitely agree. I've tried to reword it without 
making it too much more verbose. How's this?

[-- Attachment #2: 0001-Support-setting-comint-terminal-connection-locally.patch --]
[-- Type: text/plain, Size: 3550 bytes --]

From 7fe3e2b6c118508300e08da04f039d21403ff9d0 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Thu, 28 Oct 2021 08:45:15 -0700
Subject: [PATCH] Support setting comint terminal connection-locally

* lisp/comint.el (comint-term-environment): Make it connection-aware.
* doc/emacs/misc.texi (Shell Options): Document the above change, and
explain how this interacts with 'system-uses-terminfo'.
* etc/NEWS: Announce the above change.
---
 doc/emacs/misc.texi | 12 +++++++++---
 etc/NEWS            |  8 ++++++++
 lisp/comint.el      | 13 +++++++------
 3 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi
index 5123a716dc..7e7f7c5e27 100644
--- a/doc/emacs/misc.texi
+++ b/doc/emacs/misc.texi
@@ -1497,14 +1497,20 @@ Shell Options
 underlying shell, of course.
 
 @vindex comint-terminfo-terminal
+@vindex system-uses-terminfo
 @vindex TERM@r{, environment variable, in sub-shell}
 Comint mode sets the @env{TERM} environment variable to a safe default
 value, but this value disables some useful features.  For example,
 color is disabled in applications that use @env{TERM} to determine if
 color is supported.  Therefore, Emacs provides an option
-@code{comint-terminfo-terminal}, which you can set to a terminal that
-is present in your system's terminfo database, in order to take
-advantage of advanced features of that terminal.
+@code{comint-terminfo-terminal} to let you choose a terminal with more
+advanced features, as defined in your system's terminfo database.
+Emacs will use this option as the value for @env{TERM} so long as
+@code{system-uses-terminfo} is non-nil.
+
+Both @code{comint-terminfo-terminal} and @code{system-uses-terminfo}
+can be declared as connection-local to adjust these options to match
+what a remote system expects (@pxref{Connection Variables}).
 
 @node Terminal emulator
 @subsection Emacs Terminal Emulator
diff --git a/etc/NEWS b/etc/NEWS
index c1b8adc511..2a8a3f08e7 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -183,6 +183,14 @@ To improve security, if an sql product has ':password-in-comint' set
 to t, a password supplied via the minibuffer will be sent in-process,
 as opposed to via the command-line.
 
+** Comint
+
++++
+*** 'comint-term-environment' is now aware of connection-local variables.
+The option 'comint-terminfo-terminal' and variable
+'system-uses-terminfo' can now be set as connection-local variables to
+change the terminal used on a remote host.
+
 \f
 * New Modes and Packages in Emacs 29.1
 
diff --git a/lisp/comint.el b/lisp/comint.el
index e925b3a4b6..c114bdf758 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -889,12 +889,13 @@ comint-term-environment
   ;; and there is no way for us to define it here.
   ;; Some programs that use terminfo get very confused
   ;; if TERM is not a valid terminal type.
-  (if (and (boundp 'system-uses-terminfo) system-uses-terminfo)
-      (list (format "TERM=%s" comint-terminfo-terminal)
-            "TERMCAP="
-            (format "COLUMNS=%d" (window-width)))
-    (list "TERM=emacs"
-          (format "TERMCAP=emacs:co#%d:tc=unknown:" (window-width)))))
+  (with-connection-local-variables
+   (if system-uses-terminfo
+       (list (format "TERM=%s" comint-terminfo-terminal)
+             "TERMCAP="
+             (format "COLUMNS=%d" (window-width)))
+     (list "TERM=emacs"
+           (format "TERMCAP=emacs:co#%d:tc=unknown:" (window-width))))))
 
 (defun comint-nonblank-p (str)
   "Return non-nil if STR contains non-whitespace syntax."
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* bug#51426: 29.0.50; [PATCH] Should 'comint-term-environment' be connection-aware?
  2021-10-28 15:49       ` Jim Porter
@ 2021-10-28 16:48         ` Michael Albinus
  2021-10-29  5:26           ` Jim Porter
  0 siblings, 1 reply; 10+ messages in thread
From: Michael Albinus @ 2021-10-28 16:48 UTC (permalink / raw)
  To: Jim Porter; +Cc: 51426-done

Version: 29.1

Jim Porter <jporterbugs@gmail.com> writes:

Hi Jim,

> Looking at it again, I definitely agree. I've tried to reword it
> without making it too much more verbose. How's this?

Fine. I've committed this in your name to master, slightly
modified. Closing the bug.

What I'm curious about is whether we shall give more guidance using this
feature. The majority of the users don't know connection-local
variables, your example from the initial message might be instructive
for them.

WDYT?

Best regards, Michael.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#51426: 29.0.50; [PATCH] Should 'comint-term-environment' be connection-aware?
  2021-10-28 16:48         ` Michael Albinus
@ 2021-10-29  5:26           ` Jim Porter
  2021-10-29  8:21             ` Michael Albinus
  0 siblings, 1 reply; 10+ messages in thread
From: Jim Porter @ 2021-10-29  5:26 UTC (permalink / raw)
  To: 51426, michael.albinus

[-- Attachment #1: Type: text/plain, Size: 1101 bytes --]

On 10/28/2021 9:48 AM, Michael Albinus wrote:
> What I'm curious about is whether we shall give more guidance using this
> feature. The majority of the users don't know connection-local
> variables, your example from the initial message might be instructive
> for them.
> 
> WDYT?

Sure, that seems like a good idea. I expanded the example in the section 
on "Per-Connection Local Variables" to show setting 
`system-uses-terminfo'. Hopefully this will point people in the right 
direction, and make it more apparent that 
`connection-local-set-profiles' lets you set multiple profiles for a 
connection, not just one. (That's documented in the Emacs Lisp manual, 
but I think it would be helpful to show it in the Emacs manual as well.)

Perhaps it would make sense to mention this in the Tramp manual too, 
such as under the section "Running shell on a remote host". On the other 
hand, setting `system-uses-terminfo' connection-locally only applies to 
Emacs 29+, so it might make that section more confusing to include it 
there. People might expect it to work on older versions of Emacs as well.

[-- Attachment #2: 0001-Expand-the-documentation-for-connection-local-variab.patch --]
[-- Type: text/plain, Size: 2673 bytes --]

From b2ca1c7884790886142af12115c5fc5c20979a25 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Thu, 28 Oct 2021 22:14:07 -0700
Subject: [PATCH] Expand the documentation for connection local variables

* doc/emacs/custom.texi (Per-Connection Local Variables): Expand the
example to include setting 'system-uses-terminfo'.
---
 doc/emacs/custom.texi | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi
index eb30a6acc5..a158631825 100644
--- a/doc/emacs/custom.texi
+++ b/doc/emacs/custom.texi
@@ -1474,9 +1474,10 @@ Connection Variables
 
   Most of the variables reflect the situation on the local machine.
 Often, they must use a different value when you operate in buffers
-with a remote default directory.  Think about the shell to be applied
-when calling @code{shell} -- it might be @file{/bin/bash} on your
-local machine, and @file{/bin/ksh} on a remote machine.
+with a remote default directory.  Think about the behavior when
+calling @code{shell} -- on your local machine, you might use
+@file{/bin/bash} and rely on termcap, but on a remote machine, it may
+be @file{/bin/ksh} and terminfo.
 
   This can be accomplished with @dfn{connection-local variables}.
 Directory and file local variables override connection-local
@@ -1492,6 +1493,9 @@ Connection Variables
 criteria, identifying a remote machine:
 
 @example
+(connection-local-set-profile-variables 'remote-terminfo
+   '((system-uses-terminfo . t)))
+
 (connection-local-set-profile-variables 'remote-ksh
    '((shell-file-name . "/bin/ksh")
      (shell-command-switch . "-c")))
@@ -1501,13 +1505,15 @@ Connection Variables
      (shell-command-switch . "-c")))
 
 (connection-local-set-profiles
-   '(:application tramp :machine "remotemachine") 'remote-ksh)
+   '(:application tramp :machine "remotemachine")
+   'remote-terminfo 'remote-ksh)
 @end example
 
-  This code declares two different profiles, @code{remote-ksh} and
-@code{remote-bash}. The profile @code{remote-ksh} is applied to all
+  This code declares three different profiles, @code{remote-terminfo},
+@code{remote-ksh}, and @code{remote-bash}. The profiles
+@code{remote-terminfo} and @code{remote-ksh} are applied to all
 buffers which have a remote default directory matching the regexp
-@code{"remotemachine} as host name.  Such a criteria can also
+@code{"remotemachine"} as host name.  Such a criteria can also
 discriminate for the properties @code{:protocol} (this is the Tramp
 method) or @code{:user} (a remote user name).  The @code{nil} criteria
 matches all buffers with a remote default directory.
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* bug#51426: 29.0.50; [PATCH] Should 'comint-term-environment' be connection-aware?
  2021-10-29  5:26           ` Jim Porter
@ 2021-10-29  8:21             ` Michael Albinus
  2021-10-29 16:39               ` Jim Porter
  0 siblings, 1 reply; 10+ messages in thread
From: Michael Albinus @ 2021-10-29  8:21 UTC (permalink / raw)
  To: Jim Porter; +Cc: 51426

Jim Porter <jporterbugs@gmail.com> writes:

Hi Jim,

> Sure, that seems like a good idea. I expanded the example in the
> section on "Per-Connection Local Variables" to show setting
> `system-uses-terminfo'. Hopefully this will point people in the right
> direction, and make it more apparent that
> `connection-local-set-profiles' lets you set multiple profiles for a
> connection, not just one. (That's documented in the Emacs Lisp manual,
> but I think it would be helpful to show it in the Emacs manual as
> well.)

Thanks. However, you don't show the second setting,
comint-terminfo-terminal. Is it obvious to the reader that this shall be
changed as well?

> Perhaps it would make sense to mention this in the Tramp manual too,
> such as under the section "Running shell on a remote host". On the
> other hand, setting `system-uses-terminfo' connection-locally only
> applies to Emacs 29+, so it might make that section more confusing to
> include it there. People might expect it to work on older versions of
> Emacs as well.

I believe we can leave it as it is. There are other connection-local
variables, understood by Tramp, and not mentioned in the Tramp manual.

Best regards, Michael.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#51426: 29.0.50; [PATCH] Should 'comint-term-environment' be connection-aware?
  2021-10-29  8:21             ` Michael Albinus
@ 2021-10-29 16:39               ` Jim Porter
  2021-10-30 15:43                 ` Michael Albinus
  0 siblings, 1 reply; 10+ messages in thread
From: Jim Porter @ 2021-10-29 16:39 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 51426

[-- Attachment #1: Type: text/plain, Size: 1985 bytes --]

On 10/29/2021 1:21 AM, Michael Albinus wrote:
> Jim Porter <jporterbugs@gmail.com> writes:
> 
>> Sure, that seems like a good idea. I expanded the example in the
>> section on "Per-Connection Local Variables" to show setting
>> `system-uses-terminfo'. Hopefully this will point people in the right
>> direction, and make it more apparent that
>> `connection-local-set-profiles' lets you set multiple profiles for a
>> connection, not just one. (That's documented in the Emacs Lisp manual,
>> but I think it would be helpful to show it in the Emacs manual as
>> well.)
> 
> Thanks. However, you don't show the second setting,
> comint-terminfo-terminal. Is it obvious to the reader that this shall be
> changed as well?

I didn't change it initially because I wasn't sure it's a value that 
people are likely to change connection-locally. `system-uses-terminfo' 
is definitely important to be able to set connection-locally: while many 
systems support terminfo, some don't (e.g. FreeBSD and MS Windows). 
`comint-terminfo-terminal' seemed less consequential.

However, after doing a bit of archaeology, I think it might make sense 
to `comint-terminfo-terminal' connection-locally in the example, so I've 
attached an updated patch. `comint-terminfo-terminal' was only added in 
Emacs 26.1, and I believe the "dumb-emacs-ansi" terminfo file was added 
to Debian's ncurses after that, so it makes sense that someone would 
want to set this differently when connecting to a newer host vs an older 
host. (I think TERM=dumb-emacs-ansi is the best setting to use if your 
terminfo database has it, since it reflects comint's capabilities more 
accurately than TERM=dumb.)

I didn't explain the above reasoning in the manual though, since it 
won't be so relevant as time goes on. Once people see that you can do 
this, it should hopefully be reasonably obvious why. If we need more 
explanation beyond this, it probably makes sense to expand the docstring 
for `comint-terminfo-terminal'.

[-- Attachment #2: 0001-Expand-the-documentation-for-connection-local-variab.patch --]
[-- Type: text/plain, Size: 2728 bytes --]

From be23aebfd9c2e349ef73f4516520d0745e44e11e Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Thu, 28 Oct 2021 22:14:07 -0700
Subject: [PATCH] Expand the documentation for connection local variables

* doc/emacs/custom.texi (Per-Connection Local Variables): Expand the
example to include setting 'system-uses-terminfo'.
---
 doc/emacs/custom.texi | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi
index eb30a6acc5..bc70ae61c9 100644
--- a/doc/emacs/custom.texi
+++ b/doc/emacs/custom.texi
@@ -1474,9 +1474,10 @@ Connection Variables
 
   Most of the variables reflect the situation on the local machine.
 Often, they must use a different value when you operate in buffers
-with a remote default directory.  Think about the shell to be applied
-when calling @code{shell} -- it might be @file{/bin/bash} on your
-local machine, and @file{/bin/ksh} on a remote machine.
+with a remote default directory.  Think about the behavior when
+calling @code{shell} -- on your local machine, you might use
+@file{/bin/bash} and rely on termcap, but on a remote machine, it may
+be @file{/bin/ksh} and terminfo.
 
   This can be accomplished with @dfn{connection-local variables}.
 Directory and file local variables override connection-local
@@ -1492,6 +1493,10 @@ Connection Variables
 criteria, identifying a remote machine:
 
 @example
+(connection-local-set-profile-variables 'remote-terminfo
+   '((system-uses-terminfo . t)
+     (comint-terminfo-terminal . "dumb-emacs-ansi")))
+
 (connection-local-set-profile-variables 'remote-ksh
    '((shell-file-name . "/bin/ksh")
      (shell-command-switch . "-c")))
@@ -1501,13 +1506,15 @@ Connection Variables
      (shell-command-switch . "-c")))
 
 (connection-local-set-profiles
-   '(:application tramp :machine "remotemachine") 'remote-ksh)
+   '(:application tramp :machine "remotemachine")
+   'remote-terminfo 'remote-ksh)
 @end example
 
-  This code declares two different profiles, @code{remote-ksh} and
-@code{remote-bash}. The profile @code{remote-ksh} is applied to all
+  This code declares three different profiles, @code{remote-terminfo},
+@code{remote-ksh}, and @code{remote-bash}. The profiles
+@code{remote-terminfo} and @code{remote-ksh} are applied to all
 buffers which have a remote default directory matching the regexp
-@code{"remotemachine} as host name.  Such a criteria can also
+@code{"remotemachine"} as host name.  Such a criteria can also
 discriminate for the properties @code{:protocol} (this is the Tramp
 method) or @code{:user} (a remote user name).  The @code{nil} criteria
 matches all buffers with a remote default directory.
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* bug#51426: 29.0.50; [PATCH] Should 'comint-term-environment' be connection-aware?
  2021-10-29 16:39               ` Jim Porter
@ 2021-10-30 15:43                 ` Michael Albinus
  0 siblings, 0 replies; 10+ messages in thread
From: Michael Albinus @ 2021-10-30 15:43 UTC (permalink / raw)
  To: Jim Porter; +Cc: 51426

Jim Porter <jporterbugs@gmail.com> writes:

Hi Jim,

>> Thanks. However, you don't show the second setting,
>> comint-terminfo-terminal. Is it obvious to the reader that this shall be
>> changed as well?
>
> I didn't change it initially because I wasn't sure it's a value that
> people are likely to change connection-locally. `system-uses-terminfo'
> is definitely important to be able to set connection-locally: while
> many systems support terminfo, some don't (e.g. FreeBSD and MS
> Windows). `comint-terminfo-terminal' seemed less consequential.
>
> However, after doing a bit of archaeology, I think it might make sense
> to `comint-terminfo-terminal' connection-locally in the example, so
> I've attached an updated patch. `comint-terminfo-terminal' was only
> added in Emacs 26.1, and I believe the "dumb-emacs-ansi" terminfo file
> was added to Debian's ncurses after that, so it makes sense that
> someone would want to set this differently when connecting to a newer
> host vs an older host. (I think TERM=dumb-emacs-ansi is the best
> setting to use if your terminfo database has it, since it reflects
> comint's capabilities more accurately than TERM=dumb.)
>
> I didn't explain the above reasoning in the manual though, since it
> won't be so relevant as time goes on. Once people see that you can do
> this, it should hopefully be reasonably obvious why. If we need more
> explanation beyond this, it probably makes sense to expand the
> docstring for `comint-terminfo-terminal'.

Thanks. I've pushed your patch almost as-it-is to master (adding a
missing space).

Best regards, Michael.





^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-10-30 15:43 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-26 22:54 bug#51426: 29.0.50; [PATCH] Should 'comint-term-environment' be connection-aware? Jim Porter
2021-10-27  8:20 ` Michael Albinus
2021-10-28  0:45   ` Jim Porter
2021-10-28  8:02     ` Michael Albinus
2021-10-28 15:49       ` Jim Porter
2021-10-28 16:48         ` Michael Albinus
2021-10-29  5:26           ` Jim Porter
2021-10-29  8:21             ` Michael Albinus
2021-10-29 16:39               ` Jim Porter
2021-10-30 15:43                 ` Michael Albinus

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).