Concatenate strings in elisp

prosseek picture prosseek · Sep 16, 2010 · Viewed 26.7k times · Source

I need to concatenate path string as follows, so I added the following lines to my .emacs file:

(setq org_base_path "~/smcho/time/")
(setq org-default-notes-file-path (concatenate 'string org_base_path "notes.org"))
(setq todo-file-path (concatenate 'string org_base_path "gtd.org"))
(setq journal-file-path (concatenate 'string org_base_path "journal.org"))
(setq today-file-path (concatenate 'string org_base_path "2010.org"))

When I do C-h v today-file-path RET to check, it has no variable assigned.

What's wrong with my code? Is there any other way to concatenate the path string?

EDIT

I found that the problem was caused by wrong setup, the code actually works. Thanks for the answers which are better than my code.

Answer

offby1 picture offby1 · Sep 17, 2010

You can use (concat "foo" "bar") rather than (concatenate 'string "foo" "bar"). Both work, but of course the former is shorter.