emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] Changes to emacs/lisp/progmodes/cc-mode.el,v


From: Chong Yidong
Subject: [Emacs-diffs] Changes to emacs/lisp/progmodes/cc-mode.el,v
Date: Thu, 31 Jul 2008 01:37:35 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Chong Yidong <cyd>      08/07/31 01:37:35

Index: cc-mode.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/progmodes/cc-mode.el,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -b -r1.79 -r1.80
--- cc-mode.el  24 Jul 2008 02:55:59 -0000      1.79
+++ cc-mode.el  31 Jul 2008 01:37:35 -0000      1.80
@@ -657,6 +657,26 @@
       (and (cdr rfn)
           (setq require-final-newline mode-require-final-newline)))))
 
+(defun c-before-hack-hook ()
+  "Set the CC Mode style and \"offsets\" when in the buffer's local variables.
+They are set only when, respectively, the pseudo variables
+`c-file-style' and `c-file-offsets' are present in the list.
+
+This function is called from the hook `before-hack-local-variables-hook'."
+  (when c-buffer-is-cc-mode
+    (let ((stile (cdr (assq 'c-file-style file-local-variables-alist)))
+         (offsets (cdr (assq 'c-file-offsets file-local-variables-alist))))
+      (when stile
+       (or (stringp stile) (error "c-file-style is not a string"))
+       (c-set-style stile))
+      (when offsets
+       (mapc
+        (lambda (langentry)
+          (let ((langelem (car langentry))
+                (offset (cdr langentry)))
+            (c-set-offset langelem offset)))
+        offsets)))))
+
 (defun c-remove-any-local-eval-or-mode-variables ()
   ;; If the buffer specifies `mode' or `eval' in its File Local Variable list
   ;; or on the first line, remove all occurrences.  See
@@ -748,7 +768,9 @@
            (hack-local-variables))
          nil))))
 
-(add-hook 'hack-local-variables-hook 'c-postprocess-file-styles)
+(if (boundp 'before-hack-local-variables-hook)
+    (add-hook 'before-hack-local-variables-hook 'c-before-hack-hook)
+  (add-hook 'hack-local-variables-hook 'c-postprocess-file-styles))
 
 (defmacro c-run-mode-hooks (&rest hooks)
   ;; Emacs 21.1 has introduced a system with delayed mode hooks that




reply via email to

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