emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [ob][bug] C++-mode is unknown
@ 2013-07-13 13:12 Rasmus
  2013-07-13 13:23 ` Rasmus
  2013-07-13 13:38 ` [ob][bug] C++-mode is unknown Eric Schulte
  0 siblings, 2 replies; 11+ messages in thread
From: Rasmus @ 2013-07-13 13:12 UTC (permalink / raw)
  To: emacs-orgmode

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

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

* Re: [ob][bug] C++-mode is unknown
  2013-07-13 13:12 [ob][bug] C++-mode is unknown Rasmus
@ 2013-07-13 13:23 ` Rasmus
  2013-07-13 21:53   ` export to markdown Rill
  2013-07-13 13:38 ` [ob][bug] C++-mode is unknown Eric Schulte
  1 sibling, 1 reply; 11+ messages in thread
From: Rasmus @ 2013-07-13 13:23 UTC (permalink / raw)
  To: emacs-orgmode

Rasmus <rasmus@gmx.us> 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!

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

* Re: [ob][bug] C++-mode is unknown
  2013-07-13 13:12 [ob][bug] C++-mode is unknown Rasmus
  2013-07-13 13:23 ` Rasmus
@ 2013-07-13 13:38 ` Eric Schulte
  2013-07-13 14:41   ` Rasmus
  1 sibling, 1 reply; 11+ messages in thread
From: Eric Schulte @ 2013-07-13 13:38 UTC (permalink / raw)
  To: Rasmus; +Cc: emacs-orgmode

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 <rasmus@gmx.us> 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

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

* Re: [ob][bug] C++-mode is unknown
  2013-07-13 13:38 ` [ob][bug] C++-mode is unknown Eric Schulte
@ 2013-07-13 14:41   ` Rasmus
  2013-07-13 17:59     ` Rasmus
  0 siblings, 1 reply; 11+ messages in thread
From: Rasmus @ 2013-07-13 14:41 UTC (permalink / raw)
  To: schulte.eric; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 393 bytes --]

Eric Schulte <schulte.eric@gmail.com> 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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Better-C-recognition.patch --]
[-- Type: text/x-diff, Size: 1608 bytes --]

From de9ffd3f5b3d36f149beafed7882ab78b86c5dd2 Mon Sep 17 00:00:00 2001
From: rasmus <rasmus@gmx.us>
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


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

* Re: [ob][bug] C++-mode is unknown
  2013-07-13 14:41   ` Rasmus
@ 2013-07-13 17:59     ` Rasmus
  2013-07-13 18:39       ` Eric Schulte
  0 siblings, 1 reply; 11+ messages in thread
From: Rasmus @ 2013-07-13 17:59 UTC (permalink / raw)
  To: emacs-orgmode

Rasmus <rasmus@gmx.us> writes:

> Eric Schulte <schulte.eric@gmail.com> 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.

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

* Re: [ob][bug] C++-mode is unknown
  2013-07-13 17:59     ` Rasmus
@ 2013-07-13 18:39       ` Eric Schulte
  2013-07-13 18:59         ` Rasmus
  0 siblings, 1 reply; 11+ messages in thread
From: Eric Schulte @ 2013-07-13 18:39 UTC (permalink / raw)
  To: Rasmus; +Cc: emacs-orgmode

Rasmus <rasmus@gmx.us> writes:

> Rasmus <rasmus@gmx.us> writes:
>
>> Eric Schulte <schulte.eric@gmail.com> 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

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

* Re: [ob][bug] C++-mode is unknown
  2013-07-13 18:39       ` Eric Schulte
@ 2013-07-13 18:59         ` Rasmus
  0 siblings, 0 replies; 11+ messages in thread
From: Rasmus @ 2013-07-13 18:59 UTC (permalink / raw)
  To: emacs-orgmode

Eric Schulte <schulte.eric@gmail.com> 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

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

* export to markdown
  2013-07-13 13:23 ` Rasmus
@ 2013-07-13 21:53   ` Rill
  2013-07-13 22:08     ` Suvayu Ali
  0 siblings, 1 reply; 11+ messages in thread
From: Rill @ 2013-07-13 21:53 UTC (permalink / raw)
  To: emacs-orgmode

Hi Everybody,
I'm new to orgmode and I've been reading the manual. In section 12.8 it 
describes exporting to markdown; however, the keystrokes described there 
don't seem to work. I'm using org 8.0.6.
And since I'm new here, I'll tell you that I'm using org on a Raspberry 
Pi with speech and it's great.
Rill

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

* Re: export to markdown
  2013-07-13 21:53   ` export to markdown Rill
@ 2013-07-13 22:08     ` Suvayu Ali
       [not found]       ` <51E1D61E.9050502@yahoo.com>
  0 siblings, 1 reply; 11+ messages in thread
From: Suvayu Ali @ 2013-07-13 22:08 UTC (permalink / raw)
  To: emacs-orgmode

On Sat, Jul 13, 2013 at 04:53:09PM -0500, Rill wrote:
> Hi Everybody,
> I'm new to orgmode and I've been reading the manual. In section 12.8 it
> describes exporting to markdown; however, the keystrokes described there
> don't seem to work. I'm using org 8.0.6.

Did you load ox-md before trying?  Either require it, or add it to
org-export-backends.

Cheers,

PS: Next time please start a new thread (using compose) instead of
    reponding to some an existing thread.  I would have missed your post
    had I not been reading the thread you responded to.

-- 
Suvayu

Open source is the future. It sets us free.

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

* Re: export to markdown
       [not found]       ` <51E1D61E.9050502@yahoo.com>
@ 2013-07-14  7:49         ` Suvayu Ali
  2013-07-14 17:35           ` Rill
  0 siblings, 1 reply; 11+ messages in thread
From: Suvayu Ali @ 2013-07-14  7:49 UTC (permalink / raw)
  To: Rill; +Cc: Emacs Org Mode List

On Sat, Jul 13, 2013 at 05:35:10PM -0500, Rill wrote:
> On 07/13/2013 05:08 PM, Suvayu Ali wrote:
> >On Sat, Jul 13, 2013 at 04:53:09PM -0500, Rill wrote:
> >>Hi Everybody,
> >>I'm new to orgmode and I've been reading the manual. In section 12.8 it
> >>describes exporting to markdown; however, the keystrokes described there
> >>don't seem to work. I'm using org 8.0.6.
> >Did you load ox-md before trying?  Either require it, or add it to
> >org-export-backends.
>
> My ignorance: How do I do this?

As with every other Emacs library:

  (require 'ox-md)

or:

  (add-to-list 'org-export-backends 'md)

before you load Org mode, either with (require 'org) or by openning an
Org file.

> >PS: Next time please start a new thread (using compose) instead of
> >     reponding to some an existing thread.  I would have missed your post
> >     had I not been reading the thread you responded to.
> >
> >My bad. I thought I had. I wanted to get the address right.

Copy paste?  ;)

You forgot to include the list (or hit reply all) in your response.  I
have added it back.  It is good to keep discussion on the list, then
others can chime in with their insight.  :)

Cheers,

-- 
Suvayu

Open source is the future. It sets us free.

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

* Re: export to markdown
  2013-07-14  7:49         ` Suvayu Ali
@ 2013-07-14 17:35           ` Rill
  0 siblings, 0 replies; 11+ messages in thread
From: Rill @ 2013-07-14 17:35 UTC (permalink / raw)
  To: Suvayu Ali; +Cc: Emacs Org Mode List

On 07/14/2013 02:49 AM, Suvayu Ali wrote:
> On Sat, Jul 13, 2013 at 05:35:10PM -0500, Rill wrote:
>> On 07/13/2013 05:08 PM, Suvayu Ali wrote:
>>> On Sat, Jul 13, 2013 at 04:53:09PM -0500, Rill wrote:
>>>> Hi Everybody,
>>>> I'm new to orgmode and I've been reading the manual. In section 12.8 it
>>>> describes exporting to markdown; however, the keystrokes described there
>>>> don't seem to work. I'm using org 8.0.6.
>>> Did you load ox-md before trying?  Either require it, or add it to
>>> org-export-backends.
>> My ignorance: How do I do this?
> As with every other Emacs library:
>
>    (require 'ox-md)
> This worked nicely.
> or:
>
>    (add-to-list 'org-export-backends 'md)
>
> before you load Org mode, either with (require 'org) or by openning an
> Org file.
> Thank you for your patience. I'm new to all this.
>>> PS: Next time please start a new thread (using compose) instead of
>>>      reponding to some an existing thread.  I would have missed your post
>>>      had I not been reading the thread you responded to.
>>>
>>> My bad. I thought I had. I wanted to get the address right.
> Copy paste?  ;)
>
> You forgot to include the list (or hit reply all) in your response.  I
> have added it back.  It is good to keep discussion on the list, then
> others can chime in with their insight.  :)
> Of course. Good thing I don't work with heavy machinery. :d
> Cheers,
>

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

end of thread, other threads:[~2013-07-14 17:35 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-13 13:12 [ob][bug] C++-mode is unknown Rasmus
2013-07-13 13:23 ` Rasmus
2013-07-13 21:53   ` export to markdown Rill
2013-07-13 22:08     ` Suvayu Ali
     [not found]       ` <51E1D61E.9050502@yahoo.com>
2013-07-14  7:49         ` Suvayu Ali
2013-07-14 17:35           ` Rill
2013-07-13 13:38 ` [ob][bug] C++-mode is unknown Eric Schulte
2013-07-13 14:41   ` Rasmus
2013-07-13 17:59     ` Rasmus
2013-07-13 18:39       ` Eric Schulte
2013-07-13 18:59         ` Rasmus

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).