Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get path to current emacs script file when loaded with -l parameter

Tags:

emacs

elisp

From within a lisp file being loaded and run with emacs -l path/to/script/foo.el can I get the path to file being run?

For example, is there some way to determine what path/to/script is from within foo.el?

I am not very experienced with lisp so please be gentle with your solutions.

Emacs 22.3.1 on Windows 7

like image 524
Jesse Vogt Avatar asked Nov 03 '10 15:11

Jesse Vogt


1 Answers

The variable load-file-name is bound to the name of the file as it is being loaded. To get the directory, you'd just use file-name-directory, like so:

(file-name-directory load-file-name)
like image 69
Trey Jackson Avatar answered Nov 04 '22 23:11

Trey Jackson