Re: How to detect current in logbook drawer?

2020-08-16 Thread numbch...@gmail.com
Now I added `save-match-data` in my org-link-beautify. Thanks for tips.

Indeed. I will try this problem later and update here if got any news.

At last, thanks for your helping. Really thanks. :)

[stardiviner] GPG key ID: 47C32433
IRC(freeenode): stardiviner Twitter:  @numbchild
Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
Blog: http://stardiviner.github.io/


On Mon, Aug 17, 2020 at 9:50 AM Ihor Radchenko  wrote:

> > I reviewed my org-link-beautify (
> > https://github.com/stardiviner/org-link-beautify) source code, I have
> not
> > use any regexp matching. I guess the function
> > `org-link-beautify--get-element` invoked `(org-element-context)` caused
> > this problem or other similar places. But I use `debug-on-entry` on
> > `org-element-context`. Still have not got stoppoint backtrace.
>
> Judging from source code of `org-element-context`, it does modify match
> data. You can probably send a bug (or patch) fixing this. All is needed
> is to wrap the code into `save-match-data`.
>
> For you package, you can simply wrap all the code in `org-link-beautify`
> into (save-match-data ... ).
>
> > And another step `debug-on-entry` on `org-link-beautify`,
> > `org-agenda-finalize`, `org-activate-links`. I have not got a stoppoint
> > backtrace on any of upper functions when org-agenda initializes. This is
> > weird, because I tested to use `debug-on-entry` on `org-agenda`. It can
> > popup a stoppoint backtrace.
>
> Strange. I had no problem with debugging `org-agenda-finalize` on my
> system.
>
> Best,
> Ihor
>
>
> "numbch...@gmail.com"  writes:
>
> > Ihor, thanks for your detailed help.
> > I followed your steps, the `elp` step, I confirmed `org-link-beautify` is
> > invoked and fall into an infinite loop.
> >
> > ```
> > org-link-beautify  11265   58.586412984  0.0052007468
> > ```
> >
> > And another step `debug-on-entry` on `org-link-beautify`,
> > `org-agenda-finalize`, `org-activate-links`. I have not got a stoppoint
> > backtrace on any of upper functions when org-agenda initializes. This is
> > weird, because I tested to use `debug-on-entry` on `org-agenda`. It can
> > popup a stoppoint backtrace.
> >
> > I reviewed my org-link-beautify (
> > https://github.com/stardiviner/org-link-beautify) source code, I have
> not
> > use any regexp matching. I guess the function
> > `org-link-beautify--get-element` invoked `(org-element-context)` caused
> > this problem or other similar places. But I use `debug-on-entry` on
> > `org-element-context`. Still have not got stoppoint backtrace.
> >
> > Need your more help. Sorry for disturbing you
> >
> > [stardiviner] GPG key ID: 47C32433
> > IRC(freeenode): stardiviner Twitter:  @numbchild
> > Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
> > Blog: http://stardiviner.github.io/
> >
> >
> > On Sun, Aug 16, 2020 at 2:39 PM Ihor Radchenko 
> wrote:
> >
> >> > Your suggestion is very useful, I can see what function is invoked
> many
> >> > times. But still can't understand what's the cause.
> >>
> >> Looking at your CPU profiler report I can see that the slow part is
> >> happening while running org-agenda-finalize when agenda buffer is
> >> already populated. Most of time is taken by calling your function. I
> >> suspect that it is simply called many times (maybe infinite loop?).
> >>
> >> You may check the number of times your function is called using
> >>
> >> (require 'elp)
> >> (elp-instrument-function #'org-link-beautify)
> >> ;; run agenda
> >> ;; M-x elp-results
> >>
> >> Another suggestion would be invoking debug-on-entry for you function,
> >> for org-activate-links, and for org-agenda-finalize.
> >>
> >> Best,
> >> Ihor
> >>
> >>
> >>
> >>
> >> "numbch...@gmail.com"  writes:
> >>
> >> > I tried use debug-on-entry on:
> >> >   + org-agenda-list(nil)
> >> > - org-agenda-mode()
> >> >   + org-agenda-set-mode-name()
> >> > - org-update-dblock
> >> >   + org-dblock-write:clocktable
> >> >
> >> > But got no lucky, Then I followed your another suggestion, use
> profiler:
> >> >
> >> > I got a very big message log, (not suitable for paste in email, so I
> >> paste
> >> > it on Gist)
> >> >
> >> > - CPU profiler report: https://www.pastery.net/gststf/
> >> > - Memory profiler report:
> https://www.pastery.net/gststf+qzyxaf/#qzyxaf
> >> >
> >> > The very deepest call stacks seems the output format is not long
> enough,
> >> so
> >> > can't display.
> >> >
> >> > Your suggestion is very useful, I can see what function is invoked
> many
> >> > times. But still can't understand what's the cause.
> >> >
> >> > [stardiviner] GPG key ID: 47C32433
> >> > IRC(freeenode): stardiviner Twitter:  @numbchild
> >> > Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
> >> > Blog: http://stardiviner.github.io/
> >> >
> >> >
> >> > On Sat, Aug 15, 2020 at 2:02 PM Ihor Radchenko 
> >>

Re: How to detect current in logbook drawer?

2020-08-16 Thread Ihor Radchenko
> I reviewed my org-link-beautify (
> https://github.com/stardiviner/org-link-beautify) source code, I have not
> use any regexp matching. I guess the function
> `org-link-beautify--get-element` invoked `(org-element-context)` caused
> this problem or other similar places. But I use `debug-on-entry` on
> `org-element-context`. Still have not got stoppoint backtrace.

Judging from source code of `org-element-context`, it does modify match
data. You can probably send a bug (or patch) fixing this. All is needed
is to wrap the code into `save-match-data`.

For you package, you can simply wrap all the code in `org-link-beautify`
into (save-match-data ... ).

> And another step `debug-on-entry` on `org-link-beautify`,
> `org-agenda-finalize`, `org-activate-links`. I have not got a stoppoint
> backtrace on any of upper functions when org-agenda initializes. This is
> weird, because I tested to use `debug-on-entry` on `org-agenda`. It can
> popup a stoppoint backtrace.

Strange. I had no problem with debugging `org-agenda-finalize` on my
system.

Best,
Ihor


"numbch...@gmail.com"  writes:

> Ihor, thanks for your detailed help.
> I followed your steps, the `elp` step, I confirmed `org-link-beautify` is
> invoked and fall into an infinite loop.
>
> ```
> org-link-beautify  11265   58.586412984  0.0052007468
> ```
>
> And another step `debug-on-entry` on `org-link-beautify`,
> `org-agenda-finalize`, `org-activate-links`. I have not got a stoppoint
> backtrace on any of upper functions when org-agenda initializes. This is
> weird, because I tested to use `debug-on-entry` on `org-agenda`. It can
> popup a stoppoint backtrace.
>
> I reviewed my org-link-beautify (
> https://github.com/stardiviner/org-link-beautify) source code, I have not
> use any regexp matching. I guess the function
> `org-link-beautify--get-element` invoked `(org-element-context)` caused
> this problem or other similar places. But I use `debug-on-entry` on
> `org-element-context`. Still have not got stoppoint backtrace.
>
> Need your more help. Sorry for disturbing you
>
> [stardiviner] GPG key ID: 47C32433
> IRC(freeenode): stardiviner Twitter:  @numbchild
> Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
> Blog: http://stardiviner.github.io/
>
>
> On Sun, Aug 16, 2020 at 2:39 PM Ihor Radchenko  wrote:
>
>> > Your suggestion is very useful, I can see what function is invoked many
>> > times. But still can't understand what's the cause.
>>
>> Looking at your CPU profiler report I can see that the slow part is
>> happening while running org-agenda-finalize when agenda buffer is
>> already populated. Most of time is taken by calling your function. I
>> suspect that it is simply called many times (maybe infinite loop?).
>>
>> You may check the number of times your function is called using
>>
>> (require 'elp)
>> (elp-instrument-function #'org-link-beautify)
>> ;; run agenda
>> ;; M-x elp-results
>>
>> Another suggestion would be invoking debug-on-entry for you function,
>> for org-activate-links, and for org-agenda-finalize.
>>
>> Best,
>> Ihor
>>
>>
>>
>>
>> "numbch...@gmail.com"  writes:
>>
>> > I tried use debug-on-entry on:
>> >   + org-agenda-list(nil)
>> > - org-agenda-mode()
>> >   + org-agenda-set-mode-name()
>> > - org-update-dblock
>> >   + org-dblock-write:clocktable
>> >
>> > But got no lucky, Then I followed your another suggestion, use profiler:
>> >
>> > I got a very big message log, (not suitable for paste in email, so I
>> paste
>> > it on Gist)
>> >
>> > - CPU profiler report: https://www.pastery.net/gststf/
>> > - Memory profiler report: https://www.pastery.net/gststf+qzyxaf/#qzyxaf
>> >
>> > The very deepest call stacks seems the output format is not long enough,
>> so
>> > can't display.
>> >
>> > Your suggestion is very useful, I can see what function is invoked many
>> > times. But still can't understand what's the cause.
>> >
>> > [stardiviner] GPG key ID: 47C32433
>> > IRC(freeenode): stardiviner Twitter:  @numbchild
>> > Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
>> > Blog: http://stardiviner.github.io/
>> >
>> >
>> > On Sat, Aug 15, 2020 at 2:02 PM Ihor Radchenko 
>> wrote:
>> >
>> >> >Here is the backtrace of "toggle-debug-on-quit" when I refresh
>> org-agenda
>> >> >but has long time suspend.
>> >>
>> >> That looks unreadable for me. Also, debug on quit may not show the
>> >> problematic part depending on your luck.
>> >>
>> >> It would be easier to understand your problem if you provided the
>> >> profiler report (M-x profiler-start ... M-x profiler-report).
>> >> Then, you could debug-on-entry using the problematic part according to
>> >> the profiler report.
>> >>
>> >> A blind guess - maybe you are modifying match data somewhere in your
>> >> code. This might cause infinite loop in
>> >>
>> >> > (while (org-activate-links (point-max)) (goto-char (match-end 0)))
>> >>
>>

Re: How to detect current in logbook drawer?

2020-08-16 Thread numbch...@gmail.com
I figured an temporary workaround solution:

Use `(unless (memq major-mode org-link-beautify-exclude-modes) ...` in
`org-link-beautify` function to exclude `org-agenda-mode`.

But I still wonder what caused this problem.

[stardiviner] GPG key ID: 47C32433
IRC(freeenode): stardiviner Twitter:  @numbchild
Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
Blog: http://stardiviner.github.io/


On Mon, Aug 17, 2020 at 8:38 AM numbch...@gmail.com 
wrote:

> Ihor, thanks for your detailed help.
> I followed your steps, the `elp` step, I confirmed `org-link-beautify` is
> invoked and fall into an infinite loop.
>
> ```
> org-link-beautify  11265   58.586412984  0.0052007468
> ```
>
> And another step `debug-on-entry` on `org-link-beautify`,
> `org-agenda-finalize`, `org-activate-links`. I have not got a stoppoint
> backtrace on any of upper functions when org-agenda initializes. This is
> weird, because I tested to use `debug-on-entry` on `org-agenda`. It can
> popup a stoppoint backtrace.
>
> I reviewed my org-link-beautify (
> https://github.com/stardiviner/org-link-beautify) source code, I have not
> use any regexp matching. I guess the function
> `org-link-beautify--get-element` invoked `(org-element-context)` caused
> this problem or other similar places. But I use `debug-on-entry` on
> `org-element-context`. Still have not got stoppoint backtrace.
>
> Need your more help. Sorry for disturbing you
>
> [stardiviner] GPG key ID: 47C32433
> IRC(freeenode): stardiviner Twitter:  @numbchild
> Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
> Blog: http://stardiviner.github.io/
>
>
> On Sun, Aug 16, 2020 at 2:39 PM Ihor Radchenko  wrote:
>
>> > Your suggestion is very useful, I can see what function is invoked many
>> > times. But still can't understand what's the cause.
>>
>> Looking at your CPU profiler report I can see that the slow part is
>> happening while running org-agenda-finalize when agenda buffer is
>> already populated. Most of time is taken by calling your function. I
>> suspect that it is simply called many times (maybe infinite loop?).
>>
>> You may check the number of times your function is called using
>>
>> (require 'elp)
>> (elp-instrument-function #'org-link-beautify)
>> ;; run agenda
>> ;; M-x elp-results
>>
>> Another suggestion would be invoking debug-on-entry for you function,
>> for org-activate-links, and for org-agenda-finalize.
>>
>> Best,
>> Ihor
>>
>>
>>
>>
>> "numbch...@gmail.com"  writes:
>>
>> > I tried use debug-on-entry on:
>> >   + org-agenda-list(nil)
>> > - org-agenda-mode()
>> >   + org-agenda-set-mode-name()
>> > - org-update-dblock
>> >   + org-dblock-write:clocktable
>> >
>> > But got no lucky, Then I followed your another suggestion, use profiler:
>> >
>> > I got a very big message log, (not suitable for paste in email, so I
>> paste
>> > it on Gist)
>> >
>> > - CPU profiler report: https://www.pastery.net/gststf/
>> > - Memory profiler report: https://www.pastery.net/gststf+qzyxaf/#qzyxaf
>> >
>> > The very deepest call stacks seems the output format is not long
>> enough, so
>> > can't display.
>> >
>> > Your suggestion is very useful, I can see what function is invoked many
>> > times. But still can't understand what's the cause.
>> >
>> > [stardiviner] GPG key ID: 47C32433
>> > IRC(freeenode): stardiviner Twitter:  @numbchild
>> > Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
>> > Blog: http://stardiviner.github.io/
>> >
>> >
>> > On Sat, Aug 15, 2020 at 2:02 PM Ihor Radchenko 
>> wrote:
>> >
>> >> >Here is the backtrace of "toggle-debug-on-quit" when I refresh
>> org-agenda
>> >> >but has long time suspend.
>> >>
>> >> That looks unreadable for me. Also, debug on quit may not show the
>> >> problematic part depending on your luck.
>> >>
>> >> It would be easier to understand your problem if you provided the
>> >> profiler report (M-x profiler-start ... M-x profiler-report).
>> >> Then, you could debug-on-entry using the problematic part according to
>> >> the profiler report.
>> >>
>> >> A blind guess - maybe you are modifying match data somewhere in your
>> >> code. This might cause infinite loop in
>> >>
>> >> > (while (org-activate-links (point-max)) (goto-char (match-end 0)))
>> >>
>> >> Best,
>> >> Ihor
>> >>
>> >> "numbch...@gmail.com"  writes:
>> >>
>> >> > Thanks for replying, Ihor. I will look into this regexp.
>> >> >
>> >> > Here is the backtrace of "toggle-debug-on-quit" when I refresh
>> org-agenda
>> >> > but has long time suspend.
>> >> >
>> >> > ```
>> >> > Debugger entered--Lisp error: (quit)
>> >> >
>> >> >
>> >>
>> re-search-forward("\\(\\[\\[\\(\\(?:[^][\\]\\|\\(?:\\)*[][]\\|+[^][]\\)+..."
>> >> > 17651 t)
>> >> >   (while (re-search-forward org-link-any-re limit t) (let* ((start
>> >> > (match-beginning 0)) (end (match-end 0)) (vi

Re: How to detect current in logbook drawer?

2020-08-16 Thread numbch...@gmail.com
Ihor, thanks for your detailed help.
I followed your steps, the `elp` step, I confirmed `org-link-beautify` is
invoked and fall into an infinite loop.

```
org-link-beautify  11265   58.586412984  0.0052007468
```

And another step `debug-on-entry` on `org-link-beautify`,
`org-agenda-finalize`, `org-activate-links`. I have not got a stoppoint
backtrace on any of upper functions when org-agenda initializes. This is
weird, because I tested to use `debug-on-entry` on `org-agenda`. It can
popup a stoppoint backtrace.

I reviewed my org-link-beautify (
https://github.com/stardiviner/org-link-beautify) source code, I have not
use any regexp matching. I guess the function
`org-link-beautify--get-element` invoked `(org-element-context)` caused
this problem or other similar places. But I use `debug-on-entry` on
`org-element-context`. Still have not got stoppoint backtrace.

Need your more help. Sorry for disturbing you

[stardiviner] GPG key ID: 47C32433
IRC(freeenode): stardiviner Twitter:  @numbchild
Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
Blog: http://stardiviner.github.io/


On Sun, Aug 16, 2020 at 2:39 PM Ihor Radchenko  wrote:

> > Your suggestion is very useful, I can see what function is invoked many
> > times. But still can't understand what's the cause.
>
> Looking at your CPU profiler report I can see that the slow part is
> happening while running org-agenda-finalize when agenda buffer is
> already populated. Most of time is taken by calling your function. I
> suspect that it is simply called many times (maybe infinite loop?).
>
> You may check the number of times your function is called using
>
> (require 'elp)
> (elp-instrument-function #'org-link-beautify)
> ;; run agenda
> ;; M-x elp-results
>
> Another suggestion would be invoking debug-on-entry for you function,
> for org-activate-links, and for org-agenda-finalize.
>
> Best,
> Ihor
>
>
>
>
> "numbch...@gmail.com"  writes:
>
> > I tried use debug-on-entry on:
> >   + org-agenda-list(nil)
> > - org-agenda-mode()
> >   + org-agenda-set-mode-name()
> > - org-update-dblock
> >   + org-dblock-write:clocktable
> >
> > But got no lucky, Then I followed your another suggestion, use profiler:
> >
> > I got a very big message log, (not suitable for paste in email, so I
> paste
> > it on Gist)
> >
> > - CPU profiler report: https://www.pastery.net/gststf/
> > - Memory profiler report: https://www.pastery.net/gststf+qzyxaf/#qzyxaf
> >
> > The very deepest call stacks seems the output format is not long enough,
> so
> > can't display.
> >
> > Your suggestion is very useful, I can see what function is invoked many
> > times. But still can't understand what's the cause.
> >
> > [stardiviner] GPG key ID: 47C32433
> > IRC(freeenode): stardiviner Twitter:  @numbchild
> > Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
> > Blog: http://stardiviner.github.io/
> >
> >
> > On Sat, Aug 15, 2020 at 2:02 PM Ihor Radchenko 
> wrote:
> >
> >> >Here is the backtrace of "toggle-debug-on-quit" when I refresh
> org-agenda
> >> >but has long time suspend.
> >>
> >> That looks unreadable for me. Also, debug on quit may not show the
> >> problematic part depending on your luck.
> >>
> >> It would be easier to understand your problem if you provided the
> >> profiler report (M-x profiler-start ... M-x profiler-report).
> >> Then, you could debug-on-entry using the problematic part according to
> >> the profiler report.
> >>
> >> A blind guess - maybe you are modifying match data somewhere in your
> >> code. This might cause infinite loop in
> >>
> >> > (while (org-activate-links (point-max)) (goto-char (match-end 0)))
> >>
> >> Best,
> >> Ihor
> >>
> >> "numbch...@gmail.com"  writes:
> >>
> >> > Thanks for replying, Ihor. I will look into this regexp.
> >> >
> >> > Here is the backtrace of "toggle-debug-on-quit" when I refresh
> org-agenda
> >> > but has long time suspend.
> >> >
> >> > ```
> >> > Debugger entered--Lisp error: (quit)
> >> >
> >> >
> >>
> re-search-forward("\\(\\[\\[\\(\\(?:[^][\\]\\|\\(?:\\)*[][]\\|+[^][]\\)+..."
> >> > 17651 t)
> >> >   (while (re-search-forward org-link-any-re limit t) (let* ((start
> >> > (match-beginning 0)) (end (match-end 0)) (visible-start (or
> >> > (match-beginning 3) (match-beginning 2))) (visible-end (or (match-end
> 3)
> >> > (match-end 2))) (style (cond ((eq 60 (char-after start)) 'angle) ((eq
> 91
> >> > (char-after ...)) 'bracket) (t 'plain (if (and (memq style
> >> > org-highlight-links) (not (string-match-p
> org-element-paragraph-separate
> >> > (match-string 0))) (not (and (eq style 'plain) (let (...) (if ... ...
> >> > ...) (progn (let* ((link-object (save-excursion ... ...)) (link
> >> > (org-element-property :raw-link link-object)) (type
> (org-element-property
> >> > :type link-object)) (path (org-element-property :path link-object))
> >> > (propertie

Re: How to detect current in logbook drawer?

2020-08-15 Thread Ihor Radchenko
> Your suggestion is very useful, I can see what function is invoked many
> times. But still can't understand what's the cause.

Looking at your CPU profiler report I can see that the slow part is
happening while running org-agenda-finalize when agenda buffer is
already populated. Most of time is taken by calling your function. I
suspect that it is simply called many times (maybe infinite loop?).

You may check the number of times your function is called using

(require 'elp)
(elp-instrument-function #'org-link-beautify)
;; run agenda
;; M-x elp-results

Another suggestion would be invoking debug-on-entry for you function,
for org-activate-links, and for org-agenda-finalize.

Best,
Ihor




"numbch...@gmail.com"  writes:

> I tried use debug-on-entry on:
>   + org-agenda-list(nil)
> - org-agenda-mode()
>   + org-agenda-set-mode-name()
> - org-update-dblock
>   + org-dblock-write:clocktable
>
> But got no lucky, Then I followed your another suggestion, use profiler:
>
> I got a very big message log, (not suitable for paste in email, so I paste
> it on Gist)
>
> - CPU profiler report: https://www.pastery.net/gststf/
> - Memory profiler report: https://www.pastery.net/gststf+qzyxaf/#qzyxaf
>
> The very deepest call stacks seems the output format is not long enough, so
> can't display.
>
> Your suggestion is very useful, I can see what function is invoked many
> times. But still can't understand what's the cause.
>
> [stardiviner] GPG key ID: 47C32433
> IRC(freeenode): stardiviner Twitter:  @numbchild
> Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
> Blog: http://stardiviner.github.io/
>
>
> On Sat, Aug 15, 2020 at 2:02 PM Ihor Radchenko  wrote:
>
>> >Here is the backtrace of "toggle-debug-on-quit" when I refresh org-agenda
>> >but has long time suspend.
>>
>> That looks unreadable for me. Also, debug on quit may not show the
>> problematic part depending on your luck.
>>
>> It would be easier to understand your problem if you provided the
>> profiler report (M-x profiler-start ... M-x profiler-report).
>> Then, you could debug-on-entry using the problematic part according to
>> the profiler report.
>>
>> A blind guess - maybe you are modifying match data somewhere in your
>> code. This might cause infinite loop in
>>
>> > (while (org-activate-links (point-max)) (goto-char (match-end 0)))
>>
>> Best,
>> Ihor
>>
>> "numbch...@gmail.com"  writes:
>>
>> > Thanks for replying, Ihor. I will look into this regexp.
>> >
>> > Here is the backtrace of "toggle-debug-on-quit" when I refresh org-agenda
>> > but has long time suspend.
>> >
>> > ```
>> > Debugger entered--Lisp error: (quit)
>> >
>> >
>> re-search-forward("\\(\\[\\[\\(\\(?:[^][\\]\\|\\(?:\\)*[][]\\|+[^][]\\)+..."
>> > 17651 t)
>> >   (while (re-search-forward org-link-any-re limit t) (let* ((start
>> > (match-beginning 0)) (end (match-end 0)) (visible-start (or
>> > (match-beginning 3) (match-beginning 2))) (visible-end (or (match-end 3)
>> > (match-end 2))) (style (cond ((eq 60 (char-after start)) 'angle) ((eq 91
>> > (char-after ...)) 'bracket) (t 'plain (if (and (memq style
>> > org-highlight-links) (not (string-match-p org-element-paragraph-separate
>> > (match-string 0))) (not (and (eq style 'plain) (let (...) (if ... ...
>> > ...) (progn (let* ((link-object (save-excursion ... ...)) (link
>> > (org-element-property :raw-link link-object)) (type (org-element-property
>> > :type link-object)) (path (org-element-property :path link-object))
>> > (properties (list ... ... ... ... ... ... ... ... ... ... ... t)))
>> > (org-remove-flyspell-overlays-in start end) (org-rear-nonsticky-at end)
>> (if
>> > (not (eq ... style)) (add-text-properties start end properties)
>> > (remove-text-properties start end '...) (let (...) (add-text-properties
>> > start visible-start hidden) (add-text-properties visible-start
>> visible-end
>> > properties) (add-text-properties visible-end end hidden)
>> > (org-rear-nonsticky-at visible-start) (org-rear-nonsticky-at
>> visible-end)))
>> > (let ((f ...)) (if (functionp f) (progn ...))) (throw :exit t))
>> >   (catch :exit (while (re-search-forward org-link-any-re limit t) (let*
>> > ((start (match-beginning 0)) (end (match-end 0)) (visible-start (or
>> > (match-beginning 3) (match-beginning 2))) (visible-end (or (match-end 3)
>> > (match-end 2))) (style (cond ((eq 60 ...) 'angle) ((eq 91 ...) 'bracket)
>> (t
>> > 'plain (if (and (memq style org-highlight-links) (not (string-match-p
>> > org-element-paragraph-separate (match-string 0))) (not (and (eq style
>> ...)
>> > (let ... ... (progn (let* ((link-object ...) (link ...) (type ...)
>> > (path ...) (properties ...)) (org-remove-flyspell-overlays-in start end)
>> > (org-rear-nonsticky-at end) (if (not ...) (add-text-properties start end
>> > properties) (remove-text-properties start end ...) (let ... ... ... ...
>> ...
>> > ...)) (let (...) (if ... ...)) (throw 

Re: How to detect current in logbook drawer?

2020-08-15 Thread numbch...@gmail.com
Also I noticed one thing:

 The problem happens on when link (org-link-beautify enabled) is behind "-"
directly:

 #+begin_src org
 ,* headline
   :LOGBOOK:
   CLOCK: [2020-07-23 Thu 22:05]--[2020-07-23 Thu 22:14] =>  0:09
   - [[file:~/Code/Emacs/org-mode/lisp/org-agenda.el::(defcustom
org-agenda-start-with-clockreport-mode
nil][org-agenda-start-with-clockreport-mode]]
   :END:
 #+end_src

 But no problem when preceding content is not link. For example:

 #+begin_src org
 ,* headline
   :LOGBOOK:
   CLOCK: [2020-07-23 Thu 22:05]--[2020-07-23 Thu 22:14] =>  0:09
   - kk
 [[file:~/Code/Emacs/org-mode/lisp/org-agenda.el::(defcustom
org-agenda-start-with-clockreport-mode
nil][org-agenda-start-with-clockreport-mode]]
   :END:
 #+end_src

[stardiviner] GPG key ID: 47C32433
IRC(freeenode): stardiviner Twitter:  @numbchild
Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
Blog: http://stardiviner.github.io/


On Sat, Aug 15, 2020 at 2:02 PM Ihor Radchenko  wrote:

> >Here is the backtrace of "toggle-debug-on-quit" when I refresh org-agenda
> >but has long time suspend.
>
> That looks unreadable for me. Also, debug on quit may not show the
> problematic part depending on your luck.
>
> It would be easier to understand your problem if you provided the
> profiler report (M-x profiler-start ... M-x profiler-report).
> Then, you could debug-on-entry using the problematic part according to
> the profiler report.
>
> A blind guess - maybe you are modifying match data somewhere in your
> code. This might cause infinite loop in
>
> > (while (org-activate-links (point-max)) (goto-char (match-end 0)))
>
> Best,
> Ihor
>
> "numbch...@gmail.com"  writes:
>
> > Thanks for replying, Ihor. I will look into this regexp.
> >
> > Here is the backtrace of "toggle-debug-on-quit" when I refresh org-agenda
> > but has long time suspend.
> >
> > ```
> > Debugger entered--Lisp error: (quit)
> >
> >
> re-search-forward("\\(\\[\\[\\(\\(?:[^][\\]\\|\\(?:\\)*[][]\\|+[^][]\\)+..."
> > 17651 t)
> >   (while (re-search-forward org-link-any-re limit t) (let* ((start
> > (match-beginning 0)) (end (match-end 0)) (visible-start (or
> > (match-beginning 3) (match-beginning 2))) (visible-end (or (match-end 3)
> > (match-end 2))) (style (cond ((eq 60 (char-after start)) 'angle) ((eq 91
> > (char-after ...)) 'bracket) (t 'plain (if (and (memq style
> > org-highlight-links) (not (string-match-p org-element-paragraph-separate
> > (match-string 0))) (not (and (eq style 'plain) (let (...) (if ... ...
> > ...) (progn (let* ((link-object (save-excursion ... ...)) (link
> > (org-element-property :raw-link link-object)) (type (org-element-property
> > :type link-object)) (path (org-element-property :path link-object))
> > (properties (list ... ... ... ... ... ... ... ... ... ... ... t)))
> > (org-remove-flyspell-overlays-in start end) (org-rear-nonsticky-at end)
> (if
> > (not (eq ... style)) (add-text-properties start end properties)
> > (remove-text-properties start end '...) (let (...) (add-text-properties
> > start visible-start hidden) (add-text-properties visible-start
> visible-end
> > properties) (add-text-properties visible-end end hidden)
> > (org-rear-nonsticky-at visible-start) (org-rear-nonsticky-at
> visible-end)))
> > (let ((f ...)) (if (functionp f) (progn ...))) (throw :exit t))
> >   (catch :exit (while (re-search-forward org-link-any-re limit t) (let*
> > ((start (match-beginning 0)) (end (match-end 0)) (visible-start (or
> > (match-beginning 3) (match-beginning 2))) (visible-end (or (match-end 3)
> > (match-end 2))) (style (cond ((eq 60 ...) 'angle) ((eq 91 ...) 'bracket)
> (t
> > 'plain (if (and (memq style org-highlight-links) (not (string-match-p
> > org-element-paragraph-separate (match-string 0))) (not (and (eq style
> ...)
> > (let ... ... (progn (let* ((link-object ...) (link ...) (type ...)
> > (path ...) (properties ...)) (org-remove-flyspell-overlays-in start end)
> > (org-rear-nonsticky-at end) (if (not ...) (add-text-properties start end
> > properties) (remove-text-properties start end ...) (let ... ... ... ...
> ...
> > ...)) (let (...) (if ... ...)) (throw :exit t)) nil)
> >   org-activate-links(17651)
> >   (while (org-activate-links (point-max)) (goto-char (match-end 0)))
> >   (save-excursion (while (org-activate-links (point-max)) (goto-char
> > (match-end 0
> >   (save-excursion (goto-char (point-min)) (save-excursion (while
> > (org-activate-links (point-max)) (goto-char (match-end 0 (if (eq
> > org-agenda-remove-tags t) nil (org-agenda-align-tags)) (if
> > org-agenda-with-colors nil (remove-text-properties (point-min)
> (point-max)
> > '(face nil))) (if (and (boundp 'org-overriding-columns-format)
> > org-overriding-columns-format) (progn (set (make-local-variable
> > 'org-local-columns-format) org-overriding-columns-format))) (if
> > org-agenda-view-columns-initially (progn (org-agenda-columns))) (if
> > org-agen

Re: How to detect current in logbook drawer?

2020-08-15 Thread numbch...@gmail.com
I tried use debug-on-entry on:
  + org-agenda-list(nil)
- org-agenda-mode()
  + org-agenda-set-mode-name()
- org-update-dblock
  + org-dblock-write:clocktable

But got no lucky, Then I followed your another suggestion, use profiler:

I got a very big message log, (not suitable for paste in email, so I paste
it on Gist)

- CPU profiler report: https://www.pastery.net/gststf/
- Memory profiler report: https://www.pastery.net/gststf+qzyxaf/#qzyxaf

The very deepest call stacks seems the output format is not long enough, so
can't display.

Your suggestion is very useful, I can see what function is invoked many
times. But still can't understand what's the cause.

[stardiviner] GPG key ID: 47C32433
IRC(freeenode): stardiviner Twitter:  @numbchild
Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
Blog: http://stardiviner.github.io/


On Sat, Aug 15, 2020 at 2:02 PM Ihor Radchenko  wrote:

> >Here is the backtrace of "toggle-debug-on-quit" when I refresh org-agenda
> >but has long time suspend.
>
> That looks unreadable for me. Also, debug on quit may not show the
> problematic part depending on your luck.
>
> It would be easier to understand your problem if you provided the
> profiler report (M-x profiler-start ... M-x profiler-report).
> Then, you could debug-on-entry using the problematic part according to
> the profiler report.
>
> A blind guess - maybe you are modifying match data somewhere in your
> code. This might cause infinite loop in
>
> > (while (org-activate-links (point-max)) (goto-char (match-end 0)))
>
> Best,
> Ihor
>
> "numbch...@gmail.com"  writes:
>
> > Thanks for replying, Ihor. I will look into this regexp.
> >
> > Here is the backtrace of "toggle-debug-on-quit" when I refresh org-agenda
> > but has long time suspend.
> >
> > ```
> > Debugger entered--Lisp error: (quit)
> >
> >
> re-search-forward("\\(\\[\\[\\(\\(?:[^][\\]\\|\\(?:\\)*[][]\\|+[^][]\\)+..."
> > 17651 t)
> >   (while (re-search-forward org-link-any-re limit t) (let* ((start
> > (match-beginning 0)) (end (match-end 0)) (visible-start (or
> > (match-beginning 3) (match-beginning 2))) (visible-end (or (match-end 3)
> > (match-end 2))) (style (cond ((eq 60 (char-after start)) 'angle) ((eq 91
> > (char-after ...)) 'bracket) (t 'plain (if (and (memq style
> > org-highlight-links) (not (string-match-p org-element-paragraph-separate
> > (match-string 0))) (not (and (eq style 'plain) (let (...) (if ... ...
> > ...) (progn (let* ((link-object (save-excursion ... ...)) (link
> > (org-element-property :raw-link link-object)) (type (org-element-property
> > :type link-object)) (path (org-element-property :path link-object))
> > (properties (list ... ... ... ... ... ... ... ... ... ... ... t)))
> > (org-remove-flyspell-overlays-in start end) (org-rear-nonsticky-at end)
> (if
> > (not (eq ... style)) (add-text-properties start end properties)
> > (remove-text-properties start end '...) (let (...) (add-text-properties
> > start visible-start hidden) (add-text-properties visible-start
> visible-end
> > properties) (add-text-properties visible-end end hidden)
> > (org-rear-nonsticky-at visible-start) (org-rear-nonsticky-at
> visible-end)))
> > (let ((f ...)) (if (functionp f) (progn ...))) (throw :exit t))
> >   (catch :exit (while (re-search-forward org-link-any-re limit t) (let*
> > ((start (match-beginning 0)) (end (match-end 0)) (visible-start (or
> > (match-beginning 3) (match-beginning 2))) (visible-end (or (match-end 3)
> > (match-end 2))) (style (cond ((eq 60 ...) 'angle) ((eq 91 ...) 'bracket)
> (t
> > 'plain (if (and (memq style org-highlight-links) (not (string-match-p
> > org-element-paragraph-separate (match-string 0))) (not (and (eq style
> ...)
> > (let ... ... (progn (let* ((link-object ...) (link ...) (type ...)
> > (path ...) (properties ...)) (org-remove-flyspell-overlays-in start end)
> > (org-rear-nonsticky-at end) (if (not ...) (add-text-properties start end
> > properties) (remove-text-properties start end ...) (let ... ... ... ...
> ...
> > ...)) (let (...) (if ... ...)) (throw :exit t)) nil)
> >   org-activate-links(17651)
> >   (while (org-activate-links (point-max)) (goto-char (match-end 0)))
> >   (save-excursion (while (org-activate-links (point-max)) (goto-char
> > (match-end 0
> >   (save-excursion (goto-char (point-min)) (save-excursion (while
> > (org-activate-links (point-max)) (goto-char (match-end 0 (if (eq
> > org-agenda-remove-tags t) nil (org-agenda-align-tags)) (if
> > org-agenda-with-colors nil (remove-text-properties (point-min)
> (point-max)
> > '(face nil))) (if (and (boundp 'org-overriding-columns-format)
> > org-overriding-columns-format) (progn (set (make-local-variable
> > 'org-local-columns-format) org-overriding-columns-format))) (if
> > org-agenda-view-columns-initially (progn (org-agenda-columns))) (if
> > org-agenda-fontify-priorities (progn (org-agenda-fontify-prioriti

Re: How to detect current in logbook drawer?

2020-08-15 Thread numbch...@gmail.com
Thanks for replying, Ihor. I will look into this regexp.

Here is the backtrace of "toggle-debug-on-quit" when I refresh org-agenda
but has long time suspend.

```
Debugger entered--Lisp error: (quit)

re-search-forward("\\(\\[\\[\\(\\(?:[^][\\]\\|\\(?:\\)*[][]\\|+[^][]\\)+..."
17651 t)
  (while (re-search-forward org-link-any-re limit t) (let* ((start
(match-beginning 0)) (end (match-end 0)) (visible-start (or
(match-beginning 3) (match-beginning 2))) (visible-end (or (match-end 3)
(match-end 2))) (style (cond ((eq 60 (char-after start)) 'angle) ((eq 91
(char-after ...)) 'bracket) (t 'plain (if (and (memq style
org-highlight-links) (not (string-match-p org-element-paragraph-separate
(match-string 0))) (not (and (eq style 'plain) (let (...) (if ... ...
...) (progn (let* ((link-object (save-excursion ... ...)) (link
(org-element-property :raw-link link-object)) (type (org-element-property
:type link-object)) (path (org-element-property :path link-object))
(properties (list ... ... ... ... ... ... ... ... ... ... ... t)))
(org-remove-flyspell-overlays-in start end) (org-rear-nonsticky-at end) (if
(not (eq ... style)) (add-text-properties start end properties)
(remove-text-properties start end '...) (let (...) (add-text-properties
start visible-start hidden) (add-text-properties visible-start visible-end
properties) (add-text-properties visible-end end hidden)
(org-rear-nonsticky-at visible-start) (org-rear-nonsticky-at visible-end)))
(let ((f ...)) (if (functionp f) (progn ...))) (throw :exit t))
  (catch :exit (while (re-search-forward org-link-any-re limit t) (let*
((start (match-beginning 0)) (end (match-end 0)) (visible-start (or
(match-beginning 3) (match-beginning 2))) (visible-end (or (match-end 3)
(match-end 2))) (style (cond ((eq 60 ...) 'angle) ((eq 91 ...) 'bracket) (t
'plain (if (and (memq style org-highlight-links) (not (string-match-p
org-element-paragraph-separate (match-string 0))) (not (and (eq style ...)
(let ... ... (progn (let* ((link-object ...) (link ...) (type ...)
(path ...) (properties ...)) (org-remove-flyspell-overlays-in start end)
(org-rear-nonsticky-at end) (if (not ...) (add-text-properties start end
properties) (remove-text-properties start end ...) (let ... ... ... ... ...
...)) (let (...) (if ... ...)) (throw :exit t)) nil)
  org-activate-links(17651)
  (while (org-activate-links (point-max)) (goto-char (match-end 0)))
  (save-excursion (while (org-activate-links (point-max)) (goto-char
(match-end 0
  (save-excursion (goto-char (point-min)) (save-excursion (while
(org-activate-links (point-max)) (goto-char (match-end 0 (if (eq
org-agenda-remove-tags t) nil (org-agenda-align-tags)) (if
org-agenda-with-colors nil (remove-text-properties (point-min) (point-max)
'(face nil))) (if (and (boundp 'org-overriding-columns-format)
org-overriding-columns-format) (progn (set (make-local-variable
'org-local-columns-format) org-overriding-columns-format))) (if
org-agenda-view-columns-initially (progn (org-agenda-columns))) (if
org-agenda-fontify-priorities (progn (org-agenda-fontify-priorities))) (if
(and org-agenda-dim-blocked-tasks org-blocker-hook) (progn
(org-agenda-dim-blocked-tasks))) (org-agenda-mark-clocking-task) (if
org-agenda-entry-text-mode (progn (org-agenda-entry-text-hide)
(org-agenda-entry-text-show))) (if (and (featurep 'org-habit)
(save-excursion (next-single-property-change (point-min) 'org-habit-p)))
(progn (org-habit-insert-consistency-graphs))) (setq org-agenda-type
(org-get-at-bol 'org-agenda-type)) (if (or (eq
org-agenda-show-inherited-tags 'always) (and (listp
org-agenda-show-inherited-tags) (memq org-agenda-type
org-agenda-show-inherited-tags)) (and (eq org-agenda-show-inherited-tags t)
(or (eq org-agenda-use-tag-inheritance t) (and (listp
org-agenda-use-tag-inheritance) (not (memq org-agenda-type
org-agenda-use-tag-inheritance)) nil (let (mrk) (save-excursion
(goto-char (point-min)) (while (equal (forward-line) 0) (if (setq mrk
(get-text-property ... ...)) (progn (put-text-property ... ... ...
...))) (setq org-agenda-represented-tags nil
org-agenda-represented-categories nil) (if org-agenda-top-headline-filter
(progn (org-agenda-filter-top-headline-apply
org-agenda-top-headline-filter))) (if org-agenda-tag-filter (progn
(org-agenda-filter-apply org-agenda-tag-filter 'tag t))) (if (get
'org-agenda-tag-filter :preset-filter) (progn (org-agenda-filter-apply (get
'org-agenda-tag-filter :preset-filter) 'tag t))) (if
org-agenda-category-filter (progn (org-agenda-filter-apply
org-agenda-category-filter 'category))) (if (get
'org-agenda-category-filter :preset-filter) (progn (org-agenda-filter-apply
(get 'org-agenda-category-filter :preset-filter) 'category))) (if
org-agenda-regexp-filter (progn (org-agenda-filter-apply
org-agenda-regexp-filter 'regexp))) (if (get 'org-agenda-regexp-filter
:preset-filter) (progn (org-agenda-filter-apply (get
'org-agenda-regexp-filter :preset-filter) 'regexp))) (if
org-agenda-effort-

Re: How to detect current in logbook drawer?

2020-08-15 Thread Ihor Radchenko
I think you may do something like the following:
1. search backward for drawer-re, but limit search to the beginning of
headline
2. it should not be :END:
2. search next drawer-re from the point of previous search, but limit
search to next headline
3. make sure the drawer line at point is :END:
4. check if point is within the boundaries

Hope it helps.

Best,
Ihor


"numbch...@gmail.com"  writes:

> I tried this helper function.
>
> ```elisp
> (defun org-link-beautify--in-logbook-drawer-p (position)
>   "Detect whether point is in Org logbook drawer using
> `org-logbook-drawer-re'."
>   (and (> (point)
>   (save-excursion
> (re-search-backward
>  (rx (seq bol (0+ (any "\t ")) ":LOGBOOK:" (0+ (any "\t "))
> "\n")
>(< (point)
>   (save-excursion
> (re-search-forward
>  (rx (seq bol (0+ (any "\t ")) ":END:" (0+ (any "\t "))
> eol)))
> ```
> But it's logic is wrong. I becomes global buffer scope. Is there any better
> correct solution?
>
>
> [stardiviner] GPG key ID: 47C32433
> IRC(freeenode): stardiviner Twitter:  @numbchild
> Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
> Blog: http://stardiviner.github.io/
>
>
> On Fri, Aug 14, 2020 at 1:15 PM Ihor Radchenko  wrote:
>
>> > I want to get around this problem. So need to know how to detect
>> currently
>> > in logbook drawer or something else which used to record clocking note,
>> > `org-add-note`, etc.
>>
>> You may try to use `org-logbook-drawer-re'.
>>
>> > When I toggle org-log-mode and related options in org-agenda buffer. I
>> > found my org-link-beautify will caused long time suspend and no stop.
>> After
>> > debug, I found org-link-beautify text-property caused this problem.
>>
>> Could you provide more details how your text property is causing the
>> problem in org-agenda? Which function in agenda is slow?
>>
>> Best,
>> Ihor
>>
>>
>> "numbch...@gmail.com"  writes:
>>
>> > I have a org-mode extension:
>> >
>> https://github.com/stardiviner/org-link-beautify/blob/master/org-link-beautify.el#L71
>> >
>> > It will beautify links with text-properties.
>> >
>> > When I toggle org-log-mode and related options in org-agenda buffer. I
>> > found my org-link-beautify will caused long time suspend and no stop.
>> After
>> > debug, I found org-link-beautify text-property caused this problem.
>> >
>> > I want to get around this problem. So need to know how to detect
>> currently
>> > in logbook drawer or something else which used to record clocking note,
>> > `org-add-note`, etc.
>> >
>> > Or maybe org-agenda upstream can do something to work around this
>> > text-properties issue?
>> >
>> > [stardiviner] GPG key ID: 47C32433
>> > IRC(freeenode): stardiviner Twitter:  @numbchild
>> > Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
>> > Blog: http://stardiviner.github.io/
>>



Re: How to detect current in logbook drawer?

2020-08-15 Thread Ihor Radchenko
>Here is the backtrace of "toggle-debug-on-quit" when I refresh org-agenda
>but has long time suspend.

That looks unreadable for me. Also, debug on quit may not show the
problematic part depending on your luck.

It would be easier to understand your problem if you provided the
profiler report (M-x profiler-start ... M-x profiler-report).
Then, you could debug-on-entry using the problematic part according to
the profiler report.

A blind guess - maybe you are modifying match data somewhere in your
code. This might cause infinite loop in

> (while (org-activate-links (point-max)) (goto-char (match-end 0)))

Best,
Ihor

"numbch...@gmail.com"  writes:

> Thanks for replying, Ihor. I will look into this regexp.
>
> Here is the backtrace of "toggle-debug-on-quit" when I refresh org-agenda
> but has long time suspend.
>
> ```
> Debugger entered--Lisp error: (quit)
>
> re-search-forward("\\(\\[\\[\\(\\(?:[^][\\]\\|\\(?:\\)*[][]\\|+[^][]\\)+..."
> 17651 t)
>   (while (re-search-forward org-link-any-re limit t) (let* ((start
> (match-beginning 0)) (end (match-end 0)) (visible-start (or
> (match-beginning 3) (match-beginning 2))) (visible-end (or (match-end 3)
> (match-end 2))) (style (cond ((eq 60 (char-after start)) 'angle) ((eq 91
> (char-after ...)) 'bracket) (t 'plain (if (and (memq style
> org-highlight-links) (not (string-match-p org-element-paragraph-separate
> (match-string 0))) (not (and (eq style 'plain) (let (...) (if ... ...
> ...) (progn (let* ((link-object (save-excursion ... ...)) (link
> (org-element-property :raw-link link-object)) (type (org-element-property
> :type link-object)) (path (org-element-property :path link-object))
> (properties (list ... ... ... ... ... ... ... ... ... ... ... t)))
> (org-remove-flyspell-overlays-in start end) (org-rear-nonsticky-at end) (if
> (not (eq ... style)) (add-text-properties start end properties)
> (remove-text-properties start end '...) (let (...) (add-text-properties
> start visible-start hidden) (add-text-properties visible-start visible-end
> properties) (add-text-properties visible-end end hidden)
> (org-rear-nonsticky-at visible-start) (org-rear-nonsticky-at visible-end)))
> (let ((f ...)) (if (functionp f) (progn ...))) (throw :exit t))
>   (catch :exit (while (re-search-forward org-link-any-re limit t) (let*
> ((start (match-beginning 0)) (end (match-end 0)) (visible-start (or
> (match-beginning 3) (match-beginning 2))) (visible-end (or (match-end 3)
> (match-end 2))) (style (cond ((eq 60 ...) 'angle) ((eq 91 ...) 'bracket) (t
> 'plain (if (and (memq style org-highlight-links) (not (string-match-p
> org-element-paragraph-separate (match-string 0))) (not (and (eq style ...)
> (let ... ... (progn (let* ((link-object ...) (link ...) (type ...)
> (path ...) (properties ...)) (org-remove-flyspell-overlays-in start end)
> (org-rear-nonsticky-at end) (if (not ...) (add-text-properties start end
> properties) (remove-text-properties start end ...) (let ... ... ... ... ...
> ...)) (let (...) (if ... ...)) (throw :exit t)) nil)
>   org-activate-links(17651)
>   (while (org-activate-links (point-max)) (goto-char (match-end 0)))
>   (save-excursion (while (org-activate-links (point-max)) (goto-char
> (match-end 0
>   (save-excursion (goto-char (point-min)) (save-excursion (while
> (org-activate-links (point-max)) (goto-char (match-end 0 (if (eq
> org-agenda-remove-tags t) nil (org-agenda-align-tags)) (if
> org-agenda-with-colors nil (remove-text-properties (point-min) (point-max)
> '(face nil))) (if (and (boundp 'org-overriding-columns-format)
> org-overriding-columns-format) (progn (set (make-local-variable
> 'org-local-columns-format) org-overriding-columns-format))) (if
> org-agenda-view-columns-initially (progn (org-agenda-columns))) (if
> org-agenda-fontify-priorities (progn (org-agenda-fontify-priorities))) (if
> (and org-agenda-dim-blocked-tasks org-blocker-hook) (progn
> (org-agenda-dim-blocked-tasks))) (org-agenda-mark-clocking-task) (if
> org-agenda-entry-text-mode (progn (org-agenda-entry-text-hide)
> (org-agenda-entry-text-show))) (if (and (featurep 'org-habit)
> (save-excursion (next-single-property-change (point-min) 'org-habit-p)))
> (progn (org-habit-insert-consistency-graphs))) (setq org-agenda-type
> (org-get-at-bol 'org-agenda-type)) (if (or (eq
> org-agenda-show-inherited-tags 'always) (and (listp
> org-agenda-show-inherited-tags) (memq org-agenda-type
> org-agenda-show-inherited-tags)) (and (eq org-agenda-show-inherited-tags t)
> (or (eq org-agenda-use-tag-inheritance t) (and (listp
> org-agenda-use-tag-inheritance) (not (memq org-agenda-type
> org-agenda-use-tag-inheritance)) nil (let (mrk) (save-excursion
> (goto-char (point-min)) (while (equal (forward-line) 0) (if (setq mrk
> (get-text-property ... ...)) (progn (put-text-property ... ... ...
> ...))) (setq org-agenda-represented-tags nil
> org-agenda-represented-categories nil) (if org-agenda-top-headline-filter
> (progn (org-agenda

Re: How to detect current in logbook drawer?

2020-08-15 Thread numbch...@gmail.com
I tried this helper function.

```elisp
(defun org-link-beautify--in-logbook-drawer-p (position)
  "Detect whether point is in Org logbook drawer using
`org-logbook-drawer-re'."
  (and (> (point)
  (save-excursion
(re-search-backward
 (rx (seq bol (0+ (any "\t ")) ":LOGBOOK:" (0+ (any "\t "))
"\n")
   (< (point)
  (save-excursion
(re-search-forward
 (rx (seq bol (0+ (any "\t ")) ":END:" (0+ (any "\t "))
eol)))
```
But it's logic is wrong. I becomes global buffer scope. Is there any better
correct solution?


[stardiviner] GPG key ID: 47C32433
IRC(freeenode): stardiviner Twitter:  @numbchild
Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
Blog: http://stardiviner.github.io/


On Fri, Aug 14, 2020 at 1:15 PM Ihor Radchenko  wrote:

> > I want to get around this problem. So need to know how to detect
> currently
> > in logbook drawer or something else which used to record clocking note,
> > `org-add-note`, etc.
>
> You may try to use `org-logbook-drawer-re'.
>
> > When I toggle org-log-mode and related options in org-agenda buffer. I
> > found my org-link-beautify will caused long time suspend and no stop.
> After
> > debug, I found org-link-beautify text-property caused this problem.
>
> Could you provide more details how your text property is causing the
> problem in org-agenda? Which function in agenda is slow?
>
> Best,
> Ihor
>
>
> "numbch...@gmail.com"  writes:
>
> > I have a org-mode extension:
> >
> https://github.com/stardiviner/org-link-beautify/blob/master/org-link-beautify.el#L71
> >
> > It will beautify links with text-properties.
> >
> > When I toggle org-log-mode and related options in org-agenda buffer. I
> > found my org-link-beautify will caused long time suspend and no stop.
> After
> > debug, I found org-link-beautify text-property caused this problem.
> >
> > I want to get around this problem. So need to know how to detect
> currently
> > in logbook drawer or something else which used to record clocking note,
> > `org-add-note`, etc.
> >
> > Or maybe org-agenda upstream can do something to work around this
> > text-properties issue?
> >
> > [stardiviner] GPG key ID: 47C32433
> > IRC(freeenode): stardiviner Twitter:  @numbchild
> > Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
> > Blog: http://stardiviner.github.io/
>


Re: How to detect current in logbook drawer?

2020-08-13 Thread Ihor Radchenko
> I want to get around this problem. So need to know how to detect currently
> in logbook drawer or something else which used to record clocking note,
> `org-add-note`, etc.

You may try to use `org-logbook-drawer-re'.

> When I toggle org-log-mode and related options in org-agenda buffer. I
> found my org-link-beautify will caused long time suspend and no stop. After
> debug, I found org-link-beautify text-property caused this problem.

Could you provide more details how your text property is causing the
problem in org-agenda? Which function in agenda is slow?

Best,
Ihor


"numbch...@gmail.com"  writes:

> I have a org-mode extension:
> https://github.com/stardiviner/org-link-beautify/blob/master/org-link-beautify.el#L71
>
> It will beautify links with text-properties.
>
> When I toggle org-log-mode and related options in org-agenda buffer. I
> found my org-link-beautify will caused long time suspend and no stop. After
> debug, I found org-link-beautify text-property caused this problem.
>
> I want to get around this problem. So need to know how to detect currently
> in logbook drawer or something else which used to record clocking note,
> `org-add-note`, etc.
>
> Or maybe org-agenda upstream can do something to work around this
> text-properties issue?
>
> [stardiviner] GPG key ID: 47C32433
> IRC(freeenode): stardiviner Twitter:  @numbchild
> Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
> Blog: http://stardiviner.github.io/