emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-insert-item, indent causes a soft freeze or error message
@ 2020-07-06  8:51 Duianto -
  2020-07-06 10:08 ` Nicolas Goaziou
  0 siblings, 1 reply; 3+ messages in thread
From: Duianto - @ 2020-07-06  8:51 UTC (permalink / raw)
  To: emacs-orgmode

Hello

Depending on the indentation amount on the line following a list item,
when (org-insert-item) is evaluated.

Causes Emacs to soft freeze (can be canceled by pressing: C-g)
or an error message is shown: (args-out-of-range 0 1)


Reproduction Steps:

Copy the following lines:
1. a
   b
2. c

(the second line is indented by 3 spaces)

Open a new buffer: C-x b test.org RET
Switch to org mode: M-x org-mode RET
Paste the copied lines: C-y
Move the cursor to the end of the first line, after the: a
(if the cursor is before the a, then the list item is added on a new line above
probably as expected)
Evaluate the following command: S-M-; (org-insert-item) RET

Observed:
The only visible change is that the cursor moves to the beginning of
the "Eval:" prompt in the minibuffer.
The Emacs cpu usage spikes (an infinite loop?)
The soft freeze can be canceled by pressing: C-g
The buffer now shows:
1. a
1.
   b
2. c

The initial example above had three spaces before the: b
The same soft freeze is observed if more spaces are added before the: b
(I only tested it, up to five spaces, but I there might not be an upper limit)

Indented by one or two spaces:
If the initial second line is indented with one or two spaces, then
Emacs shows an error message instead of freezing.
A Backtrace buffer opens with the message:

Debugger entered--Lisp error: (args-out-of-range 0 1)
  replace-match("1. " nil nil nil 1)
  #f(compiled-function (struct old-struct item) #<bytecode
0x497071>)(((1 0 "1. " nil nil nil 6) (6 0 "2. " nil nil nil 13) (16 0
"1. " nil nil nil 20)) ((1 0 "1. " nil nil nil 6) (6 0 "1. " nil nil
nil 13) (16 0 "2. " nil nil nil 20)) 16)
  org-list-struct-apply-struct(((1 0 "1. " nil nil nil 6) (6 0 "2. "
nil nil nil 13) (16 0 "1. " nil nil nil 20)) ((1 0 "1. " nil nil nil
6) (6 0 "1. " nil nil nil 13) (16 0 "2. " nil nil nil 20)))
  org-list-write-struct(((1 0 "1. " nil nil nil 6) (6 0 "2. " nil nil
nil 13) (16 0 "1. " nil nil nil 20)) ((1) (6) (16)))
  org-insert-item()
  eval((org-insert-item) nil)
  eval-expression((org-insert-item) nil nil 127)
  funcall-interactively(eval-expression (org-insert-item) nil nil 127)
  call-interactively(eval-expression nil nil)
  command-execute(eval-expression)


No indentation:
If the indentation is removed from the second line:
1. a
b
2. c

Then it might be working as expected:
1. a
2.
b
2. c

a correctly numbered list item is inserted.

The fourth lines list number: 2. c
didn't change, but it might be expected since there was no indentation
before the: b
therefore it might be assumed that the list ended there.

At least Emacs didn't freeze or show any errors.


System info:
Org mode version 9.3.7 (9.3.7-4-gba6ca7-elpaplus @
c:/Users/username/.emacs.d/elpa/org-plus-contrib-20200622/)
GNU Emacs 26.3 (build 1, x86_64-w64-mingw32) of 2019-08-29
Windows 1903


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

* Re: org-insert-item, indent causes a soft freeze or error message
  2020-07-06  8:51 org-insert-item, indent causes a soft freeze or error message Duianto -
@ 2020-07-06 10:08 ` Nicolas Goaziou
  2020-07-06 11:50   ` Duianto -
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Goaziou @ 2020-07-06 10:08 UTC (permalink / raw)
  To: Duianto -; +Cc: emacs-orgmode

Hello,

Duianto - <otnaiud@gmail.com> writes:

> Reproduction Steps:
>
> Copy the following lines:
> 1. a
>    b
> 2. c
>

[...]

> Move the cursor to the end of the first line, after the: a

[...]

> Evaluate the following command: S-M-; (org-insert-item) RET

[...]

> A Backtrace buffer opens with the message:
>
> Debugger entered--Lisp error: (args-out-of-range 0 1)
>   replace-match("1. " nil nil nil 1)
>   #f(compiled-function (struct old-struct item) #<bytecode
> 0x497071>)(((1 0 "1. " nil nil nil 6) (6 0 "2. " nil nil nil 13) (16 0
> "1. " nil nil nil 20)) ((1 0 "1. " nil nil nil 6) (6 0 "1. " nil nil
> nil 13) (16 0 "2. " nil nil nil 20)) 16)
>   org-list-struct-apply-struct(((1 0 "1. " nil nil nil 6) (6 0 "2. "
> nil nil nil 13) (16 0 "1. " nil nil nil 20)) ((1 0 "1. " nil nil nil
> 6) (6 0 "1. " nil nil nil 13) (16 0 "2. " nil nil nil 20)))
>   org-list-write-struct(((1 0 "1. " nil nil nil 6) (6 0 "2. " nil nil
> nil 13) (16 0 "1. " nil nil nil 20)) ((1) (6) (16)))
>   org-insert-item()
>   eval((org-insert-item) nil)
>   eval-expression((org-insert-item) nil nil 127)
>   funcall-interactively(eval-expression (org-insert-item) nil nil 127)
>   call-interactively(eval-expression nil nil)
>   command-execute(eval-expression)

Fixed. Thank you.
>
> No indentation:
> If the indentation is removed from the second line:
> 1. a
> b
> 2. c
>
> Then it might be working as expected:
> 1. a
> 2.
> b
> 2. c
>
> a correctly numbered list item is inserted.
>
> The fourth lines list number: 2. c
> didn't change, but it might be expected since there was no indentation
> before the: b
> therefore it might be assumed that the list ended there.

This is expected. You need to fix the second list manually, with C-c C-c.

Regards,
-- 
Nicolas Goaziou


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

* Re: org-insert-item, indent causes a soft freeze or error message
  2020-07-06 10:08 ` Nicolas Goaziou
@ 2020-07-06 11:50   ` Duianto -
  0 siblings, 0 replies; 3+ messages in thread
From: Duianto - @ 2020-07-06 11:50 UTC (permalink / raw)
  To: Duianto -, emacs-orgmode

I applied the fix manually and there are no more freezes or error messages.

Thank you.

On Mon, Jul 6, 2020 at 12:08 PM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
>
> Hello,
>
> Duianto - <otnaiud@gmail.com> writes:
>
> > Reproduction Steps:
> >
> > Copy the following lines:
> > 1. a
> >    b
> > 2. c
> >
>
> [...]
>
> > Move the cursor to the end of the first line, after the: a
>
> [...]
>
> > Evaluate the following command: S-M-; (org-insert-item) RET
>
> [...]
>
> > A Backtrace buffer opens with the message:
> >
> > Debugger entered--Lisp error: (args-out-of-range 0 1)
> >   replace-match("1. " nil nil nil 1)
> >   #f(compiled-function (struct old-struct item) #<bytecode
> > 0x497071>)(((1 0 "1. " nil nil nil 6) (6 0 "2. " nil nil nil 13) (16 0
> > "1. " nil nil nil 20)) ((1 0 "1. " nil nil nil 6) (6 0 "1. " nil nil
> > nil 13) (16 0 "2. " nil nil nil 20)) 16)
> >   org-list-struct-apply-struct(((1 0 "1. " nil nil nil 6) (6 0 "2. "
> > nil nil nil 13) (16 0 "1. " nil nil nil 20)) ((1 0 "1. " nil nil nil
> > 6) (6 0 "1. " nil nil nil 13) (16 0 "2. " nil nil nil 20)))
> >   org-list-write-struct(((1 0 "1. " nil nil nil 6) (6 0 "2. " nil nil
> > nil 13) (16 0 "1. " nil nil nil 20)) ((1) (6) (16)))
> >   org-insert-item()
> >   eval((org-insert-item) nil)
> >   eval-expression((org-insert-item) nil nil 127)
> >   funcall-interactively(eval-expression (org-insert-item) nil nil 127)
> >   call-interactively(eval-expression nil nil)
> >   command-execute(eval-expression)
>
> Fixed. Thank you.
> >
> > No indentation:
> > If the indentation is removed from the second line:
> > 1. a
> > b
> > 2. c
> >
> > Then it might be working as expected:
> > 1. a
> > 2.
> > b
> > 2. c
> >
> > a correctly numbered list item is inserted.
> >
> > The fourth lines list number: 2. c
> > didn't change, but it might be expected since there was no indentation
> > before the: b
> > therefore it might be assumed that the list ended there.
>
> This is expected. You need to fix the second list manually, with C-c C-c.
>
> Regards,
> --
> Nicolas Goaziou


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

end of thread, other threads:[~2020-07-06 11:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-06  8:51 org-insert-item, indent causes a soft freeze or error message Duianto -
2020-07-06 10:08 ` Nicolas Goaziou
2020-07-06 11:50   ` Duianto -

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).