GNU bug report logs - #7604
`loop', PATCH: loop, cl-parse-loop-clause, cl-map-intervals -- being the intervals of

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: minor; Reported by: MON KEY <monkey@HIDDEN>; Keywords: patch; dated Fri, 10 Dec 2010 01:25:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 7604 <at> debbugs.gnu.org:


Received: (at 7604) by debbugs.gnu.org; 26 Feb 2016 06:28:18 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 26 01:28:18 2016
Received: from localhost ([127.0.0.1]:46653 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1aZBsv-0008Rr-QJ
	for submit <at> debbugs.gnu.org; Fri, 26 Feb 2016 01:28:17 -0500
Received: from hermes.netfonds.no ([80.91.224.195]:37115)
 by debbugs.gnu.org with esmtp (Exim 4.84)
 (envelope-from <larsi@HIDDEN>) id 1aZBst-0008Rj-V2
 for 7604 <at> debbugs.gnu.org; Fri, 26 Feb 2016 01:28:16 -0500
Received: from [175.103.25.178] (helo=mouse)
 by hermes.netfonds.no with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.72) (envelope-from <larsi@HIDDEN>)
 id 1aZBsW-0005KB-Ld; Fri, 26 Feb 2016 07:27:53 +0100
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: MON KEY <monkey@HIDDEN>
Subject: Re: bug#7604: `loop', PATCH: loop, cl-parse-loop-clause,
 cl-map-intervals -- being the intervals of
References: <AANLkTimXrkuKmQeUdSbyaAEJsxq9KTX5VSW1jSpDUumr@HIDDEN>
Date: Fri, 26 Feb 2016 16:57:48 +1030
In-Reply-To: <AANLkTimXrkuKmQeUdSbyaAEJsxq9KTX5VSW1jSpDUumr@HIDDEN>
 (MON KEY's message of "Thu, 9 Dec 2010 20:30:03 -0500")
Message-ID: <8760xcugt7.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-MailScanner-ID: 1aZBsW-0005KB-Ld
X-Netfonds-MailScanner: Found to be clean
X-Netfonds-MailScanner-From: larsi@HIDDEN
MailScanner-NULL-Check: 1457072874.15872@oLIkFntVaPVmtdpQPXUU4A
X-Spam-Status: No
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 7604
Cc: 7604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)

MON KEY <monkey@HIDDEN> writes:

> Current through BZR-102620 there is a bug around `loop',
> `cl-parse-loop-clause', and `cl-map-intervals' which put them in
> conflict with the manual (which is unclear w/re intended usage):
>
>  ,----
>  | `for VAR being the intervals [of BUFFER] ...'
>  |  This clause iterates over all intervals of a buffer with constant
>  |  text properties.  The variable VAR will be bound to conses of
>  |  start and end positions, where one start position is always equal
>  |  to the previous end position.  The clause allows `of', `from',
>  |  `to', and `property' terms, where the latter term restricts the
>  |  search to just the specified property.  The `of' term may specify
>  |  either a buffer or a string.
>  `----

[...]

> There should be an additional infix filler word preceding `property'
> as their is with the hash-table loop clauses, and he right fix IMO
> would be to add a `using' syntax instead of and/or in addition to
> testing for `property' which is pretty clearly (of itself) NTRT.
> Such an addtion would allow for:
>
> (loop for <VAR> being the intervals in <BUFFER> using property <PROP>
> from <INT> to <INT>
>       collecting tp)
>
> Regardless, the ttached patch is current w/ BZR-102620. It fixes the
> problem and remains backwards compatable with the existing behaviour
> in Emacs 23.
>
> rgrep says nothing in core uses this loop idiom so it should be a
> fairly clean fix.

Since nothing uses it, and it's a non-standard Emacs extension to loop,
perhaps we should just remove the intervals stuff from cl-loop?

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




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#7604; Package emacs. Full text available.
Added tag(s) patch. Request was from Lars Magne Ingebrigtsen <larsi@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 10 Dec 2010 01:24:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Dec 09 20:24:12 2010
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1PQriV-0005O9-PU
	for submit <at> debbugs.gnu.org; Thu, 09 Dec 2010 20:24:12 -0500
Received: from eggs.gnu.org ([140.186.70.92])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <stan@HIDDEN>) id 1PQriT-0005Nw-Ox
	for submit <at> debbugs.gnu.org; Thu, 09 Dec 2010 20:24:10 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <stan@HIDDEN>) id 1PQroH-0006S8-Ah
	for submit <at> debbugs.gnu.org; Thu, 09 Dec 2010 20:30:11 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW
	autolearn=unavailable version=3.3.1
Received: from lists.gnu.org ([199.232.76.165]:56392)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <stan@HIDDEN>) id 1PQroH-0006S4-7x
	for submit <at> debbugs.gnu.org; Thu, 09 Dec 2010 20:30:09 -0500
Received: from [140.186.70.92] (port=45018 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1PQroF-000803-85
	for bug-gnu-emacs@HIDDEN; Thu, 09 Dec 2010 20:30:09 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <stan@HIDDEN>) id 1PQroD-0006RD-S9
	for bug-gnu-emacs@HIDDEN; Thu, 09 Dec 2010 20:30:06 -0500
Received: from mail-ww0-f49.google.com ([74.125.82.49]:57313)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <stan@HIDDEN>) id 1PQroD-0006Qy-MJ
	for bug-gnu-emacs@HIDDEN; Thu, 09 Dec 2010 20:30:05 -0500
Received: by wwb17 with SMTP id 17so3109880wwb.30
	for <bug-gnu-emacs@HIDDEN>; Thu, 09 Dec 2010 17:30:03 -0800 (PST)
MIME-Version: 1.0
Received: by 10.216.159.207 with SMTP id s57mr201626wek.43.1291944603722; Thu,
	09 Dec 2010 17:30:03 -0800 (PST)
Received: by 10.216.70.212 with HTTP; Thu, 9 Dec 2010 17:30:03 -0800 (PST)
Date: Thu, 9 Dec 2010 20:30:03 -0500
X-Google-Sender-Auth: X99cVPn9WBk--0Rgk7d4Bn6Fqdg
Message-ID: <AANLkTimXrkuKmQeUdSbyaAEJsxq9KTX5VSW1jSpDUumr@HIDDEN>
Subject: `loop', PATCH: loop, cl-parse-loop-clause, cl-map-intervals -- being
	the intervals of
From: MON KEY <monkey@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Content-Type: text/plain; charset=UTF-8
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Spam-Score: -5.2 (-----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -5.2 (-----)

Current through BZR-102620 there is a bug around `loop',
`cl-parse-loop-clause', and `cl-map-intervals' which put them in
conflict with the manual (which is unclear w/re intended usage):

 ,----
 | `for VAR being the intervals [of BUFFER] ...'
 |  This clause iterates over all intervals of a buffer with constant
 |  text properties.  The variable VAR will be bound to conses of
 |  start and end positions, where one start position is always equal
 |  to the previous end position.  The clause allows `of', `from',
 |  `to', and `property' terms, where the latter term restricts the
 |  search to just the specified property.  The `of' term may specify
 |  either a buffer or a string.
 `----

(loop for <VAR> being the intervals of property <PROP> from <INT> to <INT>
      collecting <VAR>)

The above works (by accident).

What should work (but doesn't) is:

(loop for <VAR> being the intervals in <BUFFER> of property <PROP>
from <INT> to <INT>
      collecting <VAR>)

The `intervals' feature is an extension to the Common Lisp `loop'
macro but is not in keeping with the syntax.

My understanding of the above is following should work (it doesn't):

(loop for <VAR> being the intervals of <BUFFER> of property <PROP>
from <INT> to <INT>
      collecting tp)

Additionally, the source provides that `in' may be used in the same
manner as `of':

(loop for <VAR> being the intervals in <BUFFER> property <PROP> from
<INT> to <INT>
      collecting tp)

So, I would also expect either of these to work as well (they don't):

(loop for <VAR> being the intervals in <BUFFER> of property <PROP>
from <INT> to <INT>
      collecting tp)

(loop for <VAR> being the intervals of <BUFFER> in property <PROP>
from <INT> to <INT>
      collecting tp)

There should be an additional infix filler word preceding `property'
as their is with the hash-table loop clauses, and he right fix IMO
would be to add a `using' syntax instead of and/or in addition to
testing for `property' which is pretty clearly (of itself) NTRT.
Such an addtion would allow for:

(loop for <VAR> being the intervals in <BUFFER> using property <PROP>
from <INT> to <INT>
      collecting tp)

Regardless, the ttached patch is current w/ BZR-102620. It fixes the
problem and remains backwards compatable with the existing behaviour
in Emacs 23.

rgrep says nothing in core uses this loop idiom so it should be a
fairly clean fix.

--- /ediff25130lIS	2010-12-09 20:06:14.727993830 -0500
+++ /lisp/emacs-lisp/cl-macs.el	2010-12-09 19:54:51.992860000 -0500
@@ -916,17 +916,23 @@
 			  (lambda (,var ,(make-symbol "--cl-var--"))
 			    (progn . --cl-map) nil)
 			  ,buf ,from ,to))))
-
+
 	       ((memq word '(interval intervals))
 		(let ((buf nil) (prop nil) (from nil) (to nil)
 		      (var1 (make-symbol "--cl-var1--"))
 		      (var2 (make-symbol "--cl-var2--")))
-		  (while (memq (car loop-args) '(in of property from to))
-		    (cond ((eq (car loop-args) 'from) (setq from (cl-pop2 loop-args)))
-			  ((eq (car loop-args) 'to) (setq to (cl-pop2 loop-args)))
-			  ((eq (car loop-args) 'property)
-			   (setq prop (cl-pop2 loop-args)))
-			  (t (setq buf (cl-pop2 loop-args)))))
+                  (while (memq (car loop-args) '(in of property from to))
+                    (cond ((eq (car loop-args) 'from) (setq from
(cl-pop2 loop-args)))
+                          ((eq (car loop-args) 'to) (setq to (cl-pop2
loop-args)))
+                          ((eq (car loop-args) 'property) (setq prop
(cl-pop2 loop-args)))
+                          ((memq (car loop-args) '(in of))
+                           (or (and (eq (cadr loop-args) 'property)
+                                    (pop loop-args)
+                                    (setq prop (cl-pop2 loop-args)))
+                               (setq buf (cl-pop2 loop-args))))
+                          (t (or (and (or (stringp (car loop-args))
(bufferp (car loop-args)))
+                                      (setq buf (car loop-args)))
+                                 (error "Expected buffer or string")))))
 		  (if (and (consp var) (symbolp (car var)) (symbolp (cdr var)))
 		      (setq var1 (car var) var2 (cdr var))
 		    (push (list var (list 'cons var1 var2)) loop-for-sets))

--
/s_P\




Acknowledgement sent to MON KEY <monkey@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#7604; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 26 Feb 2016 06:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.