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

11,925

Solution 1

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.

Solution 2

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))
Share:
11,925

Related videos on Youtube

rabidmachine9
Author by

rabidmachine9

I love experimenting with things I don't know...

Updated on June 04, 2022

Comments

  • rabidmachine9
    rabidmachine9 almost 2 years

    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