unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Jim Porter <jporterbugs@gmail.com>
To: Michael Albinus <michael.albinus@gmx.de>
Cc: 51426@debbugs.gnu.org
Subject: bug#51426: 29.0.50; [PATCH] Should 'comint-term-environment' be connection-aware?
Date: Wed, 27 Oct 2021 17:45:53 -0700	[thread overview]
Message-ID: <2c3dffbc-9af0-f318-15bc-cce91a106898@gmail.com> (raw)
In-Reply-To: <87cznqev5g.fsf@gmx.de>

[-- 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


  reply	other threads:[~2021-10-28  0:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=2c3dffbc-9af0-f318-15bc-cce91a106898@gmail.com \
    --to=jporterbugs@gmail.com \
    --cc=51426@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).