Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

add-to-list 'load-path doesn't seem to work

Whenever I see some installation instruction for an emacs package it always suggests to use add-to-list 'load-path it never works for me. For some reason and I have to use load-file. For example, this will not work:

(add-to-list 'load-path "~/.emacs.d/jade-mode")
(require 'sws-mode)
(require 'jade-mode)    
(add-to-list 'auto-mode-alist '("\\.styl$" . sws-mode))
(add-to-list 'auto-mode-alist '("\\.jade$" . sws-mode))

but this will work:

(load-file "~/.emacs.d/jade-mode/sws-mode.el")
(load-file "~/.emacs.d/jade-mode/jade-mode.el")
(require 'sws-mode)
(require 'jade-mode)    

anybody can tell me why? EDIT: I use Carbon Emacs on MAC OS X 10.5

like image 743
rabidmachine9 Avatar asked Aug 02 '11 17:08

rabidmachine9


2 Answers

Perhaps the problem is that the leading tilde ('~') is not expanded when require searches the entries in the load-path list. Consider using the expand-file-name function to prepare your entry for subsequent use by require:

(add-to-list 'load-path (expand-file-name "jademode" "~/.emacs.d"))

or

(add-to-list 'load-path (expand-file-name "~/.emacs.d/jademode"))

It would help to know which Emacs you're using on which operating system.

like image 104
seh Avatar answered Oct 17 '22 22:10

seh


i'm not 100% sure but i would guess that the list is not instantiated and thus you can't add anything to the load-path list, i just instantiate the list with

    (setq load-path (cons (expand-file-name "~/.emacs.d/lisp")
              load-path))
like image 28
Xtroce Avatar answered Oct 17 '22 22:10

Xtroce