emacsorg-mode

Cannot define custom interactive functions for org-agenda-files


I'm new to Emacs and I'm using Doom Emacs (for the sake of having evil key bindings) and I'm trying to define 3 org agenda functions so I can work with contexts. The code below is pretty self explanatory:

;; Defining contexts to be used
(after! org
  (defun org-focus-private() "Set focus on private things."
        (interactive)
        (set org-agenda-files '("~/org/private.org")))

  (defun org-focus-work() "Set focus on work things."
        (interactive)
        (set org-agenda-files '("~/org/work.org")))

  (defun org-focus-all() "Set focus on all things."
        (interactive)
        (set org-agenda-files '("~/org/work.org"
                                "~/org/private.org")))
  )

This piece of code is inserted in the file "~/.config/doom/config.el". So far so good.

I can call all 3 functions above as normal by using "M-x "; they are being loaded just fine in Doom Emacs.

The issue I'm having is that when I call any of the 3 functions, I'm getting the following error message: "Wrong type argument: symbolp, ("~/org/")"

What I checked:

  1. The code itself for errors; elisp is validating the code normally with no warnings and no errors.

  2. The path and file names. I can cd normally to "~/org" and I can see 3 files there: work.org, private.org and plan-free.org (this last one I do not want loaded, it is just part of my workflow).

Any ideas on what might be causing this issue? Thanks in advance to anyone who can cast some light into this dark-I-do-not-know-what-to-do issue.


Solution

  • Provide more context. Set debug-on-error to t and show the backtrace.

    A guess is that the error is from your value of org-agenda-files not being a symbol. set requires its first arg to be a symbol. Try setq instead.