2

I am facing a strange behavior regarding the implementation of color for shell outputs when using eshell. This is the content of my .emacs:

(require 'xterm-color)
(require 'eshell)
(add-hook 'eshell-before-prompt-hook
          (lambda ()
            (setq xterm-color-preserve-properties t)))

(add-to-list 'eshell-preoutput-filter-functions 'xterm-color-filter)
(setq eshell-output-filter-functions (remove 'eshell-handle-ansi-color eshell-output-filter-functions))
(setenv "TERM" "xterm-256color")

Strangely enough, eshell does not correctly show the colors on outputs (of git, or pytest for example) after emacs is initialized. However it does not raise any errors and, after it has been initialized, I evaluate this section of my init file with C-x C-e and, after I do that and restart eshell, it works fine as I expected.

I don't understand why it would work only if executed after emacs is initialized but would not have the expected effect on .emacs.

I do have the line (setq initial-buffer-choice 'eshell) on my .emacs, but only after the section above.

Any insight on why that might be happening would be helpful. Thank you,

Edit 1

I narrowed down the problem to the setenv statement and the initial-buffer-choice. For some reason, when I have the initial-buffer-choice uncommented, the TERM variable is set to dumb. On the other hand, if I comment initial-buffer-choice and open eshell after startup, then everything works as expected.

I tried to add the setenv execution as a hook to eshell-mode and to emacs-startup, to see if I could force its execution at some other point during startup, but nothing really worked.

pgaluzio
  • 168
  • 2
  • 6
  • Emacs should raise an error "eshell-output-filter-functions is void" at startup since the variable is defined by esh-mode.el and eshell.el does NOT load it. – xuchunyang Aug 18 '20 at 15:17
  • That is what is most strange, I opened emacs with the -q option and evaluated only the code I showed above and it doesn't raise any errors, and if I open eshell it works perfect. However, in the init file it just doesn't work and there is no message in the *message* buffer regarding eshell, either. – pgaluzio Aug 18 '20 at 16:21

0 Answers0