Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old October 2nd, 2006, 10:43 AM
jantman jantman is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2006
Posts: 191 jantman User rank is Sergeant (500 - 2000 Reputation Level)jantman User rank is Sergeant (500 - 2000 Reputation Level)jantman User rank is Sergeant (500 - 2000 Reputation Level)jantman User rank is Sergeant (500 - 2000 Reputation Level)jantman User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 53 m 4 sec
Reputation Power: 16
Emacs Lisp - buffer name as part of compile-command

Hello,

I'm trying to setup GNU emacs to do some SIMPLE java work for me.

I'm working in a given folder, and want to just edit and compile programs in this one folder.

In my .emacs, I have:

Code:
(setq compile-command (concat "javac " (buffer-name)))



I cd to the folder, and run emacs sample.java

I edit the file, and then in emacs, I M-x compile.

The problem, is that in the minibuffer, it shows:
Compile command: javac *scratch*

instead of javac sample.java

Why is this? The buffer *scratch* is (by default) open, but is NOT in the one visible window - sample.java is.

How to I get this to use the correct buffer name for the active buffer?

Reply With Quote
  #2  
Old October 2nd, 2006, 08:34 PM
jantman jantman is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2006
Posts: 191 jantman User rank is Sergeant (500 - 2000 Reputation Level)jantman User rank is Sergeant (500 - 2000 Reputation Level)jantman User rank is Sergeant (500 - 2000 Reputation Level)jantman User rank is Sergeant (500 - 2000 Reputation Level)jantman User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 53 m 4 sec
Reputation Power: 16
An answer to this question was posted on LinuxQuestions.org thanks to user "ntubski".

His post was as follows:
Quote:
The problem is that compile-command gets set when the your .emacs is loaded, what you need to do is add a hook that will run every time you open a java file:

Code:
(add-hook 'java-mode-hook
	  (lambda()
	    (set (make-local-variable 'compile-command) (concat "javac " (buffer-name)))))


Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > Emacs Lisp - buffer name as part of compile-command


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway