I have just install a version of emacs (GNU Emacs 24.5.1 i686-pc-mingw32) on a Windows 8 Machine. On trying to open an example SML file (Standard ML Language). An error occurred:

File mode specification error: (error "Autoloading failed to define function sml-mode")

On deeper inspection the debugger shows this:

Debugger entered--Lisp error: (error "Autoloading failed to define function sml-mode")
set-auto-mode-0(sml-mode nil)
after-find-file(nil t)
find-file-noselect-1(# "g:/example00.sml" nil nil "g:/example00.sml" ((512 4 . 8192) (48259 . 42323)))
find-file-noselect("g:/example00.sml" nil nil nil)
call-interactively(menu-find-file-existing nil nil)

How can I resolve this error?

Edit : I installed sml-mode via list-packages.

  • Is the directory that contains the library that defines sml-mode in your load-path? If not, that's your problem.
    – Drew
    Feb 20 '17 at 18:02
  • @Drew How do I do that? (To be honest, I am very new to using emacs.)
    – krismath
    Feb 20 '17 at 18:04
  • See the Emacs manual, node Lisp Libraries. In a nutshell, you use (add-to-list 'load-path "/path/to/your/directory/") and then you use (require 'the-library).
    – Drew
    Feb 20 '17 at 18:12
  • If you installed the library using the package interface then be sure to use (package-initialize). In that case, you should not need to fiddle with load-path and require.
    – Drew
    Feb 20 '17 at 18:13
  • 1
    Put that in your init file. Start by reading about your init file.
    – Drew
    Feb 20 '17 at 21:35

This is a problem of conflicting libraries in load-path. I think you should inspect your load-path to see if you have sml-mode directory in it twice. The first directory probably doesn't contain a definition for sml-mode and hence Emacs fails to load it from there.

You can do M-x list-load-path-shadows to see if some sml-mode like file is shadowing the original file with the right definitions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.