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#18108: [PATCH] 24.3.92 : eshell-visual-options fails with some output. Date: Sun, 05 Apr 2015 21:05:43 -0700 Message-ID: <1428293143.15170.1@mail.samertm.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 X-Trace: ger.gmane.org 1428293241 14793 80.91.229.3 (6 Apr 2015 04:07:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 6 Apr 2015 04:07:21 +0000 (UTC) To: 18108@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Apr 06 06:07: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 1YeyJa-0000K4-P7 for geb-bug-gnu-emacs@m.gmane.org; Mon, 06 Apr 2015 06:07:11 +0200 Original-Received: from localhost ([::1]:38264 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YeyJZ-0000Is-Q6 for geb-bug-gnu-emacs@m.gmane.org; Mon, 06 Apr 2015 00:07:09 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:32811) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YeyJV-0000Ih-LD for bug-gnu-emacs@gnu.org; Mon, 06 Apr 2015 00:07:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YeyJS-0000RQ-Dn for bug-gnu-emacs@gnu.org; Mon, 06 Apr 2015 00:07:05 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:55976) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YeyJS-0000RM-AT for bug-gnu-emacs@gnu.org; Mon, 06 Apr 2015 00:07:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YeyJR-0005Nx-Vp for bug-gnu-emacs@gnu.org; Mon, 06 Apr 2015 00:07:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Samer Masterson Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 06 Apr 2015 04:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18108 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 18108-submit@debbugs.gnu.org id=B18108.142829316220623 (code B ref 18108); Mon, 06 Apr 2015 04:07:01 +0000 Original-Received: (at 18108) by debbugs.gnu.org; 6 Apr 2015 04:06:02 +0000 Original-Received: from localhost ([127.0.0.1]:45752 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YeyIT-0005MR-61 for submit@debbugs.gnu.org; Mon, 06 Apr 2015 00:06:01 -0400 Original-Received: from ec2-52-0-7-12.compute-1.amazonaws.com ([52.0.7.12]:55373 helo=samertm.com) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YeyIQ-0005MB-GW for 18108@debbugs.gnu.org; Mon, 06 Apr 2015 00:05:59 -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 42B3641B6B for <18108@debbugs.gnu.org>; Mon, 6 Apr 2015 04:05:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samertm.com; s=mail; t=1428293107; bh=yQe3mu62mUb2tqcLyyGpwgNxEoCS3/dS4Jr/r/CoxFQ=; h=Date:From:Subject:To:From; b=j3izUlR9/+BzJtMuScJ9nNm/tgoTa7G35EhNy1WmzYKa6/cruyvz1gpeC1n02tIaP CszafqeCXhTavP2sN2C5CjvblE7pTV0vRrLWeUJA2eixTyjqEUZVCqYoR4yF2cdihK voGah8RaX8/Hyh+GX+PX5d/lZUiFna6OOoW3CzCA= 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:101223 Archived-At: Hi, Pinging the list with a well-formed patch. Info below (quoted from my reply to 18108): > When eshell opens a visual command, it creates a buffer for the process, > switches to that buffer, and, if the process is still running, attaches > a sentinel to the process that kills the process when the sentinel dies. > If the process is not running, the visual command signals an error, > I assume because there is no good reason to show the term buffer for a > process that isn't running. > There is a race condition in the part that handles whether a command is > running: even short-lived commands, like "git --version", are running > when polled, and the error is never thrown. That means we've attached > the buffer-killing sentinel to these short-lived commands, so the buffer > they're attached to gets killed immediately afterwards. > To sum up everything wrong with the current behavior: > 1. Killing the process's buffer when the process dies is not the desired > behavior. > 2. Even if we wanted to kill the process's buffer for long running > processes but not short ones, there is *no way* to tell how long a > process will run. That means, there is no way to do this correctly. > The solution is simple: for every visual application, simply create the > term-mode buffer for it and switch to that buffer. This satisfies every > use case: if a process dies quickly with an error message, the user will > be able to read the error; if the process is running, it doesn't quit > (this is also the current behavior); if the process is long running and > dies, the user will be able to read the output of the process. I've > attached a patch that implements this behavior below. > There is a small issue with this patch: eshell does not start on a new > line when you execute a visual command, and so you need to press 'enter' > before entering a new command. If anyone has any insight into this, I'm > all ears, otherwise I can probably figure it out eventually. And the patch is below. -samer ec2e573b4644ffdfa7e035aeb66f55e847b7c991 HEAD 18108 Author: Samer Masterson Date: Sun Apr 5 20:59:37 2015 -0700 Fixes 18108. * eshell/em-term.el (eshell-exec-visual): Show term-mode buffer regardless of whether the process has died (bug#18108). (eshell-term-sentinel, eshell-parent-buffer): Now unused, remove. 2 files changed, 14 insertions(+), 37 deletions(-) lisp/ChangeLog | 6 ++++++ lisp/eshell/em-term.el | 45 ++++++++------------------------------------- Modified lisp/ChangeLog diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b2d431c..a06ad01 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2015-04-06 Samer Masterson + + * eshell/em-term.el (eshell-exec-visual): Show term-mode buffer + regardless of whether the process has died (bug#18108). + (eshell-term-sentinel, eshell-parent-buffer): Now unused, remove. + 2015-03-27 Wolfgang Jenkner * font-lock.el (font-lock--remove-face-from-text-property): New Modified lisp/eshell/em-term.el diff --git a/lisp/eshell/em-term.el b/lisp/eshell/em-term.el index 4a6ac23..7f98ee6 100644 --- a/lisp/eshell/em-term.el +++ b/lisp/eshell/em-term.el @@ -132,10 +132,6 @@ character to the invoked process." :type 'boolean :group 'eshell-term) -;;; Internal Variables: - -(defvar eshell-parent-buffer) - ;;; Functions: (defun eshell-term-initialize () @@ -171,39 +167,14 @@ allowed." (cdr args))))) (term-buf (generate-new-buffer - (concat "*" (file-name-nondirectory program) "*"))) - (eshell-buf (current-buffer))) - (save-current-buffer - (switch-to-buffer term-buf) - (term-mode) - (set (make-local-variable 'term-term-name) eshell-term-name) - (make-local-variable 'eshell-parent-buffer) - (setq eshell-parent-buffer eshell-buf) - (term-exec term-buf program program nil args) - (let ((proc (get-buffer-process term-buf))) - (if (and proc (eq 'run (process-status proc))) - (set-process-sentinel proc 'eshell-term-sentinel) - (error "Failed to invoke visual command"))) - (term-char-mode) - (if eshell-escape-control-x - (term-set-escape-char ?\C-x)))) - nil) - -;; Process sentinels receive two arguments. -(defun eshell-term-sentinel (proc _string) - "Destroy the buffer visiting PROC." - (let ((proc-buf (process-buffer proc))) - (when (and proc-buf (buffer-live-p proc-buf) - (not (eq 'run (process-status proc))) - (= (process-exit-status proc) 0)) - (if (eq (current-buffer) proc-buf) - (let ((buf (and (boundp 'eshell-parent-buffer) - eshell-parent-buffer - (buffer-live-p eshell-parent-buffer) - eshell-parent-buffer))) - (if buf - (switch-to-buffer buf)))) - (kill-buffer proc-buf)))) + (concat "*" (file-name-nondirectory program) "*")))) + (switch-to-buffer term-buf) + (term-mode) + (set (make-local-variable 'term-term-name) eshell-term-name) + (term-exec term-buf program program nil args) + (term-char-mode) + (if eshell-escape-control-x + (term-set-escape-char ?\C-x)))) ;; jww (1999-09-17): The code below will allow Eshell to send input ;; characters directly to the currently running interactive process.