From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#58937: text-property-search-backward misses one-character regions Date: Tue, 01 Nov 2022 19:00:28 +0200 Message-ID: <83zgdaboer.fsf@gnu.org> References: <87bkpqr57e.fsf@graner.name> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39598"; mail-complaints-to="usenet@ciao.gmane.io" Cc: larsi@gnus.org, 58937@debbugs.gnu.org To: Nicolas Graner Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Nov 01 18:11:09 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1opun2-000A05-JU for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 01 Nov 2022 18:11:04 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1opudT-0001ue-Nu; Tue, 01 Nov 2022 13:01:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1opudK-0001lr-Jv for bug-gnu-emacs@gnu.org; Tue, 01 Nov 2022 13:01:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1opudK-0006bI-6u for bug-gnu-emacs@gnu.org; Tue, 01 Nov 2022 13:01:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1opudK-0001Zs-2F for bug-gnu-emacs@gnu.org; Tue, 01 Nov 2022 13:01:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 01 Nov 2022 17:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58937 X-GNU-PR-Package: emacs Original-Received: via spool by 58937-submit@debbugs.gnu.org id=B58937.16673220556043 (code B ref 58937); Tue, 01 Nov 2022 17:01:02 +0000 Original-Received: (at 58937) by debbugs.gnu.org; 1 Nov 2022 17:00:55 +0000 Original-Received: from localhost ([127.0.0.1]:44107 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opudC-0001ZO-JG for submit@debbugs.gnu.org; Tue, 01 Nov 2022 13:00:54 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:51386) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opud5-0001Z7-Nf for 58937@debbugs.gnu.org; Tue, 01 Nov 2022 13:00:51 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1opucz-0006Wm-Tj; Tue, 01 Nov 2022 13:00:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=x6ZRc42H1mF0iiod4MZirayFAt2d9jo+nQ6BMocGZOg=; b=nnlJcKyAVbuU 8wH6SOKULI0+ilDWJVyLxlLmq4oIqL5Ng8HsPQsiQk+8jvnaUGbJ1fDO79OrmHd+fs4l2cuJD4wO2 IauFbi6q15pJoqxT4KFzlx9LXRc1GsfIaIcEd1BtyUFsxqVCeKH3h2EluB0BgiHLOjB4FHXqkn32x kafsrLg3GVMMcb9cmtLe+IZVkAHqdelgc+ZoeadjIeO4sZ6G2FkNcR2xqmsc6fSwk7rAgBoUCwPcw 6tvNZaXSxr6R/RA8TjZEj+trTUejBkPsHOkgm38OA7FD1I77S93s7SO0EAmIk8m4lLJV+FaBCYhrO xsuttyYhDWv7+isCgERi6A==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1opucz-0007mk-6w; Tue, 01 Nov 2022 13:00:41 -0400 In-Reply-To: <87bkpqr57e.fsf@graner.name> (message from Nicolas Graner on Tue, 01 Nov 2022 17:48:37 +0100) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: "bug-gnu-emacs" Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:246782 Archived-At: > From: Nicolas Graner > Cc: larsi@gnus.org, 58937@debbugs.gnu.org > Date: Tue, 01 Nov 2022 17:48:37 +0100 > > > Date: Tue, 01 Nov 2022 12:24:49 +0200 > > From: Eli Zaretskii > > > > Please try the patch below and see if it gives good results. > > > > diff --git a/lisp/emacs-lisp/text-property-search.el b/lisp/emacs-lisp/text-property-search.el > > index d11980f..69bbbd2 100644 > > --- a/lisp/emacs-lisp/text-property-search.el > > +++ b/lisp/emacs-lisp/text-property-search.el > > @@ -208,8 +208,12 @@ text-property--find-end-backward > > (goto-char end) > > (setq ended t))))) > > ;; End this at the first place the property changes value. > > - (setq end (previous-single-property-change > > - (point) property nil (point-min))) > > + (setq end > > + (if (text-property--match-p > > + value (get-text-property (1- (point)) property) predicate) > > + (previous-single-property-change (point) > > + property nil (point-min)) > > + (point))) > > (goto-char end)) > > (make-prop-match :beginning end > > :end (1+ start) > > It fixes the bug in all the cases I've tested so far, but also > introduces a new one: > > (with-current-buffer (generate-new-buffer "test") > (insert "123456789") > (put-text-property 2 4 'foo 'bar) > (goto-char 3) > (text-property-search-backward 'foo nil t)) > > Debugger entered--Lisp error: (args-out-of-range 0 0) > get-text-property(0 foo) Sorry, please disregard the previous message and use the patch below instead: diff --git a/lisp/emacs-lisp/text-property-search.el b/lisp/emacs-lisp/text-property-search.el index d11980f..1e7f346 100644 --- a/lisp/emacs-lisp/text-property-search.el +++ b/lisp/emacs-lisp/text-property-search.el @@ -208,8 +208,13 @@ text-property--find-end-backward (goto-char end) (setq ended t))))) ;; End this at the first place the property changes value. - (setq end (previous-single-property-change - (point) property nil (point-min))) + (setq end + (if (and (> (point) (point-min)) + (text-property--match-p + value (get-text-property (1- (point)) property) predicate) + (previous-single-property-change (point) + property nil (point-min))) + (point))) (goto-char end)) (make-prop-match :beginning end :end (1+ start)