2

I want to load the multi-web-mode package and have put it in ~/.emacs.d/ or ~/ or ~/.emacs.d/lisp/(so far).

My .emacs contains the standard from the multi-web-mode distribution:

(require 'multi-web-mode)
(setq mweb-default-major-mode 'html-mode)
(setq mweb-tags 
  '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
    (js-mode  "<script[^>]*>" "</script>")
    (css-mode "<style[^>]*>" "</style>")))
(setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
(multi-web-global-mode 1)

I get:

File error: Cannot open load file, no such file or directory, multi-web-mode

I was expecting that emacs would search in some of my directories and automatically discover it.

When I add

(load-file "~/.emacs.d/lisp/multi-web-mode.el")

or

(add-to-list 'load-path "~/.emacs.d/lisp/")

to the .emacs file the emacs lisp file is loaded alright.

Is there really no user directory where the .el files are automatically loaded from? Would I always need to do (add-to-list 'load-path "~/.emacs.d/lisp/") everytime I setup emacs?

  • What's wrong with adding that dir to load-path. If you expect to load libraries from that dir then you need to tell that to Emacs, one way or another. Just do that in your init file. Or put the library in some dir that is already in your load-path. Directly or indirectly, you are the one who puts that library in that dir. Directly or indirectly, you are the one who needs to tell Emacs about that. – Drew Jul 3 '17 at 14:50
  • There is nothing wrong with adding load-path. I was just expecting that it would seek in some user directory. I don't do much lisp programming and tend to forget syntax and names. – Finn Årup Nielsen Jul 3 '17 at 17:02
2

You can type M-x ielm

Then in the REPL type load-path to see what the default is. I know package manager appends to it but I'm not sure what else (if anything) does. You can add (add-to-list 'load-path "~/.emacs.d/lisp/") to your init.el file. It is good to get used to modifying your init.el file. I actually have multiple *.el files for my configuration that I modify. The more you use emacs the more you will want to customize it to your needs. If you search the web for emacs configuration you will find many examples on github.

I setup my .emacs.d directory with a small 'init.el' that contains load-path adjustments and a few other small things. Then I have an emacs-config directory that contains more .el files including but not limited to:

.emacs.d/home/emacs-config:

  dired-setup.el
  emacs-config.el
  hydra-binding.el
  ibuffer-setup.el
  init.el
  key-binding.el
  org-setup.el
  util-functions.el
  window-setup.el

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.