aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2012-06-27 10:39:30 -0400
committerStefan Monnier2012-06-27 10:39:30 -0400
commit6e9590e26c31ee3056c5abc347381ee35d49363b (patch)
tree01ca3b7896eca3a1e93aa1a9ebf878918fbfddb4
parent246155ebec6d2d2c0243f12b2a23b459fc6c8a99 (diff)
downloademacs-6e9590e26c31ee3056c5abc347381ee35d49363b.tar.gz
emacs-6e9590e26c31ee3056c5abc347381ee35d49363b.zip
* lisp/emacs-lisp/cl.el: Use lexical-binding. Fix flet.
(cl--symbol-function): New macro. (cl--letf, cl--letf*): Use it. Fixes: debbugs:11780
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/emacs-lisp/cl.el21
2 files changed, 21 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 0de89c47990..180f87e46b0 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,9 @@
12012-06-27 Stefan Monnier <monnier@iro.umontreal.ca> 12012-06-27 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * emacs-lisp/cl.el: Use lexical-binding. Fix flet (bug#11780).
4 (cl--symbol-function): New macro.
5 (cl--letf, cl--letf*): Use it.
6
3 * emacs-lisp/easy-mmode.el (easy-mmode-pretty-mode-name): 7 * emacs-lisp/easy-mmode.el (easy-mmode-pretty-mode-name):
4 Strip "toggle-" if any. 8 Strip "toggle-" if any.
5 9
diff --git a/lisp/emacs-lisp/cl.el b/lisp/emacs-lisp/cl.el
index b17d6f4e671..7996af4e02d 100644
--- a/lisp/emacs-lisp/cl.el
+++ b/lisp/emacs-lisp/cl.el
@@ -1,4 +1,4 @@
1;;; cl.el --- Compatibility aliases for the old CL library. 1;;; cl.el --- Compatibility aliases for the old CL library. -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2012 Free Software Foundation, Inc. 3;; Copyright (C) 2012 Free Software Foundation, Inc.
4 4
@@ -235,7 +235,6 @@
235 multiple-value-bind 235 multiple-value-bind
236 symbol-macrolet 236 symbol-macrolet
237 macrolet 237 macrolet
238 flet
239 progv 238 progv
240 psetq 239 psetq
241 do-all-symbols 240 do-all-symbols
@@ -450,6 +449,16 @@ Common Lisp.
450 (setq body (list `(lexical-let (,(pop bindings)) ,@body)))) 449 (setq body (list `(lexical-let (,(pop bindings)) ,@body))))
451 (car body))) 450 (car body)))
452 451
452(defmacro cl--symbol-function (symbol)
453 "Like `symbol-function' but return `cl--unbound' if not bound."
454 ;; (declare (gv-setter (lambda (store)
455 ;; `(if (eq ,store 'cl--unbound)
456 ;; (fmakunbound ,symbol) (fset ,symbol ,store)))))
457 `(if (fboundp ,symbol) (symbol-function ,symbol) 'cl--unbound))
458(gv-define-setter cl--symbol-function (store symbol)
459 `(if (eq ,store 'cl--unbound) (fmakunbound ,symbol) (fset ,symbol ,store)))
460
461
453;; This should really have some way to shadow 'byte-compile properties, etc. 462;; This should really have some way to shadow 'byte-compile properties, etc.
454(defmacro flet (bindings &rest body) 463(defmacro flet (bindings &rest body)
455 "Make temporary function definitions. 464 "Make temporary function definitions.
@@ -543,6 +552,8 @@ Unlike `flet', this macro is fully compliant with the Common Lisp standard.
543 (funcall setter vold))) 552 (funcall setter vold)))
544 binds)))) 553 binds))))
545 (let ((binding (car bindings))) 554 (let ((binding (car bindings)))
555 (if (eq (car-safe (car binding)) 'symbol-function)
556 (setcar (car binding) 'cl--symbol-function))
546 (gv-letplace (getter setter) (car binding) 557 (gv-letplace (getter setter) (car binding)
547 (macroexp-let2 nil vnew (cadr binding) 558 (macroexp-let2 nil vnew (cadr binding)
548 (if (symbolp (car binding)) 559 (if (symbolp (car binding))
@@ -579,7 +590,9 @@ the PLACE is not modified before executing BODY.
579 ;; Special-case for simple variables. 590 ;; Special-case for simple variables.
580 (macroexp-let* (list (if (cdr binding) binding 591 (macroexp-let* (list (if (cdr binding) binding
581 (list (car binding) (car binding)))) 592 (list (car binding) (car binding))))
582 (cl--letf* (cdr bindings) body)) 593 (cl--letf* (cdr bindings) body))
594 (if (eq (car-safe (car binding)) 'symbol-function)
595 (setcar (car binding) 'cl--symbol-function))
583 (gv-letplace (getter setter) (car binding) 596 (gv-letplace (getter setter) (car binding)
584 (macroexp-let2 macroexp-copyable-p vnew (cadr binding) 597 (macroexp-let2 macroexp-copyable-p vnew (cadr binding)
585 (macroexp-let2 nil vold getter 598 (macroexp-let2 nil vold getter
@@ -736,7 +749,7 @@ from ARGLIST using FUNC: (define-modify-macro incf (&optional (n 1)) +)"
736;; This is just kept for compatibility with code byte-compiled by Emacs-20. 749;; This is just kept for compatibility with code byte-compiled by Emacs-20.
737 750
738;; No idea if this might still be needed. 751;; No idea if this might still be needed.
739(defun cl-not-hash-table (x &optional y &rest z) 752(defun cl-not-hash-table (x &optional y &rest _z)
740 (declare (obsolete nil "24.2")) 753 (declare (obsolete nil "24.2"))
741 (signal 'wrong-type-argument (list 'cl-hash-table-p (or y x)))) 754 (signal 'wrong-type-argument (list 'cl-hash-table-p (or y x))))
742 755