emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric S Fraga <ucecesf@ucl.ac.uk>
To: Yuri Goncharov <gy@hl.ru>
Cc: emacs-orgmode@gnu.org
Subject: Re: modeline clock string
Date: Wed, 14 Apr 2010 16:50:08 +0100	[thread overview]
Message-ID: <87aat6ghjj.wl%ucecesf@ucl.ac.uk> (raw)
In-Reply-To: <20100412093815.207451b1@n14>

On Mon, 12 Apr 2010 09:38:15 +0400, Yuri Goncharov <gy@hl.ru> wrote:
> 
> 
> 
> 
> > Yuri Goncharov schrieb:
> > > I use xmonad with xmobar at my desktop. I'd like to add clock
> > > string from mode line to xmobar. Is there  way to save it to
> > > file every time when update mode line?
> > > 
> > ---Zitatende---
> > 
> > You can find information on various subjects with M-x apropos but it's
> > sometimes hard to find the right keyword. I emacs, certain functions
> > are called when certain events occur, those functions are called
> > hooks. I found display-time-hook by doing M-x apropos<ret>hook<ret>
> > and then searching for status (no result) and update (which yielded
> > display-time-hook).
> > 
> > See documentation of variable display-time-hook
> 
> Thanks to answer! I need some more help, because my knowledge of lisp
> too poor. I found two hooks like I need org-clock-in-hook and 
> org-clock-out-hook. Function  org-clock-get-clock-string returns string
> that is showing in mode line. I cant figure how to write it in file.
> Apologies to my english. 
> 
> -- 
> Yuri Goncharov

Maybe this will help:

--8<---------------cut here---------------start------------->8---
;; ---------------------------------------------------------------------------- DISPLAY-TIME
(display-time)
(defun esf/org-clocking-info-to-file ()
  (with-temp-file "~/tmp/clocking"
    ;; (message (org-clock-get-clock-string))
    (if (org-clock-is-active)
	(insert (format "org: %d/%d min" 
			(- (org-clock-get-clocked-time) org-clock-total-time)
			(org-clock-get-clocked-time))
		)
      ) ;;(org-clock-get-clock-string)
    )
  )
(add-hook 'display-time-hook 'esf/org-clocking-info-to-file)
--8<---------------cut here---------------end--------------->8---

I use this to place information on clocking at the top of my display
(using dzen2 with ratpoison).  I have minimal space so only include
the time information, not the full information which typically
includes the org-heading being clocked.

This doesn't work properly if you have two emacs instances but I can't
be bothered to improve it as I *never* have two or more emacs
running...  that's what emacsclient is for, after all... ;-)

HTH,
eric

      reply	other threads:[~2010-04-14 16:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-09  9:30 modeline clock string Yuri Goncharov
2010-04-09 10:18 ` Friedrich Delgado Friedrichs
2010-04-12  5:38   ` Yuri Goncharov
2010-04-14 15:50     ` Eric S Fraga [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87aat6ghjj.wl%ucecesf@ucl.ac.uk \
    --to=ucecesf@ucl.ac.uk \
    --cc=e.fraga@ucl.ac.uk \
    --cc=emacs-orgmode@gnu.org \
    --cc=gy@hl.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).