emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* buffer displays incorrectly after capture
@ 2022-04-01 19:46 Skip Collins
  2022-04-04 15:25 ` Skip Collins
  0 siblings, 1 reply; 7+ messages in thread
From: Skip Collins @ 2022-04-01 19:46 UTC (permalink / raw)
  To: emacs-org list

I think there is a bug in updating an org buffer window after capture
appends an entry. When the previously final entry, terminated with a
newline, is folded, the newly captured entry that is appended does not
show correctly in the buffer. Here is an example capture template:
("a" "Actions" entry
      (file "~/Documents/org/capture.org")
      "* TODO %^{action} :action:" :immediate-finish t)

There is a single existing entry in capture.org:
* TODO foo :action:
some text[newline]

I fold the entry so that it appears in the buffer like this:
* TODO foo :action:...

Then from any buffer I type 'C-c c' and choose 'a' from the capture
template dispatcher. I type 'bar<enter>'. I would expect a new
headline to be visible at the end of capture.org. Instead, nothing
changes in the buffer. When I expand foo, it looks like this
* TODO foo :action:
some text...

No amount of tabbing causes the bar entry to display. The ellipsis at
the end of 'some text...' only gets expanded when I <backtab> to cycle
global visibility, resulting in a correct display:
* TODO foo :action:
some text
* TODO bar :action:

Another manifestation of the problem shows up when using
auto-revert-mode. Starting with the single headline in a folded state
as above, when I execute the following command in a shell,
echo "* TODO bar :action:" >>capture.org
then the capture.org buffer looks like this:
* TODO foo :action:...* TODO bar :action:

TAB unfolding the first headline shows up like this:
* TODO foo :action:
some text...* TODO bar :action:

GNU Emacs 27.2 (build 1, aarch64-apple-darwin21.3.0, Carbon Version
165 AppKit 2113.3) of 2022-02-24
Org mode version 9.5.2 (release_9.5.2-423-g6d73cd)


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

* Re: buffer displays incorrectly after capture
  2022-04-01 19:46 buffer displays incorrectly after capture Skip Collins
@ 2022-04-04 15:25 ` Skip Collins
  2022-04-07 23:26   ` [BUG] " Skip Collins
  0 siblings, 1 reply; 7+ messages in thread
From: Skip Collins @ 2022-04-04 15:25 UTC (permalink / raw)
  To: emacs-org list

On Fri, Apr 1, 2022 at 3:46 PM Skip wrote:
> Another manifestation of the problem shows up when using
> auto-revert-mode. Starting with the single headline in a folded state
> as above, when I execute the following command in a shell,
> echo "* TODO bar :action:" >>capture.org
> then the capture.org buffer looks like this:
> * TODO foo :action:...* TODO bar :action:
>
> TAB unfolding the first headline shows up like this:
> * TODO foo :action:
> some text...* TODO bar :action:

I confirmed that the buffer display bug occurs with emacs -Q. Steps to
reproduce:
1. From a shell, open emacs with an empty file:
emacs -Q test.org

2. From emacs, enable auto-revert-mode:
M-x auto-revert-mode

3. From another shell, add text to the file:
echo "* foo\nsome text\n" >>test.org

4. From emacs, fold the headline:
S-TAB

5. From the shell, add more text to the file:
echo "* bar\n" >>test.org

6. Observe the incorrect display of the two headlines:
* foo...* bar

7. From emacs, fix the buffer display:
S-TAB

8. Observe the correct display of the two headlines:
* foo...
* bar

This bug seems to trigger when text is added indirectly to an org-mode
buffer, via both capture and auto-revert. I suspect it would show up
via refile as well.


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

* [BUG] buffer displays incorrectly after capture
  2022-04-04 15:25 ` Skip Collins
@ 2022-04-07 23:26   ` Skip Collins
  2022-04-26 22:52     ` [BUG] buffer folds incorrectly Skip Collins
  2022-04-27  8:49     ` [BUG] buffer displays incorrectly after capture Ihor Radchenko
  0 siblings, 2 replies; 7+ messages in thread
From: Skip Collins @ 2022-04-07 23:26 UTC (permalink / raw)
  To: emacs-org list

I think this is a real bug. Am I wrong? Seems like it should be easy to fix.

On Mon, Apr 4, 2022 at 11:25 AM Skip wrote:
> On Fri, Apr 1, 2022 at 3:46 PM Skip wrote:
> > Another manifestation of the problem shows up when using
> > auto-revert-mode. Starting with the single headline in a folded state
> > as above, when I execute the following command in a shell,
> > echo "* TODO bar :action:" >>capture.org
> > then the capture.org buffer looks like this:
> > * TODO foo :action:...* TODO bar :action:
> >
> > TAB unfolding the first headline shows up like this:
> > * TODO foo :action:
> > some text...* TODO bar :action:
>
> I confirmed that the buffer display bug occurs with emacs -Q. Steps to
> reproduce:
> 1. From a shell, open emacs with an empty file:
> emacs -Q test.org
>
> 2. From emacs, enable auto-revert-mode:
> M-x auto-revert-mode
>
> 3. From another shell, add text to the file:
> echo "* foo\nsome text\n" >>test.org
>
> 4. From emacs, fold the headline:
> S-TAB
>
> 5. From the shell, add more text to the file:
> echo "* bar\n" >>test.org
>
> 6. Observe the incorrect display of the two headlines:
> * foo...* bar
>
> 7. From emacs, fix the buffer display:
> S-TAB
>
> 8. Observe the correct display of the two headlines:
> * foo...
> * bar
>
> This bug seems to trigger when text is added indirectly to an org-mode
> buffer, via both capture and auto-revert. I suspect it would show up
> via refile as well.


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

* [BUG] buffer folds incorrectly
  2022-04-07 23:26   ` [BUG] " Skip Collins
@ 2022-04-26 22:52     ` Skip Collins
  2022-04-27  8:49     ` [BUG] buffer displays incorrectly after capture Ihor Radchenko
  1 sibling, 0 replies; 7+ messages in thread
From: Skip Collins @ 2022-04-26 22:52 UTC (permalink / raw)
  To: emacs-org list

I confirmed that an old emacs (25.1.50.1) running on Linux with an old
stock orgmode (8.2.10) does NOT exhibit the folding bug. The incorrect
behavior still happens on my up-to-date emacs/org (Org mode version
9.5.2 (release_9.5.2-25-gaf6f12 @
/opt/homebrew/Cellar/emacs-mac/emacs-28.1-mac-9.0/share/emacs/28.1/lisp/org/))

On Thu, Apr 7, 2022 at 7:26 PM Skip wrote:
>
> I think this is a real bug. Am I wrong? Seems like it should be easy to fix.
>
> On Mon, Apr 4, 2022 at 11:25 AM Skip wrote:
> > I confirmed that the buffer display bug occurs with emacs -Q. Steps to
> > reproduce:
> > 1. From a shell, open emacs with an empty file:
> > emacs -Q test.org
> >
> > 2. From emacs, enable auto-revert-mode:
> > M-x auto-revert-mode
> >
> > 3. From another shell, add text to the file:
> > echo "* foo\nsome text\n" >>test.org
> >
> > 4. From emacs, fold the headline:
> > S-TAB
> >
> > 5. From the shell, add more text to the file:
> > echo "* bar\n" >>test.org
> >
> > 6. Observe the incorrect display of the two headlines:
> > * foo...* bar
> >
> > 7. From emacs, fix the buffer display:
> > S-TAB
> >
> > 8. Observe the correct display of the two headlines:
> > * foo...
> > * bar
> >
> > This bug seems to trigger when text is added indirectly to an org-mode
> > buffer, via both capture and auto-revert. I suspect it would show up
> > via refile as well.


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

* Re: [BUG] buffer displays incorrectly after capture
  2022-04-07 23:26   ` [BUG] " Skip Collins
  2022-04-26 22:52     ` [BUG] buffer folds incorrectly Skip Collins
@ 2022-04-27  8:49     ` Ihor Radchenko
  2022-04-27 15:58       ` Skip Collins
  1 sibling, 1 reply; 7+ messages in thread
From: Ihor Radchenko @ 2022-04-27  8:49 UTC (permalink / raw)
  To: Skip Collins; +Cc: emacs-org list

Skip Collins <skip.collins@gmail.com> writes:

> I think this is a real bug. Am I wrong? Seems like it should be easy to fix.

Fixed in 2d6f26c05 on main. And no, it was not that easy to fix.
Captured headlines may or may not need to be unfolded.

Best,
Ihor


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

* Re: [BUG] buffer displays incorrectly after capture
  2022-04-27  8:49     ` [BUG] buffer displays incorrectly after capture Ihor Radchenko
@ 2022-04-27 15:58       ` Skip Collins
  2022-04-27 23:37         ` Ihor Radchenko
  0 siblings, 1 reply; 7+ messages in thread
From: Skip Collins @ 2022-04-27 15:58 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-org list

On Wed, Apr 27, 2022 at 4:48 AM Ihor Radchenko <yantar92@gmail.com> wrote:
> Fixed in 2d6f26c05 on main. And no, it was not that easy to fix.
> Captured headlines may or may not need to be unfolded.

Thanks. I confirm that behavior is correct for folded level 1
headlines. But the problem still exists at level 2 and deeper:
1. Open emacs with an empty file:
emacs test.org

2. From emacs, enable auto-revert-mode:
M-x auto-revert-mode

3. From a shell, add text to the file:
echo "* foo\nsome text\n** bar\nmore text\n" >>test.org

4. From emacs, cycle global visibility twice, so that the second level
headline is visible but folded:
S-TAB S-TAB

5. Observe the two folded headlines:
* foo...
** bar...

6. From the shell, add another level 2 headline at the end of the file:
echo "** baz\n" >>test.org

7. Observe that the new level 2 headline is not displayed as expected:
* foo...
** bar...

8. From emacs, move the cursor onto the "** bar" headline and cycle visibility:
TAB

9. Observe that the new level 2 headline still does not appear, but a
misplaced folding ellipsis does appear at the end:
* foo...
** bar
more text
...

10. Cycle global visibility twice:
S-TAB S-TAB

11. Observe the correct display of all headlines:
* foo...
** bar...
** baz


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

* Re: [BUG] buffer displays incorrectly after capture
  2022-04-27 15:58       ` Skip Collins
@ 2022-04-27 23:37         ` Ihor Radchenko
  0 siblings, 0 replies; 7+ messages in thread
From: Ihor Radchenko @ 2022-04-27 23:37 UTC (permalink / raw)
  To: Skip Collins; +Cc: emacs-org list

Skip Collins <skip.collins@gmail.com> writes:

> On Wed, Apr 27, 2022 at 4:48 AM Ihor Radchenko <yantar92@gmail.com> wrote:
>> Fixed in 2d6f26c05 on main. And no, it was not that easy to fix.
>> Captured headlines may or may not need to be unfolded.
>
> Thanks. I confirm that behavior is correct for folded level 1
> headlines. But the problem still exists at level 2 and deeper:
> ...
> 9. Observe that the new level 2 headline still does not appear, but a
> misplaced folding ellipsis does appear at the end:
> * foo...
> ** bar
> more text
> ...

This is not a bug. You will routinely see constructs like this when you
jump to a deeply nested headline in real Org files. Only level 1
headlines are always kept visible by convention (and some people even
argue that this convention should be dropped e.g. in sparse trees).

To deal with such situations, see org-reveal (possibly with prefix
arguments).

Best,
Ihor


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

end of thread, other threads:[~2022-04-27 23:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-01 19:46 buffer displays incorrectly after capture Skip Collins
2022-04-04 15:25 ` Skip Collins
2022-04-07 23:26   ` [BUG] " Skip Collins
2022-04-26 22:52     ` [BUG] buffer folds incorrectly Skip Collins
2022-04-27  8:49     ` [BUG] buffer displays incorrectly after capture Ihor Radchenko
2022-04-27 15:58       ` Skip Collins
2022-04-27 23:37         ` Ihor Radchenko

Code repositories for project(s) associated with this 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).