Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!mit-eddie!B.CS.UIUC.EDU!liberte From: liberte@B.CS.UIUC.EDU (Daniel LaLiberte) Newsgroups: comp.emacs Subject: c-style.el Message-ID: <8708262314.AA23044@b.cs.uiuc.edu> Date: Wed, 26-Aug-87 19:14:59 EDT Article-I.D.: b.8708262314.AA23044 Posted: Wed Aug 26 19:14:59 1987 Date-Received: Fri, 28-Aug-87 07:26:32 EDT Sender: daemon@eddie.MIT.EDU Lines: 93 My last attempt probably failed. Here is c-style.el which allows you to have named indentation styles. Dan LaLiberte liberte@a.cs.uiuc.edu uiucdcs!liberte --- ; Definitions for buffer specific c-mode indentation style. ; Written by Daniel LaLiberte (liberte@a.cs.uiuc.edu) ; while at Gould. This is free. ; There are several ways to call set-c-style. ; ; 1. Set the c-style variable in the local variables list ; with "c-style: GNU" or whatever you like and ; call set-c-style without argument in c-mode-hook. ; ; 2. Call set-c-style with style argument in c-mode-hook. ; This will set the style for every c file the same. ; ; 3. Put "eval: (set-c-style 'GNU)" in the local variables list. ; ; 4. Call set-c-style interactively. It prompts for the style name. ; The default value of c-style is default-c-style. ; I put (autoload 'set-c-style "c-style.el" nil t) in my .emacs. ;;; $Header: $ ;;; ;;; $Log: $ ;;; ;; Predefined styles (defvar c-styles '(K&R BSD GNU C++ Gould) "*A list of symbols for the different c-mode styles") (defvar c-style-alist '( (c-indent-level . [ 5 8 2 4 4]) (c-continued-statement-offset . [ 5 8 2 4 4]) (c-brace-offset . [-5 -8 0 -4 -4]) (c-argdecl-indent . [ 0 8 5 4 8]) (c-label-offset . [-5 -8 -2 -4 -2]) ) "*An association list between c-mode style variables and a vector of values, one for each style given in c-styles") (defvar default-c-style 'Gould "*The default value of c-style") (defvar c-style default-c-style "*The buffer specific c indentation style. May be one of the symbols in c-styles") (defun set-c-style (&optional style) "Set up the c-mode style variables from the c-style variable or if STYLE argument is given, use that. It makes the c indentation style variables buffer local." (interactive) (if (interactive-p) (setq style (let ((style-string (completing-read (format "Set c mode style to (default %s): " default-c-style) (vconcat c-styles) (function (lambda (arg) (memq arg c-styles))) ))) (if (string-equal "" style-string) default-c-style (intern style-string)) ))) (let* ((new-c-style (or style c-style)) ; use c-style if style not given (c-style-index (- (length c-styles) (length (memq new-c-style c-styles)))) ) (make-local-variable 'c-style) (if (< c-style-index (length c-styles)) (setq c-style new-c-style) (error (concat "Bad c style: " new-c-style)) ) (message "c-style: %s" c-style) ; finally, set the style variables making each one local (mapcar (function (lambda (c-style-pair) (make-local-variable (car c-style-pair)) (set (car c-style-pair) (aref (cdr c-style-pair) c-style-index)))) c-style-alist) c-style ) )