From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [Patch] Resizing shells in shell-mode Date: Sat, 24 May 2008 15:04:42 -0400 Message-ID: References: <6fa54e4e0805241138s7ca3428ay976f4331b86b89e6@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1211655919 18902 80.91.229.12 (24 May 2008 19:05:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 24 May 2008 19:05:19 +0000 (UTC) Cc: emacs-devel@gnu.org To: "Antoine Levitt" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat May 24 21:05:59 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Jzz3g-0001Fr-Vy for ged-emacs-devel@m.gmane.org; Sat, 24 May 2008 21:05:48 +0200 Original-Received: from localhost ([127.0.0.1]:43235 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jzz2w-0003NE-2d for ged-emacs-devel@m.gmane.org; Sat, 24 May 2008 15:04:50 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jzz2s-0003Mx-3w for emacs-devel@gnu.org; Sat, 24 May 2008 15:04:46 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jzz2q-0003Ml-0T for emacs-devel@gnu.org; Sat, 24 May 2008 15:04:44 -0400 Original-Received: from [199.232.76.173] (port=55566 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jzz2p-0003Mi-Rq for emacs-devel@gnu.org; Sat, 24 May 2008 15:04:43 -0400 Original-Received: from 206-248-174-248.dsl.teksavvy.com ([206.248.174.248]:42451 helo=ceviche.home) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Jzz2p-0000h1-9L for emacs-devel@gnu.org; Sat, 24 May 2008 15:04:43 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id 43E36B400C; Sat, 24 May 2008 15:04:42 -0400 (EDT) In-Reply-To: <6fa54e4e0805241138s7ca3428ay976f4331b86b89e6@mail.gmail.com> (Antoine Levitt's message of "Sat, 24 May 2008 20:38:45 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:97658 Archived-At: > Shell-mode doesn't update the COLUMNS env var, which prevents from having > pretty ls for example when resizing the window. I made a patch for this, but > I'm not sure how it should be inserted into main code, so I'm submitting it > in the hope someone will do that. It should be straightforward though. > Here's the code, to be included in shell.el > ;;listen for window configuration changes to modify COLUMNS > (add-hook 'window-configuration-change-hook > (lambda () > (if (eq major-mode 'shell-mode) (change-columns)))) > ;;filters one and exactly one input > (defun filter-all (string) > (remove-hook 'comint-preoutput-filter-functions 'filter-all) > "") > ;;tells the shell to change column, and discard reply (which should > ;;be a prompt) > (defun change-columns () > (add-hook 'comint-preoutput-filter-functions 'filter-all) > (funcall comint-input-sender > (get-buffer-process (current-buffer)) > (format "export COLUMNS=%d" (window-width))) > (accept-process-output)) Problem is: sending "export COLUMNS=%d" won't do the right thing if the process running currently isn't some bourne derivative. E.g. if it's `csh' or some completely different process. Stefan