From mboxrd@z Thu Jan 1 00:00:00 1970 From: Samuel Loury Subject: Re: [PATCH] Make use of the constant `org-clock-string' whenever possible Date: Wed, 27 Aug 2014 09:26:25 +0200 Message-ID: <87lhqaqtpa.fsf@konixwork.incubateur.ens-lyon.fr> References: <87r403d7yk.fsf@konixwork.incubateur.ens-lyon.fr> <87ppfnhchd.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57558) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMXcz-0001Km-Vv for emacs-orgmode@gnu.org; Wed, 27 Aug 2014 03:26:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XMXcq-0008Th-S5 for emacs-orgmode@gnu.org; Wed, 27 Aug 2014 03:26:45 -0400 Received: from mail-wi0-x22f.google.com ([2a00:1450:400c:c05::22f]:51927) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMXcq-0008Tc-Go for emacs-orgmode@gnu.org; Wed, 27 Aug 2014 03:26:36 -0400 Received: by mail-wi0-f175.google.com with SMTP id ho1so5330907wib.8 for ; Wed, 27 Aug 2014 00:26:35 -0700 (PDT) In-Reply-To: <87ppfnhchd.fsf@nicolasgoaziou.fr> 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: Nicolas Goaziou Cc: OrgMode ML --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Hi, Finally, I don't have time to dig into org-element.el for the time being. Nonetheless, please find attached a revised version of the patch with your comments taken into account. In order to avoid creating the regexp each time `org-at-clock-log-p' is called, I added the constant `org-clock-line-re', following the same naming convention as `org-planning-or-clock-line-re' defined above. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-PATCH-Use-org-clock-string-whenever-possible.patch Content-Transfer-Encoding: quoted-printable From=20d0247756c9a9c8a753dfba6c2de0c4f1d9ed4fc5 Mon Sep 17 00:00:00 2001 From: Konubinix Date: Tue, 26 Aug 2014 09:11:23 +0200 Subject: [PATCH] [PATCH] Use `org-clock-string' whenever possible * lisp/org-clock.el (org-find-open-clocks): * lisp/org.el (org-clone-subtree-with-time-shift, org-insert-property-drawer, org-at-clock-log-p): Use `org-clock-string' whenever possible instead of hardcoded "CLOCK". Add the `org-clock-line-re' regexp matching a line with clock info. =2D-- lisp/org-clock.el | 3 ++- lisp/org.el | 21 +++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 179d395..2ffcbfa 100644 =2D-- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -795,11 +795,12 @@ If CLOCK-SOUND is non-nil, it overrides `org-clock-so= und'." "Search through the given file and find all open clocks." (let ((buf (or (get-file-buffer file) (find-file-noselect file))) + (org-clock-re (concat org-clock-string " \\(\\[.*?\\]\\)$")) clocks) (with-current-buffer buf (save-excursion (goto-char (point-min)) =2D (while (re-search-forward "CLOCK: \\(\\[.*?\\]\\)$" nil t) + (while (re-search-forward org-clock-re nil t) (push (cons (copy-marker (match-end 1) t) (org-time-string-to-time (match-string 1))) clocks)))) clocks)) diff --git a/lisp/org.el b/lisp/org.el index 750b9d1..2dd3e80 100755 =2D-- a/lisp/org.el +++ b/lisp/org.el @@ -396,6 +396,10 @@ a timestamp with \\[org-schedule].") "Matches a line with planning or clock info. Matched keyword is in group 1.") =20 +(defconst org-clock-line-re + (concat "^[ \t]*" org-clock-string) + "Matches a line with clock info.") + ;;;; Drawer =20 (defconst org-drawer-regexp "^[ \t]*:\\(\\(?:\\w\\|[-_]\\)+\\):[ \t]*$" @@ -8659,6 +8663,7 @@ and still retain the repeater to cover future instanc= es of the task." ""))) ;; No time shift (n-no-remove -1) (drawer-re org-drawer-regexp) + (org-clock-re (format "^[ \t]*%s.*$" org-clock-string)) beg end template task idprop shift-n shift-what doshift nmin nmax) (if (not (and (integerp n) (> n 0))) @@ -8698,7 +8703,8 @@ and still retain the repeater to cover future instanc= es of the task." (org-entry-delete nil "ID") (org-id-get-create t))) (unless (=3D n 0) =2D (while (re-search-forward "^[ \t]*CLOCK:.*$" nil t) + (while (re-search-forward + org-clock-re nil t) (kill-whole-line)) (goto-char (point-min)) (while (re-search-forward drawer-re nil t) @@ -15883,6 +15889,10 @@ formats in the current buffer." 0)) (beg (point)) (re (concat "^[ \t]*" org-keyword-time-regexp)) + (org-clock-re (format + "^[ \t]*\\(:CLOCK:\\|:LOGBOOK:\\|%s\\|:END:\\)" + org-clock-string)) + (org-skip-line-list (list org-clock-string ":END:")) end hiddenp) (outline-next-heading) (setq end (point)) @@ -15891,8 +15901,10 @@ formats in the current buffer." (setq hiddenp (outline-invisible-p)) (end-of-line 1) (and (equal (char-after) ?\n) (forward-char 1)) =2D (while (looking-at "^[ \t]*\\(:CLOCK:\\|:LOGBOOK:\\|CLOCK:\\|:END:\\= )") =2D (if (member (match-string 1) '("CLOCK:" ":END:")) + (while (looking-at + org-clock-re) + (if (member (match-string 1) + org-skip-line-list) ;; just skip this line (beginning-of-line 2) ;; Drawer start, find the end @@ -17589,7 +17601,8 @@ With prefix ARG, change that many days." "Is the cursor on the clock log line?" (save-excursion (move-beginning-of-line 1) =2D (looking-at "^[ \t]*CLOCK:"))) + (looking-at + org-clock-line-re))) =20 (defvar org-clock-history) ; defined in org-clock.el (defvar org-clock-adjust-closest nil) ; defined in org-clock.el =2D-=20 2.1.0.rc1 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable =2D-=20 Konubinix GPG Key : 7439106A Fingerprint: 5993 BE7A DA65 E2D9 06CE 5C36 75D2 3CED 7439 106A --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJT/YghAAoJEHXSPO10ORBqwrMIAJqwdCsKjarkBdDk55E86gg5 UMp2+fFxPcOxQ1SVS78YT1x+UaqFKwypR81URPiGVtMBlkatL3J+TDydAxJk8pgi WHJZL1zOopbfxlSvaX+Q+G7NOPDhCzVbriGwk4+JTd3IyZxJL+/WzH0466aCdmBA GK29BhZ3KQaMLSbtC66CNrk7OnmBcp1XxqYevI9H0OksMpArhZr9uk1V96HhcKZ3 vtQn9r/tKJTTkUPIH9LDxEraiuslz8zWv+eSPgIigv9YR4p8PsqwEDG8S5ZglLxz 6QgOqP7bja/QbUrrFXjs07k0g3iSyB/64OL9qHn38sdXzO7PVZbH0/kHrAl23PQ= =gLT5 -----END PGP SIGNATURE----- --==-=-=--