From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.devel Subject: Re: amd@gnu.org: eshell and external commands Date: Thu, 09 Aug 2007 15:03:18 -0400 Message-ID: <87fy2sedjd.fsf@stupidchicken.com> References: <87zm11iqlv.fsf@stupidchicken.com> <873aysr987.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1186686387 4027 80.91.229.12 (9 Aug 2007 19:06:27 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 9 Aug 2007 19:06:27 +0000 (UTC) Cc: "Alfred M. Szmidt" , rms@gnu.org, emacs-devel@gnu.org To: John Wiegley Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Aug 09 21:06:24 2007 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 1IJDKx-0007eK-L5 for ged-emacs-devel@m.gmane.org; Thu, 09 Aug 2007 21:06:23 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IJDKx-0002gl-7L for ged-emacs-devel@m.gmane.org; Thu, 09 Aug 2007 15:06:23 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IJDKm-0002de-0Q for emacs-devel@gnu.org; Thu, 09 Aug 2007 15:06:12 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IJDKk-0002dS-63 for emacs-devel@gnu.org; Thu, 09 Aug 2007 15:06:10 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IJDKk-0002dP-0Q for emacs-devel@gnu.org; Thu, 09 Aug 2007 15:06:10 -0400 Original-Received: from cyd.mit.edu ([18.115.2.24]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IJDKe-0002K2-0l; Thu, 09 Aug 2007 15:06:04 -0400 Original-Received: by cyd.mit.edu (Postfix, from userid 1000) id 813574E36E; Thu, 9 Aug 2007 15:03:18 -0400 (EDT) In-Reply-To: (John Wiegley's message of "Thu\, 09 Aug 2007 12\:44\:56 -0600") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) X-Detected-Kernel: Linux 2.6 (newer, 1) 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:76264 Archived-At: John Wiegley writes: >> I don't know how to hack the code to implement the deferment >> behavior for "fallback to external programs" commands. Do you have >> an idea how to do it? > > You know, something you could do is to traverse the Lisp tree at the > point of decision looking for the symbol `eshell-external-command'. > If it's found, use eshell-eval-command rather than eval. That way, > the slowdown is only suffered for external commands, which are going > to be slow anyway because of the necessary invocation of an external > process. I don't understand this suggestion. Since eshell-plain-command can call eshell-external-command, wouldn't this affect everything? The approach I was trying for was to put some code in eshell-do-opt, before the throw to 'eshell-external: (defun eshell-do-opt (name options body-forms) ... (if (setq ext-command (catch 'eshell-ext-command ....)) (throw 'eshell-external (eshell-external-command ext-command args)) last-value)) (Or, alternatively, in eshell-lisp-command where this nonlocal exit is caught.) This code would need to prevent the eshell prompt from being emitted until the external process is complete, like how the 'eshell-defer mechanism works in eshell-resume-eval for "normal" external commands. However, I don't know eshell well enough to make this work. I tried adding the return value of eshell-external-command to eshell-last-async-proc but that doesn't work for some reason. Do you know what needs to be done to make it work?