all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Wishlist - Function to get to and reveal the current clocking task
@ 2007-10-03 17:52 Bernt Hansen
  2007-10-03 18:09 ` Bastien
  0 siblings, 1 reply; 9+ messages in thread
From: Bernt Hansen @ 2007-10-03 17:52 UTC (permalink / raw)
  To: emacs-orgmode

I'm finding that I want to get back to my current clocking task
frequently.  My org files are fairly large and when I fold all the tasks
the only way I know of to get back to the current clocking task is to
display today's agenda, press 'l' to get a display of my clocked tasks,
and put the cursor on the last entry then hit 'o' to close the other
window and RETURN.  I do this 20 times a day... and it's getting kind of
cumbersome :)

I'd love a function I could bind to a single key press to do this.

I know org-clock-marker points at the current location I want to get to
- I just don't know how to use it to get there and reveal the location
the same as if I used the above procedure from the agenda.

Any suggestions?

Thanks,
Bernt

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

* Re: Wishlist - Function to get to and reveal the current clocking task
  2007-10-03 17:52 Wishlist - Function to get to and reveal the current clocking task Bernt Hansen
@ 2007-10-03 18:09 ` Bastien
  2007-10-03 18:34   ` Bernt Hansen
  0 siblings, 1 reply; 9+ messages in thread
From: Bastien @ 2007-10-03 18:09 UTC (permalink / raw)
  To: emacs-orgmode

Bernt Hansen <bernt@alumni.uwaterloo.ca> writes:

> I'd love a function I could bind to a single key press to do this.
>
> I know org-clock-marker points at the current location I want to get to
> - I just don't know how to use it to get there and reveal the location
> the same as if I used the above procedure from the agenda.

Something like this?

(defun org-goto-clocked-in-entry ()
  "Go to the currently clocked-in entry."
  (interactive)
  (goto-char org-clock-marker)
  (org-show-entry)
  (org-back-to-heading))

-- 
Bastien

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

* Re: Wishlist - Function to get to and reveal the current clocking task
  2007-10-03 18:09 ` Bastien
@ 2007-10-03 18:34   ` Bernt Hansen
  2007-10-03 18:49     ` Bastien
  0 siblings, 1 reply; 9+ messages in thread
From: Bernt Hansen @ 2007-10-03 18:34 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

Bastien <bzg@altern.org> writes:

> Bernt Hansen <bernt@alumni.uwaterloo.ca> writes:
>
>> I'd love a function I could bind to a single key press to do this.
>>
>> I know org-clock-marker points at the current location I want to get to
>> - I just don't know how to use it to get there and reveal the location
>> the same as if I used the above procedure from the agenda.
>
> Something like this?
>
> (defun org-goto-clocked-in-entry ()
>   "Go to the currently clocked-in entry."
>   (interactive)
>   (goto-char org-clock-marker)
>   (org-show-entry)
>   (org-back-to-heading))

Close :) My first attempt to code this failed miserably.

Your version doesn't handle switching files/buffers.  I also got the
'before first heading' error from your version when not in an org buffer
... so I hacked at it and this is what I have now:

(defun org-goto-clocked-in-entry ()
  "Go to the currently clocked-in entry."
  (interactive)
  (if (not (marker-buffer org-clock-marker))
      (error "No active clock"))
  (display-buffer (marker-buffer org-clock-marker))
  (goto-char org-clock-marker)
  (org-show-entry)
  (org-back-to-heading))

This is closer but still not right.

If I'm in another buffer it splits the window and displays the right
stuff in the other buffer - I just need to close the current window.

My Emacs lisp skills are sadly lacking :(

Thanks!
Bernt

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

* Re: Wishlist - Function to get to and reveal the current clocking task
  2007-10-03 18:34   ` Bernt Hansen
@ 2007-10-03 18:49     ` Bastien
  2007-10-03 19:10       ` Bernt Hansen
  0 siblings, 1 reply; 9+ messages in thread
From: Bastien @ 2007-10-03 18:49 UTC (permalink / raw)
  To: emacs-orgmode

Bernt Hansen <bernt@alumni.uwaterloo.ca> writes:

> If I'm in another buffer it splits the window and displays the right
> stuff in the other buffer - I just need to close the current window.

(defun org-goto-clocked-in-entry (&optional delete-windows)
  "Go to the currently clocked-in entry.
If DELETE-WINDOWS is non-nil, delete other windows. Sigh."
  (interactive "P")
  (if (not (marker-buffer org-clock-marker))
      (error "No active clock"))
  (switch-to-buffer-other-window
   (marker-buffer org-clock-marker))
  (if delete-windows (delete-other-windows))
  (goto-char org-clock-marker)
  (org-show-entry)
  (org-back-to-heading))

I guess that comes closer.  

-- 
Bastien

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

* Re: Wishlist - Function to get to and reveal the current clocking task
  2007-10-03 18:49     ` Bastien
@ 2007-10-03 19:10       ` Bernt Hansen
  2007-10-03 19:56         ` Bastien
  0 siblings, 1 reply; 9+ messages in thread
From: Bernt Hansen @ 2007-10-03 19:10 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

Bastien <bzg@altern.org> writes:

> Bernt Hansen <bernt@alumni.uwaterloo.ca> writes:
>
>> If I'm in another buffer it splits the window and displays the right
>> stuff in the other buffer - I just need to close the current window.
>
> (defun org-goto-clocked-in-entry (&optional delete-windows)
>   "Go to the currently clocked-in entry.
> If DELETE-WINDOWS is non-nil, delete other windows. Sigh."
>   (interactive "P")
>   (if (not (marker-buffer org-clock-marker))
>       (error "No active clock"))
>   (switch-to-buffer-other-window
>    (marker-buffer org-clock-marker))
>   (if delete-windows (delete-other-windows))
>   (goto-char org-clock-marker)
>   (org-show-entry)
>   (org-back-to-heading))
>
> I guess that comes closer.  

Thanks!

(global-set-key (kbd "C-M-<f12>") (lambda () (interactive) (org-goto-clocked-in-entry t)))

:)

Now the only weird thing it does is after going to the right place - if
I hit C-M-<f12> again it goes somewhere else... and again brings it
back.  I'm not sure what's up with that but this is alot better than
navigating through the agenda for me!

Thanks Bastien!!

Regards,
Bernt

P.S. And WOW that's fast response time!!  Much appreciated!

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

* Re: Wishlist - Function to get to and reveal the current clocking task
  2007-10-03 19:10       ` Bernt Hansen
@ 2007-10-03 19:56         ` Bastien
  2007-10-03 20:43           ` Bernt Hansen
  0 siblings, 1 reply; 9+ messages in thread
From: Bastien @ 2007-10-03 19:56 UTC (permalink / raw)
  To: emacs-orgmode

Bernt Hansen <bernt@alumni.uwaterloo.ca> writes:

> Now the only weird thing it does is after going to the right place -
> if I hit C-M-<f12> again it goes somewhere else... and again brings it
> back.

I can't reproduce that. You might have gnomes on your computer. Or we
both have, and mine just misbehave differently!

-- 
Bastien

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

* Re: Wishlist - Function to get to and reveal the current clocking task
  2007-10-03 19:56         ` Bastien
@ 2007-10-03 20:43           ` Bernt Hansen
  2007-10-03 21:36             ` Bastien
  0 siblings, 1 reply; 9+ messages in thread
From: Bernt Hansen @ 2007-10-03 20:43 UTC (permalink / raw)
  To: emacs-orgmode

Bastien <bzg@altern.org> writes:

> Bernt Hansen <bernt@alumni.uwaterloo.ca> writes:
>
>> Now the only weird thing it does is after going to the right place -
>> if I hit C-M-<f12> again it goes somewhere else... and again brings it
>> back.
>
> I can't reproduce that. You might have gnomes on your computer. Or we
> both have, and mine just misbehave differently!

Well just for fun I synchronised my setup to my laptop and the gnomes
are in both :)

If I fold my buffer it works but if I show all of the buffer with C-c
C-a then repeatedly run the new function it jumps back and forth between
two points in the file (lines 335 and 365 for me - the clock marker is
on line 365 - almost at the end of the file)

Bernt

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

* Re: Re: Wishlist - Function to get to and reveal the current clocking task
  2007-10-03 20:43           ` Bernt Hansen
@ 2007-10-03 21:36             ` Bastien
  2007-10-04 14:57               ` Bernt Hansen
  0 siblings, 1 reply; 9+ messages in thread
From: Bastien @ 2007-10-03 21:36 UTC (permalink / raw)
  To: emacs-orgmode

Bernt Hansen <bernt@alumni.uwaterloo.ca> writes:

> If I fold my buffer it works but if I show all of the buffer with C-c
> C-a then repeatedly run the new function it jumps back and forth between
> two points in the file (lines 335 and 365 for me - the clock marker is
> on line 365 - almost at the end of the file)

I guess the point itself is not moving, it's just the buffer being
centered differently. Let's add recenter:

------------------------------------------------------------------------
(defun org-goto-clocked-in-entry (&optional delete-windows)
  "Go to the currently clocked-in entry."
  (interactive "P")
  (if (not (marker-buffer org-clock-marker))
      (error "No active clock"))
  (switch-to-buffer-other-window
   (marker-buffer org-clock-marker))
  (if delete-windows (delete-other-windows))
  (goto-char org-clock-marker)
  (org-show-entry)
  (org-back-to-heading)
  (recenter))
------------------------------------------------------------------------

?

-- 
Bastien

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

* Re: Wishlist - Function to get to and reveal the current clocking task
  2007-10-03 21:36             ` Bastien
@ 2007-10-04 14:57               ` Bernt Hansen
  0 siblings, 0 replies; 9+ messages in thread
From: Bernt Hansen @ 2007-10-04 14:57 UTC (permalink / raw)
  To: emacs-orgmode

Bastien <bzg@altern.org> writes:

> Bernt Hansen <bernt@alumni.uwaterloo.ca> writes:
>
>> If I fold my buffer it works but if I show all of the buffer with C-c
>> C-a then repeatedly run the new function it jumps back and forth between
>> two points in the file (lines 335 and 365 for me - the clock marker is
>> on line 365 - almost at the end of the file)
>
> I guess the point itself is not moving, it's just the buffer being
> centered differently. Let's add recenter:
>
> ------------------------------------------------------------------------
> (defun org-goto-clocked-in-entry (&optional delete-windows)
>   "Go to the currently clocked-in entry."
>   (interactive "P")
>   (if (not (marker-buffer org-clock-marker))
>       (error "No active clock"))
>   (switch-to-buffer-other-window
>    (marker-buffer org-clock-marker))
>   (if delete-windows (delete-other-windows))
>   (goto-char org-clock-marker)
>   (org-show-entry)
>   (org-back-to-heading)
>   (recenter))
> ------------------------------------------------------------------------

That seems to help.  Thanks.

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

end of thread, other threads:[~2007-10-04 15:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-03 17:52 Wishlist - Function to get to and reveal the current clocking task Bernt Hansen
2007-10-03 18:09 ` Bastien
2007-10-03 18:34   ` Bernt Hansen
2007-10-03 18:49     ` Bastien
2007-10-03 19:10       ` Bernt Hansen
2007-10-03 19:56         ` Bastien
2007-10-03 20:43           ` Bernt Hansen
2007-10-03 21:36             ` Bastien
2007-10-04 14:57               ` Bernt Hansen

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.