all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: michael_heerdegen@web.de, lekktu@gmail.com, 37488@debbugs.gnu.org
Subject: bug#37488: 27.0.50; Inconsistent naming of arg of `text-property-search-forward' and `-backward'
Date: Thu, 26 Sep 2019 21:16:19 +0200	[thread overview]
Message-ID: <87pnjmj2bg.fsf@gnus.org> (raw)
In-Reply-To: <83impfkmxp.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 26 Sep 2019 20:05:38 +0300")

Eli Zaretskii <eliz@gnu.org> writes:

>> (text-property-search-forward 'face 'bold nil)
>> 
>> and
>> 
>> (text-property-search-forward 'face 'bold
>>                               (lambda (val p-val) (not (equal val p-val))))
>> 
>> The latter will stop every time 'face changes, while the former stops in
>> a way that segments the buffer in all the regions that have not 'face
>> 'bold.
>
> You are saying that the latter will also stop where there's no 'face'
> property at all, while the former will only stop where there _is_
> 'face', but it is not 'bold'?  IOW, nil is equivalent to
>
>   (lambda (val p-val) (and p-val (not (equal val p-val))))

No, not the same, I'm afraid.  nil means "when looping over this search,
give me all regions where 'face is not bold", while your predicate will
give you all regions where there is a 'face property, but it's not nil.

>> >> What it's meant to do is basically how TAB works in buttons, which is a
>> >> common use case.  If you're looking for "o", and point is where "|" is
>> >> below, then it'll find the last "oo" section after the x-es:
>> >> 
>> >> oo|oxxxxxoo
>> >
>> > What does "o" stand for in this case?
>> 
>> Text with "o" as the property.
>
> But then the code should reject the second "oo" section because the
> value of the property there is equal to the value at point.  Right?

Oh, that's the confusion.  By "doesn't include point", I meant "doesn't
include the region point was at when the search started".

>> >> >  . What is the reason for having VALUE an optional argument?  Is it a
>> >> >    frequent/useful operation to look for a VALUE of nil?
>> >> 
>> >> If PREDICATE is nil, then having to use an explicit nil VALUE isn't
>> >> necessary.
>> >
>> > I don't understand how this answers my questions.
>> 
>> Try (text-property-search-forward 'face) on the example.  It'll give you
>> all regions that has a face property.
>
> That's a weird way to get to the result, if someone wants it.

Seems like the obvious way to me.

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





  reply	other threads:[~2019-09-26 19:16 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-23  6:03 bug#37488: 27.0.50; Inconsistent naming of arg of `text-property-search-forward' and `-backward' Michael Heerdegen
2019-09-23  7:30 ` Juanma Barranquero
2019-09-23  7:47   ` Michael Heerdegen
2019-09-25  8:52   ` Eli Zaretskii
2019-09-25  9:35     ` Michael Heerdegen
2019-09-25  9:43       ` Eli Zaretskii
2019-09-25 10:16         ` Michael Heerdegen
2019-09-25 10:26           ` Eli Zaretskii
2019-09-25 13:17           ` Lars Ingebrigtsen
2019-09-25 15:05             ` Eli Zaretskii
2019-09-26 15:13               ` Lars Ingebrigtsen
2019-09-25 13:15     ` Lars Ingebrigtsen
2019-09-25 15:01       ` Eli Zaretskii
2019-09-26 14:42         ` Eli Zaretskii
2019-09-26 15:13           ` Lars Ingebrigtsen
2019-09-26 15:12         ` Lars Ingebrigtsen
2019-09-26 17:05           ` Eli Zaretskii
2019-09-26 19:16             ` Lars Ingebrigtsen [this message]
2019-09-26 19:24               ` Eli Zaretskii
2019-09-27 14:15                 ` Lars Ingebrigtsen
2019-09-27 14:33                   ` Eli Zaretskii
2019-09-27 14:36                     ` Lars Ingebrigtsen
2019-09-28 14:45                       ` Eli Zaretskii
2019-09-26  5:55     ` Michael Heerdegen
2019-09-26  7:33       ` 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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pnjmj2bg.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=37488@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=lekktu@gmail.com \
    --cc=michael_heerdegen@web.de \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.