[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] babel: ob-C with Visual C++ and compilation-mode
From: |
Ernesto Durante |
Subject: |
[O] babel: ob-C with Visual C++ and compilation-mode |
Date: |
Mon, 04 Aug 2014 18:16:11 +0200 |
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
- [O] babel: ob-C with Visual C++ and compilation-mode,
Ernesto Durante <=
- Re: [O] babel: ob-C with Visual C++ and compilation-mode, Thierry Banel, 2014/08/11
- Re: [O] babel: ob-C with Visual C++ and compilation-mode, Ernesto Durante, 2014/08/12
- Re: [O] babel: ob-C with Visual C++ and compilation-mode, Thierry Banel, 2014/08/12
- Re: [O] babel: ob-C with Visual C++ and compilation-mode, Ernesto Durante, 2014/08/13
- Re: [O] babel: ob-C with Visual C++ and compilation-mode, Thierry Banel, 2014/08/14
- Re: [O] babel: ob-C with Visual C++ and compilation-mode, Ernesto Durante, 2014/08/15
- Re: [O] babel: ob-C with Visual C++ and compilation-mode, Thierry Banel, 2014/08/17
- Re: [O] babel: ob-C with Visual C++ and compilation-mode, Ernesto Durante, 2014/08/18
- Re: [O] babel: ob-C with Visual C++ and compilation-mode, Thierry Banel, 2014/08/18
- Re: [O] babel: ob-C with Visual C++ and compilation-mode, Ernesto Durante, 2014/08/20