[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] How to do <something> for all clocks in the region or subtree?

From: Marcin Borkowski
Subject: [O] How to do <something> for all clocks in the region or subtree?
Date: Sat, 19 Mar 2016 11:49:33 +0100
User-agent: mu4e 0.9.13; emacs

Hi list,

I have a function which does <something> on a clock the point is on.
I want to call it for every clock in the region if it is active, and if
not, then for every clock in the current subtree.  Here's what I have:

--8<---------------cut here---------------start------------->8---
(defun do-something-for-all-clocks (begin end)
  "Do <something> for all clocks in the region.
In interactive use, use region if active and current subtree
otherwise.  Use with caution!"
  (interactive (if (use-region-p)
                   (list (region-beginning)
                 (list nil nil)))
       (or begin (progn (org-back-to-heading t)
       (or end (progn (org-end-of-subtree t t)
                      (when (and (org-at-heading-p) ; see org-narrow-to-subtree
                                 (not (eobp)))
                        (backward-char 1))
      (goto-char (point-min))
      (while (re-search-forward "^CLOCK: " nil t)
        (if (eq (org-element-type (org-element-at-point))
--8<---------------cut here---------------end--------------->8---

Is it ok or is there some fancy way of iterating across all clock
entries in the region?  (I don't want any dependencies - only vanilla


Marcin Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University

reply via email to

[Prev in Thread] Current Thread [Next in Thread]