summaryrefslogtreecommitdiff
path: root/lisp/progmodes/cc-styles.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1997-07-10 07:56:17 +0000
committerRichard M. Stallman <rms@gnu.org>1997-07-10 07:56:17 +0000
commit0a213d8c3a9411ddcbd7ae670746f3e5455534a1 (patch)
treec1b7b49a0e36fde95a922c27decaf68b4e275e02 /lisp/progmodes/cc-styles.el
parent38b3e0343b686029b52f6f6c77482ea5815330b5 (diff)
downloademacs-0a213d8c3a9411ddcbd7ae670746f3e5455534a1.tar.gz
(c-copy-tree): New function.
(c-initialize-builtin-style): Use c-copy-tree.
Diffstat (limited to 'lisp/progmodes/cc-styles.el')
-rw-r--r--lisp/progmodes/cc-styles.el21
1 files changed, 19 insertions, 2 deletions
diff --git a/lisp/progmodes/cc-styles.el b/lisp/progmodes/cc-styles.el
index 975796d7b79..8d823fe65d4 100644
--- a/lisp/progmodes/cc-styles.el
+++ b/lisp/progmodes/cc-styles.el
@@ -553,7 +553,6 @@ offset for that syntactic element. Optional ADD says to add SYMBOL to
;; crucial because future c-set-style calls will always reset the
;; variables first to the `cc-mode' style before instituting the new
;; style. Only do this once!
- (require 'cl)
(or (assoc "cc-mode" c-style-alist)
(progn
(c-add-style "cc-mode"
@@ -562,7 +561,7 @@ offset for that syntactic element. Optional ADD says to add SYMBOL to
(lambda (var)
(let ((val (symbol-value var)))
(cons var (if (atom val) val
- (copy-tree val)
+ (c-copy-tree val)
))
)))
'(c-backslash-column
@@ -580,6 +579,24 @@ offset for that syntactic element. Optional ADD says to add SYMBOL to
;; c-mode-common-hook or {c,c++,objc,java}-mode-hook.
(c-set-style c-site-default-style))))
+(defun c-copy-tree (tree &optional vecp)
+ "Make a copy of TREE.
+If TREE is a cons cell, this recursively copies both its car and its cdr.
+Contrast to copy-sequence, which copies only along the cdrs. With second
+argument VECP, this copies vectors as well as conses."
+ (if (consp tree)
+ (let ((p (setq tree (copy-list tree))))
+ (while (consp p)
+ (if (or (consp (car p)) (and vecp (vectorp (car p))))
+ (setcar p (c-copy-tree (car p) vecp)))
+ (or (listp (cdr p)) (setcdr p (c-copy-tree (cdr p) vecp)))
+ (setq p (cdr p))))
+ (if (and vecp (vectorp tree))
+ (let ((i (length (setq tree (copy-sequence tree)))))
+ (while (>= (setq i (1- i)) 0)
+ (aset tree i (c-copy-tree (aref tree i) vecp))))))
+ tree)
+
(defun c-make-styles-buffer-local ()
"Make all CC Mode style variables buffer local.
If you edit primarily one style of C (or C++, Objective-C, Java) code,