]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/cc-mode.el
(c-forward-label): Fix for QT macros.
[gnu-emacs] / lisp / progmodes / cc-mode.el
index 0ae038578b7083b8291e2f838af4c0bc924957d9..044d8542bfe70e87fa6ddb61c92ab283eb16f355 100644 (file)
@@ -214,12 +214,12 @@ control).  See \"cc-mode.el\" for more info."
     ;; function is called from top-level forms that are evaluated
     ;; while cc-bytecomp is active when one does M-x eval-buffer.
     (cond
-     ;; XEmacs
-     ((cc-bytecomp-fboundp 'set-keymap-parents)
-      (set-keymap-parents map c-mode-base-map))
      ;; Emacs
      ((cc-bytecomp-fboundp 'set-keymap-parent)
       (set-keymap-parent map c-mode-base-map))
+     ;; XEmacs
+     ((cc-bytecomp-fboundp 'set-keymap-parents)
+      (set-keymap-parents map c-mode-base-map))
      ;; incompatible
      (t (error "CC Mode is incompatible with this version of Emacs")))
     map))
@@ -285,8 +285,9 @@ control).  See \"cc-mode.el\" for more info."
 
   ;; RMS says don't make these the default.
   ;; (April 2006): RMS has now approved these commands as defaults.
-  (define-key c-mode-base-map "\e\C-a"    'c-beginning-of-defun)
-  (define-key c-mode-base-map "\e\C-e"    'c-end-of-defun)
+  (unless (memq 'argumentative-bod-function c-emacs-features)
+    (define-key c-mode-base-map "\e\C-a"    'c-beginning-of-defun)
+    (define-key c-mode-base-map "\e\C-e"    'c-end-of-defun))
 
   (define-key c-mode-base-map "\C-c\C-n"  'c-forward-conditional)
   (define-key c-mode-base-map "\C-c\C-p"  'c-backward-conditional)
@@ -656,6 +657,26 @@ compatible with old code; callers should always specify it."
       (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
@@ -747,7 +768,9 @@ Note that the style variables are always made local to the buffer."
            (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
@@ -1095,6 +1118,11 @@ This does not load the font-lock package.  Use after
 ;;;###autoload (add-to-list 'auto-mode-alist '("\\.y\\(acc\\)?\\'" . c-mode))
 ;;;###autoload (add-to-list 'auto-mode-alist '("\\.lex\\'" . c-mode))
 
+;; Preprocessed files generated by C and C++ compilers.
+;;;###autoload (add-to-list 'auto-mode-alist '("\\.i\\'" . c-mode))
+;;;###autoload (add-to-list 'auto-mode-alist '("\\.ii\\'" . c++-mode))
+
+
 ;;;###autoload
 (defun c-mode ()
   "Major mode for editing K&R and ANSI C code.