aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Schmidt2012-05-06 11:38:30 -0400
committerStefan Monnier2012-05-06 11:38:30 -0400
commite129292c44b6392adadb27bbd4bce94893316ff9 (patch)
treeba16b85e97be381c3166836e8db98b03bad73e66
parent491503ddd21cae26d3e349e39ee2e139680a220f (diff)
downloademacs-e129292c44b6392adadb27bbd4bce94893316ff9.tar.gz
emacs-e129292c44b6392adadb27bbd4bce94893316ff9.zip
* lisp/emacs-lisp/cl-macs.el (cl-expr-contains): Handle cons cells
whose cdr is not a cons cell correctly. Fixes: debbugs:11038
-rw-r--r--lisp/ChangeLog17
-rw-r--r--lisp/emacs-lisp/cl-macs.el7
2 files changed, 17 insertions, 7 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 929451a85ed..afa4ae803f9 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,18 +1,23 @@
12012-05-06 Christopher Schmidt <christopher@ch.ristopher.com>
2
3 * emacs-lisp/cl-macs.el (cl-expr-contains): Handle cons cells
4 whose cdr is not a cons cell correctly (bug#11038).
5
12012-05-06 Chong Yidong <cyd@gnu.org> 62012-05-06 Chong Yidong <cyd@gnu.org>
2 7
3 * emacs-lisp/tabulated-list.el (tabulated-list-format): Accept 8 * emacs-lisp/tabulated-list.el (tabulated-list-format):
4 additional plist in column descriptors. 9 Accept additional plist in column descriptors.
5 (tabulated-list-init-header): Obey it. 10 (tabulated-list-init-header): Obey it.
6 (tabulated-list-get-entry): New function. 11 (tabulated-list-get-entry): New function.
7 (tabulated-list-put-tag): Use it. Use string-width instead of 12 (tabulated-list-put-tag): Use it. Use string-width instead of
8 length. 13 length.
9 (tabulated-list--column-number): New function. 14 (tabulated-list--column-number): New function.
10 (tabulated-list-print): Use it. 15 (tabulated-list-print): Use it.
11 (tabulated-list-print-col): New function. Set 16 (tabulated-list-print-col): New function.
12 `tabulated-list-column-name' property on each column's text. 17 Set `tabulated-list-column-name' property on each column's text.
13 (tabulated-list-print-entry): Use it. 18 (tabulated-list-print-entry): Use it.
14 (tabulated-list-delete-entry, tabulated-list-set-col): New 19 (tabulated-list-delete-entry, tabulated-list-set-col):
15 functions. 20 New functions.
16 (tabulated-list-sort-column): New command (Bug#11337). 21 (tabulated-list-sort-column): New command (Bug#11337).
17 22
18 * buff-menu.el (list-buffers): Move C-x C-b binding from 23 * buff-menu.el (list-buffers): Move C-x C-b binding from
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 35cda8cfcf6..8050da400fe 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -143,11 +143,16 @@
143 143
144;;; Count number of times X refers to Y. Return nil for 0 times. 144;;; Count number of times X refers to Y. Return nil for 0 times.
145(defun cl-expr-contains (x y) 145(defun cl-expr-contains (x y)
146 ;; FIXME: This is naive, and it will count Y as referred twice in
147 ;; (let ((Y 1)) Y) even though it should be 0. Also it is often called on
148 ;; non-macroexpanded code, so it may also miss some occurrences that would
149 ;; only appear in the expanded code.
146 (cond ((equal y x) 1) 150 (cond ((equal y x) 1)
147 ((and (consp x) (not (memq (car-safe x) '(quote function function*)))) 151 ((and (consp x) (not (memq (car-safe x) '(quote function function*))))
148 (let ((sum 0)) 152 (let ((sum 0))
149 (while x 153 (while (consp x)
150 (setq sum (+ sum (or (cl-expr-contains (pop x) y) 0)))) 154 (setq sum (+ sum (or (cl-expr-contains (pop x) y) 0))))
155 (setq sum (+ sum (or (cl-expr-contains x y) 0)))
151 (and (> sum 0) sum))) 156 (and (> sum 0) sum)))
152 (t nil))) 157 (t nil)))
153 158