unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Emacs shell: set TERM to ansi instead of dumb
@ 2019-11-23 12:37 Trevor Spiteri
  2019-11-23 15:42 ` Colin Baxter
  2019-12-01 21:57 ` Juri Linkov
  0 siblings, 2 replies; 8+ messages in thread
From: Trevor Spiteri @ 2019-11-23 12:37 UTC (permalink / raw)
  To: emacs-devel

Hello,

Since the terminal for M-x shell seems to support ansi colors and cursor 
movement, would it make sense to set TERM to ansi instead of dumb? I 
currently have an init_bash.sh containing the line TERM=ansi, but it 
seems to me that it would be better for that to be the default.

Regards.

Trevor




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

* Re: Emacs shell: set TERM to ansi instead of dumb
  2019-11-23 12:37 Emacs shell: set TERM to ansi instead of dumb Trevor Spiteri
@ 2019-11-23 15:42 ` Colin Baxter
  2019-12-01 21:57 ` Juri Linkov
  1 sibling, 0 replies; 8+ messages in thread
From: Colin Baxter @ 2019-11-23 15:42 UTC (permalink / raw)
  To: Trevor Spiteri; +Cc: emacs-devel

>>>>> Trevor Spiteri <tspiteri@ieee.org> writes:

    > Hello, Since the terminal for M-x shell seems to support ansi
    > colors and cursor movement, would it make sense to set TERM to
    > ansi instead of dumb? I currently have an init_bash.sh containing
    > the line TERM=ansi, but it seems to me that it would be better for
    > that to be the default.

    > Regards.

    > Trevor

You can also get colours if you just add "TERM dumb" to your
~/.dircolors file.

Best wishes,



-- 
Colin Baxter
www.Colin-Baxter.com



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

* Re: Emacs shell: set TERM to ansi instead of dumb
  2019-11-23 12:37 Emacs shell: set TERM to ansi instead of dumb Trevor Spiteri
  2019-11-23 15:42 ` Colin Baxter
@ 2019-12-01 21:57 ` Juri Linkov
  2019-12-04  1:48   ` rrandresf
  1 sibling, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2019-12-01 21:57 UTC (permalink / raw)
  To: Trevor Spiteri; +Cc: emacs-devel

> Since the terminal for M-x shell seems to support ansi colors and cursor
> movement, would it make sense to set TERM to ansi instead of dumb? I
> currently have an init_bash.sh containing the line TERM=ansi, but it seems
> to me that it would be better for that to be the default.

Thanks for suggestion.  I tried to use "TERM=ansi" together with
customizing 'comint-terminfo-terminal' to "ansi", and it works fine
everywhere, except compilation mode.  In compilation buffers
it inserts unhandled escape sequences that break fontification.
Had to disable ansi in compilation by customizing
'compilation-environment' to '("TERM=dumb")'.



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

* Re: Emacs shell: set TERM to ansi instead of dumb
  2019-12-01 21:57 ` Juri Linkov
@ 2019-12-04  1:48   ` rrandresf
  2019-12-04 22:41     ` Juri Linkov
  0 siblings, 1 reply; 8+ messages in thread
From: rrandresf @ 2019-12-04  1:48 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Trevor Spiteri, emacs-devel

Hi Juri.

Juri> Thanks for suggestion.  I tried to use "TERM=ansi" together with
Juri> customizing 'comint-terminfo-terminal' to "ansi", and it works
Juri> fine everywhere, except compilation mode.  In compilation
Juri> buffers it inserts unhandled escape sequences that break
Juri> fontification.  Had to disable ansi in compilation by
Juri> customizing 'compilation-environment' to '("TERM=dumb")'.

I am still seeing the "unhandled escape sequences" on "*compilation*"
buffer see:
--8<---------------cut here---------------start------------->8---
-*- mode: compilation; default-directory: "/ssh:aramirez@x220c:/home/aramirez/dev/wxwidgets/mamacha/src/tests/build/" -*-
Compilation started at Wed Dec  4 01:34:34

cd build && make -k -j4   && cd -
[35m[1mScanning dependencies of target invcross_tests[0m
make: Target 'default_target' not remade because of errors.
...
Compilation exited abnormally with code 2 at Wed Dec  4 01:34:36
--8<---------------cut here---------------end--------------->8---

BTW, above is compilation by tramp.

Those were my customizations:
--8<---------------cut here---------------start------------->8---
(progn (setq comint-terminfo-terminal "ansi") (add-to-list 'compilation-environment "TERM=dumb"))
--8<---------------cut here---------------end--------------->8---

Is there something else. I should customize?

BR
ps: probably the escape sequences are going to be replaced when sending
email. In that case https://termbin.com/41th



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

* Re: Emacs shell: set TERM to ansi instead of dumb
  2019-12-04  1:48   ` rrandresf
@ 2019-12-04 22:41     ` Juri Linkov
  2019-12-05  0:11       ` tramp compilation buffer also affected (was: Emacs shell: set TERM to ansi instead of dumb) andrés ramírez
  0 siblings, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2019-12-04 22:41 UTC (permalink / raw)
  To: rrandresf; +Cc: Trevor Spiteri, emacs-devel

> cd build && make -k -j4   && cd -
> [35m[1mScanning dependencies of target invcross_tests[0m
> make: Target 'default_target' not remade because of errors.
> ...
> Compilation exited abnormally with code 2 at Wed Dec  4 01:34:36
>
>
> BTW, above is compilation by tramp.
>
> Those were my customizations:
>
> (progn (setq comint-terminfo-terminal "ansi") (add-to-list 'compilation-environment "TERM=dumb"))
>
> Is there something else. I should customize?

Please try to add "TERM=dumb" to 'tramp-remote-process-environment'.



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

* tramp compilation buffer also affected (was: Emacs shell: set TERM to ansi instead of dumb)
  2019-12-04 22:41     ` Juri Linkov
@ 2019-12-05  0:11       ` andrés ramírez
  2019-12-08 21:33         ` tramp compilation buffer also affected Juri Linkov
  0 siblings, 1 reply; 8+ messages in thread
From: andrés ramírez @ 2019-12-05  0:11 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Trevor Spiteri, emacs-devel

Hi Juri.

Juri> Please try to add "TERM=dumb" to
Juri> 'tramp-remote-process-environment'.

Same issue after adding the item to the list:
--8<---------------cut here---------------start------------->8---
-*- mode: compilation; default-directory: "/ssh:aramirez@x220c:/home/olla/dev/wxwidgets/mamacha/src/tests/build/" -*-
Compilation started at Thu Dec  5 00:03:36

cd build && make -k -j4 && cd -
[  0%] [32mBuilding C object CMakeFiles/invcross_tests.dir/test_runner.c.o[0m
[100%] [32m[1mLinking C executable ../invcross_tests[0m
[100%] Built target invcross_tests
/home/olla/dev/wxwidgets/mamacha/src/tests

Compilation finished at Thu Dec  5 00:03:43
--8<---------------cut here---------------end--------------->8---

BTW: I also did (tramp-cleanup-this-connection, tramp-cleanup-all-buffers)
AR



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

* Re: tramp compilation buffer also affected
  2019-12-05  0:11       ` tramp compilation buffer also affected (was: Emacs shell: set TERM to ansi instead of dumb) andrés ramírez
@ 2019-12-08 21:33         ` Juri Linkov
  2019-12-09  5:54           ` andrés ramírez
  0 siblings, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2019-12-08 21:33 UTC (permalink / raw)
  To: andrés ramírez; +Cc: Trevor Spiteri, emacs-devel

> BTW: I also did (tramp-cleanup-this-connection, tramp-cleanup-all-buffers)

Actually, tramp-cleanup-... don't update the existing process-environment.
You need restart Emacs after customizing tramp-remote-process-environment.

It's easier to check whether TERM has the right value in Tramp by simply:

  M-x compile RET
  echo $TERM
  RET

For testing compilation highlighting, I just touch xterm.c and compile it,
because compilation of xterm.o always produces warnings:

  M-x compile RET
  touch xterm.c; TERM=ansi make xterm.o
  RET

It produces unhandled escape sequences in the compilation output buffer:

  touch xterm.c; TERM=ansi make xterm.o
    GEN      globals.h
    CC       xterm.o
  ^[[01m^[[Kxterm.c:^[[m^[[K In function '^[[01m^[[Kx_parse_color^[[m^[[K':
  ^[[01m^[[Kxterm.c:2425:61:^[[m^[[K ^[[01;35m^[[Kwarning: ^[[m^[[K'^[[01m^[[K%.*s^[[m^[[K' directive output may be truncated writing up to 2147483647 bytes into a region of size 28 [^[[01;35m^[[K-Wformat-truncation=^[[m^[[K]
         snprintf (rgb_color_name, sizeof rgb_color_name, "rgb:^[[01;35m^[[K%.*s^[[m^[[K/%.*s/%.*s",
                                                               ^[[01;35m^[[K^~~~^[[m^[[K
  ^[[01m^[[Kxterm.c:2425:56:^[[m^[[K ^[[01;36m^[[Knote: ^[[m^[[Kassuming directive output of 1 byte
         snprintf (rgb_color_name, sizeof rgb_color_name, ^[[01;36m^[[K"rgb:%.*s/%.*s/%.*s"^[[m^[[K,
                                                          ^[[01;36m^[[K^~~~~~~~~~~~~~~~~~~~^[[m^[[K
  ^[[01m^[[Kxterm.c:2425:56:^[[m^[[K ^[[01;36m^[[Knote: ^[[m^[[Kassuming directive output of 1 byte
  ^[[01m^[[Kxterm.c:2425:56:^[[m^[[K ^[[01;36m^[[Knote: ^[[m^[[Kassuming directive output of 1 byte
  ^[[01m^[[Kxterm.c:2425:7:^[[m^[[K ^[[01;36m^[[Knote: ^[[m^[[K'^[[01m^[[Ksnprintf^[[m^[[K' output between 7 and 6442450948 bytes into a destination of size 32
         ^[[01;36m^[[Ksnprintf (rgb_color_name, sizeof rgb_color_name, "rgb:%.*s/%.*s/%.*s",^[[m^[[K
         ^[[01;36m^[[K^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^[[m^[[K
   ^[[01;36m^[[K  digits_per_channel, color_name + 1,^[[m^[[K
     ^[[01;36m^[[K~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^[[m^[[K
   ^[[01;36m^[[K  digits_per_channel, color_name + digits_per_channel + 1,^[[m^[[K
     ^[[01;36m^[[K~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^[[m^[[K
   ^[[01;36m^[[K  digits_per_channel, color_name + 2 * digits_per_channel + 1)^[[m^[[K;
     ^[[01;36m^[[K~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^[[m^[[K

But running compile with a prefix arg processes escape sequences and produces
nice output even when Tramp process-environment is not customized:

  C-u M-x compile RET
  touch xterm.c; TERM=ansi make xterm.o
  RET



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

* Re: tramp compilation buffer also affected
  2019-12-08 21:33         ` tramp compilation buffer also affected Juri Linkov
@ 2019-12-09  5:54           ` andrés ramírez
  0 siblings, 0 replies; 8+ messages in thread
From: andrés ramírez @ 2019-12-09  5:54 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Trevor Spiteri, emacs-devel

Hi Juri.

Juri> Actually, tramp-cleanup-... don't update the existing
Juri> process-environment.  You need restart Emacs after customizing
Juri> tramp-remote-process-environment.

Juri> It's easier to check whether TERM has the right value in Tramp
Juri> by simply:

Juri>   M-x compile RET echo $TERM RET
--8<---------------cut here---------------start------------->8---
-*- mode: compilation; default-directory: "/ssh:aramirez@x220c:/home/aramirez/dev/wxwidgets/mamacha/src/tests/" -*-
Compilation started at Mon Dec  9 05:49:33

echo $TERM
ansi

Compilation finished at Mon Dec  9 05:49:34
--8<---------------cut here---------------end--------------->8---

It seems my snippet is not working then:
--8<---------------cut here---------------start------------->8---
(progn (setq comint-terminfo-terminal "ansi") (require
'compile)(add-to-list 'compilation-environment "TERM=dumb") (require
'tramp)(add-to-list 'tramp-remote-process-environment "TERM=dumb"))
--8<---------------cut here---------------end--------------->8---

Juri> For testing compilation highlighting, I just touch xterm.c and
Juri> compile it, because compilation of xterm.o always produces
Juri> warnings:

Juri>   M-x compile RET touch xterm.c; TERM=ansi make xterm.o RET

Juri> It produces unhandled escape sequences in the compilation output
Juri> buffer:

Same case for me.

Juri> But running compile with a prefix arg processes escape sequences
Juri> and produces nice output even when Tramp process-environment is
Juri> not customized:

Juri>   C-u M-x compile RET touch xterm.c; TERM=ansi make xterm.o RET

This workaround works for me. Actually IMO It should not be necessary to
restart emacs. after customizing tramp-remote-process-environment.

Thanks for the workaround. Best Regards



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

end of thread, other threads:[~2019-12-09  5:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-23 12:37 Emacs shell: set TERM to ansi instead of dumb Trevor Spiteri
2019-11-23 15:42 ` Colin Baxter
2019-12-01 21:57 ` Juri Linkov
2019-12-04  1:48   ` rrandresf
2019-12-04 22:41     ` Juri Linkov
2019-12-05  0:11       ` tramp compilation buffer also affected (was: Emacs shell: set TERM to ansi instead of dumb) andrés ramírez
2019-12-08 21:33         ` tramp compilation buffer also affected Juri Linkov
2019-12-09  5:54           ` andrés ramírez

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