From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcin Borkowski Subject: How to do for all clocks in the region or subtree? Date: Sat, 19 Mar 2016 11:49:33 +0100 Message-ID: <871t76g2te.fsf@mbork.pl> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37468) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahES1-0002nr-HX for emacs-orgmode@gnu.org; Sat, 19 Mar 2016 06:49:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ahERy-0003Kh-CP for emacs-orgmode@gnu.org; Sat, 19 Mar 2016 06:49:45 -0400 Received: from mail.mojserwer.eu ([2a01:5e00:2:52::8]:51075) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahERy-0003JJ-5A for emacs-orgmode@gnu.org; Sat, 19 Mar 2016 06:49:42 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.mojserwer.eu (Postfix) with ESMTP id BED06A2A5AC for ; Sat, 19 Mar 2016 11:49:39 +0100 (CET) Received: from mail.mojserwer.eu ([127.0.0.1]) by localhost (mail.mojserwer.eu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PmRE2scQuL1Z for ; Sat, 19 Mar 2016 11:49:37 +0100 (CET) Received: from localhost (98-171.echostar.pl [213.156.98.171]) by mail.mojserwer.eu (Postfix) with ESMTPSA id 7CAC8A2A5AB for ; Sat, 19 Mar 2016 11:49:37 +0100 (CET) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Org-Mode mailing list Hi list, I have a function which does 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 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) (region-end)) (list nil nil))) (save-excursion (save-restriction (narrow-to-region (or begin (progn (org-back-to-heading t) (point))) (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)) (point)))) (goto-char (point-min)) (while (re-search-forward "^CLOCK: " nil t) (if (eq (org-element-type (org-element-at-point)) 'clock) (do-something-with-clock-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 Org!) TIA, -- Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Faculty of Mathematics and Computer Science Adam Mickiewicz University