From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id iGXTIPE6Kl8cFQAA0tVLHw (envelope-from ) for ; Wed, 05 Aug 2020 04:52:01 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id uI+5HPE6Kl9BDAAAB5/wlQ (envelope-from ) for ; Wed, 05 Aug 2020 04:52:01 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 2FBE09403C9 for ; Wed, 5 Aug 2020 04:51:59 +0000 (UTC) Received: from localhost ([::1]:37850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3BPA-0007Gv-4P for larch@yhetil.org; Wed, 05 Aug 2020 00:51:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36120) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3BOn-0007Gd-CI for emacs-orgmode@gnu.org; Wed, 05 Aug 2020 00:51:33 -0400 Received: from pb-smtp1.pobox.com ([64.147.108.70]:53965) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3BOk-0005w9-3E for emacs-orgmode@gnu.org; Wed, 05 Aug 2020 00:51:32 -0400 Received: from pb-smtp1.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id ACC0870C63; Wed, 5 Aug 2020 00:51:27 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:in-reply-to:references:date:message-id:mime-version :content-type; s=sasl; bh=zEBx5IiRJOJk8x9IHZ60Oiv2pSg=; b=rKRUU8 Xcri2IBtnqeEuQDRC03atCzAy216vmA9lmZw9fqWpaIEZ/GtFSA9C+sJwrzMBpkH yfvA/6V2XZGzKr3kv75z1WbapRkeqT28ks4RN8UUHod0w1V0bl6DCuzjQ0xa++Hu W/htrOZBMG5HwOR8gK27LKNJTFbf9QsVs3GcU= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id A371370C62; Wed, 5 Aug 2020 00:51:27 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=kyleam.com; h=from:to:cc:subject:in-reply-to:references:date:message-id:mime-version:content-type; s=mesmtp; bh=Wh9bZ8L0RwNy0cZ3onoAIJhkbVX47UwJAjWVvndY234=; b=lx9b2jyIowvFBI3ZZmUYUc/wVWYT4zG62Pg0pobC67DF3oFaJ1sRRNpTMs67yl/1BLBqzDJzxPXfPzIUf8bYFfln/f2V33YH5Ai52u9JX/d7ji8aNqjjzDerrNYx7Hyry2xntw4qTsy4EVu0TQoFVRMDqL+sZZmJcCay4TtINwE= Received: from localhost (unknown [45.33.91.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id 18A5F70C60; Wed, 5 Aug 2020 00:51:27 -0400 (EDT) (envelope-from kyle@kyleam.com) From: Kyle Meyer To: Samuel Wales Subject: Re: [bug] args out of range upon meta-return in body of list item In-Reply-To: References: Date: Wed, 05 Aug 2020 00:51:26 -0400 Message-ID: <87bljp4rw1.fsf@kyleam.com> MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: 520D73F6-D6D7-11EA-8143-01D9BED8090B-24757444!pb-smtp1.pobox.com Received-SPF: pass client-ip=64.147.108.70; envelope-from=kyle@kyleam.com; helo=pb-smtp1.pobox.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/05 00:51:27 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=pobox.com header.s=sasl header.b=rKRUU8 X; dkim=pass header.d=kyleam.com header.s=mesmtp header.b=lx9b2jyI; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -1.21 X-TUID: DsOrBzgNZ2Dr 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