diff options
| author | Chong Yidong | 2008-07-31 01:37:35 +0000 |
|---|---|---|
| committer | Chong Yidong | 2008-07-31 01:37:35 +0000 |
| commit | a36abf0ef31eb9d684cb18b475d40be9122dc0f5 (patch) | |
| tree | d63b028f2da5fd987722daeca233cf028a66f598 | |
| parent | 7d198f1d9069a2899edf8ff288ca659d302f524d (diff) | |
| download | emacs-a36abf0ef31eb9d684cb18b475d40be9122dc0f5.tar.gz emacs-a36abf0ef31eb9d684cb18b475d40be9122dc0f5.zip | |
(c-before-hack-hook): New function
(Top Level): Install c-before-hack-hook on
before-hack-local-variables-hook, rather than
c-postprocess-file-styles on hack-local-variables-hook.
| -rw-r--r-- | lisp/progmodes/cc-mode.el | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index 06f94bde94a..044d8542bfe 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el | |||
| @@ -657,6 +657,26 @@ compatible with old code; callers should always specify it." | |||
| 657 | (and (cdr rfn) | 657 | (and (cdr rfn) |
| 658 | (setq require-final-newline mode-require-final-newline))))) | 658 | (setq require-final-newline mode-require-final-newline))))) |
| 659 | 659 | ||
| 660 | (defun c-before-hack-hook () | ||
| 661 | "Set the CC Mode style and \"offsets\" when in the buffer's local variables. | ||
| 662 | They are set only when, respectively, the pseudo variables | ||
| 663 | `c-file-style' and `c-file-offsets' are present in the list. | ||
| 664 | |||
| 665 | This function is called from the hook `before-hack-local-variables-hook'." | ||
| 666 | (when c-buffer-is-cc-mode | ||
| 667 | (let ((stile (cdr (assq 'c-file-style file-local-variables-alist))) | ||
| 668 | (offsets (cdr (assq 'c-file-offsets file-local-variables-alist)))) | ||
| 669 | (when stile | ||
| 670 | (or (stringp stile) (error "c-file-style is not a string")) | ||
| 671 | (c-set-style stile)) | ||
| 672 | (when offsets | ||
| 673 | (mapc | ||
| 674 | (lambda (langentry) | ||
| 675 | (let ((langelem (car langentry)) | ||
| 676 | (offset (cdr langentry))) | ||
| 677 | (c-set-offset langelem offset))) | ||
| 678 | offsets))))) | ||
| 679 | |||
| 660 | (defun c-remove-any-local-eval-or-mode-variables () | 680 | (defun c-remove-any-local-eval-or-mode-variables () |
| 661 | ;; If the buffer specifies `mode' or `eval' in its File Local Variable list | 681 | ;; If the buffer specifies `mode' or `eval' in its File Local Variable list |
| 662 | ;; or on the first line, remove all occurrences. See | 682 | ;; or on the first line, remove all occurrences. See |
| @@ -748,7 +768,9 @@ Note that the style variables are always made local to the buffer." | |||
| 748 | (hack-local-variables)) | 768 | (hack-local-variables)) |
| 749 | nil)))) | 769 | nil)))) |
| 750 | 770 | ||
| 751 | (add-hook 'hack-local-variables-hook 'c-postprocess-file-styles) | 771 | (if (boundp 'before-hack-local-variables-hook) |
| 772 | (add-hook 'before-hack-local-variables-hook 'c-before-hack-hook) | ||
| 773 | (add-hook 'hack-local-variables-hook 'c-postprocess-file-styles)) | ||
| 752 | 774 | ||
| 753 | (defmacro c-run-mode-hooks (&rest hooks) | 775 | (defmacro c-run-mode-hooks (&rest hooks) |
| 754 | ;; Emacs 21.1 has introduced a system with delayed mode hooks that | 776 | ;; Emacs 21.1 has introduced a system with delayed mode hooks that |