diff --git a/conf.el b/conf.el index a20962a..380b709 100644 --- a/conf.el +++ b/conf.el @@ -189,6 +189,14 @@ event of an error or nonlocal exit." `(advice-remove ,(car adform) ,(nth 2 adform))) adlist)))) +(defun nd/filter-list-prefix (prefix str-list) + "Return a subset of tags-list whose first character matches prefix.' + tags-list defaults to org-tag-alist if not given" + (seq-filter (lambda (i) + (and (stringp i) + (string-prefix-p prefix i))) + str-list)) + (defun split-and-follow-horizontally () (interactive) (split-window-below) @@ -255,7 +263,7 @@ event of an error or nonlocal exit." (load "ess-site") (setq ess-history-file "session.Rhistory") (setq ess-history-directory - (substitute-in-file-name "${XDG_CONFIG_HOME}/r/")) + (substitute-in-file-name "${XDG_CONFIG_HOME}/r/")) (setq org-log-done t) (setq org-startup-indented t) @@ -326,7 +334,7 @@ event of an error or nonlocal exit." (add-hook 'org-mode-hook (lambda () (local-set-key (kbd "C-c C-x x") 'nd/mark-subtree-done) - (local-set-key (kbd "C-c C-x c") 'nd/org-clone-subtree-with-time-shift-reset))) + (local-set-key (kbd "C-c C-x c") 'nd/org-clone-subtree-with-time-shift))) (evil-define-key 'motion org-agenda-mode-map "t" 'nd/toggle-project-toplevel-display @@ -355,14 +363,6 @@ event of an error or nonlocal exit." ("HOLD" :foreground "violet" :weight bold) ("CANC" :foreground "deep sky blue" :weight bold))) -(defun nd/filter-list-prefix (prefix str-list) - "Return a subset of tags-list whose first character matches prefix.' - tags-list defaults to org-tag-alist if not given" - (seq-filter (lambda (i) - (and (stringp i) - (string-prefix-p prefix i))) - str-list)) - (defun nd/add-tag-face (fg-name prefix) "Adds list of cons cells to org-tag-faces with foreground set to fg-name. Start and end specify the positions in org-tag-alist which define the tags @@ -409,12 +409,14 @@ event of an error or nonlocal exit." (add-to-list 'org-default-properties "PARENT_TYPE") (add-to-list 'org-default-properties "OWNER") (add-to-list 'org-default-properties "GOAL") +(add-to-list 'org-default-properties "TIME_SHIFT") + (setq org-global-properties '(("PARENT_TYPE_ALL" . "periodical iterator") ("Effort_ALL" . "0:05 0:15 0:30 1:00 1:30 2:00 3:00 4:00 5:00 6:00"))) ;; TODO this may not be needed -(setq org-use-property-inheritance '("PARENT_TYPE")) +(setq org-use-property-inheritance '("PARENT_TYPE" "TIME_SHIFT")) (let ((capfile "~/Org/capture.org")) (setq org-capture-templates @@ -1063,12 +1065,14 @@ is in the optional argument exclude" (interactive) (nd/mark-subtree-keyword "DONE" '("CANC"))) -(defun nd/org-clone-subtree-with-time-shift-reset (n &optional shift) +(defun nd/org-clone-subtree-with-time-shift (n &optional shift) "Like `org-clone-subtree-with-time-shift' except it resets checkboxes and reverts all todo keywords to TODO" (interactive "nNumber of clones to produce: ") - (let ((shift (read-from-minibuffer - "Date shift per clone (e.g. +1w, empty to copy unchanged): "))) + + (let ((shift (or (org-entry-get nil "TIME_SHIFT" 'selective) + (read-from-minibuffer + "Date shift per clone (e.g. +1w, empty to copy unchanged): ")))) (condition-case err (progn (org-clone-subtree-with-time-shift n shift) diff --git a/conf.org b/conf.org index d0e1222..5e5ddc9 100644 --- a/conf.org +++ b/conf.org @@ -495,7 +495,7 @@ By default, the tag selection window obliterates all but the current window...ho (add-hook 'org-mode-hook (lambda () (local-set-key (kbd "C-c C-x x") 'nd/mark-subtree-done) - (local-set-key (kbd "C-c C-x c") 'nd/org-clone-subtree-with-time-shift-reset))) + (local-set-key (kbd "C-c C-x c") 'nd/org-clone-subtree-with-time-shift))) #+END_SRC *** agenda #+BEGIN_SRC emacs-lisp @@ -588,15 +588,17 @@ There are several types of tags I use: #+END_SRC ** properties #+BEGIN_SRC emacs-lisp - (add-to-list 'org-default-properties "PARENT_TYPE") - (add-to-list 'org-default-properties "OWNER") - (add-to-list 'org-default-properties "GOAL") - (setq org-global-properties - '(("PARENT_TYPE_ALL" . "periodical iterator") - ("Effort_ALL" . "0:05 0:15 0:30 1:00 1:30 2:00 3:00 4:00 5:00 6:00"))) +(add-to-list 'org-default-properties "PARENT_TYPE") +(add-to-list 'org-default-properties "OWNER") +(add-to-list 'org-default-properties "GOAL") +(add-to-list 'org-default-properties "TIME_SHIFT") - ;; TODO this may not be needed - (setq org-use-property-inheritance '("PARENT_TYPE")) +(setq org-global-properties + '(("PARENT_TYPE_ALL" . "periodical iterator") + ("Effort_ALL" . "0:05 0:15 0:30 1:00 1:30 2:00 3:00 4:00 5:00 6:00"))) + +;; TODO this may not be needed +(setq org-use-property-inheritance '("PARENT_TYPE" "TIME_SHIFT")) #+END_SRC ** capture #+BEGIN_SRC emacs-lisp @@ -1335,40 +1337,42 @@ the agenda does not do this by default...it's annoying #+END_SRC ** interactive functions #+BEGIN_SRC emacs-lisp - (defun nd/mark-subtree-keyword (new-keyword &optional exclude) - "marks all tasks in a subtree with keyword unless original keyword - is in the optional argument exclude" - (let ((subtree-end (save-excursion (org-end-of-subtree t)))) - (if (not (listp exclude)) - (error "exlude must be a list if provided")) - (save-excursion - (while (< (point) subtree-end) - (let ((keyword (nd/is-todoitem-p))) - (if (and keyword (not (member keyword exclude))) - (org-todo new-keyword))) - (outline-next-heading))))) +(defun nd/mark-subtree-keyword (new-keyword &optional exclude) + "marks all tasks in a subtree with keyword unless original keyword +is in the optional argument exclude" + (let ((subtree-end (save-excursion (org-end-of-subtree t)))) + (if (not (listp exclude)) + (error "exlude must be a list if provided")) + (save-excursion + (while (< (point) subtree-end) + (let ((keyword (nd/is-todoitem-p))) + (if (and keyword (not (member keyword exclude))) + (org-todo new-keyword))) + (outline-next-heading))))) - (defun nd/mark-subtree-done () - "marks all tasks in subtree as DONE unless they are already canc" - (interactive) - (nd/mark-subtree-keyword "DONE" '("CANC"))) +(defun nd/mark-subtree-done () + "marks all tasks in subtree as DONE unless they are already canc" + (interactive) + (nd/mark-subtree-keyword "DONE" '("CANC"))) - (defun nd/org-clone-subtree-with-time-shift-reset (n &optional shift) - "Like `org-clone-subtree-with-time-shift' except it resets checkboxes - and reverts all todo keywords to TODO" - (interactive "nNumber of clones to produce: ") - (let ((shift (read-from-minibuffer - "Date shift per clone (e.g. +1w, empty to copy unchanged): "))) - (condition-case err - (progn - (org-clone-subtree-with-time-shift n shift) - (save-excursion - (dotimes (i n) - (org-forward-heading-same-level 1 t) - (org-reset-checkbox-state-subtree) - (nd/mark-subtree-keyword "TODO") - (org-cycle)))) - (error (message "%s" (error-message-string err)))))) +(defun nd/org-clone-subtree-with-time-shift (n &optional shift) + "Like `org-clone-subtree-with-time-shift' except it resets checkboxes +and reverts all todo keywords to TODO" + (interactive "nNumber of clones to produce: ") + + (let ((shift (or (org-entry-get nil "TIME_SHIFT" 'selective) + (read-from-minibuffer + "Date shift per clone (e.g. +1w, empty to copy unchanged): ")))) + (condition-case err + (progn + (org-clone-subtree-with-time-shift n shift) + (save-excursion + (dotimes (i n) + (org-forward-heading-same-level 1 t) + (org-reset-checkbox-state-subtree) + (nd/mark-subtree-keyword "TODO") + (org-cycle)))) + (error (message "%s" (error-message-string err)))))) #+END_SRC ** caldav +BEGIN_SRC emacs-lisp