From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: babel: ob-C with Visual C++ and compilation-mode Date: Sun, 17 Aug 2014 22:40:52 -0400 Message-ID: <87wqa1cii9.fsf@gmail.com> References: <878un4ut6c.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54383) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKfUs-00079o-W8 for emacs-orgmode@gnu.org; Thu, 21 Aug 2014 23:26:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XKfUo-00009u-21 for emacs-orgmode@gnu.org; Thu, 21 Aug 2014 23:26:38 -0400 Received: from mail-ie0-x233.google.com ([2607:f8b0:4001:c03::233]:39096) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKfUn-00009l-Sh for emacs-orgmode@gnu.org; Thu, 21 Aug 2014 23:26:33 -0400 Received: by mail-ie0-f179.google.com with SMTP id rl12so5636319iec.24 for ; Thu, 21 Aug 2014 20:26:32 -0700 (PDT) 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: Ernesto Durante Cc: emacs-orgmode@gnu.org Hi Ernesto, This looks like a good change and I'd like to apply it. Could you re-submit this commit after doing the following. 1. ensure no lines go beyond 80 characters in length 2. remove all lines which include only closing parens (such lines are generally considered bad lisp style) 3. commit to your local git repository with "git commit" 4. format the patch with "git format-patch" Thanks, Eric Ernesto Durante writes: > Hi, > > I am using ob-C with gcc and Microsoft Visual C++. These two compilers > have two different behaviours for outputting errors. Gcc uses the > standard error output and Visual C++ uses the regular output. > Under Windows, errors are not displayed because of the way > org-babel-eval is coded. To work on both platforms, the standard > output must be concatenated with the standard error. > > I modified the org-babel-eval in the following way. > > > diff --git a/lisp/ob-eval.el b/lisp/ob-eval.el > index 057590f..1a93460 100644 > --- a/lisp/ob-eval.el > +++ b/lisp/ob-eval.el > @@ -53,12 +53,20 @@ STDERR with `org-babel-eval-error-notify'." > (setq exit-code > (org-babel--shell-command-on-region > (point-min) (point-max) cmd err-buff)) > - (if (or (not (numberp exit-code)) (> exit-code 0)) > - (progn > - (with-current-buffer err-buff > - (org-babel-eval-error-notify exit-code (buffer-string))) > - nil) > - (buffer-string))))) > + (let ((temp-buffer-str (buffer-string))) ;;temp-buffer-str holds standard output + body > + (if (or (not (numberp exit-code)) (> exit-code 0)) > + (progn > + (with-current-buffer err-buff > + (org-babel-eval-error-notify exit-code (format "%s%s" temp-buffer-str (buffer-string))) > + ) > + (save-excursion > + (when (get-buffer org-babel-error-buffer-name) > + (with-current-buffer org-babel-error-buffer-name > + (compilation-mode) > + (read-only-mode 0) > + ))) > + nil) > + temp-buffer-str))))) > > > One suggestion. It will be nice to put the error buffer in > compilation-mode, this way errors are highlighted and we can jump > directly into the source code. I modified org-babel-eval to launch the > compilation mode in case of errors. I also removed the read-only > attribute, else the buffer content of org-babel-error-buffer-name cannot > be erased. > > Clearly, it's not a good patch because org-babel-eval seems to be > a core function in babel. Maybe for ob-C, this function should be > replaced by a new function. > > Thanks to everyone for orgmode and babel to exist. > > Best > Ernesto > -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D (see https://u.fsf.org/yw)