开发者

Plugin in Emacs

I'm trying to install lua-mode into emacs for windows but nothing seems to be working. I've set my HOME environment variable. I've added init.el and lua-mode.el to the HOME\.emacs.d directory. Then I've added the following code to init.el:

(autoload 'lua-mode "lua-mode" "Lua editing mode." t)
(add-to-list 'auto-mode-alist '("\\.lua$" . lua-mode))
(add-to-list 'interpreter-mode-alist '("lua" . lua-mode))

(add-hook 'lua-mode-hook 'turn-on-font-lock)

Nothing is working when I start up emacs and load a .lua file. The major mode is always set to fundamental and there are no other options to change to. What can I do to get this working开发者_如何学C?


It's possible that your init.el is never read, because you also have a .emacs file (or .emacs.el) in your $HOME directory. You can choose between those three alternatives for Emacs' init file, but only one of them will be read. Traditionally, that's .emacs but some operating systems have problems with that filename syntax.

Also, make sure that you placed init.el in your actual home directory, not a directory called "HOME" or something.

See here for further details on Emacs init files and here for more info on home directories.


If you're not keen on using the init.el variant, here are instruction that should make lua-mode work for you using .emacs:

  1. Start a new Emacs
  2. Type C-x C-f ~/.emacs <ENTER> (C-x means press CTRL, hold it, press x, release - same for C-f)
  3. Insert the following lines:

    (add-to-list 'load-path "/path/to/lua-mode-dir")
    
    (autoload 'lua-mode "lua-mode" "Lua editing mode." t)
    (add-to-list 'auto-mode-alist '("\\.lua$" . lua-mode))
    (add-to-list 'interpreter-mode-alist '("lua" . lua-mode))
    
    (add-hook 'lua-mode-hook 'turn-on-font-lock)
    
  4. Type C-x C-s to save the buffer to file

  5. Type C-x C-c to close Emacs

Note that in step 3 you have to adjust "/path/to/lua-mode-dir" with the actual path to the directory where you saved the file lua-mode.el on your hard disk.


maybe you need something like (require 'lua-mode) or something like that? Also make sure that the lua-mode file is in a directory in your load-path variable. Something like this before anything else:

(add-to-list 'load-path "/home/dervin/.emacs.d/site-lisp/")

or wherever, and then the require-


The lines look OK. This can depend on a number of things:

  • The init.el file is not loaded at startup. In face, this is a non-standard name when it comes to Emacs. Emacs tries to load the files ~/.emacs, ~/emacs.el, and ~/.emacs.d/init.el in order, and will load the first one found. To verify that you file has loaded, you could add (message "Loading my init.el") inside it and check the *Messages* buffer.
  • The directory where you stored the file lua-mode.el is not in the load path. In fact, the ~/.emacs.d directory is not part of the standard load path.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜