all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Changing Languages in a file
@ 2009-09-08 20:01 Jonathan Seng
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Seng @ 2009-09-08 20:01 UTC (permalink / raw)
  To: help-gnu-emacs

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

I need to change languages within a file used for generating code in another
language.  For example, I might have a Python script generating C or C++
code.

The documentation tells me I can specify at the top of the file for the
entire file, but I can't find a way to change this for sections of a file.

Is there a way to do this?

Thank you,

Jonathan

[-- Attachment #2: Type: text/html, Size: 389 bytes --]

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

* Re: Changing Languages in a file
       [not found] <mailman.6255.1252454488.2239.help-gnu-emacs@gnu.org>
@ 2009-09-09  7:41 ` Anselm Helbig
  2009-09-09 12:46 ` Colin S. Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Anselm Helbig @ 2009-09-09  7:41 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 967 bytes --]

Hi!

> I need to change languages within a file used for
> generating code in another language.  For example,
> I might have a Python script generating C or C++
> code.
> 
> The documentation tells me I can specify at the top
> of the file for the entire file, but I can't find a
> way to change this for sections of a file.
> 
> Is there a way to do this?

This is currently a weak point of Emacs. It is built around the
assumption that each buffer has exactly one major mode at a time. Read
more about major modes here:

  (info "(emacs) Major Modes")

There are some hacks to overcome this restriction, they are listed
here: 

  http://www.emacswiki.org/emacs/MultipleModes

However, setting one of these up can be a bit daunting, especially for
someone new to Emacs. IMO the cleanest and most practical solution
would be to keep your code generation templates in separate files.

HTH, 

Anselm



-- 
Anselm Helbig 
mailto:anselm.helbig+news2009@googlemail.com


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

* Re: Changing Languages in a file
       [not found] <mailman.6255.1252454488.2239.help-gnu-emacs@gnu.org>
  2009-09-09  7:41 ` Changing Languages in a file Anselm Helbig
@ 2009-09-09 12:46 ` Colin S. Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Colin S. Miller @ 2009-09-09 12:46 UTC (permalink / raw)
  To: help-gnu-emacs

Jonathan Seng wrote:
> I need to change languages within a file used for generating code in 
> another language.  For example, I might have a Python script generating 
> C or C++ code.
> 
> The documentation tells me I can specify at the top of the file for the 
> entire file, but I can't find a way to change this for sections of a file.
> 
> Is there a way to do this?
> 
> Thank you,
> 
> Jonathan

Jonathan,

If the C code is localalised to a few blocks in the python, then
this works.

M-x make-indirect-buffer RET <new buffer name>
C-x b <new buffer name>
Select the C code
M-x narrow-to-region
M-x c-mode

Not idea but it works.

HTH,
Colin S. Miller

-- 
Replace the obvious in my email address with the first three letters of the hostname to reply.


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

end of thread, other threads:[~2009-09-09 12:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.6255.1252454488.2239.help-gnu-emacs@gnu.org>
2009-09-09  7:41 ` Changing Languages in a file Anselm Helbig
2009-09-09 12:46 ` Colin S. Miller
2009-09-08 20:01 Jonathan Seng

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.