[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to get term width from Emacs shell?
From: |
kj |
Subject: |
How to get term width from Emacs shell? |
Date: |
Sun, 5 Dec 2010 02:29:30 +0000 (UTC) |
User-agent: |
nn/6.7.3 |
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.
- How to get term width from Emacs shell?,
kj <=