Question for emacs users

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
mongrol
Prole
Posts: 33
Joined: Fri Nov 30, 2012 1:01 am

Question for emacs users

Post by mongrol »

Hi all,
Normally I do my C++ dev in Vim and used Emacs for orgmode only. Now I'm moving to Lua I fancy using Emacs for this. I have lua-mode installed and the love-mode as well. I can run my code using C-! "love ./" but any debug shows up printed graphically in the love window. I'd much rather it was in a emacs debug type of window where I can use it to skip to the error.

How do other Emacs users do their love dev?
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Question for emacs users

Post by bartbes »

I'm not an emacs user, so I don't know exactly what you want. I do know, however, that all errors are printed on the terminal too, so if you catch the output of love, you should at least have it in emacs..
User avatar
the_leg
Prole
Posts: 25
Joined: Sun Sep 05, 2010 3:43 am

Re: Question for emacs users

Post by the_leg »

I use Compilation mode to capture the output and hyperlink the error messages to the source code. To enter this mode, you type 'M-x compile'. You'll be prompted to enter the compile command (or accept the default 'make' command).

Here's part of my .emacs that sets this up. I bind C-x C-k to enter this mode.

Code: Select all

(global-set-key "\C-x\C-k" 'compile)
(add-hook 'lua-mode-hook
	  (lambda ()
	    (if  (file-exists-p "main.lua")
		(progn 
		  (set (make-local-variable 'compile-command) "love . ")
		  (add-to-list 'compilation-error-regexp-alist 'love t)
		  (add-to-list 'compilation-error-regexp-alist-alist
			       '(love "^Error: Syntax error: \\(.*?\\):\\([0-9]+\\):.*$" 1 2) t))
       (set (make-local-variable 'compile-command)
                  (concat "lua " (file-name-nondirectory buffer-file-name))))))
The above checks if main.lua exists in your current dir, and if so sets the compile command to be 'love .', otherwise it sets the compile command to 'lua <current-buffer-file-name>'. The regular expression is needed to handle LOVE's error message format.

I also use flymake-lua. This checks the syntax of your Lua code as you type and highlights any errors. Here's how I set that up:

Code: Select all

(require 'flymake-lua)
(add-hook 'lua-mode-hook 'flymake-lua-load)
Let me know if you have any questions.
mongrol
Prole
Posts: 33
Joined: Fri Nov 30, 2012 1:01 am

Re: Question for emacs users

Post by mongrol »

Great! Thanks very much.
User avatar
ejmr
Party member
Posts: 302
Joined: Fri Jun 01, 2012 7:45 am
Location: South Carolina, U.S.A.
Contact:

Re: Question for emacs users

Post by ejmr »

I am also a long-term Emacs user and started this project some time ago to help with LÖVE development:

https://github.com/ejmr/love-minor-mode

Please feel free to suggest any additions that may be useful; I will admit it does not do too much at the moment.
ejmr :: Programming and Game-Dev Blog, GitHub
南無妙法蓮華經
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 7 guests