Getting the current directory in Emacs Lisp

I am trying to write a .dir-locals.el file. I want to dynamically find the directory where the file is located and merge it using "TAGS". This was my first attempt:

((nil . ((tags-file-name . (concat default-directory "TAGS")))))

This does not work. I am not an expert at Emacs Lisp. What is wrong with him?

+3
source share
4 answers

Combining the sanityinc solution and some other snippet that I found elsewhere, I get:

((nil . ((eval . (setq tags-file-name (concat (locate-dominating-file buffer-file-name ".dir-locals.el") "TAGS"))))))

I think it does what you want (a little inefficient, since we have to search .dir-locals.el twice).

+2
source

In linux, how about:

(getenv "PWD")
+2
source

- , .dir-locals.el:

((nil . ((eval . (setq tags-file-name (concat default-directory "TAGS"))))))

, , default-directory nil dir-locals, , .

, tags-file-name , . , .

, ? TAGS - , .

: add-on project-local-variables, , , . .

+1

, , (concat default-directory "TAGS") .

tags-file-name, : (setq tags-file-name (concat default-directory "TAGS")).

-1
source

All Articles