emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [bug] canonical context not work in 8.3
@ 2015-08-06 23:10 Samuel Wales
  2015-08-07  0:16 ` Nicolas Goaziou
  0 siblings, 1 reply; 11+ messages in thread
From: Samuel Wales @ 2015-08-06 23:10 UTC (permalink / raw)
  To: emacs-orgmode

(setq org-show-context-detail '((default . canonical))) not work

going from agenda appears to show the first child, and takes
5s or so.

my expectation is that canonical visibility shows no entry
and no children.  first child is non-canonical (i.e. cannot
be reproduced with arrows and tab).

reproduces with my -Q testcase on emacs-version "24.4.1" on
recent maint 8.3.

thanks.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [bug] canonical context not work in 8.3
  2015-08-06 23:10 [bug] canonical context not work in 8.3 Samuel Wales
@ 2015-08-07  0:16 ` Nicolas Goaziou
  2015-08-07  1:38   ` Samuel Wales
  0 siblings, 1 reply; 11+ messages in thread
From: Nicolas Goaziou @ 2015-08-07  0:16 UTC (permalink / raw)
  To: Samuel Wales; +Cc: emacs-orgmode

Hello,

Samuel Wales <samologist@gmail.com> writes:

> (setq org-show-context-detail '((default . canonical))) not work
>
> going from agenda appears to show the first child,

This should be fixed in maint. Thank you.

> and takes 5s or so.

Could you provide a profiling report for this?

> my expectation is that canonical visibility shows no entry
> and no children.  first child is non-canonical (i.e. cannot
> be reproduced with arrows and tab).

First child only is non-canonical. However, canonical is the state
obtained after hitting TAB on a headline. I think you want `minimal'
instead.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [bug] canonical context not work in 8.3
  2015-08-07  0:16 ` Nicolas Goaziou
@ 2015-08-07  1:38   ` Samuel Wales
  2015-08-07  8:45     ` Nicolas Goaziou
  0 siblings, 1 reply; 11+ messages in thread
From: Samuel Wales @ 2015-08-07  1:38 UTC (permalink / raw)
  To: Samuel Wales, emacs-orgmode

thank you for fixing.

canonical is always what i want, except for occur-tree.

i did profiler-start then went to org file a few times to average out
the results.  did i use the correct profiler?

 command-execute                                               60148  99%
 - call-interactively                                           60148  99%
  - org-agenda-switch-to                                        59299  98%
   - org-show-context                                           59299  98%
    - org-show-set-visibility                                   59299  98%
     - show-children                                            59170  97%
      - outline-end-of-subtree                                  35938  59%
         outline-next-heading                                    9399  15%
         org-outline-level                                       4047   6%
      - outline-map-region                                      23168  38%
       + #<compiled 0xfc19ab>                                    9558  15%
         outline-next-heading                                    7399  12%
     + org-up-heading-safe                                        117   0%
     + org-show-entry                                               4   0%
     + org-flag-heading                                             4   0%


On 8/6/15, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
> Hello,
>
> Samuel Wales <samologist@gmail.com> writes:
>
>> (setq org-show-context-detail '((default . canonical))) not work
>>
>> going from agenda appears to show the first child,
>
> This should be fixed in maint. Thank you.
>
>> and takes 5s or so.
>
> Could you provide a profiling report for this?
>
>> my expectation is that canonical visibility shows no entry
>> and no children.  first child is non-canonical (i.e. cannot
>> be reproduced with arrows and tab).
>
> First child only is non-canonical. However, canonical is the state
> obtained after hitting TAB on a headline. I think you want `minimal'
> instead.
>
>
> Regards,
>
> --
> Nicolas Goaziou
>


-- 
The Kafka Pandemic: http://thekafkapandemic.blogspot.com

Ramsay's disease DOES progress.  MANY people have died from it.  And
ANYBODY can get it.

Denmark: free Karina Hansen NOW.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [bug] canonical context not work in 8.3
  2015-08-07  1:38   ` Samuel Wales
@ 2015-08-07  8:45     ` Nicolas Goaziou
  2015-08-07 20:27       ` Samuel Wales
  0 siblings, 1 reply; 11+ messages in thread
From: Nicolas Goaziou @ 2015-08-07  8:45 UTC (permalink / raw)
  To: Samuel Wales; +Cc: emacs-orgmode

Samuel Wales <samologist@gmail.com> writes:

> thank you for fixing.
>
> canonical is always what i want, except for occur-tree.
>
> i did profiler-start then went to org file a few times to average out
> the results.  did i use the correct profiler?

You did.
>
>  command-execute                                               60148  99%
>  - call-interactively                                           60148  99%
>   - org-agenda-switch-to                                        59299  98%
>    - org-show-context                                           59299  98%
>     - org-show-set-visibility                                   59299  98%
>      - show-children                                            59170  97%
>       - outline-end-of-subtree                                  35938  59%
>          outline-next-heading                                    9399  15%
>          org-outline-level                                       4047   6%
>       - outline-map-region                                      23168  38%
>        + #<compiled 0xfc19ab>                                    9558  15%
>          outline-next-heading                                    7399  12%
>      + org-up-heading-safe                                        117   0%
>      + org-show-entry                                               4   0%
>      + org-flag-heading                                             4   0%

`show-children' is the culprit.

Could you evaluate the following function and time it again?

  (defun show-children (&optional level)
    (save-excursion
      (org-back-to-heading t)
      (let* ((current-level (funcall outline-level))
             (level (if level (+ (prefix-numeric-value level) current-level)
                      (save-excursion
                        (outline-next-heading)
                        (if (eobp) current-level (funcall outline-level))))))
        (org-map-region
         (lambda ()
           (when (<= (funcall outline-level) level)
             (outline-flag-region (if (bobp) (point) (1- (point)))
                                  (line-end-position)
                                  nil)))
         (point)
         (org-end-of-subtree t t)))))

Thank you.


Regards,

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [bug] canonical context not work in 8.3
  2015-08-07  8:45     ` Nicolas Goaziou
@ 2015-08-07 20:27       ` Samuel Wales
  2015-08-08  8:07         ` Nicolas Goaziou
  0 siblings, 1 reply; 11+ messages in thread
From: Samuel Wales @ 2015-08-07 20:27 UTC (permalink / raw)
  To: Samuel Wales, emacs-orgmode

thank you.

i compiled it and tried it.  it seems improved, to maybe 2.5s.

- command-execute                                               17977  99%
 - call-interactively                                           17977  99%
  - org-agenda-switch-to                                        16144  88%
   - org-show-context                                           16142  88%
    - org-show-set-visibility                                   16142  88%
     - show-children                                            16042  88%
      - org-map-region                                          15617  86%
       - #<compiled 0x1220ff9>                                   6905  38%
          org-outline-level                                      1780   9%
        - outline-flag-region                                      12   0%
           remove-overlays                                          4   0%
         outline-next-heading                                    4381  24%
        org-end-of-subtree                                        401   2%
       org-up-heading-safe                                         72   0%
     - org-show-entry                                              16   0%
      + byte-code                                                  16   0%
     + org-flag-heading                                             4   0%
     org-mark-ring-push                                             2   0%
  - #<compiled 0xc259e3>                                         1189   6%
   - org-agenda                                                  1189   6%
    - byte-code                                                  1189   6%
     - org-let                                                   1189   6%
      - eval                                                     1189   6%
       - let                                                     1189   6%
        - org-agenda-list                                        1189   6%
         - byte-code                                             1185   6%
          - org-agenda-prepare                                    625   3%
           - org-agenda-prepare-buffers                           618   3%
            - byte-code                                           618   3%
             + org-refresh-category-properties                    262   1%
             + org-refresh-stats-properties                       184   1%
             + org-set-regexps-and-options                         40   0%
             + org-refresh-effort-properties                       36   0%
               org-refresh-properties                              32   0%
          + byte-code                                             440   2%
          + org-agenda-finalize-entries                           104   0%
          + org-agenda-finalize                                     8   0%
  - org-agenda-next-line                                          287   1%
   - org-agenda-do-context-action                                 273   1%
    - org-display-outline-path                                    273   1%
     + org-get-outline-path                                       241   1%
     + org-unlogged-message                                        24   0%
     + org-format-outline-path                                      8   0%
   + call-interactively                                            13   0%
  + ido-hacks-execute-extended-command                            189   1%


On 8/7/15, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
> Samuel Wales <samologist@gmail.com> writes:
>
>> thank you for fixing.
>>
>> canonical is always what i want, except for occur-tree.
>>
>> i did profiler-start then went to org file a few times to average out
>> the results.  did i use the correct profiler?
>
> You did.
>>
>>  command-execute                                               60148  99%
>>  - call-interactively                                           60148
>> 99%
>>   - org-agenda-switch-to                                        59299
>> 98%
>>    - org-show-context                                           59299
>> 98%
>>     - org-show-set-visibility                                   59299
>> 98%
>>      - show-children                                            59170
>> 97%
>>       - outline-end-of-subtree                                  35938
>> 59%
>>          outline-next-heading                                    9399
>> 15%
>>          org-outline-level                                       4047
>> 6%
>>       - outline-map-region                                      23168
>> 38%
>>        + #<compiled 0xfc19ab>                                    9558
>> 15%
>>          outline-next-heading                                    7399
>> 12%
>>      + org-up-heading-safe                                        117
>> 0%
>>      + org-show-entry                                               4
>> 0%
>>      + org-flag-heading                                             4
>> 0%
>
> `show-children' is the culprit.
>
> Could you evaluate the following function and time it again?
>
>   (defun show-children (&optional level)
>     (save-excursion
>       (org-back-to-heading t)
>       (let* ((current-level (funcall outline-level))
>              (level (if level (+ (prefix-numeric-value level)
> current-level)
>                       (save-excursion
>                         (outline-next-heading)
>                         (if (eobp) current-level (funcall
> outline-level))))))
>         (org-map-region
>          (lambda ()
>            (when (<= (funcall outline-level) level)
>              (outline-flag-region (if (bobp) (point) (1- (point)))
>                                   (line-end-position)
>                                   nil)))
>          (point)
>          (org-end-of-subtree t t)))))
>
> Thank you.
>
>
> Regards,
>


-- 
The Kafka Pandemic: http://thekafkapandemic.blogspot.com

Ramsay's disease DOES progress.  MANY people have died from it.  And
ANYBODY can get it.

Denmark: free Karina Hansen NOW.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [bug] canonical context not work in 8.3
  2015-08-07 20:27       ` Samuel Wales
@ 2015-08-08  8:07         ` Nicolas Goaziou
  2015-08-08  9:19           ` Nicolas Goaziou
  0 siblings, 1 reply; 11+ messages in thread
From: Nicolas Goaziou @ 2015-08-08  8:07 UTC (permalink / raw)
  To: Samuel Wales; +Cc: emacs-orgmode

Samuel Wales <samologist@gmail.com> writes:

> i compiled it and tried it.  it seems improved, to maybe 2.5s.

I think it is as good as it can get. You probably have an awful lot of
children to display.

Anyway, could you provide the same report using an un-compiled Org?
A report using ELP (elp-instrument-package and elp-report) would be nice
too, as it gives the number of times a function is called.

Regards,

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [bug] canonical context not work in 8.3
  2015-08-08  8:07         ` Nicolas Goaziou
@ 2015-08-08  9:19           ` Nicolas Goaziou
  2015-08-09 18:53             ` Samuel Wales
  0 siblings, 1 reply; 11+ messages in thread
From: Nicolas Goaziou @ 2015-08-08  9:19 UTC (permalink / raw)
  To: Samuel Wales; +Cc: emacs-orgmode

Correcting myself,

> I think it is as good as it can get. You probably have an awful lot of
> children to display.

This one may improve the situation:

  (defun show-children (&optional level)
    (save-excursion
      (org-back-to-heading t)
      (let* ((current-level (funcall outline-level))
             (level (if level (+ (prefix-numeric-value level) current-level)
                      (save-excursion
                        (outline-next-heading)
                        (if (eobp) current-level (funcall outline-level)))))
             (re (format "^\\*\\{%d,%d\\} +" current-level level))
             (end (save-excursion (org-end-of-subtree t t))))
        (while (re-search-forward re end t)
          (outline-flag-region (line-end-position 0) (line-end-position) nil)))))

Would you mind testing it?


Regards,

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [bug] canonical context not work in 8.3
  2015-08-08  9:19           ` Nicolas Goaziou
@ 2015-08-09 18:53             ` Samuel Wales
  2015-08-10 11:39               ` Nicolas Goaziou
  0 siblings, 1 reply; 11+ messages in thread
From: Samuel Wales @ 2015-08-09 18:53 UTC (permalink / raw)
  To: Samuel Wales, emacs-orgmode

thank you.  this version is significantly faster.  qualitatively
improved.

it has a possibly minor bug.

evalled as source:

- command-execute                                                8072  98%
 - call-interactively                                            8072  98%
  - org-agenda-switch-to                                         7595  92%
   - org-show-context                                            7595  92%
    - org-show-set-visibility                                    7595  92%
     - show-children                                             7039  86%
      - save-excursion                                           7015  85%
       - let*                                                    7015  85%
        - while                                                  4832  59%
         - outline-flag-region                                    692   8%
            remove-overlays                                        12   0%
        - save-excursion                                         2179  26%
           org-end-of-subtree                                    2179  26%
        - funcall                                                   4   0%
           org-outline-level                                        4   0%

however, if the next heading has fewer stars, it errors:

Debugger entered--Lisp error: (invalid-regexp "Invalid content of \\{\\}")
  re-search-forward("^\\*\\{27,13\\} +" 2473493 t)
  (while (re-search-forward re end t) (outline-flag-region
(line-end-position 0) (line-end-position) nil))
  (let* ((current-level (funcall outline-level)) (level (if level (+
(prefix-numeric-value level) current-level) (save-excursion
(outline-next-heading) (if (eobp) current-level (funcall
outline-level))))) (re (format "^\\*\\{%d,%d\\} +" current-level
level)) (end (save-excursion (org-end-of-subtree t t)))) (while
(re-search-forward re end t) (outline-flag-region (line-end-position
0) (line-end-position) nil)))
  (save-excursion (org-back-to-heading t) (let* ((current-level
(funcall outline-level)) (level (if level (+ (prefix-numeric-value
level) current-level) (save-excursion (outline-next-heading) (if
(eobp) current-level (funcall outline-level))))) (re (format
"^\\*\\{%d,%d\\} +" current-level level)) (end (save-excursion
(org-end-of-subtree t t)))) (while (re-search-forward re end t)
(outline-flag-region (line-end-position 0) (line-end-position) nil))))
  show-children()
  org-show-set-visibility(canonical)
  org-show-context(agenda)
  org-agenda-switch-to()
  call-interactively(org-agenda-switch-to nil nil)
  command-execute(org-agenda-switch-to)


   (defun show-children (&optional level)
    (save-excursion
      (org-back-to-heading t)
      (let* ((current-level (funcall outline-level))
             (level (if level (+ (prefix-numeric-value level) current-level)
                      (save-excursion
                        (outline-next-heading)
                        (if (eobp) current-level (funcall outline-level)))))
             (re (format "^\\*\\{%d,%d\\} +" current-level level))
             (end (save-excursion (org-end-of-subtree t t))))
        (while (re-search-forward re end t)
          (outline-flag-region (line-end-position 0)
(line-end-position) nil)))))


On 8/8/15, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
> This one may improve the situation:

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [bug] canonical context not work in 8.3
  2015-08-09 18:53             ` Samuel Wales
@ 2015-08-10 11:39               ` Nicolas Goaziou
  2015-08-10 18:31                 ` Samuel Wales
  0 siblings, 1 reply; 11+ messages in thread
From: Nicolas Goaziou @ 2015-08-10 11:39 UTC (permalink / raw)
  To: Samuel Wales; +Cc: emacs-orgmode

Samuel Wales <samologist@gmail.com> writes:

> thank you.  this version is significantly faster.  qualitatively
> improved.
>
> it has a possibly minor bug.

Yes, this was a draft anyway. 

I pushed the new function to code base. However, due to the nature of
the change, it landed in master. So it will be available in Org 8.4.

Thank you.

Regards,

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [bug] canonical context not work in 8.3
  2015-08-10 11:39               ` Nicolas Goaziou
@ 2015-08-10 18:31                 ` Samuel Wales
  2015-08-10 21:39                   ` Nicolas Goaziou
  0 siblings, 1 reply; 11+ messages in thread
From: Samuel Wales @ 2015-08-10 18:31 UTC (permalink / raw)
  To: Samuel Wales, emacs-orgmode

On 8/10/15, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
> I pushed the new function to code base. However, due to the nature of
> the change, it landed in master. So it will be available in Org 8.4.

thank you.  will it work in 8.3 (maint) if i load it after loading org?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [bug] canonical context not work in 8.3
  2015-08-10 18:31                 ` Samuel Wales
@ 2015-08-10 21:39                   ` Nicolas Goaziou
  0 siblings, 0 replies; 11+ messages in thread
From: Nicolas Goaziou @ 2015-08-10 21:39 UTC (permalink / raw)
  To: Samuel Wales; +Cc: emacs-orgmode

Samuel Wales <samologist@gmail.com> writes:

> On 8/10/15, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
>> I pushed the new function to code base. However, due to the nature of
>> the change, it landed in master. So it will be available in Org 8.4.
>
> thank you.  will it work in 8.3 (maint) if i load it after loading
> org?

If you don't plan to use "outline.el", you can override `show-children'
with the following:

--8<---------------cut here---------------start------------->8---
(defun show-children (&optional level)
  "Show all direct subheadings of this heading.
Prefix arg LEVEL is how many levels below the current level should be shown.
Default is enough to cause the following heading to appear."
  (save-excursion
    (org-back-to-heading t)
    (let* ((current-level (funcall outline-level))
           (max-level (org-get-valid-level
                       current-level (if level (prefix-numeric-value level) 1)))
           (end (save-excursion (org-end-of-subtree t t)))
           (regexp-fmt "^\\*\\{%d,%s\\}\\(?: \\|$\\)")
           (past-first-child nil)
	   ;; Make sure to skip inlinetasks.
           (re (format regexp-fmt
		       current-level
		       (cond
			((not (featurep 'org-inlinetask)) "")
			(org-odd-levels-only (- (* 2 org-inlinetask-min-level)
						3))
			(t (1- org-inlinetask-min-level))))))
      ;; Display parent heading.
      (outline-flag-region (line-end-position 0) (line-end-position) nil)
      (forward-line)
      ;; Display children.  First child may be deeper than expected
      ;; MAX-LEVEL.  Since we want to display it anyway, adjust
      ;; MAX-LEVEL accordingly.
      (while (re-search-forward re end t)
        (unless past-first-child
          (setq re (format regexp-fmt
			   current-level
			   (max (funcall outline-level) max-level)))
          (setq past-first-child t))
        (outline-flag-region (line-end-position 0) (line-end-position) nil)))))
--8<---------------cut here---------------end--------------->8---

However, the patch that landed in master implements `org-show-children'
instead.


Regards,

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-08-10 21:38 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-06 23:10 [bug] canonical context not work in 8.3 Samuel Wales
2015-08-07  0:16 ` Nicolas Goaziou
2015-08-07  1:38   ` Samuel Wales
2015-08-07  8:45     ` Nicolas Goaziou
2015-08-07 20:27       ` Samuel Wales
2015-08-08  8:07         ` Nicolas Goaziou
2015-08-08  9:19           ` Nicolas Goaziou
2015-08-09 18:53             ` Samuel Wales
2015-08-10 11:39               ` Nicolas Goaziou
2015-08-10 18:31                 ` Samuel Wales
2015-08-10 21:39                   ` 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).