From: kj <no.email@please.post>
To: help-gnu-emacs@gnu.org
Subject: How to get term width from Emacs shell?
Date: Sun, 5 Dec 2010 02:29:30 +0000 (UTC) [thread overview]
Message-ID: <idetea$ogd$1@reader1.panix.com> (raw)
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.
reply other threads:[~2010-12-05 2:29 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='idetea$ogd$1@reader1.panix.com' \
--to=no.email@please.post \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.