all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* nondeterministic org-test-with-temp-text?
@ 2020-05-30 13:43 Kevin Liu
  2020-05-30 16:09 ` Nicolas Goaziou
  0 siblings, 1 reply; 9+ messages in thread
From: Kevin Liu @ 2020-05-30 13:43 UTC (permalink / raw)
  To: emacs-orgmode

I’m trying to add a test (which should fail at the moment, representing
an org-mode bug), but it seems like each ‘should’ form is actually
nondeterministic.  The first form returns nil on the first eval and t on
subsequent evals, its behavior resetting upon any command, and the
second form does the inverse, returning t on the first eval and nil on
subsequent evals.

Is this behavior expected?

(ert-deftest test-org/org-next-visible-heading ()
  (should
   (org-test-with-temp-text "* A\n** B\n\n\n* C"
     (org-overview)
     (org-cycle)
     (org-cycle)
     (org-next-visible-heading 1)
     (and (bolp) (org-at-heading-p))))
  (should
   (org-test-with-temp-text "* A\n** B\n\n\n* C"
     (org-overview)
     (org-cycle)
     (org-cycle)
     (org-cycle)
     (org-next-visible-heading 1)
     (and (bolp) (org-at-heading-p)))))


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

* Re: nondeterministic org-test-with-temp-text?
  2020-05-30 13:43 nondeterministic org-test-with-temp-text? Kevin Liu
@ 2020-05-30 16:09 ` Nicolas Goaziou
  2020-05-31  1:52   ` Kevin Liu
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2020-05-30 16:09 UTC (permalink / raw)
  To: Kevin Liu; +Cc: emacs-orgmode

Hello,

Kevin Liu <kevin@nivekuil.com> writes:

> I’m trying to add a test (which should fail at the moment, representing
> an org-mode bug), but it seems like each ‘should’ form is actually
> nondeterministic.  The first form returns nil on the first eval and t on
> subsequent evals, its behavior resetting upon any command, and the
> second form does the inverse, returning t on the first eval and nil on
> subsequent evals.
>
> Is this behavior expected?
>
> (ert-deftest test-org/org-next-visible-heading ()
>   (should
>    (org-test-with-temp-text "* A\n** B\n\n\n* C"
>      (org-overview)
>      (org-cycle)
>      (org-cycle)
>      (org-next-visible-heading 1)
>      (and (bolp) (org-at-heading-p))))

You cannot call `org-cycle' consecutively without care, because it
checks `last-command' and `this-command'. You need to fake their values
before calling `org-cycle' again.

Regards,

-- 
Nicolas Goaziou


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

* Re: nondeterministic org-test-with-temp-text?
  2020-05-30 16:09 ` Nicolas Goaziou
@ 2020-05-31  1:52   ` Kevin Liu
  2020-05-31 11:09     ` Nicolas Goaziou
  0 siblings, 1 reply; 9+ messages in thread
From: Kevin Liu @ 2020-05-31  1:52 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

On 30 May 2020 09:09, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

> You cannot call `org-cycle' consecutively without care, because it
> checks `last-command' and `this-command'. You need to fake their values
> before calling `org-cycle' again.

Good to know, thanks.

Relatedly, would you be willing to take a look at the bug at hand with
(org-next-visible-headline)?  I think the recent rewrite has changed its
behavior in a way outlined by my test cases.  Specifically, not always
landing on a headline will break speed keys.


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

* Re: nondeterministic org-test-with-temp-text?
  2020-05-31  1:52   ` Kevin Liu
@ 2020-05-31 11:09     ` Nicolas Goaziou
  2020-06-03 16:27       ` Kevin Liu
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2020-05-31 11:09 UTC (permalink / raw)
  To: Kevin Liu; +Cc: emacs-orgmode

Hello,

Kevin Liu <kevin@nivekuil.com> writes:

> Relatedly, would you be willing to take a look at the bug at hand with
> (org-next-visible-headline)?

I just fixed it, IIUC. Thank you.

Regards,

-- 
Nicolas Goaziou


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

* Re: nondeterministic org-test-with-temp-text?
  2020-05-31 11:09     ` Nicolas Goaziou
@ 2020-06-03 16:27       ` Kevin Liu
  2020-06-03 16:31         ` Kevin Liu
  2020-06-03 22:26         ` Nicolas Goaziou
  0 siblings, 2 replies; 9+ messages in thread
From: Kevin Liu @ 2020-06-03 16:27 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

On 31 May 2020 04:09, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

> I just fixed it, IIUC. Thank you.

It works indeed.  However, I believe I have found another bug :)
Try these commands with the following org file; it appears to fail to land on a heading:

(org-id-goto "105dfe8b-8507-400c-862f-a25882448051")
(org-id-goto "4a3206fc-b2f1-47d6-9876-ea30c24ecbeb")
(org-cycle)
(org-next-visible-heading)
(org-next-previous-heading)

* A
** A1
:PROPERTIES:
:ID:       4a3206fc-b2f1-47d6-9876-ea30c24ecbeb
:END:
blah
** A2
:PROPERTIES:
:ID:       60dbdfd7-04a6-4ef0-86ce-a267c16fb1e9
:END:
blah
** A3
:PROPERTIES:
:ID:       105dfe8b-8507-400c-862f-a25882448051
:END:
   blah
* B


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

* Re: nondeterministic org-test-with-temp-text?
  2020-06-03 16:27       ` Kevin Liu
@ 2020-06-03 16:31         ` Kevin Liu
  2020-06-03 22:26         ` Nicolas Goaziou
  1 sibling, 0 replies; 9+ messages in thread
From: Kevin Liu @ 2020-06-03 16:31 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode


On  3 June 2020 09:27, Kevin Liu <kevin@nivekuil.com> wrote:

> (org-next-previous-heading)

Typo; this should be (org-previous-visible-heading)


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

* Re: nondeterministic org-test-with-temp-text?
  2020-06-03 16:27       ` Kevin Liu
  2020-06-03 16:31         ` Kevin Liu
@ 2020-06-03 22:26         ` Nicolas Goaziou
  2020-06-03 23:08           ` Kevin Liu
  1 sibling, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2020-06-03 22:26 UTC (permalink / raw)
  To: Kevin Liu; +Cc: emacs-orgmode

Hello,

Kevin Liu <kevin@nivekuil.com> writes:

> Try these commands with the following org file; it appears to fail to land on a heading:
>
> (org-id-goto "105dfe8b-8507-400c-862f-a25882448051")
> (org-id-goto "4a3206fc-b2f1-47d6-9876-ea30c24ecbeb")

You only need the last `org-id-goto' call right? Is the call to this
function meaningful, or can point be left at the beginning of "A1"
headline instead?

> (org-cycle)
> (org-next-visible-heading)
> (org-previous-visible-heading)
>
> * A
> ** A1
> :PROPERTIES:
> :ID:       4a3206fc-b2f1-47d6-9876-ea30c24ecbeb
> :END:
> blah
> ** A2
> :PROPERTIES:
> :ID:       60dbdfd7-04a6-4ef0-86ce-a267c16fb1e9
> :END:
> blah
> ** A3
> :PROPERTIES:
> :ID:       105dfe8b-8507-400c-862f-a25882448051
> :END:
>    blah
> * B

FWIW, I cannot reproduce the issue.

Regards,

-- 
Nicolas Goaziou


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

* Re: nondeterministic org-test-with-temp-text?
  2020-06-03 22:26         ` Nicolas Goaziou
@ 2020-06-03 23:08           ` Kevin Liu
  2020-06-04 14:10             ` Nicolas Goaziou
  0 siblings, 1 reply; 9+ messages in thread
From: Kevin Liu @ 2020-06-03 23:08 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode



On  3 June 2020 15:26, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

> You only need the last `org-id-goto' call right? Is the call to this
> function meaningful, or can point be left at the beginning of "A1"
> headline instead?

Yes, I should have mentioned that you need to start in overview view.
The idea is to selectively reveal only two subtrees, leaving the middle A2 hidden.


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

* Re: nondeterministic org-test-with-temp-text?
  2020-06-03 23:08           ` Kevin Liu
@ 2020-06-04 14:10             ` Nicolas Goaziou
  0 siblings, 0 replies; 9+ messages in thread
From: Nicolas Goaziou @ 2020-06-04 14:10 UTC (permalink / raw)
  To: Kevin Liu; +Cc: emacs-orgmode

Hello,

Kevin Liu <kevin@nivekuil.com> writes:

> Yes, I should have mentioned that you need to start in overview view.
> The idea is to selectively reveal only two subtrees, leaving the
> middle A2 hidden.

OK. I think I fixed it. Thank you.

Regards,

-- 
Nicolas Goaziou


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

end of thread, other threads:[~2020-06-04 14:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-30 13:43 nondeterministic org-test-with-temp-text? Kevin Liu
2020-05-30 16:09 ` Nicolas Goaziou
2020-05-31  1:52   ` Kevin Liu
2020-05-31 11:09     ` Nicolas Goaziou
2020-06-03 16:27       ` Kevin Liu
2020-06-03 16:31         ` Kevin Liu
2020-06-03 22:26         ` Nicolas Goaziou
2020-06-03 23:08           ` Kevin Liu
2020-06-04 14:10             ` Nicolas Goaziou

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.