unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: "Daniel Martín" <mardani29@yahoo.es>
Cc: stefan@marxist.se, 47564@debbugs.gnu.org,
	Nicolas Graner <nicolas@graner.name>
Subject: bug#47564: text-property-search-forward does not behave as advertized
Date: Wed, 29 Jun 2022 12:44:14 +0200	[thread overview]
Message-ID: <87k08zkav5.fsf@gnus.org> (raw)
In-Reply-To: <m1tuoeayv6.fsf@yahoo.es> ("Daniel Martín"'s message of "Sat, 10 Apr 2021 18:27:41 +0200")

Daniel Martín <mardani29@yahoo.es> writes:

> Nicolas Graner <nicolas@graner.name> writes:

>> (insert "12345678")
>> (put-text-property 3 6 'foo 'bar)
>> (goto-char 1)
>> (text-property-search-forward 'foo 'bar t)
>> ;; moves point to 6 and returns range 3 to 6
>> ;; Doc says it should move the point to start of range, but it
>> ;; consistently moves to end of range.
>
> I see this was changed in
> https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=b295174210465c4285729c67ec014e0f5b53f741,
> but I don't know about the reasons for the change.  In any case, the
> docstring is now inconsistent with the documentation in the Elisp
> manual, which says that point is placed at the end (which matches the
> implementation).  I've CC Stefan, but I think the docstring error is
> that `text-property-search-forward' moves point to the end of the
> matched region, and `text-property-search-backward' moves point to the
> beginning of the matched region.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

Looking at the manual and the doc strings, they seem to be in agreement
on this point (in Emacs 29, at least).

>> (goto-char 1)
>> (text-property-search-forward 'foo 'bar nil)
>> ;; moves point to 3 and returns range 1 to 3, whre property foo is nil.
>> ;; Doc says: with PREDICATE nil, a value will match if it is
>> ;; non-nil and is NOT ‘equal’ to VALUE.
>> ;; In fact, the condition "it is non-nil" is apparently ignored.
>
> After reading the code, I'd say you're correct and the "non-nil" is
> ignored in the implementation.  This part was added in response to this
> bug report: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=37488, perhaps
> I'm missing something.

I've re-re-rewritten the documentation here after that a while ago
(because most of the additions there weren't correct).

>> (goto-char 7)
>> (text-property-search-backward 'foo 'bar t)
>> ;; returns nil. This one is really weird, considering it works OK from
>> ;; position 6 or 8. As if there was something special when you start 1
>> ;; after the end of a range.
>
> Yes, this seems like an off-by-one error in the implementation.

Looks like this has been fixed in the meantime.

So I think that everything here has been fixed by now (at least in Emacs
29), so I'm closing this bug report.  If any of these issues still
remain, please open a new bug report for those issues.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





      reply	other threads:[~2022-06-29 10:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-02 14:08 bug#47564: text-property-search-forward does not behave as advertized Nicolas Graner
2021-04-10 16:27 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-06-29 10:44   ` Lars Ingebrigtsen [this message]

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=87k08zkav5.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=47564@debbugs.gnu.org \
    --cc=mardani29@yahoo.es \
    --cc=nicolas@graner.name \
    --cc=stefan@marxist.se \
    /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).