GNU bug report logs - #21041
24.3; emacsclient doesn't discover ansi-term correctly

Previous Next

Package: emacs;

Reported by: Philipp Stephani <p.stephani2 <at> gmail.com>

Date: Sun, 12 Jul 2015 14:56:02 UTC

Severity: minor

Tags: fixed, patch

Merged with 22639

Found in versions 24.3, 24.5

Fixed in version 26.2

Done: Noam Postavsky <npostavs <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #10 received at control <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: Philipp Stephani <p.stephani2 <at> gmail.com>
Cc: 21041 <at> debbugs.gnu.org
Subject: Re: bug#21041: 24.3; emacsclient doesn't discover ansi-term correctly
Date: Mon, 23 Jul 2018 21:20:09 -0400
[Message part 1 (text/plain, inline)]
merge 21041 22639
tags 21041 + patch
quit

Philipp Stephani <p.stephani2 <at> gmail.com> writes:

> M-x ansi-term RET RET
> emacsclient -t
>
> Expected: emacsclient shows an error message
> Actual: Emacs frame opened inside ansi-term

And then gets stuck, as described in Bug#22639.

> term.el sets TERM to eterm-color, but emacsclient.c checks only for
> eterm (exact match).  I'd suggest to introduce more defensive checks in
> emacsclient.c:  abort whenever either TERM starts with eterm (prefix
> match) or INSIDE_EMACS is set.

I think "or" is too aggressive, "and" makes more sense.  "eterm" is
somewhat generic, there used to be a non-Emacs related terminal emulator
called that.

[0001-Fix-emacsclient-check-for-term.el-buffer-Bug-21041.patch (text/x-diff, inline)]
From d9d779ebe7d62e9ea928ead61a7c345f8eb2058a Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Mon, 23 Jul 2018 21:01:01 -0400
Subject: [PATCH] Fix emacsclient check for term.el buffer (Bug#21041)

* lib-src/emacsclient.c (find_tty): Check for any TERM value with
prefix of "eterm", not just "eterm" itself.  Also check for ",term:"
in INSIDE_EMACS value.
---
 lib-src/emacsclient.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index b139b2fe3f..b0243f99c2 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -1114,7 +1114,9 @@ find_tty (const char **tty_type, const char **tty_name, int noabort)
 	}
     }
 
-  if (strcmp (type, "eterm") == 0)
+  const char *inside_emacs = egetenv ("INSIDE_EMACS");
+  if (inside_emacs && strstr (inside_emacs, ",term:")
+      && strprefix ("eterm", type))
     {
       if (noabort)
 	return 0;
-- 
2.11.0


This bug report was last modified 6 years and 291 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.