Repository navigation
detect emacs terminal environments (on linux) - #2659
emacsomancer wants to merge 1 commit into
Conversation
detect Emacs specific terminal environments (e.g. ansi-term, shell, vterm, eshell, ghostel) on Linux using environment hints and process ancestry
|
Additional notes: Limitations: fastfetch (both without this pull request and with it):
[note: it seems like it should be simple to skip the terminal-theme detection when the Terminal itself is Emacs, but initialisation and order things make this complicated.] Theoretical additional improvements: we could in theory manage to report actual terminal font for graphical Emacs frontends, but it's complicated because of needing to check in Emacs the: default font, default monospace font and what actually is set buffer-locally; and for that we'd have to trace the ppids ancestry and then make a special call to emacs to check this, and I'm not sure of a way of doing that generally, but only when Emacs was run as a daemon or later launched a "server", and so it would have to be a number of I think complicated conditions for checking this (and there could in theory be multiple active daemons or servers so that would have to be traced carefully, further complicating things) and skipped if the relevant buffer is launched neither by a daemon or server (and, I think, some of the check will depend on the buffer being displayed in an Emacs window, which it presumably should be if fastfetch is being called, only the checks and tracing while fast would not be instantaneous and there could be race conditions if the user switched which buffers were displayed quickly after calling fastfetch). I'm not sure what to do about the terminal-theme issue (which is a pre-patch issue) - most solutions I can think of involve changes to initialisation order (which I would be very chary about trying) or adding somewhat otherwise redundant helpers (or, if not redundant, then somewhat code-tangling/obscuring) or just plain redundant and domain-inappropriate code ("setExeName()" in the theme section). Also, note that this patch is currently Linux-specific. probably some of the code could be moved (requiring extensive refactoring at the very least) from In theory, some of this, including what the pull request itself addresses, could be solved the other way round we could have emacs pass values into fastfetch rather than fastfetch trying to get at them. But this seems both like a mechanism that could be abused; a bit... top-heavy for single application; as well as also sort of against the spirit of fastfetch, as being (by default) sort of in charge of finding things out rather than being fed things. Currently the most obvious mechanism, for, say, retrieving actual fonts being using inside of an Emacs graphical terminal/sell session, would be using an optional Anyway, the current pull request does the more modest thing of extracting a little more information about its environment when in Emacs. Though in theory perhaps this should be reported as a separate line item: since once could be running Emacs itself in terminal mode rather than graphical mode, and then we might want to distinguish (a) shell from (b) actual terminal from (c) Emacs mode/environment/interface. That is, Emacs run in terminal mode might report, e.g.: [user running Emacs's vterm with fish shell]
or [user running Emacs's eshell shell using the eat package's eshell mode]
as against, when vterm or eshell-in-eat were run in a graphical Emacs with the same things:
or
[currently (pre -this-patch), fastfetch produces strange results for some of these combinations. post-patch "terminal" and the theoretical "terminal interface" are combined.] |
detect Emacs specific terminal environments (e.g. ansi-term, shell, vterm, eshell, ghostel) on Linux using environment hints and process ancestry
Summary
detect Emacs terminal environments and (where relevant) shell
Changes
INSIDE_EMACSenvironment variable, and assigning names for terminalsScreenshots
screenshots showing fastfetch running in emacs in graphical and terminal modes, with various combinations of Emacs terminal packages, shells packages, or external shells, and (for terminal modes) in different external terminal emulators.
Checklist