emacs-diffs
[Top][All Lists]
Advanced

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

master a889977e0b: CC Mode: Don't bind max-specpdl-size when it doesn't


From: Alan Mackenzie
Subject: master a889977e0b: CC Mode: Don't bind max-specpdl-size when it doesn't exist or is obsolete
Date: Tue, 27 Sep 2022 04:40:45 -0400 (EDT)

branch: master
commit a889977e0bfc6888cc8201133aa65b8a2b773def
Author: Alan Mackenzie <acm@muc.de>
Commit: Alan Mackenzie <acm@muc.de>

    CC Mode: Don't bind max-specpdl-size when it doesn't exist or is obsolete
    
    This is part of the changes for bug #57911.
    
    * lisp/progmodes/cc-defs.el (c-let*-maybe-max-specpdl-size): New macro.
    (c-get-lang-constant): Use the new macro in place of let*.
---
 lisp/progmodes/cc-defs.el | 45 ++++++++++++++++++++++++++++++---------------
 1 file changed, 30 insertions(+), 15 deletions(-)

diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el
index f867625480..59927f0f2c 100644
--- a/lisp/progmodes/cc-defs.el
+++ b/lisp/progmodes/cc-defs.el
@@ -2629,6 +2629,20 @@ fallback definition for all modes, to break the cycle).")
 
 (defconst c-lang--novalue "novalue")
 
+(defmacro c-let*-maybe-max-specpdl-size (varlist &rest body)
+  ;; Like let*, but doesn't bind `max-specpdl-size' if that variable
+  ;; is in the bindings list and either doesn't exist or is obsolete.
+  (declare (debug let*) (indent 1))
+  (let ((-varlist- varlist) msp-binding)
+    (if (or (not (boundp 'max-specpdl-size))
+           (get 'max-specpdl-size 'byte-obsolete-variable))
+       (cond
+        ((memq 'max-specpdl-size -varlist-)
+         (setq -varlist- (delq 'max-specpdl-size -varlist-)))
+        ((setq msp-binding (assq 'max-specpdl-size -varlist-))
+         (setq -varlist- (delq msp-binding -varlist-)))))
+    `(let* ,varlist ,@body)))
+
 (defun c-get-lang-constant (name &optional source-files mode)
   ;; Used by `c-lang-const'.
 
@@ -2669,21 +2683,22 @@ fallback definition for all modes, to break the 
cycle).")
       ;; In that case we just continue with the "assignment" before
       ;; the one currently being evaluated, thereby creating the
       ;; illusion if a `setq'-like sequence of assignments.
-      (let* ((c-buffer-is-cc-mode mode)
-            (source-pos
-             (or (assq sym c-lang-constants-under-evaluation)
-                 (cons sym (vector source nil))))
-            ;; Append `c-lang-constants-under-evaluation' even if an
-            ;; earlier entry is found.  It's only necessary to get
-            ;; the recording of dependencies above correct.
-            (c-lang-constants-under-evaluation
-             (cons source-pos c-lang-constants-under-evaluation))
-            (fallback (get mode 'c-fallback-mode))
-            value
-            ;; Make sure the recursion limits aren't very low
-            ;; since the `c-lang-const' dependencies can go deep.
-            (max-specpdl-size (max max-specpdl-size 3000))
-            (max-lisp-eval-depth (max max-lisp-eval-depth 1000)))
+      (c-let*-maybe-max-specpdl-size
+         ((c-buffer-is-cc-mode mode)
+          (source-pos
+           (or (assq sym c-lang-constants-under-evaluation)
+               (cons sym (vector source nil))))
+          ;; Append `c-lang-constants-under-evaluation' even if an
+          ;; earlier entry is found.  It's only necessary to get
+          ;; the recording of dependencies above correct.
+          (c-lang-constants-under-evaluation
+           (cons source-pos c-lang-constants-under-evaluation))
+          (fallback (get mode 'c-fallback-mode))
+          value
+          ;; Make sure the recursion limits aren't very low
+          ;; since the `c-lang-const' dependencies can go deep.
+          (max-specpdl-size (max max-specpdl-size 3000))
+          (max-lisp-eval-depth (max max-lisp-eval-depth 1000)))
 
        (if (if fallback
                (let ((backup-source-pos (copy-sequence (cdr source-pos))))



reply via email to

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