Search code examples
emacselisp

Concatenate strings in elisp


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 the wrong setup, the code actually works. Thanks for the answers which are better than my code.


Solution

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