tags:

views:

84

answers:

3

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

(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 use the key 'C-h v today-file-path' to check, it has no variable assigned.

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

ADDED

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

+1  A: 

First of all, don't use "_"; use '-' instead. Insert this into your .emacs and restart emacs (or evaluate the S-exp in a buffer) to see the effects:

(setq org-base-path (expand-file-name "~/smcho/time"))

(setq org-default-notes-file-path (format "%s/%s" org-base-path "notes.org")
      todo-file-path              (format "%s/%s" org-base-path "gtd.org")
      journal-file-path           (format "%s/%s" org-base-path "journal.org")
      today-file-path             (format "%s/%s" org-base-path "2010.org"))
OTZ
+1  A: 

Use expand-file-name to build filenames relative to a directory:

(let ((default-directory "~/smcho/time/"))
  (setq org-default-notes-file-path (expand-file-name "notes.org"))
  (setq todo-file-path (expand-file-name "gtd.org"))
  (setq journal-file-path (expand-file-name "journal.org"))
  (setq today-file-path (expand-file-name "2010.org")))
Jürgen Hötzel
+1  A: 

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

offby1