From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [PATCH] Make use of the constant `org-clock-string' whenever possible Date: Tue, 26 Aug 2014 10:38:38 +0200 Message-ID: <87ppfnhchd.fsf@nicolasgoaziou.fr> References: <87r403d7yk.fsf@konixwork.incubateur.ens-lyon.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45863) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMCGS-00027l-2Y for emacs-orgmode@gnu.org; Tue, 26 Aug 2014 04:38:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XMCGH-0004Kf-Tc for emacs-orgmode@gnu.org; Tue, 26 Aug 2014 04:38:04 -0400 Received: from relay3-d.mail.gandi.net ([2001:4b98:c:538::195]:55235) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMCGH-0004KX-NN for emacs-orgmode@gnu.org; Tue, 26 Aug 2014 04:37:53 -0400 In-Reply-To: <87r403d7yk.fsf@konixwork.incubateur.ens-lyon.fr> (Samuel Loury's message of "Tue, 26 Aug 2014 09:29:55 +0200") 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: Samuel Loury Cc: OrgMode ML Hello, Samuel Loury writes: > I would like to submit a tiny patch to make use of `org-clock-string' > instead of the hard coded value CLOCK: whenever possible. Thank you. Some comments follow. > From 8eedb019d277f7f1e8baa6641244ddf7e298d397 Mon Sep 17 00:00:00 2001 > From: Konubinix > Date: Tue, 26 Aug 2014 09:11:23 +0200 > Subject: [PATCH] Make use of the constant `org-clock-string' whenever possible > > Instead of the hardcoded value "CLOCK:". > > * lisp/org-clock.el (org-find-open-clocks) > * lisp/org.el (org-clone-subtree-with-time-shift) > * lisp/org.el (org-insert-property-drawer) > * lisp/org.el (org-at-clock-log-p) The commit message looks strange. What about [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". > TINYCHANGE Since you signed FSF papers, you don't need to add "TINYCHANGE" anymore. > - (while (re-search-forward "CLOCK: \\(\\[.*?\\]\\)$" nil t) > + (while (re-search-forward (concat org-clock-string " \\(\\[.*?\\]\\)$") nil t) You are building a new string before each search, which is sub-optimal. (let ((re (concat org-clock-string " \\(\\[.*?\\]\\)$"))) (while (re-search-forward re nil t) ...)) > - (while (re-search-forward "^[ \t]*CLOCK:.*$" nil t) > + (while (re-search-forward > + (format "^[ \t]*%s.*$" org-clock-string) nil t) Ditto. > - (while (looking-at "^[ \t]*\\(:CLOCK:\\|:LOGBOOK:\\|CLOCK:\\|:END:\\)") > - (if (member (match-string 1) '("CLOCK:" ":END:")) > + (while (looking-at > + (format > + "^[ \t]*\\(:CLOCK:\\|:LOGBOOK:\\|%s\\|:END:\\)" > + org-clock-string)) Ditto. > + (if (member (match-string 1) > + (list org-clock-string ":END:")) > - (looking-at "^[ \t]*CLOCK:"))) You are building a new list each time. > + (looking-at > + (concat "^[ \t]*" org-clock-string)))) See above. Anyway this would benefit from a rewrite using "org-element.el" (*Hint*) but that's a much bigger task. Regards, -- Nicolas Goaziou