From: Andreas Gerler Date: Sun, 11 Dec 2022 11:51:45 +0000 (+0100) Subject: fix org-clock X-Git-Url: http://git.bundesbrandschatzamt.de/?a=commitdiff_plain;h=b2dcbe4f9ca897a5a8b772d1d79c5c36e1a7f410;p=emacsconfig.git fix org-clock I have to come back later and figure out how the added snippets are working. For now I disabled the integration. The default setup is working for me now. Signed-off-by: Andreas Gerler --- diff --git a/bba-orgmode.org b/bba-orgmode.org index 67363dd6..74caa8bd 100644 --- a/bba-orgmode.org +++ b/bba-orgmode.org @@ -1355,8 +1355,16 @@ taken from http://doc.norang.ca/org-mode.org (setq org-clock-history-length 23) ;; Resume clocking task on clock-in if the clock is open (setq org-clock-in-resume t) - ;; Change tasks to NEXT when clocking in +#+end_src + +Change tasks to NEXT when clocking in. disabled right now because it +is not working in my configuration. + +#+begin_src emacs-lisp :tangle no (setq org-clock-in-switch-to-state 'bh/clock-in-to-next) +#+end_src + +#+begin_src emacs-lisp ;; Separate drawers for clocking and logs (setq org-drawers (quote ("PROPERTIES" "LOGBOOK" "RESULTS"))) ;; Save clock data and state changes and notes in the LOGBOOK drawer @@ -1376,6 +1384,9 @@ taken from http://doc.norang.ca/org-mode.org (setq org-duration-format '(:hours "%d" :require-hours t :minutes ":%02d" :require-minutes t)) (setq bh/keep-clock-running nil) +#+end_src + +#+begin_src emacs-lisp (defun bh/is-project-p () "Any task with a todo keyword subtask" @@ -1393,6 +1404,22 @@ taken from http://doc.norang.ca/org-mode.org (setq has-subtask t)))) (and is-a-task has-subtask)))) + (defun bh/is-task-p () + "Any task with a todo keyword and no subtask" + (save-restriction + (widen) + (let ((has-subtask) + (subtree-end (save-excursion (org-end-of-subtree t))) + (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1))) + (save-excursion + (forward-line 1) + (while (and (not has-subtask) + (< (point) subtree-end) + (re-search-forward "^\*+ " subtree-end t)) + (when (member (org-get-todo-state) org-todo-keywords-1) + (setq has-subtask t)))) + (and is-a-task (not has-subtask))))) + (defun bh/clock-in-to-next (kw) "Switch a task from TODO to NEXT when clocking in. Skips capture tasks, projects, and subprojects. @@ -1537,7 +1564,9 @@ taken from http://doc.norang.ca/org-mode.org (not (member (nth 2 (org-heading-components)) org-done-keywords))) (setq org-refile-target-verify-function 'bh/verify-refile-target) +#+end_src +#+begin_src emacs-lisp (defun bba-clock-in () "Clock in of workhours." (interactive) @@ -1565,7 +1594,11 @@ taken from http://doc.norang.ca/org-mode.org (insert (format-time-string "--[%Y-%m-%d %a %H:%M]")) (org-ctrl-c-ctrl-c)))) +#+end_src + +Some keybindings. +#+begin_src emacs-lisp (global-set-key (kbd "") 'org-agenda) (global-set-key (kbd " c") 'calendar) (global-set-key (kbd " I") 'bba-clock-in) @@ -1576,8 +1609,11 @@ taken from http://doc.norang.ca/org-mode.org (global-set-key (kbd "C-") 'next-buffer) (global-set-key (kbd "") 'org-clock-goto) (global-set-key (kbd "C-") 'org-clock-in) +#+end_src +TODO: this block should be splitted and moved to the right org files. +#+begin_src emacs-lisp (if (>= emacs-major-version 24) (progn @@ -1627,7 +1663,7 @@ taken from http://doc.norang.ca/org-mode.org ) -#+END_SRC +#+end_src #+BEGIN_SRC emacs-lisp (setq org-duration-format '((special . h:mm)))