bug#21041: 24.3; emacsclient doesn't discover ansi-term correctly

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

bug#21041: 24.3; emacsclient doesn't discover ansi-term correctly

Philipp Stephani
M-x ansi-term RET RET
emacsclient -t

Expected: emacsclient shows an error message
Actual: Emacs frame opened inside ansi-term

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.

This seems to be present in the emacsclient.c in head.


In GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.10.7)
 of 2014-03-07 on lamiak, modified by Debian
System Description: Ubuntu 14.04 LTS

Configured using:
 `configure '--build' 'x86_64-linux-gnu' '--build' 'x86_64-linux-gnu'
 '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib'
 '--localstatedir=/var/lib' '--infodir=/usr/share/info'
 '--mandir=/usr/share/man' '--with-pop=yes'
 '--enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.3/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.3/site-lisp:/usr/share/emacs/site-lisp'
 '--with-crt-dir=/usr/lib/x86_64-linux-gnu' '--with-x=yes'
 '--with-x-toolkit=gtk3' '--with-toolkit-scroll-bars'
 'build_alias=x86_64-linux-gnu' 'CFLAGS=-g -O2 -fstack-protector
 --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall'
 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro'
 'CPPFLAGS=-D_FORTIFY_SOURCE=2''

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
ESC [ > 0 ; 2 5 6 ; 0 c ESC x t e r m DEL DEL DEL DEL
a n s i - t e r m RET RET e m a c s c l i e n t SPC
- t RET C-x 5 0 C-x C-c C-c C-x RET C-c C-x C-c C-c
C-g C-c C-j ESC x k i l l RET b u f TAB RET RET y e
s RET ESC x r e p o r t TAB RET

Recent messages:
("emacs")
For information about GNU Emacs and the GNU system, type C-h C-a.
call-interactively: Attempt to delete the sole visible or iconified frame
You can run the command `kill-buffer' with C-x k
error in process filter: read-event: Selecting deleted buffer
error in process filter: Selecting deleted buffer

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util
mail-prsvr mail-utils term disp-table easymenu ehelp electric ring
time-date tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment
lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer loaddefs button faces cus-face macroexp files text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind
dynamic-setting system-font-setting font-render-setting move-toolbar gtk
x-toolkit x multi-tty emacs)

--
Google Germany GmbH
Dienerstraße 12
80331 München

Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Graham Law, Christine Elizabeth Flores

Diese E-Mail ist vertraulich.  Wenn Sie nicht der richtige Adressat sind,
leiten Sie diese bitte nicht weiter, informieren Sie den Absender und löschen
Sie die E-Mail und alle Anhänge.  Vielen Dank.
       
This e-mail is confidential.  If you are not the right addressee please do not
forward it, please inform the sender, and please erase this e-mail including
any attachments.  Thanks.



Reply | Threaded
Open this post in threaded view
|

bug#21041: 24.3; emacsclient doesn't discover ansi-term correctly

Noam Postavsky
merge 21041 22639
tags 21041 + patch
quit

Philipp Stephani <[hidden email]> 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.


From d9d779ebe7d62e9ea928ead61a7c345f8eb2058a Mon Sep 17 00:00:00 2001
From: Noam Postavsky <[hidden email]>
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

Reply | Threaded
Open this post in threaded view
|

bug#21041: 24.3; emacsclient doesn't discover ansi-term correctly

Noam Postavsky
tags 21041 fixed
close 21041 26.2
quit

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

Pushed to emacs-26.

[1: 5afbf62674]: 2018-08-08 19:29:59 -0400
  Fix emacsclient check for term.el buffer (Bug#21041)
  https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=5afbf62674e741b06c01216fe37a5439e9d42307