From aef6f6d3ab5999953ff83f5cc9b7c0ad26c5cd2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Cadilhac?= Date: Fri, 30 Aug 2019 12:28:58 -0500 Subject: [PATCH] org-clock: let user provide a list of default clock-in tasks. * lisp/org-clock.el (org-clock-default-tasks): New variable. (org-clock-select-task): Implement it. --- lisp/org-clock.el | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 9e64645cb..b8523e3e1 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -168,6 +168,18 @@ which case all digits and capital letters are used up by the :group 'org-clock :type 'integer) +(defcustom org-clock-default-tasks nil + "Default tasks that always appear in the clock-in dialog. +This should be a list of pairs (KEY . ID), where KEY is the key +used to select the task, and ID is the unique identifier of the +task." + :group 'org-clock + :version "26.2" + :package-version '(Org . "9.3") + :type '(repeat (cons :tag "Key and ID" + (character :tag "Access key") + (string :tag "Task ID")))) + (defcustom org-clock-goto-may-find-recent-task t "Non-nil means `org-clock-goto' can go to recent task if no active clock." :group 'org-clock @@ -626,6 +638,15 @@ there is no recent clock to choose from." (+ i (- ?A 10))) m)) (if (fboundp 'int-to-char) (setf (car s) (int-to-char (car s)))) (push s sel-list))) + (let (has-elt m) + (dolist (charid org-clock-default-tasks) + ;; Only add tasks that actually exist + (when (setq m (org-id-find (cdr charid) 'marker)) + (unless has-elt + (setq has-elt t) + (insert (org-add-props "Default Tasks\n" nil 'face 'bold))) + (setq s (org-clock-insert-selection-line (car charid) m)) + (push s sel-list)))) (run-hooks 'org-clock-before-select-task-hook) (goto-char (point-min)) ;; Set min-height relatively to circumvent a possible but in -- 2.23.0