5

I'm a bit confused because the I'm trying to configure org within spacemacs as advised in the official layer documentation for spacemacs), I should use (with-eval-after-load 'org ( ... :

(defun dotspacemacs/user-config ()
  "Configuration function.
 This function is called at the very end of Spacemacs initialization after
layers configuration."
  ;; My keys
  (global-set-key [f2] 'deft)
  ;; My Notes
  (setq deft-directory "c:/Users/ZsBotykai/Dropbox/Notes/"
        deft-extensions '("org" "md" "txt")
        deft-use-filename-as-title t
        deft-text-mode 'org-mode)

  ;; ORG settings
  (with-eval-after-load 'org (
                              (setq org-agenda-files
                                    "c:/Users/USERNAME/Dropbox/Notes/"))
;; Further lines snipped...

I'm getting the following error:

(Spacemacs) Error in dotspacemacs/user-config: Invalid function: (setq org-agenda-files "c:/Users/USERNAME/Dropbox/Notes/")

I did try to use

(with-eval-after-load 'org (
                            (setq org-agenda-files
                                  '("c:/Users/USERNAME/Dropbox/Notes/")))

Without any success. Could you point me into the right direction?

  • 2
    Note that with-eval-after-load (and eval-after-load) is only necessary to set up configuration that depends on the package being loaded. A setq with a literal value does therefore not need it (but manipulating a package's keymap does). – wasamasa Jan 9 '16 at 13:27
8

As pointed in the spacemacs Gitter channel, you should do just:

(with-eval-after-load 'org (setq org-agenda-files
                              '("c:/Users/USERNAME/Dropbox/Notes/")))

The reason is that when the lisp reader tries to evaluate that code you put, it interprets that (setq org-agenda-files '("c:/Users/USERNAME/Dropbox/Notes/")) is a whole function, which is wrong.

The macro with-eval-after-load just expects a form to execute.

Hope it helps. (credits to honkhonkhonk, gitter channel)

1

An alternative way. I have been using the following form in my init.el:

(spacemacs|use-package-add-hook org-mode
  :post-config
  (progn
      (setq org-agenda-files '("c:/Users/USERNAME/Dropbox/Notes/")
    ))

I use this form for almost all the layers that I need to customize. It helps to separate my customizations instead of stuffing them all in dotspacemacs/user-config. Perhaps with-eval-after-load has some advantages, but I do not know.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.