emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [bug] args out of range upon meta-return in body of list item
@ 2020-08-04 22:41 Samuel Wales
  2020-08-05  4:51 ` Kyle Meyer
  0 siblings, 1 reply; 9+ messages in thread
From: Samuel Wales @ 2020-08-04 22:41 UTC (permalink / raw)
  To: emacs-orgmode

recent maint on emacs 25.

i know this is an imperfect bug report with no mce that you can
probably repro.  but perhaps it can trigger an idea that could lead
directly to a fix.  my brain and computer limitations cannot do better
at this time.

when i run m-ret at the caret i get this bt.  my intent is to make a
new list item containing prefer as its header.

   1) [ ] towels
      1) [ ] 12 very large (asdfasdf asdfasdf) solid color,
         like the ones i use, thick -- asdafsdf -- ^prefer
         to get them slightly wider
         - not any ...
         - not any pattern (something like different color on
           end might be ok, dunno) or anything garish
      2) [ ] 6 dark aasdfa dfnkajs dkfaskdf kasdn
         fkasdnkfanksdfn kasdfn
   2) asdfasdfasdf

Debugger entered--Lisp error: (args-out-of-range -1 3)
  replace-match("1) " nil nil nil 1)
  #[771 ...
  org-list-struct-apply-struct(...
  org-list-write-struct(...
  org-insert-item(nil)
  funcall-interactively(org-insert-item nil)
  call-interactively(org-insert-item)
  org-meta-return(nil)
  funcall-interactively(org-meta-return nil)
  call-interactively(org-meta-return nil nil)
  command-execute(org-meta-return)


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

* Re: [bug] args out of range upon meta-return in body of list item
  2020-08-04 22:41 [bug] args out of range upon meta-return in body of list item Samuel Wales
@ 2020-08-05  4:51 ` Kyle Meyer
  2020-08-05  5:18   ` Samuel Wales
  2020-08-16  9:45   ` Nicolas Goaziou
  0 siblings, 2 replies; 9+ messages in thread
From: Kyle Meyer @ 2020-08-05  4:51 UTC (permalink / raw)
  To: Samuel Wales; +Cc: emacs-orgmode

Samuel Wales writes:

> recent maint on emacs 25.
>
> i know this is an imperfect bug report with no mce that you can
> probably repro.  but perhaps it can trigger an idea that could lead
> directly to a fix.  my brain and computer limitations cannot do better
> at this time.

The example, instructions, and backtrace you provided are all very
helpful.  Thanks.

> when i run m-ret at the caret i get this bt.  my intent is to make a
> new list item containing prefer as its header.
>
>    1) [ ] towels
>       1) [ ] 12 very large (asdfasdf asdfasdf) solid color,
>          like the ones i use, thick -- asdafsdf -- ^prefer
>          to get them slightly wider
>          - not any ...
>          - not any pattern (something like different color on
>            end might be ok, dunno) or anything garish
>       2) [ ] 6 dark aasdfa dfnkajs dkfaskdf kasdn
>          fkasdnkfanksdfn kasdfn
>    2) asdfasdfasdf
>
> Debugger entered--Lisp error: (args-out-of-range -1 3)
>   replace-match("1) " nil nil nil 1)
>   #[771 ...
>   org-list-struct-apply-struct(...
>   org-list-write-struct(...
>   org-insert-item(nil)
>   funcall-interactively(org-insert-item nil)
>   call-interactively(org-insert-item)
>   org-meta-return(nil)
>   funcall-interactively(org-meta-return nil)
>   call-interactively(org-meta-return nil nil)
>   command-execute(org-meta-return)

I don't have more time to spend on this at the moment, but some quick
notes.

  * The error you show happens on maint, but doesn't on master.  It
    looks like it went away with 07a4a7286 (list: Fix regression when
    inserting items, 2020-07-06), which was prompted by this report:
    https://orgmode.org/list/CAE-tX7iH59DNO8K2a6O_Wu7_DqqRgPJ5r_y=ZQdusTcR5vrpqw@mail.gmail.com/

    I think this can be cherry picked to maint.

  * Although the error is gone, the result still looks off.  In
    particular, the "2) [ ] 6 dark" line loses its bullet.

I suspect that the remaining issue is related to the error you show
above.  Here's a bit of context from org-list-struct-apply-struct:

    (looking-at org-list-full-item-re)
    ;; a.  Replace bullet
    (unless (equal old-bul new-bul)
      (replace-match new-bul nil nil nil 1))
    ;; b.  Replace checkbox.
    (cond
     ((equal (match-string 3) new-box))
     ((and (match-string 3) new-box)
      (replace-match new-box nil nil nil 3))
     ((match-string 3)

The code downstream of (looking-at ...) assumes a match, but it seems
that's not valid, even after 07a4a7286.  The patch below guards the
downstream code with (when (looking-at ...)) and fixes this particular
"lost bullet" case I mentioned above.

The change doesn't make any tests fail, but I'd need to look into the
code a bit more to be comfortable with the change.  (For instance, is
the fact that there isn't a match here a sign that something's going
wrong upstream?)  Also, the patch should include a test that is
distilled from your example.


diff --git a/lisp/org-list.el b/lisp/org-list.el
index 727d89c36..61d5def5b 100644
--- a/lisp/org-list.el
+++ b/lisp/org-list.el
@@ -1866,26 +1866,26 @@ (defun org-list-struct-apply-struct (struct old-struct)
 			      (org-list-get-bullet item struct)))
 		    (old-bul (org-list-get-bullet item old-struct))
 		    (new-box (org-list-get-checkbox item struct)))
-	       (looking-at org-list-full-item-re)
-	       ;; a.  Replace bullet
-	       (unless (equal old-bul new-bul)
-		 (replace-match new-bul nil nil nil 1))
-	       ;; b.  Replace checkbox.
-	       (cond
-		((equal (match-string 3) new-box))
-		((and (match-string 3) new-box)
-		 (replace-match new-box nil nil nil 3))
-		((match-string 3)
-		 (looking-at ".*?\\([ \t]*\\[[ X-]\\]\\)")
-		 (replace-match "" nil nil nil 1))
-		(t (let ((counterp (match-end 2)))
-		     (goto-char (if counterp (1+ counterp) (match-end 1)))
-		     (insert (concat new-box (unless counterp " "))))))
-	       ;; c.  Indent item to appropriate column.
-	       (unless (= new-ind old-ind)
-		 (delete-region (goto-char (point-at-bol))
-				(progn (skip-chars-forward " \t") (point)))
-		 (indent-to new-ind)))))))
+	       (when (looking-at org-list-full-item-re)
+		 ;; a.  Replace bullet
+		 (unless (equal old-bul new-bul)
+		   (replace-match new-bul nil nil nil 1))
+		 ;; b.  Replace checkbox.
+		 (cond
+		  ((equal (match-string 3) new-box))
+		  ((and (match-string 3) new-box)
+		   (replace-match new-box nil nil nil 3))
+		  ((match-string 3)
+		   (looking-at ".*?\\([ \t]*\\[[ X-]\\]\\)")
+		   (replace-match "" nil nil nil 1))
+		  (t (let ((counterp (match-end 2)))
+		       (goto-char (if counterp (1+ counterp) (match-end 1)))
+		       (insert (concat new-box (unless counterp " "))))))
+		 ;; c.  Indent item to appropriate column.
+		 (unless (= new-ind old-ind)
+		   (delete-region (goto-char (point-at-bol))
+				  (progn (skip-chars-forward " \t") (point)))
+		   (indent-to new-ind))))))))
     ;; 1. First get list of items and position endings.  We maintain
     ;;    two alists: ITM-SHIFT, determining indentation shift needed
     ;;    at item, and END-LIST, a pseudo-alist where key is ending


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

* Re: [bug] args out of range upon meta-return in body of list item
  2020-08-05  4:51 ` Kyle Meyer
@ 2020-08-05  5:18   ` Samuel Wales
  2020-08-16  9:45   ` Nicolas Goaziou
  1 sibling, 0 replies; 9+ messages in thread
From: Samuel Wales @ 2020-08-05  5:18 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: emacs-orgmode

thank you for looking into it.


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

* Re: [bug] args out of range upon meta-return in body of list item
  2020-08-05  4:51 ` Kyle Meyer
  2020-08-05  5:18   ` Samuel Wales
@ 2020-08-16  9:45   ` Nicolas Goaziou
  2020-08-16 15:36     ` Kyle Meyer
  1 sibling, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2020-08-16  9:45 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: emacs-orgmode

Hello,

Kyle Meyer <kyle@kyleam.com> writes:

> The change doesn't make any tests fail, but I'd need to look into the
> code a bit more to be comfortable with the change.  (For instance, is
> the fact that there isn't a match here a sign that something's going
> wrong upstream?)

Yes, the problem lies in `org-list-insert-item'. I pushed a fix and
a test for that.

Regards,
-- 
Nicolas Goaziou


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

* Re: [bug] args out of range upon meta-return in body of list item
  2020-08-16  9:45   ` Nicolas Goaziou
@ 2020-08-16 15:36     ` Kyle Meyer
  2020-08-16 22:12       ` Samuel Wales
  0 siblings, 1 reply; 9+ messages in thread
From: Kyle Meyer @ 2020-08-16 15:36 UTC (permalink / raw)
  To: emacs-orgmode

Nicolas Goaziou writes:

> Yes, the problem lies in `org-list-insert-item'. I pushed a fix and
> a test for that.

Great.  Thank you!


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

* Re: [bug] args out of range upon meta-return in body of list item
  2020-08-16 15:36     ` Kyle Meyer
@ 2020-08-16 22:12       ` Samuel Wales
  2020-08-20 20:55         ` Samuel Wales
  0 siblings, 1 reply; 9+ messages in thread
From: Samuel Wales @ 2020-08-16 22:12 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: emacs-orgmode

thank you both.

On 8/16/20, Kyle Meyer <kyle@kyleam.com> wrote:
> Nicolas Goaziou writes:
>
>> Yes, the problem lies in `org-list-insert-item'. I pushed a fix and
>> a test for that.
>
> Great.  Thank you!
>


-- 
The Kafka Pandemic

Please learn what misopathy is.
https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html


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

* Re: [bug] args out of range upon meta-return in body of list item
  2020-08-16 22:12       ` Samuel Wales
@ 2020-08-20 20:55         ` Samuel Wales
  2020-08-20 21:16           ` Nicolas Goaziou
  0 siblings, 1 reply; 9+ messages in thread
From: Samuel Wales @ 2020-08-20 20:55 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: emacs-orgmode

i presume the fix will come out in the next release of maint?
[still getting in maint, which is ok; just confirming.]

On 8/16/20, Samuel Wales <samologist@gmail.com> wrote:
> thank you both.
>
> On 8/16/20, Kyle Meyer <kyle@kyleam.com> wrote:
>> Nicolas Goaziou writes:
>>
>>> Yes, the problem lies in `org-list-insert-item'. I pushed a fix and
>>> a test for that.
>>
>> Great.  Thank you!
>>
>
>
> --
> The Kafka Pandemic
>
> Please learn what misopathy is.
> https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html
>


-- 
The Kafka Pandemic

Please learn what misopathy is.
https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html


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

* Re: [bug] args out of range upon meta-return in body of list item
  2020-08-20 20:55         ` Samuel Wales
@ 2020-08-20 21:16           ` Nicolas Goaziou
  2020-08-20 21:47             ` Samuel Wales
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2020-08-20 21:16 UTC (permalink / raw)
  To: Samuel Wales; +Cc: emacs-orgmode

Hello,

Samuel Wales <samologist@gmail.com> writes:

> i presume the fix will come out in the next release of maint?

I applied the fix on master because it is built on top of another fix
from there. So no, it should be available in Org 9.4 only.

Regards,
-- 
Nicolas Goaziou


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

* Re: [bug] args out of range upon meta-return in body of list item
  2020-08-20 21:16           ` Nicolas Goaziou
@ 2020-08-20 21:47             ` Samuel Wales
  0 siblings, 0 replies; 9+ messages in thread
From: Samuel Wales @ 2020-08-20 21:47 UTC (permalink / raw)
  To: Samuel Wales, Kyle Meyer, emacs-orgmode

thanks.  just wanted to make sure i wasn't supposed to report that it
wasn't working or was a different bug.

On 8/20/20, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
> Hello,
>
> Samuel Wales <samologist@gmail.com> writes:
>
>> i presume the fix will come out in the next release of maint?
>
> I applied the fix on master because it is built on top of another fix
> from there. So no, it should be available in Org 9.4 only.
>
> Regards,
> --
> Nicolas Goaziou
>


-- 
The Kafka Pandemic

Please learn what misopathy is.
https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html


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

end of thread, other threads:[~2020-08-20 21:47 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-04 22:41 [bug] args out of range upon meta-return in body of list item Samuel Wales
2020-08-05  4:51 ` Kyle Meyer
2020-08-05  5:18   ` Samuel Wales
2020-08-16  9:45   ` Nicolas Goaziou
2020-08-16 15:36     ` Kyle Meyer
2020-08-16 22:12       ` Samuel Wales
2020-08-20 20:55         ` Samuel Wales
2020-08-20 21:16           ` Nicolas Goaziou
2020-08-20 21:47             ` Samuel Wales

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