* How to get term width from Emacs shell?
@ 2010-12-05 2:29 kj
0 siblings, 0 replies; only message in thread
From: kj @ 2010-12-05 2:29 UTC (permalink / raw)
To: help-gnu-emacs
I run some shell-like programs from within the emacs shell, such
as Mathematica in text mode. I want to find a way for the Mathematica
initialization module (init.m) to *automatically* figure out the
width of the terminal (i.e. without any help/hints from me).
If I were running this on a regular terminal, I'd probably do a
system call to "tput cols", but when I do this from within an emacs
shell, I get the error 'unknown terminal emacs"'.
Ironically, the grandparent Emacs process knows perfectly well what
the window width is: it's what (window-width) evaluates to. The
problem lies in how to get this information from this all-knowing
grandparent Emacs process, through to the grandchild Mathematica
(or whatever) subshell. The hierarchy I'm thinking of is something
like
Emacs -> zsh -> Mathematica
I know how to get Mathematica to ask its parent (zsh) to run a
process (e.g. to get some information), but I don't know how to
get the parent (zsh) to request some information from *its* parent.
Any suggestions would be much appreciated!
~kj
PS: One possibility would be to fiddle with my emacs shell startup
(on the "Elisp side" of this process, that is) so that, once the
Emacs process starts a shell subprcess, it initializes an environment
variable with the value of (window-width) at that moment. This is
already beyond my skill level, but even if I could do it, it is a
suboptimal solution, because the Emacs window could easily change
in size after the shell was started, thereby rendering any environment
setting obsolete. Therefore, a solution that always returns the
*current* window width would be preferable.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-12-05 2:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-05 2:29 How to get term width from Emacs shell? kj
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).