emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* babel: ob-C with Visual C++ and compilation-mode
@ 2014-08-04 16:16 Ernesto Durante
  2014-08-11 19:40 ` Thierry Banel
  2014-08-18  2:40 ` Eric Schulte
  0 siblings, 2 replies; 23+ messages in thread
From: Ernesto Durante @ 2014-08-04 16:16 UTC (permalink / raw)
  To: emacs-orgmode


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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2014-09-10  9:40 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-04 16:16 babel: ob-C with Visual C++ and compilation-mode Ernesto Durante
2014-08-11 19:40 ` Thierry Banel
2014-08-12 14:24   ` Ernesto Durante
2014-08-12 22:03     ` Thierry Banel
2014-08-13 20:58       ` Ernesto Durante
2014-08-14 20:40         ` Thierry Banel
2014-08-15 17:22           ` Ernesto Durante
2014-08-17 11:20             ` Thierry Banel
2014-08-18 11:19               ` Ernesto Durante
2014-08-18 12:51                 ` Eric Schulte
2014-08-24 13:05                   ` Ernesto Durante
2014-08-28 14:02                     ` Eric Schulte
2014-08-18 19:59                 ` Thierry Banel
2014-08-20 20:40                   ` Ernesto Durante
2014-08-21 19:48                     ` Thierry Banel
2014-08-24 12:57                       ` Ernesto Durante
2014-08-28 19:44                         ` Thierry Banel
2014-08-18  2:41         ` Eric Schulte
2014-08-18  2:40 ` Eric Schulte
2014-08-23 11:03   ` Ernesto Durante
2014-08-25 16:35   ` [PATCH] " Ernesto Durante
2014-08-28 14:46     ` Eric Schulte
2014-09-10  9:27       ` Achim Gratz

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).