From: Eli Zaretskii <eliz@gnu.org>
To: nicolas@graner.name
Cc: larsi@gnus.org, 58937@debbugs.gnu.org
Subject: bug#58937: text-property-search-backward misses one-character regions
Date: Tue, 01 Nov 2022 19:05:41 +0200 [thread overview]
Message-ID: <83wn8ebo62.fsf@gnu.org> (raw)
In-Reply-To: <83zgdaboer.fsf@gnu.org> (message from Eli Zaretskii on Tue, 01 Nov 2022 19:00:28 +0200)
> Date: Tue, 01 Nov 2022 19:00:28 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: larsi@gnus.org, 58937@debbugs.gnu.org
>
> > From: Nicolas Graner <nicolas@graner.name>
> > 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 <eliz@gnu.org>
> > >
> > > 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:
Not my best day, I guess. Please use this patch instead of the
previous two:
diff --git a/lisp/emacs-lisp/text-property-search.el b/lisp/emacs-lisp/text-property-search.el
index d11980f..d41222b 100644
--- a/lisp/emacs-lisp/text-property-search.el
+++ b/lisp/emacs-lisp/text-property-search.el
@@ -208,8 +208,14 @@ 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)
next prev parent reply other threads:[~2022-11-01 17:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-31 23:20 bug#58937: text-property-search-backward misses one-character regions Nicolas Graner
2022-11-01 10:24 ` Eli Zaretskii
2022-11-01 16:48 ` Nicolas Graner
2022-11-01 16:56 ` Eli Zaretskii
2022-11-01 17:00 ` Eli Zaretskii
2022-11-01 17:05 ` Eli Zaretskii [this message]
2022-11-02 23:40 ` Nicolas Graner
2022-11-03 9:35 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83wn8ebo62.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=58937@debbugs.gnu.org \
--cc=larsi@gnus.org \
--cc=nicolas@graner.name \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.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).