123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- (require 'org)
- (defvar org-sec-me nil
- "Tag that defines TASK todo entries associated to me")
- (defvar org-sec-with nil
- "Value of the :with: property when doing an
- org-sec-tag-entry. Change it with org-sec-set-with,
- set to C-c w. Defaults to org-sec-me")
- (defvar org-sec-where ""
- "Value of the :at: property when doing an
- org-sec-tag-entry. Change it with org-sec-set-with,
- set to C-c W")
- (defvar org-sec-with-history '()
- "History list of :with: properties")
- (defvar org-sec-where-history '()
- "History list of :where: properties")
- (defun org-sec-set-with ()
- "Changes the value of the org-sec-with variable for use in the
- next call of org-sec-tag-entry. Leave it empty to default to
- org-sec-me (you)."
- (interactive)
- (setq org-sec-with (let ((w (read-string "With: " nil
- 'org-sec-with-history "")))
- (if (string= w "")
- nil
- w))))
- (global-set-key "\C-cw" 'org-sec-set-with)
- (defun org-sec-set-where ()
- "Changes the value of the org-sec-where variable for use
- in the next call of org-sec-tag-entry."
- (interactive)
- (setq org-sec-where
- (read-string "Where: " nil
- 'org-sec-where-history "")))
- (global-set-key "\C-cW" 'org-sec-set-where)
- (defun org-sec-set-dowith ()
- "Sets the value of the dowith property."
- (interactive)
- (let ((do-with
- (read-string "Do with: "
- nil 'org-sec-dowith-history "")))
- (unless (string= do-with "")
- (org-entry-put nil "dowith" do-with))))
- (global-set-key "\C-cd" 'org-sec-set-dowith)
- (defun org-sec-set-doat ()
- "Sets the value of the doat property."
- (interactive)
- (let ((do-at (read-string "Do at: "
- nil 'org-sec-doat-history "")))
- (unless (string= do-at "")
- (org-entry-put nil "doat" do-at))))
- (global-set-key "\C-cD" 'org-sec-set-doat)
- (defun org-sec-tag-entry ()
- "Adds a :with: property with the value of org-sec-with if
- defined, an :at: property with the value of org-sec-where
- if defined, and an :on: property with the current time."
- (interactive)
- (save-excursion
- (org-entry-put nil "on" (format-time-string
- (org-time-stamp-format 'long)
- (current-time)))
- (unless (string= org-sec-where "")
- (org-entry-put nil "at" org-sec-where))
- (if org-sec-with
- (org-entry-put nil "with" org-sec-with))))
- (global-set-key "\C-cj" 'org-sec-tag-entry)
- (defun join (lst sep &optional pre post)
- (mapconcat (function (lambda (x) (concat pre x post))) lst sep))
- (defun org-sec-get-with ()
- (if org-sec-with
- org-sec-with
- org-sec-me))
- (defun org-sec-with-view (par &optional who)
- "Select tasks marked as dowith=who, where who
- defaults to the value of org-sec-with."
- (org-tags-view '(4) (join (split-string (if who
- who
- (org-sec-get-with)))
- "|" "dowith=\"" "\"")))
- (defun org-sec-where-view (par)
- "Select tasks marked as doat=org-sec-where."
- (org-tags-view '(4) (concat "doat={" org-sec-where "}")))
- (defun org-sec-assigned-with-view (par &optional who)
- "Select tasks assigned to who, by default org-sec-with."
- (org-tags-view '(4)
- (concat (join (split-string (if who
- who
- (org-sec-get-with)))
- "|")
- "/TASK")))
- (defun org-sec-stuck-with-view (par &optional who)
- "Select stuck projects assigned to who, by default
- org-sec-with."
- (let ((org-stuck-projects
- `(,(concat "+prj+"
- (join (split-string (if who
- who
- (org-sec-get-with))) "|")
- "/-MAYBE-DONE")
- ("TODO" "TASK") ())))
- (org-agenda-list-stuck-projects)))
- (defun org-sec-who-view (par)
- "Builds agenda for a given user. Queried. "
- (let ((who (read-string "Build todo for user/tag: "
- "" "" "")))
- (org-sec-with-view "TODO dowith" who)
- (org-sec-assigned-with-view "TASK with" who)
- (org-sec-stuck-with-view "STUCK with" who)))
- (provide 'org-secretary)
|