From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: [PATCH] babel: ob-C with Visual C++ and compilation-mode Date: Thu, 28 Aug 2014 10:46:50 -0400 Message-ID: <87tx4w4qkj.fsf@gmail.com> References: <878un4ut6c.fsf@gmail.com> <87wqa1cii9.fsf@gmail.com> <87bnr8zfvr.fsf_-_@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39619) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XN11T-00024z-67 for emacs-orgmode@gnu.org; Thu, 28 Aug 2014 10:50:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XN11O-0005n6-BL for emacs-orgmode@gnu.org; Thu, 28 Aug 2014 10:49:59 -0400 Received: from mail-ie0-x22e.google.com ([2607:f8b0:4001:c03::22e]:55380) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XN11O-0005n1-3t for emacs-orgmode@gnu.org; Thu, 28 Aug 2014 10:49:54 -0400 Received: by mail-ie0-f174.google.com with SMTP id at20so1088351iec.19 for ; Thu, 28 Aug 2014 07:49:53 -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 Ernesto Durante writes: > Eric Schulte writes: > > Hi Eric, > > You will find in attachment three patches > Hi Ernesto, Thank you for sending these along, they look great. > > + First patch, modify org-babel-eval to load compilation-mode in case >of errors > Applied. > > + Second patch, modify org-babel-eval to deal with Microsoft visual > C++ errors by concatenating the standard output with the standard error > Not applied. I believe that concatenating STDOUT to STDERR for *every* language simply because Microsoft Visual Studio does not correctly use STDERR is not the correct approach here. Perhaps a more tailored solution may be possible for this problem which will not have global effects. > > + Third patch, add to ob-C the missing function >org-babel-expand-body:cpp > Applied. Thanks! Eric > > Best > Ernesto > > From 3e4f163a2b357c58a52b7811539ff4032d432aaf Mon Sep 17 00:00:00 2001 > From: Ernesto Durante > Date: Mon, 25 Aug 2014 17:27:24 +0200 > Subject: [PATCH 1/3] org-babel-eval: compilation-mode to deal with errors in > (C/C++/D) > > --- > lisp/ob-eval.el | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/lisp/ob-eval.el b/lisp/ob-eval.el > index 057590f..9fbbb42 100644 > --- a/lisp/ob-eval.el > +++ b/lisp/ob-eval.el > @@ -57,6 +57,12 @@ STDERR with `org-babel-eval-error-notify'." > (progn > (with-current-buffer err-buff > (org-babel-eval-error-notify exit-code (buffer-string))) > + (save-excursion > + (when (get-buffer org-babel-error-buffer-name) > + (with-current-buffer org-babel-error-buffer-name > + (compilation-mode) > + ;;compilation-mode enforces read-only > + (read-only-mode 0)))) > nil) > (buffer-string))))) > > -- > 1.8.3.1 > > From 9e306dbb39325998a5149840b229ffa802ec40e9 Mon Sep 17 00:00:00 2001 > From: Ernesto Durante > Date: Mon, 25 Aug 2014 17:54:51 +0200 > Subject: [PATCH 2/3] org-babel-eval: showing Microsoft Visual C++ errors > > --- > lisp/ob-eval.el | 27 +++++++++++++++------------ > 1 file changed, 15 insertions(+), 12 deletions(-) > > diff --git a/lisp/ob-eval.el b/lisp/ob-eval.el > index 9fbbb42..0e69583 100644 > --- a/lisp/ob-eval.el > +++ b/lisp/ob-eval.el > @@ -53,18 +53,21 @@ 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))) > - (save-excursion > - (when (get-buffer org-babel-error-buffer-name) > - (with-current-buffer org-babel-error-buffer-name > - (compilation-mode) > - ;;compilation-mode enforces read-only > - (read-only-mode 0)))) > - nil) > - (buffer-string))))) > + (let ((outb-str (buffer-string))) > + ;;outb-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 > + (concat outb-str (buffer-string)))) > + (save-excursion > + (when (get-buffer org-babel-error-buffer-name) > + (with-current-buffer org-babel-error-buffer-name > + (compilation-mode) > + ;;compilation-mode enforces read-only > + (read-only-mode 0)))) > + nil) > + outb-str))))) > > (defun org-babel-eval-read-file (file) > "Return the contents of FILE as a string." > -- > 1.8.3.1 > > From c93e02a52d57a5eeb7b9b8aba04c6764f8122d5c Mon Sep 17 00:00:00 2001 > From: Ernesto Durante > Date: Mon, 25 Aug 2014 18:16:01 +0200 > Subject: [PATCH 3/3] ob-C: fix missing function org-babel-expand-body:cpp > > --- > lisp/ob-C.el | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/lisp/ob-C.el b/lisp/ob-C.el > index 2e146d4..076276e 100644 > --- a/lisp/ob-C.el > +++ b/lisp/ob-C.el > @@ -82,6 +82,11 @@ is currently being evaluated.") > This function calls `org-babel-execute:C++'." > (org-babel-execute:C++ body params)) > > +(defun org-babel-expand-body:cpp (body params) > + "Expand a block of C++ code with org-babel according to it's > +header arguments." > + (org-babel-expand-body:C++ body params)) > + > (defun org-babel-execute:C++ (body params) > "Execute a block of C++ code with org-babel. > This function is called by `org-babel-execute-src-block'." -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D (see https://u.fsf.org/yw)