[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: using string variable with file name

From: saneman
Subject: Re: using string variable with file name
Date: Sat, 23 Feb 2008 13:16:11 +0100
User-agent: Thunderbird (X11/20071022)

Joost Kremers wrote:
saneman wrote:
In my .emacs file I have made:

;; Directories
(setq mylisp "~/work/mylisp/")

;; Line numbers
(load-file mylisp cons "setnu.el")
(global-set-key "\C-cl" 'setnu-mode)

But this gives an error. How do I "cons" the variable mylisp with a filename?

(cons mylisp "setnu.el")

however, that gives you a cons, which (i think) is not what you want. in
order to concatenate strings, you need concat:

(concat mylisp "setnu.el")

but even that is probably not the best way to do what you want. it's
probably better to add "~/work/mylisp" to your load path:

(setq load-path (cons "~/work/mylisp" load-path))

then you can load the file without explicitly naming its path:

(load-file "setnu.el")

When using you last advice:
(setq load-path (cons "~/work/mylisp" load-path))
(load-file "setnu.el")

I get the error:
File error: "Cannot open load file", "/home/saneman/setnu.el"

Seems that the load-path is not updated.

The fist solution:
(setq mylisp "~/work/mylisp/")
(load-file (concat mylisp "setnu.el" ))

works. Are there any rules that say that .el files will not be found in the load-path?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]