0

Every time I run this, it gets added to the list, but I want to replace the entry "ab" with any new definition I come up with.

(setq hukarz
    `("ab"
      "foo bar"
      tags                   
      "+foo"
      (
       )
      ))

(add-to-list 'org-agenda-custom-commands hukarz)

Is there any way I can treat the list as an associative array, so that whenever I add something to the list, it updates the entry defined in the first parameter, just like "ab" in my example, which really is the shortcut in Org Agenda.

2
  • I presume you'd want this when testing a new entry. If so, I recommend you put the definition in a small file (say test-agenda-comman.el) that you can load again and again. The only thing you need to add is a setq at the top of the file to set org-agenda-custom-commands to nil. Then start a new emacs session with emacs -q -l test-agenda-command.el and test the new command out. Tweak it in the file and reload the file to test the ttweaked version: repeat as necessary. You can even keep the file under source control, so you can go back to previous versions.
    – NickD
    Aug 20, 2023 at 17:46
  • When you are happy, copy the entry and the add-to-list to your init file where you define all your other entries.
    – NickD
    Aug 20, 2023 at 17:47

1 Answer 1

0

You can absolutely write custom code that will find and replace the entries in that data structure, but you do have to put the work into it.

Since org-mode iterates over org-agenda-custom-commands, and because of the complex way that it can be configured (see the help for this variable), doing this requires writing code that is slightly more than trivial. If you do the work, though, it will very likely be valuable to the community :)

Your Answer

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

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