0

This set up ignores the custom-set-variables statement and generates the warning reproduced below. If I uncomment the first statement, however, it works. This is probably a novice's issue... Is there any way to make the first statement using the interface such as to prevent syntax errors?

(add-to-list 'org-refile-targets '("~/Documents/org/.notes.org"  :maxlevel . 4))
;; (setq org-refile-targets '(("~/Documents/org/.notes.org" :maxlevel . 4)))
(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(org-agenda-files '("~/Documents/org/.notes.org"))
 '(org-babel-load-languages '((python . t) (emacs-lisp . t) (shell . t)))
 '(org-capture-templates
   '(("b" "Bookmark" entry
      (file+headline "~/Documents/org/.notes.org" "Review")
      (file "~/Documents/org/tpl-bookm.txt")
      :immediate-finish t :jump-to-captured t :empty-lines-before 1)
     ("c" "Code" entry
      (file+olp "~/Documents/org/.notes.org" "Code")
      (file "~/Documents/org/tpl-code.txt")
      :empty-lines 1)
     ("d" "Deadline" entry
      (file+headline "~/Documents/org/.notes.org" "Deadline")
      (file "~/Documents/org/tpl-deadl.txt"))
     ("j" "Journal" entry
      (file+olp+datetree "~/Documents/org/.notes.org" "Journal")
      (file "~/Documents/org/tpl-journ.txt")
      :empty-lines 1 :tree-type week)
     ("t" "Task" entry
      (file+headline "~/Documents/org/.notes.org" "Task")
      (file "~/Documents/org/tpl-task.txt")
      :empty-lines 1)))
 '(org-default-notes-file "~/Documents/org/.notes.org")
 '(org-directory "~/Documents/org")
 '(org-log-into-drawer t)
 '(package-archives
   '(("gnu" . "https://elpa.gnu.org/packages/")
     ("melpa" . "https://melpa.org/packages/")))
 '(package-selected-packages
   '(ob-sagemath babel emacsql-mysql csv-mode gh-md emojify-logos emojify gnu-elpa org auctex)))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )
(put 'downcase-region 'disabled nil)

Under Warnings:

Warning (initialization): An error occurred while loading ‘/home/erwann/.emacs’:

Symbol's value as variable is void: org-refile-targets

To ensure normal operation, you should investigate and remove the cause of the error in your initialization file. Start Emacs with the ‘--debug-init’ option to view a complete error backtrace. Disable showing Disable logging Warning (org): Capture requirement: switching buffer #<buffer .notes> to Org mode Disable showing Disable logging

1
  • This is probably a duplicate.
    – NickD
    Jan 25, 2023 at 22:37

1 Answer 1

1

It is the first line in the code that causes the error. Your are attempting to add a value to a list before the list has been initialized. This is resulting in an error being thrown because the org-refile-targets variable is not yet defined.

To get around this, you can wrap the code in a with-eval-after-load block so that the value is added to the list after it has been initialized.

(with-eval-after-load 'org-refile
  (add-to-list 'org-refile-targets '("~/Documents/org/.notes.org"  :maxlevel . 4)))

This will ensure that the value is added to the list after the org-refile-targets variable has been initialized and defined.

1
  • @Erwann did this solve your issue? If so please accept the answer or else let me know if there is still a problem.
    – Hubisan
    Aug 14, 2023 at 21:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.