From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Samuel Loury <konubinix@gmail.com>
Cc: OrgMode ML <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] Make use of the constant `org-clock-string' whenever possible
Date: Tue, 26 Aug 2014 10:38:38 +0200 [thread overview]
Message-ID: <87ppfnhchd.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <87r403d7yk.fsf@konixwork.incubateur.ens-lyon.fr> (Samuel Loury's message of "Tue, 26 Aug 2014 09:29:55 +0200")
Hello,
Samuel Loury <konubinix@gmail.com> 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 <konubinix@gmail.com>
> 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
next prev parent reply other threads:[~2014-08-26 8:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-26 7:29 [PATCH] Make use of the constant `org-clock-string' whenever possible Samuel Loury
2014-08-26 8:38 ` Nicolas Goaziou [this message]
2014-08-26 9:41 ` Samuel Loury
2014-08-27 7:34 ` Nicolas Goaziou
2014-08-27 11:33 ` Marcin Borkowski
2014-08-31 19:56 ` Nicolas Goaziou
2014-09-01 6:59 ` Marcin Borkowski
2014-08-27 7:26 ` Samuel Loury
2014-08-27 8:11 ` Nicolas Goaziou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ppfnhchd.fsf@nicolasgoaziou.fr \
--to=mail@nicolasgoaziou.fr \
--cc=emacs-orgmode@gnu.org \
--cc=konubinix@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).