help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get term width from Emacs shell?


From: rustom
Subject: Re: How to get term width from Emacs shell?
Date: Tue, 7 Dec 2010 01:08:53 -0800 (PST)
User-agent: G2/1.0

On Dec 5, 7:29 am, kj <no.em...@please.post> wrote:
> 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.

This is not an answer to your question but...
Why use a shell?  Instead of a specific mathematica mode
http://library.wolfram.com/infocenter/Demos/4567/ (dont know how
current it is)
Or at worst a customization of comint?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]