Re: [O] [ob][bug] C++-mode is unknown
Eric Schulte writes: >>> Do you find the attached patch acceptable? >> Scratch it, it's not working as it should. > I actually applied this patch, undid the portion in ob-C.el because we > shouldn't be modifying org-babel-load-languages from ob-* files, ^^ No this was what made my patch suck, but I only discovered when I tried to export a document and got an error later. I didn't and don't understand the finer mechanics of ob well enough, I must admit. > and added another change which include the org-src-lang-mode > languages to the options in org-babel-demarcate-block. Cool. That was what I tried to archive. > Let me know if this leaves anything out. For now, no. Some of the examples from the Eigen tutorial render horribly, but it's mostly 'cause they have several matrices/vectors in one 'program' and strings are added to the beginning, e.g. "m * v=\n..." where '...' is a matrix. But I can't think of an easy remedy to this. Thanks, Rasmus -- Together we'll stand, divided we'll fall
Re: [O] [ob][bug] C++-mode is unknown
Rasmus writes: > Rasmus writes: > >> Eric Schulte writes: >> >>> Use the `org-src-lang-modes' variable to associate a src code block name >>> with a major mode. This list already contains ("cpp" . c++) for C++ >>> code blocks, but perhaps ("C++" . c++) should be added as well. >> >> Thanks for the pointers! >> >> Do you find the attached patch acceptable? > > Scratch it, it's not working as it should. > I actually applied this patch, undid the portion in ob-C.el because we shouldn't be modifying org-babel-load-languages from ob-* files, and added another change which include the org-src-lang-mode languages to the options in org-babel-demarcate-block. Let me know if this leaves anything out. Thanks, -- Eric Schulte http://cs.unm.edu/~eschulte
Re: [O] [ob][bug] C++-mode is unknown
Rasmus writes: > Eric Schulte writes: > >> Use the `org-src-lang-modes' variable to associate a src code block name >> with a major mode. This list already contains ("cpp" . c++) for C++ >> code blocks, but perhaps ("C++" . c++) should be added as well. > > Thanks for the pointers! > > Do you find the attached patch acceptable? Scratch it, it's not working as it should. –Rasmus -- There are known knowns; there are things we know that we know.
Re: [O] [ob][bug] C++-mode is unknown
Eric Schulte writes: > Use the `org-src-lang-modes' variable to associate a src code block name > with a major mode. This list already contains ("cpp" . c++) for C++ > code blocks, but perhaps ("C++" . c++) should be added as well. Thanks for the pointers! Do you find the attached patch acceptable? –Rasmus -- This space left intentionally blank>From de9ffd3f5b3d36f149beafed7882ab78b86c5dd2 Mon Sep 17 00:00:00 2001 From: rasmus Date: Sat, 13 Jul 2013 16:30:04 +0200 Subject: [PATCH] Better C++ recognition * ob-C.el: Added =C++= to =`org-babel-load-languages'= automatically after loading =C=. * org-src.el (org-src-lang-modes): Added association between language =C++= and =`c++-mode'=. =C++= is added to org-babel-load-languages to make `org-babel-demarcate-block' recognize =C++= as a proper language. --- lisp/ob-C.el| 2 ++ lisp/org-src.el | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/ob-C.el b/lisp/ob-C.el index e9eec93..b0eaf6f 100644 --- a/lisp/ob-C.el +++ b/lisp/ob-C.el @@ -39,6 +39,8 @@ (defvar org-babel-tangle-lang-exts) (add-to-list 'org-babel-tangle-lang-exts '("C++" . "cpp")) +(let ((x (member '(C . t) org-babel-load-languages))) + (setcdr x (cons '(C++ . t) (subseq x 1 (defvar org-babel-default-header-args:C '()) diff --git a/lisp/org-src.el b/lisp/org-src.el index 81b8e40..0f88174 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -179,7 +179,7 @@ but which mess up the display of a snippet in Org exported files.") (defcustom org-src-lang-modes '(("ocaml" . tuareg) ("elisp" . emacs-lisp) ("ditaa" . artist) ("asymptote" . asy) ("dot" . fundamental) ("sqlite" . sql) -("calc" . fundamental) ("C" . c) ("cpp" . c++) +("calc" . fundamental) ("C" . c) ("cpp" . c++) ("C++" . c++) ("screen" . shell-script)) "Alist mapping languages to their major mode. The key is the language name, the value is the string that should -- 1.8.3.2
Re: [O] [ob][bug] C++-mode is unknown
Use the `org-src-lang-modes' variable to associate a src code block name with a major mode. This list already contains ("cpp" . c++) for C++ code blocks, but perhaps ("C++" . c++) should be added as well. Best, Rasmus writes: > Hi, > > The Emacs C++ mode is called c++-mode. In babel C++ is C++. > Hence, the following problematic case holds. > > With the block, (lowercase c) > > #+begin_src c++ >... > #+end_src > > I can edit it in the c++-mode and get nice fontification, but I can't > execute it. > > With (capital c) > > #+begin_src C++ >... > #+end_src > > I can execute the block in Org, but I can't edit it in c++-mode. > > I'm not very knowledgeable about Babel, so the best fix I could find > was adding > > (defalias 'C++-mode 'c++-mode) > > to the top of ob-c.el (after requiring cc-mode). Of course C++ could > also be renamed c++, but the correct name does in fact seem to use > capitals (cf. Wikipedia). > > Ob-template didn't mention how to associate a language with a given > mode. > > Cheers, > Rasmus -- Eric Schulte http://cs.unm.edu/~eschulte
Re: [O] [ob][bug] C++-mode is unknown
Rasmus writes: > The Emacs C++ mode is called c++-mode. In babel C++ is C++. > Hence, the following problematic case holds. > [...] Also, shouldn't C++ be in the list of languages when running org-babel-demarcate-block (C-c C-v C-d)? Oh, and here's my details if relevant: Org-mode version 8.0.3 (release_8.0.3-309-gabacff @ /usr/share/emacs/site-lisp/org/) GNU Emacs 24.3.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.8.2) of 2013-07-05 on *host*. –Rasmus -- Enough with the bla bla!
[O] [ob][bug] C++-mode is unknown
Hi, The Emacs C++ mode is called c++-mode. In babel C++ is C++. Hence, the following problematic case holds. With the block, (lowercase c) #+begin_src c++ ... #+end_src I can edit it in the c++-mode and get nice fontification, but I can't execute it. With (capital c) #+begin_src C++ ... #+end_src I can execute the block in Org, but I can't edit it in c++-mode. I'm not very knowledgeable about Babel, so the best fix I could find was adding (defalias 'C++-mode 'c++-mode) to the top of ob-c.el (after requiring cc-mode). Of course C++ could also be renamed c++, but the correct name does in fact seem to use capitals (cf. Wikipedia). Ob-template didn't mention how to associate a language with a given mode. Cheers, Rasmus -- Got mashed potatoes. Ain't got no T-Bone. No T-Bone