From: MON KEY <monkey@sandpframing.com>
To: 7604@debbugs.gnu.org
Subject: bug#7604: `loop', PATCH: loop, cl-parse-loop-clause, cl-map-intervals -- being the intervals of
Date: Thu, 9 Dec 2010 20:30:03 -0500 [thread overview]
Message-ID: <AANLkTimXrkuKmQeUdSbyaAEJsxq9KTX5VSW1jSpDUumr@mail.gmail.com> (raw)
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\
next reply other threads:[~2010-12-10 1:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-10 1:30 MON KEY [this message]
2016-02-26 6:27 ` bug#7604: `loop', PATCH: loop, cl-parse-loop-clause, cl-map-intervals -- being the intervals of Lars Ingebrigtsen
2019-06-27 16:45 ` Lars Ingebrigtsen
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=AANLkTimXrkuKmQeUdSbyaAEJsxq9KTX5VSW1jSpDUumr@mail.gmail.com \
--to=monkey@sandpframing.com \
--cc=7604@debbugs.gnu.org \
/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.