From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#33167: 26; Doc string of `region-extract-function' Date: Sat, 27 Oct 2018 14:20:36 +0300 Message-ID: <831s8bocu3.fsf@gnu.org> References: <2e187b74-9999-4090-96b4-bb13d1f27544@default> NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1540639150 27637 195.159.176.226 (27 Oct 2018 11:19:10 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 27 Oct 2018 11:19:10 +0000 (UTC) Cc: 33167-done@debbugs.gnu.org To: Drew Adams Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Oct 27 13:19:06 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGMcU-000778-Bd for geb-bug-gnu-emacs@m.gmane.org; Sat, 27 Oct 2018 13:19:06 +0200 Original-Received: from localhost ([::1]:36083 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gGMea-0000jK-Py for geb-bug-gnu-emacs@m.gmane.org; Sat, 27 Oct 2018 07:21:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41293) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gGMeR-0000ie-QS for bug-gnu-emacs@gnu.org; Sat, 27 Oct 2018 07:21:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gGMeM-0008La-LO for bug-gnu-emacs@gnu.org; Sat, 27 Oct 2018 07:21:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:40398) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gGMeM-0008LP-G6 for bug-gnu-emacs@gnu.org; Sat, 27 Oct 2018 07:21:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gGMeM-0006DQ-Bm for bug-gnu-emacs@gnu.org; Sat, 27 Oct 2018 07:21:02 -0400 Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Sat, 27 Oct 2018 11:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 33167 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Mail-Followup-To: 33167@debbugs.gnu.org, eliz@gnu.org, drew.adams@oracle.com Original-Received: via spool by 33167-done@debbugs.gnu.org id=D33167.154063924623844 (code D ref 33167); Sat, 27 Oct 2018 11:21:02 +0000 Original-Received: (at 33167-done) by debbugs.gnu.org; 27 Oct 2018 11:20:46 +0000 Original-Received: from localhost ([127.0.0.1]:44655 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGMe5-0006CW-IC for submit@debbugs.gnu.org; Sat, 27 Oct 2018 07:20:45 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:59762) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGMe3-0006CJ-Pq for 33167-done@debbugs.gnu.org; Sat, 27 Oct 2018 07:20:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gGMdt-000842-75 for 33167-done@debbugs.gnu.org; Sat, 27 Oct 2018 07:20:38 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:54702) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gGMdt-00083w-35; Sat, 27 Oct 2018 07:20:33 -0400 Original-Received: from [176.228.60.248] (port=1311 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1gGMds-0001mL-Lu; Sat, 27 Oct 2018 07:20:33 -0400 In-reply-to: <2e187b74-9999-4090-96b4-bb13d1f27544@default> (message from Drew Adams on Fri, 26 Oct 2018 08:32:04 -0700 (PDT)) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:151673 Archived-At: > Date: Fri, 26 Oct 2018 08:32:04 -0700 (PDT) > From: Drew Adams > > - 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 . END) 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.