From mboxrd@z Thu Jan 1 00:00:00 1970 From: julien Barnier Subject: Re: [babel] [PATCH] Fix sh block execution in session Date: Mon, 6 Jun 2011 10:10:15 +0000 (UTC) Message-ID: References: <87pqmsux0e.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([140.186.70.92]:60436) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QTWla-0005mW-1t for emacs-orgmode@gnu.org; Mon, 06 Jun 2011 06:10:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QTWlY-0001ut-UG for emacs-orgmode@gnu.org; Mon, 06 Jun 2011 06:10:38 -0400 Received: from lo.gmane.org ([80.91.229.12]:50555) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QTWlY-0001uf-IW for emacs-orgmode@gnu.org; Mon, 06 Jun 2011 06:10:36 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QTWlU-00078K-6k for emacs-orgmode@gnu.org; Mon, 06 Jun 2011 12:10:34 +0200 Received: from zone129host186.ens-lsh.fr ([zone129host186.ens-lsh.fr]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 06 Jun 2011 12:10:32 +0200 Received: from julien by zone129host186.ens-lsh.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 06 Jun 2011 12:10:32 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Hi Eric, > 1. do you have a minimal example of a shell code block which works after > your patch but not before? Well, in fact it seems that almost any shell block cause problems when executed in a session. This one, for example : #+begin_src sh :session test :results output echo "foo" #+end_src > 2. I assume that the changes to ob-comit were required for your ob-sh > changes to work and were not intended to affect other languages? Yes, I would have preferred no to touch to ob-comint, but it seems that I was forced too. The changes to ob-sh have only one aim : to be sure that the commands in the shell block are send one at a time, and that we wait for the previous command to be completed before sending the following one. The current org-sh code only uses a "(sleep-for 0.25)" delay, which is not always sufficient. The changes to ob-comint modify the way the end of activity indicator is looking for. The current code is : #+begin_src emacs-lisp (goto-char comint-last-input-end) (not (save-excursion (and (re-search-forward comint-prompt-regexp nil t) (re-search-forward (regexp-quote ,eoe-indicator) nil t)))) #+end_src >From my initial sh code block, the execution ended with this : #+begin_example julien@L018198:~/org/perso$ echo "foo" foo julien@L018198:~/org/perso$ echo 'org_babel_sh_eoe' org_babel_sh_eoe julien@L018198:~/org/perso$ #+end_example With the current code, the "(goto-char comint-last-input-end)" would put the point at the beginning of the "org_babel_sh_eoe" line. Then, the "(re-search-forward comint-prompt-regexp nil t)" would put the point after the $ on the last line. So the following "(re-search-forward (regexp-quote ,eoe-indicator) nil t)" will never find anything, as the eoe-indicator is now behind the point. That's why I feel that the two searches must be switched. > 3. When switching the order of the prompt and eoe check in ob-comint, > did you try *only* looking for the eoe indicator? It seems to me > that once that is present the check for a followup prompt may not be > required and it may make sense to simply remove that code. It seems to work if you omit the prompt check (at least for shell blocks), but this prompt check could be useful, as it ensures that the interpreter is ready to get another command, and as it places the point at the right place for that. But I'm not sure this check is necessary. This change doesn't seem to affect evaluation on R source blocks. I've tried to test it with ruby, but session evaluation seems broken for this language ? #+begin_src R :results output :session rtest y <- 2 for (i in 1:100000) i y #+end_src > All in all I agree that the ob-sh changes look like an improvement and > should be applied. I'm less sure of the changes to ob-comint, simply > because I don't understand the mechanism through which swapping the > regexp checks changes behavior. However if the ob-sh changes depend > upon the ob-comint changes there is no point in applying them piecemeal. Well, I can't assure you that the change in ob-comint won't affect any other language, but I can assure you that the change in ob-sh is dependant from the one in ob-comint. Thanks a lot for your answer, and I'm available for any other question or testing request. Sincerely, Julien