From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Samer Masterson Newsgroups: gmane.emacs.bugs Subject: bug#12689: 24.2; Eshell ${cmd} substitution Date: Sun, 05 Apr 2015 20:41:04 -0700 Message-ID: <1428291664.14271.0@mail.samertm.com> References: <1424775372.11596.6@mail.samertm.com> <83bnkaqdp9.fsf@gnu.org> <1425471247.1450.2@mail.samertm.com> <83ioegpsrt.fsf@gnu.org> <1425551640.2108.1@mail.samertm.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed X-Trace: ger.gmane.org 1428291741 27530 80.91.229.3 (6 Apr 2015 03:42:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 6 Apr 2015 03:42:21 +0000 (UTC) Cc: John Wiegley , 12689@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Apr 06 05:42:11 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YexvO-0001cD-O3 for geb-bug-gnu-emacs@m.gmane.org; Mon, 06 Apr 2015 05:42:10 +0200 Original-Received: from localhost ([::1]:38219 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YexvN-0003Zg-Ok for geb-bug-gnu-emacs@m.gmane.org; Sun, 05 Apr 2015 23:42:09 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58178) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YexvK-0003ZQ-4G for bug-gnu-emacs@gnu.org; Sun, 05 Apr 2015 23:42:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YexvG-0001Vt-Ui for bug-gnu-emacs@gnu.org; Sun, 05 Apr 2015 23:42:06 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:55964) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YexvG-0001Vl-RU for bug-gnu-emacs@gnu.org; Sun, 05 Apr 2015 23:42:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YexvG-0004ky-D7 for bug-gnu-emacs@gnu.org; Sun, 05 Apr 2015 23:42:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Samer Masterson Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 06 Apr 2015 03:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12689 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 12689-submit@debbugs.gnu.org id=B12689.142829168918246 (code B ref 12689); Mon, 06 Apr 2015 03:42:02 +0000 Original-Received: (at 12689) by debbugs.gnu.org; 6 Apr 2015 03:41:29 +0000 Original-Received: from localhost ([127.0.0.1]:45740 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Yexui-0004kD-P5 for submit@debbugs.gnu.org; Sun, 05 Apr 2015 23:41:29 -0400 Original-Received: from ec2-52-0-7-12.compute-1.amazonaws.com ([52.0.7.12]:55333 helo=samertm.com) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Yexug-0004jv-27 for 12689@debbugs.gnu.org; Sun, 05 Apr 2015 23:41:26 -0400 Original-Received: from [10.20.0.210] (208-90-214-199.PUBLIC.monkeybrains.net [208.90.214.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by samertm.com (Postfix) with ESMTPSA id 49AB141B6B; Mon, 6 Apr 2015 03:40:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samertm.com; s=mail; t=1428291635; bh=pGSHr6QrnON+Y/FCxPLN8d35gaKNbHaGxfCXFuhhEwk=; h=Date:From:Subject:To:Cc:In-Reply-To:References:From; b=ex5h1ij1E0DxcNvB6aVI0FzZ9MNXZ2zrZrqR8ve2hlJi1p6Lfuxw9/34H3vg3xklj 5fAiHdB0T0Wlhd3iK4azeumO15zYsHZ9Ts+iirkyZtpIOVByV+Tagsmzn7NLNsCT3q jNVg8X/yUHpcEikPty2A2/xrxiWuM09HctzxUItE= In-Reply-To: <1425551640.2108.1@mail.samertm.com> X-Mailer: geary/0.9.1 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:101221 Archived-At: Hi, I haven't finished, but I'm putting this work on hold for now as I've spent ages on it, and I'll return to this when I've learned more about eshell's architecture. The state of my work is below. The patch below addresses the points you brought up, but it is incomplete for two reasons: - my code uses eshell-wait-for-process, which doesn't seem to be the correct wait to actually wait for a process to end because it locks up Emacs (because the core of eshell-wait-for-process is a while loop). - "prompt$ ${ext_command_one} | ext_command_two" will not reset the eshell prompt to normal if ext_command_one takes longer than ext_command_two. It works normally when ext_command_two takes longer than ext_command_one. So I need to figure out a couple things in order to unblock myself: - how eshell knows to wait for other external processes (excluding eshell-wait-for-process), and whether that can be used at command-level granularity. E.g. for "cmd ${ext_cmd0} | ext_cmd1", the entire process needs to wait for both sides of the pipe to finish, and "cmd" needs to wait for "ext_cmd0" to finish before executing). "cmd ${ext_cmd0}" also shouldn't lock Emacs. - where the entry point is for the command prompt, and how the command prompt is reset after a set of commands finishes. I've cc'd johnw because he might know the answer to the above questions, and what the correct approach to fixing this should be. I'll return to this when I've learned more about how eshell works. -samer work-in-progress patch: --- a/lisp/eshell/esh-cmd.el +++ b/lisp/eshell/esh-cmd.el @@ -851,8 +851,9 @@ This is used on systems where `start-process' is not supported." (defmacro eshell-as-subcommand (command) "Execute COMMAND using a temp buffer. This is used so that certain Lisp commands, such as `cd', when -executed in a subshell, do not disturb the environment of the main -Eshell buffer." +executed in a subshell, do not disturb the environment of the +main Eshell buffer. If COMMAND is an external command, it is +called synchronously." `(let ,eshell-subcommand-bindings ,command)) @@ -1234,14 +1235,21 @@ COMMAND may result in an alias being executed, or a plain command." (defun eshell-plain-command (command args) "Insert output from a plain COMMAND, using ARGS. COMMAND may result in either a Lisp function being executed by name, -or an external command." +or an external command. + +If COMMAND is in an external command and `eshell-in-subcommand-p' +is true, `eshell-plain-command' is synchronous and waits for +COMMAND to finish." (let* ((esym (eshell-find-alias-function command)) (sym (or esym (intern-soft command)))) (if (and sym (fboundp sym) (or esym eshell-prefer-lisp-functions (not (eshell-search-path command)))) (eshell-lisp-command sym args) - (eshell-external-command command args)))) + (let ((ext (eshell-external-command command args))) + (if eshell-in-subcommand-p + (eshell-wait-for-process ext) + ext)))))