emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#33167: closed (26; Doc string of `region-extract-f


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#33167: closed (26; Doc string of `region-extract-function')
Date: Sat, 27 Oct 2018 11:21:02 +0000

Your message dated Sat, 27 Oct 2018 14:20:36 +0300
with message-id <address@hidden>
and subject line Re: bug#33167: 26; Doc string of `region-extract-function'
has caused the debbugs.gnu.org bug report #33167,
regarding 26; Doc string of `region-extract-function'
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
33167: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=33167
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: 26; Doc string of `region-extract-function' Date: Fri, 26 Oct 2018 08:32:04 -0700 (PDT)
I don't understand these parts of the description:

 - nil: return the content as a string.

What does that mean, for a noncontiguous region?  Are the buffer
substrings for all of the region segments (zones) concatenated together?
If so, say that.

 - anything else: delete the region and return its content
   as a string, after filtering it with `filter-buffer-substring', which
   is called with METHOD as its 3rd argument.

So first the region is deleted, and the deleted content (see previous)
is filtered via `(filter-buffer-substring BEG END METHOD)' and then
returned.

Some of what I don't understand:

1. What are the BEG and END args passed to `filter-buffer-substring'?
   Is BEG the smallest car of any of the zones in the noncontiguous
   region, and END the largest cdr of any of the zones?

2. `filter-buffer-substring' calls the value of
   `filter-buffer-substring-function' with the same 3 args.  But what
   can that function do with BEG and END (which are what?)?  It's
   presumably a function that expects to use a single stretch of buffer
   text from BEG to END.  But here we're talking about a noncontiguous 

3. The 3rd arg to `filter-buffer-substring' just deletes the region from
   BEG to END if it is non-nil, so it seems like passing that non-nil
   3rd arg is useless, as the region gets deleted anyway, by
   `region-extract-function'.

4. The use of `filter-buffer-substring' is also unclear.  It is passed
   BEG and END (and METHOD, but see #3, above).  And it filters the
   buffer text between BEG and END.  But see #1 above - are BEG and END
   buffer positions that make sense for the whole region text?  Just
   what happens here?

This is quite unclear to me.  And following the rabbit hole from
`region-extract-function' down to `filter-buffer-substring' and then to
`filter-buffer-substring-function' does not make things more clear.

Or is what happens perhaps that EACH element of the noncontiguous
region, that is, each zone (BEG<N> . END<N>) of the list ((BEG1 . END1)
...) gets filtered by `filter-buffer-substring', passing its BEG END and
EMTHOD - so that a mapcar is applied?  In that case, how are the
resulting buffer substrings assembled - are they concatenated to get the
return value?

In GNU Emacs 26.1 (build 1, x86_64-w64-mingw32)
 of 2018-05-30
Repository revision: 07f8f9bc5a51f5aa94eb099f3e15fbe0c20ea1ea
Windowing system distributor `Microsoft Corp.', version 10.0.16299
Configured using:
 `configure --without-dbus --host=x86_64-w64-mingw32
 --without-compress-install 'CFLAGS=-O2 -static -g3''



--- End Message ---
--- Begin Message --- Subject: Re: bug#33167: 26; Doc string of `region-extract-function' Date: Sat, 27 Oct 2018 14:20:36 +0300
> Date: Fri, 26 Oct 2018 08:32:04 -0700 (PDT)
> From: Drew Adams <address@hidden>
> 
>  - nil: return the content as a string.
> 
> What does that mean, for a noncontiguous region?  Are the buffer
> substrings for all of the region segments (zones) concatenated together?
> If so, say that.

No, the value is a list of strings in this case.  I fixed the doc
string to say that.

> 1. What are the BEG and END args passed to `filter-buffer-substring'?
>    Is BEG the smallest car of any of the zones in the noncontiguous
>    region, and END the largest cdr of any of the zones?

They are the first and the last positions of the region for
filter-buffer-substring to act upon.  That function is not supposed to
process non-contiguous regions.

> 2. `filter-buffer-substring' calls the value of
>    `filter-buffer-substring-function' with the same 3 args.  But what
>    can that function do with BEG and END (which are what?)?  It's
>    presumably a function that expects to use a single stretch of buffer
>    text from BEG to END.  But here we're talking about a noncontiguous 

No, we are talking about contiguous regions when this function is
concerned.

> 3. The 3rd arg to `filter-buffer-substring' just deletes the region from
>    BEG to END if it is non-nil, so it seems like passing that non-nil
>    3rd arg is useless, as the region gets deleted anyway, by
>    `region-extract-function'.

Not sure what is the problem here.

> 4. The use of `filter-buffer-substring' is also unclear.  It is passed
>    BEG and END (and METHOD, but see #3, above).  And it filters the
>    buffer text between BEG and END.  But see #1 above - are BEG and END
>    buffer positions that make sense for the whole region text?  Just
>    what happens here?

See above.  It is not the job of filter-buffer-substring to DTRT when
the region is non-contiguous, it is the job of its callers.  See
rect.el for one example.

> This is quite unclear to me.  And following the rabbit hole from
> `region-extract-function' down to `filter-buffer-substring' and then to
> `filter-buffer-substring-function' does not make things more clear.

It isn't supposed to.  If you want to see how non-contiguous regions
are used in this context, you need to look in places that do so.

> Or is what happens perhaps that EACH element of the noncontiguous
> region, that is, each zone (BEG<N> . END<N>) of the list ((BEG1 . END1)
> ...) gets filtered by `filter-buffer-substring', passing its BEG END and
> METHOD

Yes!

> - so that a mapcar is applied?

Not literally, but the result is a list, yes.

> In that case, how are the resulting buffer substrings assembled -
> are they concatenated to get the return value?

No, you get a list.  Again, see rect.el.

Bottom line: I fixed the doc string of region-extract-function to say
what are the values when the region is non-contiguous, and how
filter-buffer-substring is invoked in that case.  But I don't think
there's anything else that should be done here, because the details of
using this facility for non-contiguous regions is entirely up to the
Lisp program which implements such a feature.

Thanks.


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]