LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-18-2008, 12:49 PM   #1
raskol
Member
 
Registered: Mar 2008
Posts: 51

Rep: Reputation: 15
More Emacs-help, interpret/compile from emacs?


1. how do i change between programlanguages?
i mean so the editor knows how to indent. i program in Python, Java, Lisp
and Prolog.

2. can i compile any code? i mean can emacs compile and run JAVA-rpograms and LISP-programs?
or is emacs "just" an editor?

Last edited by raskol; 04-18-2008 at 01:23 PM.
 
Old 04-18-2008, 02:25 PM   #2
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
Quote:
Originally Posted by raskol View Post
1. how do i change between programlanguages?
i mean so the editor knows how to indent. i program in Python, Java, Lisp
and Prolog.

2. can i compile any code? i mean can emacs compile and run JAVA-rpograms and LISP-programs?
or is emacs "just" an editor?
1. emacs knows file exensions & will choose a highlight syntax accordingly. If it doesn't figure it out, you have three options:

The easiest is "M-x <language>-mode", i.e. "M-x php-mode" or "M-x c++-mode".

A second method is to put a comment in the file that tells emacs what syntax to use, the line would look something like:

Code:
// -*- mode: c++ -*-
... I believe that has to be the first or one of the first lines in the file.

The last, more permanent way is to add an entry to your .emacs file. I don't know enough about that method to give you good instruction, but an example from my .emacs is this:

Code:
(autoload 'python-mode "python-mode" "Python Mode." t)
(add-to-list 'auto-mode-alist '("\\.py\\'\\|\\.rfs\\'" . python-mode))
(add-to-list 'interpreter-mode-alist '("python" . python-mode))

Of course, all of this assumes that you have the elisp for each of the languages you're looking for.



2. I believe lisp and scheme can be run right in the emacs session (and mail too), but I don't remember how to do it as it's been a *very* long time since Ive written anything in those languages, That said, you can always open up a shell buffer, i.e. "M-x shell" which will give you a shell where you can do anything you could do in the shell.
 
Old 04-19-2008, 01:24 PM   #3
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,784

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
Quote:
Originally Posted by raskol View Post
2. can i compile any code? i mean can emacs compile and run JAVA-rpograms and LISP-programs?
or is emacs "just" an editor?
You can evaluate elisp "programs" from the *scratch* buffer: type (+ 1 1) and then type C-j. There is a good tutorial for Emacs Lisp that comes with Emacs 22: "<f1>imEmacs Lisp Intro" to see it.

Emacs can't run Java programs, but it can run any arbitrary shell command to compile things: do M-x compile, this command will interpret the output of the compiler, you can press M-g M-n to jump to the next error in the source.

For more fancy integration you can try out JDEE, though last time I tried it, I found it somewhat buggy.

For Scheme there is quack, for Common Lisp there is SLIME
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Emacs editing, Pt.5: Shape your Emacs view LXer Syndicated Linux News 0 08-09-2007 07:46 AM
Alt no longer META key when using in-terminal option of Emacs (emacs -nw) frznchckn Linux - Software 1 06-02-2007 02:41 AM
LXer: Emacs tips: Customize your Emacs experience LXer Syndicated Linux News 0 08-10-2006 12:21 PM
emacs shell-mode doesn't interpret prompt variable CoonerTheRed Linux - Software 1 05-09-2005 04:23 AM
edb (emacs database) won't open file - emacs 20 & 21 tip184 Linux - Software 0 04-03-2004 07:31 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration