From bd65533b97459d7e6d868f6e27e5dd1e7e2d66b7 Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Sun, 5 Jan 2020 11:56:05 +0100 Subject: [PATCH] Update custom setter for special org agenda files The setter will now complain if the file to be added to `org-agenda-files' does not exist and is not readable. It also now uses the proper functions from `org' to update `org-agenda-files'. --- site-lisp/db-org.el | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/site-lisp/db-org.el b/site-lisp/db-org.el index 28fc76a..1ceb29b 100644 --- a/site-lisp/db-org.el +++ b/site-lisp/db-org.el @@ -16,13 +16,21 @@ "Set SYMBOL to VALUE and update `org-agenda-files’ afterwards. Remove the old value of SYMBOL from `org-agenda-files’ and add the new one instead." - (require 'org) - (when (boundp symbol) - (setq org-agenda-files (cl-delete (symbol-value symbol) org-agenda-files))) + (when (and (boundp symbol) + (symbol-value symbol)) + (require 'org) + (org-remove-file (symbol-value symbol))) (set-default symbol value) - (push value org-agenda-files) - (setq-default org-agenda-files - (cl-delete-duplicates org-agenda-files :test #'cl-equalp))) + (when value + (if (not (and (stringp value) + (file-exists-p value) + (file-readable-p value))) + (user-error "File %s does not exist or is not readable; not setting %s." + value symbol) + (require 'org) + (message "Adding: %s" value) + (with-current-buffer (find-file-noselect value) + (org-agenda-file-to-front 'to-end))))) (defun db/org-agenda-list-deadlines (&optional match) ;; XXX org-agenda-later does not work, fix this