all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* org-clock: Custom shortcuts for C-u C-c C-x C-i
@ 2019-02-11 16:29 Leo Gaspard
  2019-02-13 13:23 ` Michaël Cadilhac
  0 siblings, 1 reply; 5+ messages in thread
From: Leo Gaspard @ 2019-02-11 16:29 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

When I run C-u C-c C-x C-i I get a choice between the interrupted task,
the current task, the default task and recent tasks.

I however wonder whether it's possible to add in custom shortcuts to
fixed tasks? This would help me easily clock into my “IRC”, “Mails”
etc. tasks, to and from which I frequently switch.

Do you have any idea how to accomplish that? I haven't been able to find
anything in the manual [1].

[1] https://orgmode.org/org.html#Clocking-commands

Cheers, and thank you once again for this great piece of software!
  Leo

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: org-clock: Custom shortcuts for C-u C-c C-x C-i
  2019-02-11 16:29 org-clock: Custom shortcuts for C-u C-c C-x C-i Leo Gaspard
@ 2019-02-13 13:23 ` Michaël Cadilhac
  2019-02-13 17:46   ` Leo Gaspard
  0 siblings, 1 reply; 5+ messages in thread
From: Michaël Cadilhac @ 2019-02-13 13:23 UTC (permalink / raw)
  To: Leo Gaspard; +Cc: emacs-orgmode

Hi there Leo;

This is not possible out of the box; can you say a bit more about how
you expect to indicate which tasks are to be always present?

A quick-and-dirty way to implement something along these lines is to
modify org-clock-history-push to always keep a selected set of markers
in org-clock-history.

Cheers;
M.

On Mon, 11 Feb 2019 at 16:32, Leo Gaspard <orgmode@leo.gaspard.io> wrote:
>
> Hello,
>
> When I run C-u C-c C-x C-i I get a choice between the interrupted task,
> the current task, the default task and recent tasks.
>
> I however wonder whether it's possible to add in custom shortcuts to
> fixed tasks? This would help me easily clock into my “IRC”, “Mails”
> etc. tasks, to and from which I frequently switch.
>
> Do you have any idea how to accomplish that? I haven't been able to find
> anything in the manual [1].
>
> [1] https://orgmode.org/org.html#Clocking-commands
>
> Cheers, and thank you once again for this great piece of software!
>   Leo
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: org-clock: Custom shortcuts for C-u C-c C-x C-i
  2019-02-13 13:23 ` Michaël Cadilhac
@ 2019-02-13 17:46   ` Leo Gaspard
  2019-02-14 12:32     ` Michaël Cadilhac
  0 siblings, 1 reply; 5+ messages in thread
From: Leo Gaspard @ 2019-02-13 17:46 UTC (permalink / raw)
  To: Michaël Cadilhac; +Cc: emacs-orgmode

Hi Michaël,

Michaël Cadilhac <michael@cadilhac.name> writes:
> This is not possible out of the box; can you say a bit more about how
> you expect to indicate which tasks are to be always present?

I would be thinking of something like defining a list of key -> link to
a task (that may be generated with org-id's task ID, [[*foobar]] links
or whatever) in my `init.el`.

> A quick-and-dirty way to implement something along these lines is to
> modify org-clock-history-push to always keep a selected set of markers
> in org-clock-history.

Hmm… That sounds like it'd work, but would have a pretty terrible UX. I
guess I'll go with just using custom shortcuts for now, then, if there's
no easy way to integrate it with C-ucxi. (I don't feel like I'm ready to
dive into too intricate elisp yet)

Thank you for your feedback!
Cheers,
  Leo

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: org-clock: Custom shortcuts for C-u C-c C-x C-i
  2019-02-13 17:46   ` Leo Gaspard
@ 2019-02-14 12:32     ` Michaël Cadilhac
  2019-08-30 17:38       ` Michaël Cadilhac
  0 siblings, 1 reply; 5+ messages in thread
From: Michaël Cadilhac @ 2019-02-14 12:32 UTC (permalink / raw)
  To: Leo Gaspard; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 556 bytes --]

Hi Leo;

On Wed, 13 Feb 2019 at 17:46, Leo Gaspard <orgmode@leo.gaspard.io> wrote:
> Michaël Cadilhac <michael@cadilhac.name> writes:
> > This is not possible out of the box; can you say a bit more about how
> > you expect to indicate which tasks are to be always present?
>
> I would be thinking of something like defining a list of key -> link to
> a task (that may be generated with org-id's task ID, [[*foobar]] links
> or whatever) in my `init.el`.

Alright, can you give this patch a spin and see if that's what you want?

Cheers;
M.

[-- Attachment #2: default-tasks.patch --]
[-- Type: text/x-patch, Size: 1285 bytes --]

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 343264f7e..1f0870e62 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -164,6 +164,13 @@ which case all digits and capital letters are used up by the
   :group 'org-clock
   :type 'integer)
 
+(defcustom org-clock-default-tasks nil
+  "List of pairs (KEY . ID) ..."
+  :group 'org-clock
+  :type '(repeat (cons :tag "Key and ID"
+		       (character :tag "Access char")
+		       (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
@@ -622,6 +629,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)
+	    (setq m (org-id-find (cdr charid) 'marker))
+	    (when m
+	      (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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: org-clock: Custom shortcuts for C-u C-c C-x C-i
  2019-02-14 12:32     ` Michaël Cadilhac
@ 2019-08-30 17:38       ` Michaël Cadilhac
  0 siblings, 0 replies; 5+ messages in thread
From: Michaël Cadilhac @ 2019-08-30 17:38 UTC (permalink / raw)
  To: Leo Gaspard; +Cc: Org-Mode mailing list


[-- Attachment #1.1: Type: text/plain, Size: 838 bytes --]

By the way, I've been using this for quite some time, and I find it quite
useful.  It may be worth considering it for inclusion—see attached patch.
Opinions?



On Thu, 14 Feb 2019 at 06:32, Michaël Cadilhac <michael@cadilhac.name>
wrote:

> Hi Leo;
>
> On Wed, 13 Feb 2019 at 17:46, Leo Gaspard <orgmode@leo.gaspard.io> wrote:
> > Michaël Cadilhac <michael@cadilhac.name> writes:
> > > This is not possible out of the box; can you say a bit more about how
> > > you expect to indicate which tasks are to be always present?
> >
> > I would be thinking of something like defining a list of key -> link to
> > a task (that may be generated with org-id's task ID, [[*foobar]] links
> > or whatever) in my `init.el`.
>
> Alright, can you give this patch a spin and see if that's what you want?
>
> Cheers;
> M.
>

[-- Attachment #1.2: Type: text/html, Size: 1344 bytes --]

[-- Attachment #2: 0001-org-clock-let-user-provide-a-list-of-default-clock-i.patch --]
[-- Type: text/x-patch, Size: 1991 bytes --]

From aef6f6d3ab5999953ff83f5cc9b7c0ad26c5cd2f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Cadilhac?= <michael@cadilhac.name>
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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-08-30 17:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-11 16:29 org-clock: Custom shortcuts for C-u C-c C-x C-i Leo Gaspard
2019-02-13 13:23 ` Michaël Cadilhac
2019-02-13 17:46   ` Leo Gaspard
2019-02-14 12:32     ` Michaël Cadilhac
2019-08-30 17:38       ` Michaël Cadilhac

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.