* Agenda in the mode-line?
@ 2013-08-01 13:30 Kyle Sexton
2013-08-02 14:36 ` Bastien
0 siblings, 1 reply; 8+ messages in thread
From: Kyle Sexton @ 2013-08-01 13:30 UTC (permalink / raw)
To: emacs-orgmode
All,
Does anyone know if there is a feature to show something like 'Tasks: 4'
on the mode-line for tasks that are currently open?
Thanks!
--
Kyle Sexton
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Agenda in the mode-line?
2013-08-01 13:30 Agenda in the mode-line? Kyle Sexton
@ 2013-08-02 14:36 ` Bastien
2013-08-02 14:59 ` Kyle Sexton
0 siblings, 1 reply; 8+ messages in thread
From: Bastien @ 2013-08-02 14:36 UTC (permalink / raw)
To: Kyle Sexton; +Cc: emacs-orgmode
Hi Kyle,
Kyle Sexton <ks@mocker.org> writes:
> Does anyone know if there is a feature to show something like 'Tasks: 4'
> on the mode-line for tasks that are currently open?
This is the default behavior since long: hitting "I" to clock in a
task in the agenda or C-c C-x C-i in an Org buffer will append the
task name to the modeline, together with the time spent.
Don't you have this? Even with emacs -Q?
HTH,
--
Bastien
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Agenda in the mode-line?
2013-08-02 14:36 ` Bastien
@ 2013-08-02 14:59 ` Kyle Sexton
2013-08-02 17:07 ` Nick Dokos
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Kyle Sexton @ 2013-08-02 14:59 UTC (permalink / raw)
To: Bastien; +Cc: emacs-orgmode, Kyle Sexton
Bastien <bzg@gnu.org> writes:
> Kyle Sexton <ks@mocker.org> writes:
>
>> Does anyone know if there is a feature to show something like 'Tasks: 4'
>> on the mode-line for tasks that are currently open?
>
> This is the default behavior since long: hitting "I" to clock in a
> task in the agenda or C-c C-x C-i in an Org buffer will append the
> task name to the modeline, together with the time spent.
>
> Don't you have this? Even with emacs -Q?
>
Sorry, it appears I didn't make my use case very clear. What you are
speaking of is clocking into a task, and indeed that does show up on the
modeline.
What I am after is more of a overview of "How many total TODO tasks do I
have", ideally with some function to limit or match based on tag.
Something like this in the modeline:
#+BEGIN_EXAMPLE
[Work: 3/10 Home: 2/20]
^--- Total number of TODOs in home.org
^------ Total number of TODOs due today in home.org
#+END_EXAMPLE
That way I have a constant reminder of the number of things left without
having to pull up the agenda.
--
Kyle Sexton
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Agenda in the mode-line?
2013-08-02 14:59 ` Kyle Sexton
@ 2013-08-02 17:07 ` Nick Dokos
2013-08-02 17:49 ` Kyle Sexton
2013-08-03 3:48 ` Eric Abrahamsen
2013-08-04 18:18 ` Daniel Clemente
2 siblings, 1 reply; 8+ messages in thread
From: Nick Dokos @ 2013-08-02 17:07 UTC (permalink / raw)
To: emacs-orgmode
Kyle Sexton <ks@mocker.org> writes:
> Bastien <bzg@gnu.org> writes:
>
>> Kyle Sexton <ks@mocker.org> writes:
>>
>>> Does anyone know if there is a feature to show something like 'Tasks: 4'
>>> on the mode-line for tasks that are currently open?
>>
>> This is the default behavior since long: hitting "I" to clock in a
>> task in the agenda or C-c C-x C-i in an Org buffer will append the
>> task name to the modeline, together with the time spent.
>>
>> Don't you have this? Even with emacs -Q?
>>
>
> Sorry, it appears I didn't make my use case very clear. What you are
> speaking of is clocking into a task, and indeed that does show up on the
> modeline.
>
> What I am after is more of a overview of "How many total TODO tasks do I
> have", ideally with some function to limit or match based on tag.
>
> Something like this in the modeline:
>
> #+BEGIN_EXAMPLE
> [Work: 3/10 Home: 2/20]
> ^--- Total number of TODOs in home.org
> ^------ Total number of TODOs due today in home.org
> #+END_EXAMPLE
>
> That way I have a constant reminder of the number of things left without
> having to pull up the agenda.
>
I don't think the feature exists but it should be buildable - although I
think it is not exactly simple.
It should be easy to write a function that uses the org mapping API to
produce a string of the form "[Work: 3/10 Home: 2/20]" and assign it to
a variable, say mode-line-org-tasks. The variable can be added to
mode-line-format.
The problem is to force mode-line redisplay when things change,
e.g. when you mark a TODO task DONE, or add another task to work.org.
If the file gets modified, then filenotify.el can be used, but since the
agenda files are kept open, the buffer is modified but the file is not
(until the buffer is saved) and I'm not sure how to detect such changes
and propagate them to the mode line. I thought there must be a hook to
allow this, but I haven't found one yet.
The rather yucky alternative is to poll the relevant buffers (say once a
minute) to see if they are modified and if so, run the function to set
the variable and force mode-line redisplay.
--
Nick
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Agenda in the mode-line?
2013-08-02 17:07 ` Nick Dokos
@ 2013-08-02 17:49 ` Kyle Sexton
2013-08-03 5:27 ` Nick Dokos
0 siblings, 1 reply; 8+ messages in thread
From: Kyle Sexton @ 2013-08-02 17:49 UTC (permalink / raw)
To: Nick Dokos; +Cc: emacs-orgmode
Nick Dokos <ndokos@gmail.com> writes:
> I don't think the feature exists but it should be buildable - although I
> think it is not exactly simple.
>
> It should be easy to write a function that uses the org mapping API to
> produce a string of the form "[Work: 3/10 Home: 2/20]" and assign it to
> a variable, say mode-line-org-tasks. The variable can be added to
> mode-line-format.
That part is beyond my elisp ability, but good to know that the feature
doesn't currently exist.
> The problem is to force mode-line redisplay when things change,
> e.g. when you mark a TODO task DONE, or add another task to work.org.
> If the file gets modified, then filenotify.el can be used, but since the
> agenda files are kept open, the buffer is modified but the file is not
> (until the buffer is saved) and I'm not sure how to detect such changes
> and propagate them to the mode line. I thought there must be a hook to
> allow this, but I haven't found one yet.
>
> The rather yucky alternative is to poll the relevant buffers (say once a
> minute) to see if they are modified and if so, run the function to set
> the variable and force mode-line redisplay.
I already have a function for org-mobile to sync, could something like
that be hooked into?
#+BEGIN_SRC emacs-lisp
;; Push to mobile-org
;; moble sync
(defvar org-mobile-sync-timer nil)
(defvar org-mobile-sync-idle-secs (* 60 10))
(defun org-mobile-sync ()
(interactive)
(org-mobile-pull)
(org-mobile-push))
(defun org-mobile-sync-enable ()
"enable mobile org idle sync"
(interactive)
(setq org-mobile-sync-timer
(run-with-idle-timer org-mobile-sync-idle-secs t
'org-mobile-sync)))
(defun org-mobile-sync-disable ()
"disable mobile org idle sync"
(interactive)
(cancel-timer org-mobile-sync-timer))
(org-mobile-sync-enable)
#+END_SRC
--
Kyle Sexton
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Agenda in the mode-line?
2013-08-02 14:59 ` Kyle Sexton
2013-08-02 17:07 ` Nick Dokos
@ 2013-08-03 3:48 ` Eric Abrahamsen
2013-08-04 18:18 ` Daniel Clemente
2 siblings, 0 replies; 8+ messages in thread
From: Eric Abrahamsen @ 2013-08-03 3:48 UTC (permalink / raw)
To: emacs-orgmode
Kyle Sexton <ks@mocker.org> writes:
> Bastien <bzg@gnu.org> writes:
>
>> Kyle Sexton <ks@mocker.org> writes:
>>
>>> Does anyone know if there is a feature to show something like 'Tasks: 4'
>>> on the mode-line for tasks that are currently open?
>>
>> This is the default behavior since long: hitting "I" to clock in a
>> task in the agenda or C-c C-x C-i in an Org buffer will append the
>> task name to the modeline, together with the time spent.
>>
>> Don't you have this? Even with emacs -Q?
>>
>
> Sorry, it appears I didn't make my use case very clear. What you are
> speaking of is clocking into a task, and indeed that does show up on the
> modeline.
>
> What I am after is more of a overview of "How many total TODO tasks do I
> have", ideally with some function to limit or match based on tag.
>
> Something like this in the modeline:
>
> #+BEGIN_EXAMPLE
> [Work: 3/10 Home: 2/20]
> ^--- Total number of TODOs in home.org
> ^------ Total number of TODOs due today in home.org
> #+END_EXAMPLE
>
> That way I have a constant reminder of the number of things left without
> having to pull up the agenda.
>
> --
> Kyle Sexton
A lighter-weight and easier to code version of this might be produced
directly from the current *Org Agenda* buffer. Ie, every time you call
org-agenda, or org-agenda-redo, you could build a variable that creates
this mode line, maybe in `org-agenda-finalize-hook'.
So long as you don't need separate queries for the agenda buffer and the
modeline, this seems like it would work fine. Then your timer could run
`org-agenda-redo', or you could just bind that to a key in the global or
org-mode keymaps.
Eric
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Agenda in the mode-line?
2013-08-02 17:49 ` Kyle Sexton
@ 2013-08-03 5:27 ` Nick Dokos
0 siblings, 0 replies; 8+ messages in thread
From: Nick Dokos @ 2013-08-03 5:27 UTC (permalink / raw)
To: emacs-orgmode
Kyle Sexton <ks@mocker.org> writes:
> Nick Dokos <ndokos@gmail.com> writes:
>
>> I don't think the feature exists but it should be buildable - although I
>> think it is not exactly simple.
>>
>> It should be easy to write a function that uses the org mapping API to
>> produce a string of the form "[Work: 3/10 Home: 2/20]" and assign it to
>> a variable, say mode-line-org-tasks. The variable can be added to
>> mode-line-format.
>
> That part is beyond my elisp ability, but good to know that the feature
> doesn't currently exist.
>
Here is an implementation of the above. If you paste the code into a
buffer, change the paths appropriately and M-x eval-buffer, you should
get a mode line with the stats. mode-line-format is buffer-local so you
can get rid of the modified mode-line-format by just killing the buffer.
--8<---------------cut here---------------start------------->8---
(defun org-agenda-mode-line (&optional files)
"Construct a string of the form [<file>:<todo-today>/<todo> ...]
for all the files in the argument list (or all the agenda files if the argument is nil)."
(let ((afiles))
(setq afiles
(if (not files)
(org-agenda-files)
files))
(concat "["
(mapconcat (function org-mode-line-stats) afiles " ")
"]")))
(defun org-count-todo ()
"If the current headline is SCHEDULED and its scheduled date is on or before today
then count it in todo-today. Count it unconditionally in todo-total."
(let ((sched (org-entry-get (point) "SCHEDULED")))
(if (and sched
(<= (time-to-days (org-time-string-to-time sched)) (org-today)))
(incf todo-today))
(incf todo-total)))
(defun org-mode-line-stats (file)
"Use org-map-entries to step through the TODO headlines. Apply the org-count-todo
function on each headline and return a string of the form <file>:<todo-today>/<todo>."
(let ((buffer (get-file-buffer file))
(todo-today 0)
(todo-total 0))
(if buffer
(save-excursion
(set-buffer buffer)
;; do the org mapping API dance
(org-map-entries
(function org-count-todo)
"/+TODO" 'file)))
(concat (file-name-base file) (format ":%d/%d" todo-today todo-total))))
(setq mode-line-org-agenda-stats (org-agenda-mode-line '("/home/nick/lib/org/home.org" "/home/nick/lib/org/work.org")))
(nconc mode-line-format '(mode-line-org-agenda-stats))
--8<---------------cut here---------------end--------------->8---
The code assumes that the relevant files are already visited
(e.g. you've already done C-c a a or M-x org-agenda-list). Otherwise,
get-file-buffer will return nil and the counting will be skipped: you'll
get 0/0 values. Also, what to search for is hardwired but it should be
clear how to change it to use different criteria.
The update problem below is still TBD.
>> The problem is to force mode-line redisplay when things change,
>> e.g. when you mark a TODO task DONE, or add another task to work.org.
>> If the file gets modified, then filenotify.el can be used, but since the
>> agenda files are kept open, the buffer is modified but the file is not
>> (until the buffer is saved) and I'm not sure how to detect such changes
>> and propagate them to the mode line. I thought there must be a hook to
>> allow this, but I haven't found one yet.
>>
>> The rather yucky alternative is to poll the relevant buffers (say once a
>> minute) to see if they are modified and if so, run the function to set
>> the variable and force mode-line redisplay.
>
> I already have a function for org-mobile to sync, could something like
> that be hooked into?
>
> #+BEGIN_SRC emacs-lisp
> ;; Push to mobile-org
> ;; moble sync
> (defvar org-mobile-sync-timer nil)
> (defvar org-mobile-sync-idle-secs (* 60 10))
> (defun org-mobile-sync ()
> (interactive)
> (org-mobile-pull)
> (org-mobile-push))
> (defun org-mobile-sync-enable ()
> "enable mobile org idle sync"
> (interactive)
> (setq org-mobile-sync-timer
> (run-with-idle-timer org-mobile-sync-idle-secs t
> 'org-mobile-sync)))
> (defun org-mobile-sync-disable ()
> "disable mobile org idle sync"
> (interactive)
> (cancel-timer org-mobile-sync-timer))
> (org-mobile-sync-enable)
> #+END_SRC
--
Nick
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Agenda in the mode-line?
2013-08-02 14:59 ` Kyle Sexton
2013-08-02 17:07 ` Nick Dokos
2013-08-03 3:48 ` Eric Abrahamsen
@ 2013-08-04 18:18 ` Daniel Clemente
2 siblings, 0 replies; 8+ messages in thread
From: Daniel Clemente @ 2013-08-04 18:18 UTC (permalink / raw)
To: Kyle Sexton; +Cc: emacs-orgmode
El Fri, 02 Aug 2013 09:59:55 -0500 Kyle Sexton va escriure:
> What I am after is more of a overview of "How many total TODO tasks do I
> have", ideally with some function to limit or match based on tag.
>
I manually run a script each day to update many things, one of them is exporting the agenda to a file. I can then use „wc -l“ to count the number of tasks and „grep“ to filter.
The downside is that the file is usually outdated. But computing it at every change would be too slow.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-08-04 18:20 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-01 13:30 Agenda in the mode-line? Kyle Sexton
2013-08-02 14:36 ` Bastien
2013-08-02 14:59 ` Kyle Sexton
2013-08-02 17:07 ` Nick Dokos
2013-08-02 17:49 ` Kyle Sexton
2013-08-03 5:27 ` Nick Dokos
2013-08-03 3:48 ` Eric Abrahamsen
2013-08-04 18:18 ` Daniel Clemente
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).