* (org-entry-get (point) "CLOCK") fails now
@ 2015-08-30 11:41 Martin Kaffanke
2015-08-30 12:25 ` Nicolas Goaziou
0 siblings, 1 reply; 7+ messages in thread
From: Martin Kaffanke @ 2015-08-30 11:41 UTC (permalink / raw)
To: emacs-orgmode
Hi there,
I have an exisiting code using for monnth, and it worked well at the end
of July - now End of August I need it again, but it returns nil, even on
the org entries which I have successfully used my code.
Why is "CLOCK" property now missing (after elpa updates) in
org-entry-get?
It is even missing in (org-entry-properties) - which I don't use, I just
looked at it...
And how do I have to rewrite my code now?
Thanks,
Martin
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: (org-entry-get (point) "CLOCK") fails now
2015-08-30 11:41 (org-entry-get (point) "CLOCK") fails now Martin Kaffanke
@ 2015-08-30 12:25 ` Nicolas Goaziou
2015-08-30 13:06 ` Marcin Borkowski
2015-08-30 15:37 ` Martin Kaffanke
0 siblings, 2 replies; 7+ messages in thread
From: Nicolas Goaziou @ 2015-08-30 12:25 UTC (permalink / raw)
To: Martin Kaffanke; +Cc: emacs-orgmode
Hello,
Martin Kaffanke <martin@kaffanke.at> writes:
> Why is "CLOCK" property now missing (after elpa updates) in
> org-entry-get?
I removed it because it was not used in the code base, and the stored
value was dubious anyway, i.e., the first CLOCK keyword in the entry,
which could also be the first chronologically, or the last one, or
anything between since there is no rule about the order of CLOCK
keywords in an entry.
> And how do I have to rewrite my code now?
I don't have enough information to answer.
What is your code supposed to do? What did you use CLOCK property for?
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: (org-entry-get (point) "CLOCK") fails now
2015-08-30 12:25 ` Nicolas Goaziou
@ 2015-08-30 13:06 ` Marcin Borkowski
2015-08-30 15:21 ` Nicolas Goaziou
2015-08-30 15:37 ` Martin Kaffanke
1 sibling, 1 reply; 7+ messages in thread
From: Marcin Borkowski @ 2015-08-30 13:06 UTC (permalink / raw)
To: Martin Kaffanke, emacs-orgmode
On 2015-08-30, at 14:25, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
> Hello,
>
> Martin Kaffanke <martin@kaffanke.at> writes:
>
>> Why is "CLOCK" property now missing (after elpa updates) in
>> org-entry-get?
>
> I removed it because it was not used in the code base, and the stored
> value was dubious anyway, i.e., the first CLOCK keyword in the entry,
> which could also be the first chronologically, or the last one, or
> anything between since there is no rule about the order of CLOCK
> keywords in an entry.
>
>> And how do I have to rewrite my code now?
>
> I don't have enough information to answer.
>
> What is your code supposed to do? What did you use CLOCK property for?
Let me hijack this thread a bit;-), since my issue seems similar.
I need to get the number of minutes just clocked (so only the last clock
entry) in org-clock-out-hook. Currently, what I'm doing is very
hackish: I check current-message for regex "LINE REMOVED$", and if it
doesn't match, I do looking-back with a regex catching things like 0:12.
All this seems extremely fragile. Is there a better way? (Probably
yes, but what is it?)
> Regards,
Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: (org-entry-get (point) "CLOCK") fails now
2015-08-30 13:06 ` Marcin Borkowski
@ 2015-08-30 15:21 ` Nicolas Goaziou
2015-08-30 20:18 ` Marcin Borkowski
0 siblings, 1 reply; 7+ messages in thread
From: Nicolas Goaziou @ 2015-08-30 15:21 UTC (permalink / raw)
To: Marcin Borkowski; +Cc: emacs-orgmode, Martin Kaffanke
Hello,
Marcin Borkowski <mbork@mbork.pl> writes:
> Let me hijack this thread a bit;-), since my issue seems similar.
> I need to get the number of minutes just clocked (so only the last clock
> entry) in org-clock-out-hook. Currently, what I'm doing is very
> hackish: I check current-message for regex "LINE REMOVED$", and if it
> doesn't match, I do looking-back with a regex catching things like 0:12.
> All this seems extremely fragile. Is there a better way? (Probably
> yes, but what is it?)
Point should be on clocked out clock when `org-clock-out-hook' is run.
You can probably use
(org-element-property :duration (org-element-at-point))
to extract last duration.
Note that this issue is not similar to OP's issue, because CLOCK
property, for whatever value it was supposed to contain, wouldn't have
helped here.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: (org-entry-get (point) "CLOCK") fails now
2015-08-30 12:25 ` Nicolas Goaziou
2015-08-30 13:06 ` Marcin Borkowski
@ 2015-08-30 15:37 ` Martin Kaffanke
2015-08-30 18:59 ` Nicolas Goaziou
1 sibling, 1 reply; 7+ messages in thread
From: Martin Kaffanke @ 2015-08-30 15:37 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode
Nicolas Goaziou writes:
>
>> And how do I have to rewrite my code now?
>
> I don't have enough information to answer.
>
> What is your code supposed to do? What did you use CLOCK property for?
I have only one CLOCK property for my entry and I just want to extract
the start time of that clock entry. I did after the get-entry:
(let*
(
....
(clockentry (org-entry-get (point) "CLOCK"))
(clockstart (apply 'encode-time (org-parse-time-string clockentry)))
....
)
.....
)
So maybe you just know how to rewrite this two lines?
Thanks,
Martin
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: (org-entry-get (point) "CLOCK") fails now
2015-08-30 15:37 ` Martin Kaffanke
@ 2015-08-30 18:59 ` Nicolas Goaziou
0 siblings, 0 replies; 7+ messages in thread
From: Nicolas Goaziou @ 2015-08-30 18:59 UTC (permalink / raw)
To: Martin Kaffanke; +Cc: emacs-orgmode
Martin Kaffanke <martin@kaffanke.at> writes:
> I have only one CLOCK property for my entry and I just want to extract
> the start time of that clock entry. I did after the get-entry:
>
> (let*
> (
> ....
> (clockentry (org-entry-get (point) "CLOCK"))
> (clockstart (apply 'encode-time (org-parse-time-string clockentry)))
> ....
> )
> .....
> )
>
>
> So maybe you just know how to rewrite this two lines?
Well, that's an usual pattern: search something using a lax regexp,
discard false positives with parser, and return a specific value:
(let ((clockstart
(org-with-wide-buffer
(org-back-to-heading t)
(let ((end (save-excursion (outline-next-heading)))
(re (concat "^[ \t]*" org-clock-string)))
(catch :found
(while (re-search-forward re end t)
(let ((element (org-element-at-point)))
(when (eq (org-element-type element) 'clock)
(throw :found
(org-timestamp--to-internal-time
(org-element-property :value element)))))))))))
...)
I should probably rename `org-timestamp--to-internal-time' to
`org-timestamp-to-internal-time' if it is useful out of org.el.
Regards,
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: (org-entry-get (point) "CLOCK") fails now
2015-08-30 15:21 ` Nicolas Goaziou
@ 2015-08-30 20:18 ` Marcin Borkowski
0 siblings, 0 replies; 7+ messages in thread
From: Marcin Borkowski @ 2015-08-30 20:18 UTC (permalink / raw)
To: Martin Kaffanke, emacs-orgmode
On 2015-08-30, at 17:21, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
> Hello,
>
> Point should be on clocked out clock when `org-clock-out-hook' is run.
> You can probably use
>
> (org-element-property :duration (org-element-at-point))
>
> to extract last duration.
Thanks, that does the trick!
Still, I'm not sure how to handle the situation when the last line is
automatically removed due to
(setq org-clock-out-remove-zero-time-clocks t)
> Regards,
Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-08-30 20:18 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-30 11:41 (org-entry-get (point) "CLOCK") fails now Martin Kaffanke
2015-08-30 12:25 ` Nicolas Goaziou
2015-08-30 13:06 ` Marcin Borkowski
2015-08-30 15:21 ` Nicolas Goaziou
2015-08-30 20:18 ` Marcin Borkowski
2015-08-30 15:37 ` Martin Kaffanke
2015-08-30 18:59 ` Nicolas Goaziou
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).