diff options
author | Kyle Meyer <kyle@kyleam.com> | 2014-11-07 01:22:26 -0500 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2014-11-07 01:22:26 -0500 |
commit | 6f856ffefc6ff56daf95c5a3845b735811442d9e (patch) | |
tree | d3dd448552d12e685a9578e5d7ac5d3ab94fcad1 /lisp | |
parent | 46ba631bd3d78cfd26b48c97dee21648f699cea7 (diff) | |
download | emacs.d-6f856ffefc6ff56daf95c5a3845b735811442d9e.tar.gz |
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.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/init-org.el | 26 |
1 files changed, 25 insertions, 1 deletions
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 "" |