emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 197fbfc: * lisp/subr.el (setq-default): Define as a


From: Stefan Monnier
Subject: [Emacs-diffs] master 197fbfc: * lisp/subr.el (setq-default): Define as a macro
Date: Mon, 1 Apr 2019 12:35:16 -0400 (EDT)

branch: master
commit 197fbfc71f49b307baa3831a30732c3a0c4c7420
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    * lisp/subr.el (setq-default): Define as a macro
    
    * lisp/emacs-lisp/bytecomp.el (byte-compile-setq-default): Delete.
    (byte-compile-set-default): Inline the part that it used.
    
    * lisp/emacs-lisp/edebug.el (setq-default): Remove the debug spec.
    
    * src/data.c (Fsetq_default): Delete.
    (syms_of_data): Don't register.
---
 lisp/abbrev.el              |  3 +--
 lisp/emacs-lisp/bytecomp.el | 35 ++++++++++-------------------------
 lisp/emacs-lisp/edebug.el   |  1 -
 lisp/subr.el                | 20 ++++++++++++++++++++
 src/data.c                  | 31 -------------------------------
 5 files changed, 31 insertions(+), 59 deletions(-)

diff --git a/lisp/abbrev.el b/lisp/abbrev.el
index 855d80c..3c88ec6 100644
--- a/lisp/abbrev.el
+++ b/lisp/abbrev.el
@@ -940,8 +940,7 @@ If READABLE is nil, an expression is inserted.  The 
expression is
 a call to `define-abbrev-table' that when evaluated will define
 the abbrev table NAME exactly as it is currently defined.
 Abbrevs marked as \"system abbrevs\" are ignored."
-  (let ((table (symbol-value name))
-        (symbols (abbrev--table-symbols name readable)))
+  (let ((symbols (abbrev--table-symbols name readable)))
     (setq symbols (sort symbols 'string-lessp))
     (let ((standard-output (current-buffer)))
       (if readable
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 66b40a8..9dd5151 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -3910,7 +3910,6 @@ discarding."
 
 
 (byte-defop-compiler-1 setq)
-(byte-defop-compiler-1 setq-default)
 (byte-defop-compiler-1 quote)
 
 (defun byte-compile-setq (form)
@@ -3935,34 +3934,20 @@ discarding."
         (byte-compile-form nil byte-compile--for-effect)))
     (setq byte-compile--for-effect nil)))
 
-(defun byte-compile-setq-default (form)
-  (setq form (cdr form))
-  (if (null form)                      ; (setq-default), with no arguments
-      (byte-compile-form nil byte-compile--for-effect)
-    (if (> (length form) 2)
-       (let ((setters ()))
-         (while (consp form)
-           (push `(setq-default ,(pop form) ,(pop form)) setters))
-         (byte-compile-form (cons 'progn (nreverse setters))))
-      (let ((var (car form)))
-       (and (or (not (symbolp var))
-                (macroexp--const-symbol-p var t))
-            (byte-compile-warning-enabled-p 'constants)
-            (byte-compile-warn
-             "variable assignment to %s `%s'"
-             (if (symbolp var) "constant" "nonvariable")
-             (prin1-to-string var)))
-       (byte-compile-normal-call `(set-default ',var ,@(cdr form)))))))
-
 (byte-defop-compiler-1 set-default)
 (defun byte-compile-set-default (form)
   (let ((varexp (car-safe (cdr-safe form))))
     (if (eq (car-safe varexp) 'quote)
-        ;; If the varexp is constant, compile it as a setq-default
-        ;; so we get more warnings.
-        (byte-compile-setq-default `(setq-default ,(car-safe (cdr varexp))
-                                                  ,@(cddr form)))
-      (byte-compile-normal-call form))))
+        ;; If the varexp is constant, check the var's name.
+        (let ((var (car-safe (cdr varexp))))
+          (and (or (not (symbolp var))
+                  (macroexp--const-symbol-p var t))
+               (byte-compile-warning-enabled-p 'constants)
+               (byte-compile-warn
+               "variable assignment to %s `%s'"
+               (if (symbolp var) "constant" "nonvariable")
+               (prin1-to-string var)))))
+    (byte-compile-normal-call form)))
 
 (defun byte-compile-quote (form)
   (byte-compile-constant (car (cdr form))))
diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el
index 8b4cb1a..6dfcc24 100644
--- a/lisp/emacs-lisp/edebug.el
+++ b/lisp/emacs-lisp/edebug.el
@@ -2165,7 +2165,6 @@ into `edebug--cl-macrolet-defs' which is checked in 
`edebug-list-form-args'."
 (def-edebug-spec let* let)
 
 (def-edebug-spec setq (&rest symbolp form))
-(def-edebug-spec setq-default setq)
 
 (def-edebug-spec cond (&rest (&rest form)))
 
diff --git a/lisp/subr.el b/lisp/subr.el
index f1a1ddd..6a9492a 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -118,6 +118,26 @@ BODY should be a list of Lisp expressions.
   ;; depend on backquote.el.
   (list 'function (cons 'lambda cdr)))
 
+(defmacro setq-default (&rest args)
+  "Set the default value of variable VAR to VALUE.
+VAR, the variable name, is literal (not evaluated);
+VALUE is an expression: it is evaluated and its value returned.
+The default value of a variable is seen in buffers
+that do not have their own values for the variable.
+
+More generally, you can use multiple variables and values, as in
+  (setq-default VAR VALUE VAR VALUE...)
+This sets each VAR's default value to the corresponding VALUE.
+The VALUE for the Nth VAR can refer to the new default values
+of previous VARs.
+
+\(setq-default [VAR VALUE]...)"
+  (declare (debug setq))
+  (let ((exps nil))
+    (while args
+      (push `(set-default ',(pop args) ,(pop args)) exps))
+    `(progn . ,(nreverse exps))))
+
 (defmacro setq-local (var val)
   "Set variable VAR to value VAL in current buffer."
   ;; Can't use backquote here, it's too early in the bootstrap.
diff --git a/src/data.c b/src/data.c
index 15b6106..30c578d 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1744,36 +1744,6 @@ for this variable.  */)
   set_default_internal (symbol, value, SET_INTERNAL_SET);
   return value;
 }
-
-DEFUN ("setq-default", Fsetq_default, Ssetq_default, 0, UNEVALLED, 0,
-       doc: /* Set the default value of variable VAR to VALUE.
-VAR, the variable name, is literal (not evaluated);
-VALUE is an expression: it is evaluated and its value returned.
-The default value of a variable is seen in buffers
-that do not have their own values for the variable.
-
-More generally, you can use multiple variables and values, as in
-  (setq-default VAR VALUE VAR VALUE...)
-This sets each VAR's default value to the corresponding VALUE.
-The VALUE for the Nth VAR can refer to the new default values
-of previous VARs.
-usage: (setq-default [VAR VALUE]...)  */)
-  (Lisp_Object args)
-{
-  Lisp_Object args_left, symbol, val;
-
-  args_left = val = args;
-
-  while (CONSP (args_left))
-    {
-      val = eval_sub (Fcar (XCDR (args_left)));
-      symbol = XCAR (args_left);
-      Fset_default (symbol, val);
-      args_left = Fcdr (XCDR (args_left));
-    }
-
-  return val;
-}
 
 /* Lisp functions for creating and removing buffer-local variables.  */
 
@@ -4047,7 +4017,6 @@ syms_of_data (void)
   defsubr (&Sdefault_boundp);
   defsubr (&Sdefault_value);
   defsubr (&Sset_default);
-  defsubr (&Ssetq_default);
   defsubr (&Smake_variable_buffer_local);
   defsubr (&Smake_local_variable);
   defsubr (&Skill_local_variable);



reply via email to

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