* How to dynamically change org-clock-mode-line-total?
@ 2018-01-26 11:23 Marcin Borkowski
2018-01-26 18:41 ` Nick Dokos
0 siblings, 1 reply; 3+ messages in thread
From: Marcin Borkowski @ 2018-01-26 11:23 UTC (permalink / raw)
To: Org-Mode mailing list
Hi all,
I want to be able to dynamically switch between various settings of
org-clock-mode-line-total. To this end, I wrote the following code.
--8<---------------cut here---------------start------------->8---
(setq org-clock-mode-line-total-settings
'((current . "time spent in this chunk on the current task")
(today . "time spent today on the current task")
(all . "total time spent on the current task")))
(setq org-clock-mode-line-total-setting-number 0)
(defun toggle-org-clock-mode-line-total-setting (setting-number)
"Toggle between org-clock-mode-line-total settings.
With a numeric argument, use setting SETTING-NUMBER."
(interactive "P")
(if (numberp setting-number)
(setq org-clock-mode-line-total-setting-number
(mod setting-number (length org-clock-mode-line-total-settings)))
(setq org-clock-mode-line-total-setting-number
(mod (1+ org-clock-mode-line-total-setting-number)
(length org-clock-mode-line-total-settings))))
(let ((org-clock-mode-line-total-setting (nth org-clock-mode-line-total-setting-number
org-clock-mode-line-total-settings)))
(setq org-clock-mode-line-total (car org-clock-mode-line-total-setting))
(org-clock-update-mode-line)
(message "Modeline shows %s."
(cdr org-clock-mode-line-total-setting))))
--8<---------------cut here---------------end--------------->8---
Unfortunately, it doesn't work. I checked that the variable
org-clock-mode-line-total is modified correctly, but even after saying
(org-clock-update-mode-line), nothing gets updated. Am I doing
something wrong?
TIA,
--
Marcin Borkowski
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to dynamically change org-clock-mode-line-total?
2018-01-26 11:23 How to dynamically change org-clock-mode-line-total? Marcin Borkowski
@ 2018-01-26 18:41 ` Nick Dokos
2018-02-01 21:01 ` Marcin Borkowski
0 siblings, 1 reply; 3+ messages in thread
From: Nick Dokos @ 2018-01-26 18:41 UTC (permalink / raw)
To: emacs-orgmode
Marcin Borkowski <mbork@mbork.pl> writes:
> Hi all,
>
> I want to be able to dynamically switch between various settings of
> org-clock-mode-line-total. To this end, I wrote the following code.
>
> (setq org-clock-mode-line-total-settings
> '((current . "time spent in this chunk on the current task")
> (today . "time spent today on the current task")
> (all . "total time spent on the current task")))
> (setq org-clock-mode-line-total-setting-number 0)
>
> (defun toggle-org-clock-mode-line-total-setting (setting-number)
> "Toggle between org-clock-mode-line-total settings.
> With a numeric argument, use setting SETTING-NUMBER."
> (interactive "P")
> (if (numberp setting-number)
> (setq org-clock-mode-line-total-setting-number
> (mod setting-number (length org-clock-mode-line-total-settings)))
> (setq org-clock-mode-line-total-setting-number
> (mod (1+ org-clock-mode-line-total-setting-number)
> (length org-clock-mode-line-total-settings))))
> (let ((org-clock-mode-line-total-setting (nth org-clock-mode-line-total-setting-number
> org-clock-mode-line-total-settings)))
> (setq org-clock-mode-line-total (car org-clock-mode-line-total-setting))
> (org-clock-update-mode-line)
> (message "Modeline shows %s."
> (cdr org-clock-mode-line-total-setting))))
>
> Unfortunately, it doesn't work. I checked that the variable
> org-clock-mode-line-total is modified correctly, but even after saying
> (org-clock-update-mode-line), nothing gets updated. Am I doing
> something wrong?
>
AFAICT, org-clock-mode-line-total is not used by
org-clock-update-mode-line at all. It may be that the name of the
variable is misleading. The only place I see it used is
org-clock-get-sum-start.
--
Nick
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to dynamically change org-clock-mode-line-total?
2018-01-26 18:41 ` Nick Dokos
@ 2018-02-01 21:01 ` Marcin Borkowski
0 siblings, 0 replies; 3+ messages in thread
From: Marcin Borkowski @ 2018-02-01 21:01 UTC (permalink / raw)
To: Nick Dokos; +Cc: emacs-orgmode
On 2018-01-26, at 19:41, Nick Dokos <ndokos@gmail.com> wrote:
> Marcin Borkowski <mbork@mbork.pl> writes:
>
>> Hi all,
>>
>> I want to be able to dynamically switch between various settings of
>> org-clock-mode-line-total. To this end, I wrote the following code.
>>
>> (setq org-clock-mode-line-total-settings
>> '((current . "time spent in this chunk on the current task")
>> (today . "time spent today on the current task")
>> (all . "total time spent on the current task")))
>> (setq org-clock-mode-line-total-setting-number 0)
>>
>> (defun toggle-org-clock-mode-line-total-setting (setting-number)
>> "Toggle between org-clock-mode-line-total settings.
>> With a numeric argument, use setting SETTING-NUMBER."
>> (interactive "P")
>> (if (numberp setting-number)
>> (setq org-clock-mode-line-total-setting-number
>> (mod setting-number (length org-clock-mode-line-total-settings)))
>> (setq org-clock-mode-line-total-setting-number
>> (mod (1+ org-clock-mode-line-total-setting-number)
>> (length org-clock-mode-line-total-settings))))
>> (let ((org-clock-mode-line-total-setting (nth org-clock-mode-line-total-setting-number
>> org-clock-mode-line-total-settings)))
>> (setq org-clock-mode-line-total (car org-clock-mode-line-total-setting))
>> (org-clock-update-mode-line)
>> (message "Modeline shows %s."
>> (cdr org-clock-mode-line-total-setting))))
>>
>> Unfortunately, it doesn't work. I checked that the variable
>> org-clock-mode-line-total is modified correctly, but even after saying
>> (org-clock-update-mode-line), nothing gets updated. Am I doing
>> something wrong?
>>
>
> AFAICT, org-clock-mode-line-total is not used by
> org-clock-update-mode-line at all. It may be that the name of the
> variable is misleading. The only place I see it used is
> org-clock-get-sum-start.
Thanks, that helped! It seems my function is now working (almost)
correctly, although it is now cargo cult programming - I don't really
understand what's going on here. I'll try to make sense of it tomorrow,
now it's too late;-).
Best,
--
Marcin Borkowski
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-02-01 21:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-26 11:23 How to dynamically change org-clock-mode-line-total? Marcin Borkowski
2018-01-26 18:41 ` Nick Dokos
2018-02-01 21:01 ` Marcin Borkowski
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.