From 6f856ffefc6ff56daf95c5a3845b735811442d9e Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Fri, 7 Nov 2014 01:22:26 -0500 Subject: Set up new method for adding files to Org agenda org-agenda-files can be a directory, which allows the files that make up the agenda to be changed without having to change emacs configuration files. So, instead of using org-agenda-file-to-front, which modifies org-agenda-files in custom.el, the new agenda file can just be linked to the agenda directory. --- lisp/init-org.el | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/init-org.el b/lisp/init-org.el index 0076fdb..a37f330 100644 --- a/lisp/init-org.el +++ b/lisp/init-org.el @@ -294,10 +294,34 @@ be restored properly." (tags priority-down category-keep) (search category-keep))) -(setq org-agenda-files (file-expand-wildcards "~/notes/agenda/*.org")) +(defvar km/org-agenda-file-directory "~/notes/agenda/") +(setq org-agenda-files (list km/org-agenda-file-directory)) (setq org-agenda-text-search-extra-files (file-expand-wildcards "~/notes/extra/*.org")) +(defun km/org-agenda-add-or-remove-file (file) + "Add or remove link to FILE in `km/org-agenda-file-directory'. +If a link for FILE does not exist, create it. Otherwise, remove +it. Like `org-agenda-file-to-front', this results in FILE being +displayed in the agenda." + (interactive (list (case major-mode + (org-mode (buffer-file-name)) + (dired-mode (dired-get-filename)) + (org-agenda-mode (ignore-errors (save-window-excursion + (org-agenda-goto) + (buffer-file-name)))) + (t (read-file-name "Link file: "))))) + (let ((agenda-file (expand-file-name (file-name-nondirectory file) + km/org-agenda-file-directory))) + (if (file-equal-p (file-truename agenda-file) file) + (progn + (when (called-interactively-p) (message "Deleting %s" agenda-file)) + (delete-file agenda-file)) + (when (called-interactively-p) (message "Adding %s" agenda-file)) + (make-symbolic-link file agenda-file)))) + +(define-key km/global-org-map "n" 'km/org-agenda-add-or-remove-file) + (setq org-agenda-custom-commands '(("d" todo "DONE" nil) ("u" "Unschedule TODO entries" alltodo "" -- cgit v1.2.3