emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r108525: Clean up scoping rule of pre


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r108525: Clean up scoping rule of predefined single-word vars.
Date: Fri, 08 Jun 2012 09:18:26 -0400
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 108525
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Fri 2012-06-08 09:18:26 -0400
message:
  Clean up scoping rule of predefined single-word vars.
  * lisp/startup.el (argv, argi): Make lexically scoped.
  * lisp/emacs-lisp/float-sup.el (pi): Use internal-make-var-non-special.
  * lisp/emacs-lisp/cl-macs.el: Use lexical-binding.
  Rename cl-bind-* to cl--bind-*.
  * lisp/files.el: Don't require `cl' since it doesn't use it.
  * lisp/emacs-lisp/pcase.el, lisp/emacs-lisp/macroexp.el: Add coding cookie.
  * src/eval.c (Fmake_var_non_special): New primitive.
  (syms_of_eval): Defsubr it.
  * src/lread.c (syms_of_lread): Mark `values' as lexically scoped.
modified:
  lisp/ChangeLog
  lisp/emacs-lisp/cl-loaddefs.el
  lisp/emacs-lisp/cl-macs.el
  lisp/emacs-lisp/float-sup.el
  lisp/emacs-lisp/macroexp.el
  lisp/emacs-lisp/pcase.el
  lisp/files.el
  lisp/startup.el
  src/ChangeLog
  src/eval.c
  src/lread.c
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-06-08 12:24:27 +0000
+++ b/lisp/ChangeLog    2012-06-08 13:18:26 +0000
@@ -1,3 +1,12 @@
+2012-06-08  Stefan Monnier  <address@hidden>
+
+       * startup.el (argv, argi): Make lexically scoped.
+       * emacs-lisp/float-sup.el (pi): Use internal-make-var-non-special.
+       * emacs-lisp/cl-macs.el: Use lexical-binding.
+       Rename cl-bind-* to cl--bind-*.
+       * files.el: Don't require `cl' since it doesn't use it.
+       * emacs-lisp/pcase.el, emacs-lisp/macroexp.el: Add coding cookie.
+
 2012-06-08  Juanma Barranquero  <address@hidden>
 
        * textmodes/texinfmt.el: Fix bug#11640 (reverts part of revno:89810).

=== modified file 'lisp/emacs-lisp/cl-loaddefs.el'
--- a/lisp/emacs-lisp/cl-loaddefs.el    2012-06-08 08:44:45 +0000
+++ b/lisp/emacs-lisp/cl-loaddefs.el    2012-06-08 13:18:26 +0000
@@ -263,7 +263,7 @@
 ;;;;;;  cl-do* cl-do cl-loop cl-return-from cl-return cl-block cl-etypecase
 ;;;;;;  cl-typecase cl-ecase cl-case cl-load-time-value cl-eval-when
 ;;;;;;  cl-destructuring-bind cl-function cl-defmacro cl-defun cl-gentemp
-;;;;;;  cl-gensym) "cl-macs" "cl-macs.el" "ce1ef5c6c925f03cb425d9a46cfa6d5f")
+;;;;;;  cl-gensym) "cl-macs" "cl-macs.el" "07b3d08f956d6740ea1979825c84bc01")
 ;;; Generated autoloads from cl-macs.el
 
 (autoload 'cl-gensym "cl-macs" "\

=== modified file 'lisp/emacs-lisp/cl-macs.el'
--- a/lisp/emacs-lisp/cl-macs.el        2012-06-08 02:54:35 +0000
+++ b/lisp/emacs-lisp/cl-macs.el        2012-06-08 13:18:26 +0000
@@ -1,4 +1,4 @@
-;;; cl-macs.el --- Common Lisp macros
+;;; cl-macs.el --- Common Lisp macros  --*- lexical-binding: t -*-
 
 ;; Copyright (C) 1993, 2001-2012  Free Software Foundation, Inc.
 
@@ -310,8 +310,8 @@
 (defconst cl-lambda-list-keywords
   '(&optional &rest &key &allow-other-keys &aux &whole &body &environment))
 
-(defvar cl-bind-block) (defvar cl-bind-defs) (defvar cl-bind-enquote)
-(defvar cl-bind-inits) (defvar cl-bind-lets) (defvar cl-bind-forms)
+(defvar cl--bind-block) (defvar cl--bind-defs) (defvar cl--bind-enquote)
+(defvar cl--bind-inits) (defvar cl--bind-lets) (defvar cl--bind-forms)
 
 (declare-function help-add-fundoc-usage "help-fns" (docstring arglist))
 
@@ -346,20 +346,20 @@
                  ))))
             arglist)))
 
-(defun cl--transform-lambda (form cl-bind-block)
+(defun cl--transform-lambda (form bind-block)
   (let* ((args (car form)) (body (cdr form)) (orig-args args)
-        (cl-bind-defs nil) (cl-bind-enquote nil)
-        (cl-bind-inits nil) (cl-bind-lets nil) (cl-bind-forms nil)
+        (cl--bind-block bind-block) (cl--bind-defs nil) (cl--bind-enquote nil)
+        (cl--bind-inits nil) (cl--bind-lets nil) (cl--bind-forms nil)
         (header nil) (simple-args nil))
     (while (or (stringp (car body))
               (memq (car-safe (car body)) '(interactive cl-declare)))
       (push (pop body) header))
     (setq args (if (listp args) (cl-copy-list args) (list '&rest args)))
     (let ((p (last args))) (if (cdr p) (setcdr p (list '&rest (cdr p)))))
-    (if (setq cl-bind-defs (cadr (memq '&cl-defs args)))
-       (setq args (delq '&cl-defs (delq cl-bind-defs args))
-             cl-bind-defs (cadr cl-bind-defs)))
-    (if (setq cl-bind-enquote (memq '&cl-quote args))
+    (if (setq cl--bind-defs (cadr (memq '&cl-defs args)))
+       (setq args (delq '&cl-defs (delq cl--bind-defs args))
+             cl--bind-defs (cadr cl--bind-defs)))
+    (if (setq cl--bind-enquote (memq '&cl-quote args))
        (setq args (delq '&cl-quote args)))
     (if (memq '&whole args) (error "&whole not currently implemented"))
     (let* ((p (memq '&environment args)) (v (cadr p))
@@ -369,20 +369,20 @@
     (while (and args (symbolp (car args))
                (not (memq (car args) '(nil &rest &body &key &aux)))
                (not (and (eq (car args) '&optional)
-                         (or cl-bind-defs (consp (cadr args))))))
+                         (or cl--bind-defs (consp (cadr args))))))
       (push (pop args) simple-args))
-    (or (eq cl-bind-block 'cl-none)
-       (setq body (list `(cl-block ,cl-bind-block ,@body))))
+    (or (eq cl--bind-block 'cl-none)
+       (setq body (list `(cl-block ,cl--bind-block ,@body))))
     (if (null args)
        (cl-list* nil (nreverse simple-args) (nconc (nreverse header) body))
       (if (memq '&optional simple-args) (push '&optional args))
       (cl--do-arglist args nil (- (length simple-args)
                                   (if (memq '&optional simple-args) 1 0)))
-      (setq cl-bind-lets (nreverse cl-bind-lets))
-      (cl-list* (and cl-bind-inits `(cl-eval-when (compile load eval)
-                                ,@(nreverse cl-bind-inits)))
+      (setq cl--bind-lets (nreverse cl--bind-lets))
+      (cl-list* (and cl--bind-inits `(cl-eval-when (compile load eval)
+                                ,@(nreverse cl--bind-inits)))
             (nconc (nreverse simple-args)
-                   (list '&rest (car (pop cl-bind-lets))))
+                   (list '&rest (car (pop cl--bind-lets))))
             (nconc (let ((hdr (nreverse header)))
                       ;; Macro expansion can take place in the middle of
                       ;; apparently harmless computation, so it should not
@@ -395,15 +395,15 @@
                                        (cons 'fn
                                              (cl--make-usage-args orig-args))))
                               hdr)))
-                   (list `(let* ,cl-bind-lets
-                             ,@(nreverse cl-bind-forms)
+                   (list `(let* ,cl--bind-lets
+                             ,@(nreverse cl--bind-forms)
                              ,@body)))))))
 
 (defun cl--do-arglist (args expr &optional num)   ; uses bind-*
   (if (nlistp args)
       (if (or (memq args cl-lambda-list-keywords) (not (symbolp args)))
          (error "Invalid argument name: %s" args)
-       (push (list args expr) cl-bind-lets))
+       (push (list args expr) cl--bind-lets))
     (setq args (cl-copy-list args))
     (let ((p (last args))) (if (cdr p) (setcdr p (list '&rest (cdr p)))))
     (let ((p (memq '&body args))) (if p (setcar p '&rest)))
@@ -417,9 +417,9 @@
       (if (listp (cadr restarg))
          (setq restarg (make-symbol "--cl-rest--"))
        (setq restarg (cadr restarg)))
-      (push (list restarg expr) cl-bind-lets)
+      (push (list restarg expr) cl--bind-lets)
       (if (eq (car args) '&whole)
-         (push (list (cl-pop2 args) restarg) cl-bind-lets))
+         (push (list (cl-pop2 args) restarg) cl--bind-lets))
       (let ((p args))
        (setq minarg restarg)
        (while (and p (not (memq (car p) cl-lambda-list-keywords)))
@@ -437,8 +437,8 @@
           (if (or laterarg (= safety 0)) poparg
             `(if ,minarg ,poparg
                 (signal 'wrong-number-of-arguments
-                        (list ,(and (not (eq cl-bind-block 'cl-none))
-                                    `',cl-bind-block)
+                        (list ,(and (not (eq cl--bind-block 'cl-none))
+                                    `',cl--bind-block)
                               (length ,restarg)))))))
        (setq num (1+ num) laterarg t))
       (while (and (eq (car args) '&optional) (pop args))
@@ -447,10 +447,10 @@
            (or (consp arg) (setq arg (list arg)))
            (if (cddr arg) (cl--do-arglist (nth 2 arg) `(and ,restarg t)))
            (let ((def (if (cdr arg) (nth 1 arg)
-                        (or (car cl-bind-defs)
-                            (nth 1 (assq (car arg) cl-bind-defs)))))
+                        (or (car cl--bind-defs)
+                            (nth 1 (assq (car arg) cl--bind-defs)))))
                  (poparg `(pop ,restarg)))
-             (and def cl-bind-enquote (setq def `',def))
+             (and def cl--bind-enquote (setq def `',def))
              (cl--do-arglist (car arg)
                             (if def `(if ,restarg ,poparg ,def) poparg))
              (setq num (1+ num))))))
@@ -461,10 +461,10 @@
            (push `(if ,restarg
                        (signal 'wrong-number-of-arguments
                                (list
-                                ,(and (not (eq cl-bind-block 'cl-none))
-                                      `',cl-bind-block)
+                                ,(and (not (eq cl--bind-block 'cl-none))
+                                      `',cl--bind-block)
                                 (+ ,num (length ,restarg)))))
-                  cl-bind-forms)))
+                  cl--bind-forms)))
       (while (and (eq (car args) '&key) (pop args))
        (while (and args (not (memq (car args) cl-lambda-list-keywords)))
          (let ((arg (pop args)))
@@ -473,9 +473,9 @@
                           (intern (format ":%s" (car arg)))))
                   (varg (if (consp (car arg)) (cl-cadar arg) (car arg)))
                   (def (if (cdr arg) (cadr arg)
-                         (or (car cl-bind-defs) (cadr (assq varg 
cl-bind-defs)))))
+                         (or (car cl--bind-defs) (cadr (assq varg 
cl--bind-defs)))))
                   (look `(memq ',karg ,restarg)))
-             (and def cl-bind-enquote (setq def `',def))
+             (and def cl--bind-enquote (setq def `',def))
              (if (cddr arg)
                  (let* ((temp (or (nth 2 arg) (make-symbol "--cl-var--")))
                         (val `(car (cdr ,temp))))
@@ -509,11 +509,11 @@
                               ,(format "Keyword argument %%s not one of %s"
                                        keys)
                               (car ,var)))))))
-           (push `(let ((,var ,restarg)) ,check) cl-bind-forms)))
+           (push `(let ((,var ,restarg)) ,check) cl--bind-forms)))
       (while (and (eq (car args) '&aux) (pop args))
        (while (and args (not (memq (car args) cl-lambda-list-keywords)))
          (if (consp (car args))
-             (if (and cl-bind-enquote (cl-cadar args))
+             (if (and cl--bind-enquote (cl-cadar args))
                  (cl--do-arglist (caar args)
                                 `',(cadr (pop args)))
                (cl--do-arglist (caar args) (cadr (pop args))))
@@ -536,12 +536,12 @@
 (defmacro cl-destructuring-bind (args expr &rest body)
   (declare (indent 2)
            (debug (&define cl-macro-list def-form cl-declarations def-body)))
-  (let* ((cl-bind-lets nil) (cl-bind-forms nil) (cl-bind-inits nil)
-        (cl-bind-defs nil) (cl-bind-block 'cl-none) (cl-bind-enquote nil))
+  (let* ((cl--bind-lets nil) (cl--bind-forms nil) (cl--bind-inits nil)
+        (cl--bind-defs nil) (cl--bind-block 'cl-none) (cl--bind-enquote nil))
     (cl--do-arglist (or args '(&aux)) expr)
-    (append '(progn) cl-bind-inits
-           (list `(let* ,(nreverse cl-bind-lets)
-                     ,@(nreverse cl-bind-forms) ,@body)))))
+    (append '(progn) cl--bind-inits
+           (list `(let* ,(nreverse cl--bind-lets)
+                     ,@(nreverse cl--bind-forms) ,@body)))))
 
 
 ;;; The `cl-eval-when' form.
@@ -582,7 +582,7 @@
        (t (eval form) form)))
 
 ;;;###autoload
-(defmacro cl-load-time-value (form &optional read-only)
+(defmacro cl-load-time-value (form &optional _read-only)
   "Like `progn', but evaluates the body at load time.
 The result of the body appears to the compiler as a quoted constant."
   (declare (debug (form &optional sexp)))
@@ -734,7 +734,7 @@
 (defvar cl--loop-result-var) (defvar cl--loop-steps) (defvar 
cl--loop-symbol-macs)
 
 ;;;###autoload
-(defmacro cl-loop (&rest cl--loop-args)
+(defmacro cl-loop (&rest loop-args)
   "The Common Lisp `cl-loop' macro.
 Valid clauses are:
   for VAR from/upfrom/downfrom NUM to/upto/downto/above/below NUM by NUM,
@@ -750,9 +750,9 @@
 
 \(fn CLAUSE...)"
   (declare (debug (&rest &or symbolp form)))
-  (if (not (memq t (mapcar 'symbolp (delq nil (delq t (cl-copy-list 
cl--loop-args))))))
-      `(cl-block nil (while t ,@cl--loop-args))
-    (let ((cl--loop-name nil)  (cl--loop-bindings nil)
+  (if (not (memq t (mapcar 'symbolp (delq nil (delq t (cl-copy-list 
loop-args))))))
+      `(cl-block nil (while t ,@loop-args))
+    (let ((cl--loop-args loop-args) (cl--loop-name nil) (cl--loop-bindings nil)
          (cl--loop-body nil)   (cl--loop-steps nil)
          (cl--loop-result nil) (cl--loop-result-explicit nil)
          (cl--loop-result-var nil) (cl--loop-finish-flag nil)
@@ -1807,7 +1807,7 @@
   (declare (debug t))
   (cons 'progn body))
 ;;;###autoload
-(defmacro cl-the (type form)
+(defmacro cl-the (_type form)
   (declare (indent 1) (debug (cl-type-spec form)))
   form)
 
@@ -2386,8 +2386,8 @@
   (declare (indent 1) (debug ((&rest (gate place &optional form)) body)))
   (if (and (not (cdr bindings)) (cdar bindings) (symbolp (caar bindings)))
       `(let ,bindings ,@body)
-    (let ((lets nil) (sets nil)
-         (unsets nil) (rev (reverse bindings)))
+    (let ((lets nil)
+          (rev (reverse bindings)))
       (while rev
        (let* ((place (if (symbolp (caar rev))
                          `(symbol-value ',(caar rev))
@@ -2822,11 +2822,13 @@
          ((eq (car type) 'satisfies) (list (cadr type) val))
          (t (error "Bad type spec: %s" type)))))
 
+(defvar cl--object)
 ;;;###autoload
 (defun cl-typep (object type)   ; See compiler macro below.
   "Check that OBJECT is of type TYPE.
 TYPE is a Common Lisp-style type specifier."
-  (eval (cl--make-type-test 'object type)))
+  (let ((cl--object object)) ;; Yuck!!
+    (eval (cl--make-type-test 'cl--object type))))
 
 ;;;###autoload
 (defmacro cl-check-type (form type &optional string)

=== modified file 'lisp/emacs-lisp/float-sup.el'
--- a/lisp/emacs-lisp/float-sup.el      2012-01-19 07:21:25 +0000
+++ b/lisp/emacs-lisp/float-sup.el      2012-06-08 13:18:26 +0000
@@ -28,13 +28,9 @@
 ;; Provide an easy hook to tell if we are running with floats or not.
 ;; Define pi and e via math-lib calls (much less prone to killer typos).
 (defconst float-pi (* 4 (atan 1)) "The value of Pi (3.1415926...).")
-(progn
-  ;; Simulate a defconst that doesn't declare the variable dynamically bound.
-  (setq-default pi float-pi)
-  (put 'pi 'variable-documentation
-       "Obsolete since Emacs-23.3.  Use `float-pi' instead.")
-  (put 'pi 'risky-local-variable t)
-  (push 'pi current-load-list))
+(defconst pi float-pi
+  "Obsolete since Emacs-23.3.  Use `float-pi' instead.")
+(internal-make-var-non-special 'pi)
 
 (defconst float-e (exp 1) "The value of e (2.7182818...).")
 

=== modified file 'lisp/emacs-lisp/macroexp.el'
--- a/lisp/emacs-lisp/macroexp.el       2012-06-08 02:54:35 +0000
+++ b/lisp/emacs-lisp/macroexp.el       2012-06-08 13:18:26 +0000
@@ -1,4 +1,4 @@
-;;; macroexp.el --- Additional macro-expansion support -*- lexical-binding: t 
-*-
+;;; macroexp.el --- Additional macro-expansion support -*- lexical-binding: t; 
coding: utf-8 -*-
 ;;
 ;; Copyright (C) 2004-2012 Free Software Foundation, Inc.
 ;;

=== modified file 'lisp/emacs-lisp/pcase.el'
--- a/lisp/emacs-lisp/pcase.el  2012-06-07 19:25:48 +0000
+++ b/lisp/emacs-lisp/pcase.el  2012-06-08 13:18:26 +0000
@@ -1,4 +1,4 @@
-;;; pcase.el --- ML-style pattern-matching macro for Elisp -*- 
lexical-binding: t -*-
+;;; pcase.el --- ML-style pattern-matching macro for Elisp -*- 
lexical-binding: t; coding: utf-8 -*-
 
 ;; Copyright (C) 2010-2012  Free Software Foundation, Inc.
 

=== modified file 'lisp/files.el'
--- a/lisp/files.el     2012-06-06 12:34:09 +0000
+++ b/lisp/files.el     2012-06-08 13:18:26 +0000
@@ -28,8 +28,6 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl))
-
 (defvar font-lock-keywords)
 
 (defgroup backup nil

=== modified file 'lisp/startup.el'
--- a/lisp/startup.el   2012-04-27 05:40:46 +0000
+++ b/lisp/startup.el   2012-06-08 13:18:26 +0000
@@ -101,16 +101,15 @@
   "List of command-line args not yet processed.")
 
 (defvaralias 'argv 'command-line-args-left
-  ;; FIXME: Bad name for a dynamically bound variable.
   "List of command-line args not yet processed.
 This is a convenience alias, so that one can write \(pop argv\)
 inside of --eval command line arguments in order to access
 following arguments.")
+(internal-make-var-non-special 'argv)
 
-(with-no-warnings
-  ;; FIXME: Bad name for a dynamically bound variable
-  (defvar argi nil
-    "Current command-line argument."))
+(defvar argi nil
+  "Current command-line argument.")
+(internal-make-var-non-special 'argi)
 
 (defvar command-line-functions nil    ;; lrs 7/31/89
   "List of functions to process unrecognized command-line arguments.

=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-06-08 12:19:28 +0000
+++ b/src/ChangeLog     2012-06-08 13:18:26 +0000
@@ -1,3 +1,9 @@
+2012-06-08  Stefan Monnier  <address@hidden>
+
+       * eval.c (Fmake_var_non_special): New primitive.
+       (syms_of_eval): Defsubr it.
+       * lread.c (syms_of_lread): Mark `values' as lexically scoped.
+
 2012-06-08  Juanma Barranquero  <address@hidden>
 
        * dispnew.c (showing_window_margins_p): Wrap in #if 0 to prevent unused
@@ -23,7 +29,7 @@
        (roundup_size): New constant.
        (struct vector_block): New data type.
        (vector_blocks, vector_free_lists, zero_vector): New variables.
-       (all_vectors): Renamed to `large_vectors'.
+       (all_vectors): Rename to `large_vectors'.
        (allocate_vector_from_block, init_vectors, allocate_vector_from_block)
        (sweep_vectors): New functions.
        (allocate_vectorlike): Return `zero_vector' as the only vector of

=== modified file 'src/eval.c'
--- a/src/eval.c        2012-06-08 02:47:26 +0000
+++ b/src/eval.c        2012-06-08 13:18:26 +0000
@@ -790,6 +790,17 @@
   return sym;
 }
 
+/* Make SYMBOL lexically scoped.  */
+DEFUN ("internal-make-var-non-special", Fmake_var_non_special,
+       Smake_var_non_special, 1, 1, 0,
+       doc: /* Internal function.  */)
+     (Lisp_Object symbol)
+{
+  CHECK_SYMBOL (symbol);
+  XSYMBOL (symbol)->declared_special = 0;
+  return Qnil;
+}
+
 
 DEFUN ("let*", FletX, SletX, 1, UNEVALLED, 0,
        doc: /* Bind variables according to VARLIST then eval BODY.
@@ -3582,6 +3593,7 @@
   defsubr (&Sdefvar);
   defsubr (&Sdefvaralias);
   defsubr (&Sdefconst);
+  defsubr (&Smake_var_non_special);
   defsubr (&Slet);
   defsubr (&SletX);
   defsubr (&Swhile);

=== modified file 'src/lread.c'
--- a/src/lread.c       2012-05-30 03:59:42 +0000
+++ b/src/lread.c       2012-06-08 13:18:26 +0000
@@ -4375,7 +4375,8 @@
 
   DEFVAR_LISP ("values", Vvalues,
               doc: /* List of values of all expressions which were read, 
evaluated and printed.
-Order is reverse chronological.  */);
+                      Order is reverse chronological.  */);
+  XSYMBOL (intern ("values"))->declared_special = 0;
 
   DEFVAR_LISP ("standard-input", Vstandard_input,
               doc: /* Stream for read to get input from.
@@ -4393,7 +4394,7 @@
 
 The positions are relative to the last call to `read' or
 `read-from-string'.  It is probably a bad idea to set this variable at
-the toplevel; bind it instead. */);
+the toplevel; bind it instead.  */);
   Vread_with_symbol_positions = Qnil;
 
   DEFVAR_LISP ("read-symbol-positions-list", Vread_symbol_positions_list,
@@ -4408,7 +4409,7 @@
 
 Note that a symbol will appear multiple times in this list, if it was
 read multiple times.  The list is in the same order as the symbols
-were read in. */);
+were read in.  */);
   Vread_symbol_positions_list = Qnil;
 
   DEFVAR_LISP ("read-circle", Vread_circle,


reply via email to

[Prev in Thread] Current Thread [Next in Thread]