all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* usage of bgein_src in 'Literal examples' section
@ 2008-06-04 22:21 Patrick Drechsler
  2008-06-05  0:30 ` Bernt Hansen
  0 siblings, 1 reply; 7+ messages in thread
From: Patrick Drechsler @ 2008-06-04 22:21 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

I like the new feature in "literal examples" using #+BEGIN_SRC <mode>!

But how do I find which mode Emacs is using for a certain file type?

I could not figure out how to replace <mode> for simple C or CPP files.

Here is a simple C file:

--8<---------------cut here---------------start------------->8---
int main(void)
{
	return 0;
}
--8<---------------cut here---------------end--------------->8---

I have tried different results from `M-x describe-mode' as well as stuff
like:

#+BEGIN_SRC c
#+BEGIN_SRC c/law
#+BEGIN_SRC cc
#+BEGIN_SRC c-mode
#+BEGIN_SRC cc-mode

What is the correct <mode> to insert?

The doc-string says this:

,----
|    If the example is source code from a programming language, or any
| other text that can be marked up by font-lock in Emacs, you can ask
| for the example to look like the fontified Emacs buffer(1).  This is
| done with the `src' block, where you also need to specify the name of
| the major mode that should be used to fontify the example:
| 
|      #+BEGIN_SRC emacs-lisp
|      (defun org-xor (a b)
|         "Exclusive or."
|         (if a (not b) b))
|      #+END_SRC
`----

Maybe it would be nice to add something along the lines of:

--8<---------------cut here---------------start------------->8--- 

You can find out the Emacs mode corresponding to your source language by
visiting a file in the particular mode and calling 

`M-x <describe?-???>'.

--8<---------------cut here---------------end--------------->8---

TIA

Patrick
-- 
An idea is like a cup of coffee, it's not going to stay hot forever.

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

* Re: usage of bgein_src in 'Literal examples' section
  2008-06-04 22:21 usage of bgein_src in 'Literal examples' section Patrick Drechsler
@ 2008-06-05  0:30 ` Bernt Hansen
  2008-06-05  1:40   ` Patrick Drechsler
  0 siblings, 1 reply; 7+ messages in thread
From: Bernt Hansen @ 2008-06-05  0:30 UTC (permalink / raw)
  To: Patrick Drechsler; +Cc: emacs-orgmode

Patrick Drechsler <patrick@pdrechsler.de> writes:

> I like the new feature in "literal examples" using #+BEGIN_SRC <mode>!
>
> But how do I find which mode Emacs is using for a certain file type?
>
> I could not figure out how to replace <mode> for simple C or CPP files.
>
> Here is a simple C file:
>
> --8<---------------cut here---------------start------------->8---
> int main(void)
> {
> 	return 0;
> }
> --8<---------------cut here---------------end--------------->8---
>
> I have tried different results from `M-x describe-mode' as well as stuff
> like:
>
> #+BEGIN_SRC c
> #+BEGIN_SRC c/law
> #+BEGIN_SRC cc
> #+BEGIN_SRC c-mode
> #+BEGIN_SRC cc-mode
>
> What is the correct <mode> to insert?
>

This works for me:

* C Source Example
#+BEGIN_SRC c
int main(void)
{
  return 0;
}
#+END_SRC

And then C-c ' anywhere inside the block

HTH

-Bernt

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

* Re: usage of bgein_src in 'Literal examples' section
  2008-06-05  0:30 ` Bernt Hansen
@ 2008-06-05  1:40   ` Patrick Drechsler
  2008-06-05  1:58     ` Bernt Hansen
  0 siblings, 1 reply; 7+ messages in thread
From: Patrick Drechsler @ 2008-06-05  1:40 UTC (permalink / raw)
  Cc: emacs-orgmode

Bernt Hansen schrieb:
> Patrick Drechsler <patrick@pdrechsler.de> writes:
> 
>> I like the new feature in "literal examples" using #+BEGIN_SRC <mode>!
>>
>> But how do I find which mode Emacs is using for a certain file type?
>>
>> I could not figure out how to replace <mode> for simple C or CPP files.
>>
>> What is the correct <mode> to insert?
[snip]
> This works for me:
> 
> * C Source Example
> #+BEGIN_SRC c
> int main(void)
> {
>   return 0;
> }
> #+END_SRC
[snip]
> 
> HTH

Yes, it did, thanks a lot Bernt!

Mmmh, I just have to many emacs devel versions currently on my system to 
reproduce the original error at the moment...

But how do I find out which is the correct string for the Emacs mode?

Is there a `M-x describe-??' method?

Patrick

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

* Re: usage of bgein_src in 'Literal examples' section
  2008-06-05  1:40   ` Patrick Drechsler
@ 2008-06-05  1:58     ` Bernt Hansen
  2008-06-06 10:39       ` Patrick Drechsler
  0 siblings, 1 reply; 7+ messages in thread
From: Bernt Hansen @ 2008-06-05  1:58 UTC (permalink / raw)
  To: Patrick Drechsler; +Cc: emacs-orgmode

Patrick Drechsler <patrick@pdrechsler.de> writes:

> But how do I find out which is the correct string for the Emacs mode?
>
> Is there a `M-x describe-??' method?

I think any function ending in '-mode' would be valid

If you open a file and it automatically loads the correct mode the mode
is listed on the modeline in ()
e.g. while composing this message it's (Message MML Fly OrgStruct) as
major mode and minor modes.

There's a variable 'auto-mode-alist' (C-h v auto-mode-alist) which lists
the mappings of filenames to modes.

I have entries like this in mine:

 ("\\.txt$" . outline-mode)
 ("\\.css\\'" . css-mode)
 ("\\.py\\'" . python-mode)
etc

so for *.py files which use python-mode

#+BEGIN_SRC python
def foo():
    print "in foo"
    10

if __name__ == '__main__':
    foo()
#+END_SRC

HTH,
Bernt

PS. Sorry I didn't answer that the first time around...

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

* Re: usage of bgein_src in 'Literal examples' section
  2008-06-05  1:58     ` Bernt Hansen
@ 2008-06-06 10:39       ` Patrick Drechsler
  2008-06-06 11:27         ` Dominik, C.
  0 siblings, 1 reply; 7+ messages in thread
From: Patrick Drechsler @ 2008-06-06 10:39 UTC (permalink / raw)
  To: emacs-orgmode

Bernt Hansen <bernt@norang.ca> writes:

> Patrick Drechsler <patrick@pdrechsler.de> writes:
>
>> But how do I find out which is the correct string for the Emacs mode?
>>
>> Is there a `M-x describe-??' method?
>

[...]

> There's a variable 'auto-mode-alist' (C-h v auto-mode-alist) which
> lists the mappings of filenames to modes.

[...]

Thank Bernt, this the the variable I was looking for!

Cheers,

Patrick 
-- 
Sleep: Thing used by ineffective people as a substitute for coffee.
Ambition: A poor excuse for not having enough sense to be lazy.

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

* RE: Re: usage of bgein_src in 'Literal examples' section
  2008-06-06 10:39       ` Patrick Drechsler
@ 2008-06-06 11:27         ` Dominik, C.
  2008-06-07 13:44           ` Patrick Drechsler
  0 siblings, 1 reply; 7+ messages in thread
From: Dominik, C. @ 2008-06-06 11:27 UTC (permalink / raw)
  To: Patrick Drechsler, emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1320 bytes --]


You can also load the file into Emacs and then check the value of
the variable `major-mode' in that buffer.  It will be c-mode or org-mode
or whatever.  From this value, just strig the "-mode" and you have
the value you need to use in the begin_src line.

- Carsten

-----Original Message-----
From: emacs-orgmode-bounces+dominik=science.uva.nl@gnu.org on behalf of Patrick Drechsler
Sent: Fri 6/6/2008 12:39 PM
To: emacs-orgmode@gnu.org
Subject: [Orgmode] Re: usage of bgein_src in 'Literal examples' section
 
Bernt Hansen <bernt@norang.ca> writes:

> Patrick Drechsler <patrick@pdrechsler.de> writes:
>
>> But how do I find out which is the correct string for the Emacs mode?
>>
>> Is there a `M-x describe-??' method?
>

[...]

> There's a variable 'auto-mode-alist' (C-h v auto-mode-alist) which
> lists the mappings of filenames to modes.

[...]

Thank Bernt, this the the variable I was looking for!

Cheers,

Patrick 
-- 
Sleep: Thing used by ineffective people as a substitute for coffee.
Ambition: A poor excuse for not having enough sense to be lazy.




_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[-- Attachment #1.2: Type: text/html, Size: 2049 bytes --]

[-- Attachment #2: Type: text/plain, Size: 204 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: usage of bgein_src in 'Literal examples' section
  2008-06-06 11:27         ` Dominik, C.
@ 2008-06-07 13:44           ` Patrick Drechsler
  0 siblings, 0 replies; 7+ messages in thread
From: Patrick Drechsler @ 2008-06-07 13:44 UTC (permalink / raw)
  To: emacs-orgmode

"Dominik, C." <C.Dominik@uva.nl> writes:

>> Bernt Hansen <bernt@norang.ca> writes:
>>
>>> Patrick Drechsler <patrick@pdrechsler.de> writes:
>>>
>>>> But how do I find out which is the correct string for the Emacs mode?
>>>>
>>>> Is there a `M-x describe-??' method?
>>>
>>
>>> There's a variable 'auto-mode-alist' (C-h v auto-mode-alist) which
>>> lists the mappings of filenames to modes.
>>
>> Thank Bernt, this the the variable I was looking for!
>
> You can also load the file into Emacs and then check the value of the
> variable `major-mode' in that buffer.  It will be c-mode or org-mode
> or whatever.  From this value, just strig the "-mode" and you have the
> value you need to use in the begin_src line.

This also works fine, thanks for your feedback Dominik. As mentioned in
a previous mail I got a bit confused between different emacs buidls on
my machine, sorry for the noise.

Cheers,

Patrick  
-- 
1 + 1 = 3 for large values of 1 and small values of 3. ;-)

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

end of thread, other threads:[~2008-06-07 13:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-04 22:21 usage of bgein_src in 'Literal examples' section Patrick Drechsler
2008-06-05  0:30 ` Bernt Hansen
2008-06-05  1:40   ` Patrick Drechsler
2008-06-05  1:58     ` Bernt Hansen
2008-06-06 10:39       ` Patrick Drechsler
2008-06-06 11:27         ` Dominik, C.
2008-06-07 13:44           ` Patrick Drechsler

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.