From: Christopher Schmidt <christopher@ch.ristopher.com>
To: 11038@debbugs.gnu.org
Subject: bug#11038: 24.0.94; 24.0.94; cl loop macroexpand fails with (wrong-type-argument listp emacs)
Date: Sun, 06 May 2012 16:53:45 +0200 [thread overview]
Message-ID: <20120506145346.625342027A@saturn.ch.ristopher.com> (raw)
In-Reply-To: <jwvsjh6u1xo.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sat, 17 Mar 2012 21:37:42 -0400")
[-- Attachment #1: Type: text/plain, Size: 494 bytes --]
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> Indeed, there's a bug in cl-expr-contains because it does not
> correctly handle all forms of Elisp. This is a very long standing
> bug. It might be possible to fix it by macro-expanding the code
> before calling cl-expr-contains, but since I'm not familiar with
> `loop' nor with its implementation, I'd rather let someone else write
> the corresponding patch (which may have to wait for 24.2).
Here is an (admittedly very naive) patch.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: cl-expr-contains.diff --]
[-- Type: text/x-diff, Size: 1607 bytes --]
=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog 2012-05-06 08:43:46 +0000
+++ lisp/ChangeLog 2012-05-06 13:47:05 +0000
@@ -1,3 +1,8 @@
+2012-05-06 Christopher Schmidt <christopher@ch.ristopher.com>
+
+ * emacs-lisp/cl-macs.el (cl-expr-contains): Handle cons cells
+ whose cdr is not a cons cell correctly (Bug#11038).
+
2012-05-06 Chong Yidong <cyd@gnu.org>
* emacs-lisp/tabulated-list.el (tabulated-list-format): Accept
=== modified file 'lisp/emacs-lisp/cl-loaddefs.el'
--- lisp/emacs-lisp/cl-loaddefs.el 2012-04-26 03:18:47 +0000
+++ lisp/emacs-lisp/cl-loaddefs.el 2012-05-06 13:50:33 +0000
@@ -286,7 +286,7 @@
;;;;;; flet progv psetq do-all-symbols do-symbols dotimes dolist
;;;;;; do* do loop return-from return block etypecase typecase ecase
;;;;;; case load-time-value eval-when destructuring-bind function*
-;;;;;; defmacro* defun* gentemp gensym) "cl-macs" "cl-macs.el" "abb2e33c6f61539d69ddbe7c4046261b")
+;;;;;; defmacro* defun* gentemp gensym) "cl-macs" "cl-macs.el" "69f391c482a4981642368c6716aacfc8")
;;; Generated autoloads from cl-macs.el
(autoload 'gensym "cl-macs" "\
=== modified file 'lisp/emacs-lisp/cl-macs.el'
--- lisp/emacs-lisp/cl-macs.el 2012-04-26 03:18:47 +0000
+++ lisp/emacs-lisp/cl-macs.el 2012-05-06 13:36:29 +0000
@@ -146,8 +146,9 @@
(cond ((equal y x) 1)
((and (consp x) (not (memq (car-safe x) '(quote function function*))))
(let ((sum 0))
- (while x
+ (while (consp x)
(setq sum (+ sum (or (cl-expr-contains (pop x) y) 0))))
+ (setq sum (+ sum (or (cl-expr-contains x y) 0)))
(and (> sum 0) sum)))
(t nil)))
[-- Attachment #3: Type: text/plain, Size: 504 bytes --]
I grepped through the sources of cl.*\.el. cl-expr-contains and
cl-expr-contains-any are not specific to the loop implementation. I
think the functions do what their names say, inspect an expression and
count occurrences of symbols. The comment above cl-expr-contains says
so as well (";;; Count number of times X refers to Y. Return nil for 0
times.").
I tested my patch for a few hours with my configuration that makes heavy
use of cl. I have not run in any problem so far.
Christopher
next prev parent reply other threads:[~2012-05-06 14:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-17 22:27 bug#11038: 24.0.94; 24.0.94; cl loop macroexpand fails with (wrong-type-argument listp emacs) Christopher Schmidt
2012-03-18 1:37 ` Stefan Monnier
2012-05-06 14:53 ` Christopher Schmidt [this message]
2012-05-06 15:39 ` Stefan Monnier
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=20120506145346.625342027A@saturn.ch.ristopher.com \
--to=christopher@ch.ristopher.com \
--cc=11038@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.