From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: kj Newsgroups: gmane.emacs.help Subject: How to get term width from Emacs shell? Date: Sun, 5 Dec 2010 02:29:30 +0000 (UTC) Organization: none Message-ID: NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1291950330 23489 80.91.229.12 (10 Dec 2010 03:05:30 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 10 Dec 2010 03:05:30 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Dec 10 04:05:26 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PQtIT-0007UG-Mm for geh-help-gnu-emacs@m.gmane.org; Fri, 10 Dec 2010 04:05:25 +0100 Original-Received: from localhost ([127.0.0.1]:33842 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQtIS-0002Cd-T4 for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Dec 2010 22:05:25 -0500 Original-Path: usenet.stanford.edu!panix!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 38 Original-NNTP-Posting-Host: panix2.panix.com Original-X-Trace: reader1.panix.com 1291516170 25101 166.84.1.2 (5 Dec 2010 02:29:30 GMT) Original-X-Complaints-To: abuse@panix.com Original-NNTP-Posting-Date: Sun, 5 Dec 2010 02:29:30 +0000 (UTC) X-No-Confirm: yes User-Agent: nn/6.7.3 Original-Xref: usenet.stanford.edu gnu.emacs.help:182868 X-Mailman-Approved-At: Thu, 09 Dec 2010 20:09:23 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:77246 Archived-At: 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.