Mercurial > emacs
annotate lisp/progmodes/cc-compat.el @ 71621:7250b94586cb
Add a paragraph for non-ASCII examples at the head. Add
Bulgarian and Hungarian. Add more "hello"s to Danish and Swedish.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Wed, 05 Jul 2006 01:28:13 +0000 |
parents | 63b772bfba93 |
children | cf3e4c6cd4c3 a5812696f7bf |
rev | line source |
---|---|
18720 | 1 ;;; cc-compat.el --- cc-mode compatibility with c-mode.el confusion |
2 | |
69140
3d8b060d10fb
cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents:
68773
diff
changeset
|
3 ;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006 Free Software |
3d8b060d10fb
cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents:
68773
diff
changeset
|
4 ;; Foundation, Inc. |
18720 | 5 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
6 ;; Authors: 1998- Martin Stjernholm |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
7 ;; 1994-1999 Barry A. Warsaw |
30405 | 8 ;; Maintainer: bug-cc-mode@gnu.org |
18720 | 9 ;; Created: August 1994, split from cc-mode.el |
20141 | 10 ;; Version: See cc-mode.el |
18720 | 11 ;; Keywords: c languages oop |
12 | |
13 ;; This file is part of GNU Emacs. | |
14 | |
15 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
16 ;; it under the terms of the GNU General Public License as published by | |
17 ;; the Free Software Foundation; either version 2, or (at your option) | |
18 ;; any later version. | |
19 | |
20 ;; GNU Emacs is distributed in the hope that it will be useful, | |
21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
23 ;; GNU General Public License for more details. | |
24 | |
25 ;; You should have received a copy of the GNU General Public License | |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
26 ;; along with this program; see the file COPYING. If not, write to |
64085 | 27 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
28 ;; Boston, MA 02110-1301, USA. | |
18720 | 29 |
30 ;;; Commentary: | |
31 ;; | |
32 ;; Boring old c-mode.el (BOCM) is confusion and brain melt. cc-mode.el | |
33 ;; is clarity of thought and purity of chi. If you are still unwilling | |
34 ;; to accept enlightenment, this might help, or it may prolong your | |
35 ;; agony. | |
36 ;; | |
37 ;; To use, add the following to your c-mode-hook: | |
38 ;; | |
39 ;; (require 'cc-compat) | |
40 ;; (c-set-style "BOCM") | |
36920 | 41 ;; |
42 ;; This file is completely unsupported! Although it has been patched | |
43 ;; superficially to keep pace with the rest of CC Mode, it hasn't been | |
44 ;; tested for a long time. | |
18720 | 45 |
46 ;;; Code: | |
47 | |
48 (eval-when-compile | |
26817 | 49 (let ((load-path |
36920 | 50 (if (and (boundp 'byte-compile-dest-file) |
51 (stringp byte-compile-dest-file)) | |
52 (cons (file-name-directory byte-compile-dest-file) load-path) | |
26817 | 53 load-path))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
54 (load "cc-bytecomp" nil t))) |
36920 | 55 |
56 (cc-require 'cc-defs) | |
57 (cc-require 'cc-vars) | |
58 (cc-require 'cc-styles) | |
59 (cc-require 'cc-engine) | |
18720 | 60 |
61 | |
62 ;; In case c-mode.el isn't loaded | |
63 (defvar c-indent-level 2 | |
64 "*Indentation of C statements with respect to containing block.") | |
70590
63b772bfba93
Move `safe-local-variable' declarations to the respective files.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69140
diff
changeset
|
65 ;;;###autoload(put 'c-indent-level 'safe-local-variable 'integerp) |
63b772bfba93
Move `safe-local-variable' declarations to the respective files.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
69140
diff
changeset
|
66 |
18720 | 67 (defvar c-brace-imaginary-offset 0 |
68 "*Imagined indentation of a C open brace that actually follows a statement.") | |
69 (defvar c-brace-offset 0 | |
70 "*Extra indentation for braces, compared with other text in same context.") | |
71 (defvar c-argdecl-indent 5 | |
72 "*Indentation level of declarations of C function arguments.") | |
73 (defvar c-label-offset -2 | |
74 "*Offset of C label lines and case statements relative to usual indentation.") | |
75 (defvar c-continued-statement-offset 2 | |
76 "*Extra indent for lines not starting new statements.") | |
77 (defvar c-continued-brace-offset 0 | |
78 "*Extra indent for substatements that start with open-braces. | |
79 This is in addition to c-continued-statement-offset.") | |
80 | |
81 | |
82 | |
83 ;; these offsets are taken by brute force testing c-mode.el, since | |
84 ;; there's no logic to what it does. | |
85 (let* ((offsets '(c-offsets-alist . | |
86 ((defun-block-intro . cc-block-intro-offset) | |
87 (statement-block-intro . cc-block-intro-offset) | |
88 (defun-open . 0) | |
89 (class-open . 0) | |
90 (inline-open . c-brace-offset) | |
91 (block-open . c-brace-offset) | |
92 (block-close . cc-block-close-offset) | |
93 (brace-list-open . c-brace-offset) | |
94 (substatement-open . cc-substatement-open-offset) | |
95 (substatement . c-continued-statement-offset) | |
96 (knr-argdecl-intro . c-argdecl-indent) | |
97 (case-label . c-label-offset) | |
98 (access-label . c-label-offset) | |
99 (label . c-label-offset) | |
100 )))) | |
101 (c-add-style "BOCM" offsets)) | |
102 | |
103 | |
104 (defun cc-block-intro-offset (langelem) | |
105 ;; taken directly from calculate-c-indent confusion | |
106 (save-excursion | |
107 (c-backward-syntactic-ws) | |
108 (if (eq (char-before) ?{) | |
109 (forward-char -1) | |
110 (goto-char (cdr langelem))) | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
111 (let* ((curcol (save-excursion |
18720 | 112 (goto-char (cdr langelem)) |
113 (current-column))) | |
114 (bocm-lossage | |
115 ;; If no previous statement, indent it relative to line | |
116 ;; brace is on. For open brace in column zero, don't let | |
117 ;; statement start there too. If c-indent-level is zero, | |
118 ;; use c-brace-offset + c-continued-statement-offset | |
119 ;; instead. For open-braces not the first thing in a line, | |
120 ;; add in c-brace-imaginary-offset. | |
121 (+ (if (and (bolp) (zerop c-indent-level)) | |
122 (+ c-brace-offset c-continued-statement-offset) | |
123 c-indent-level) | |
124 ;; Move back over whitespace before the openbrace. If | |
125 ;; openbrace is not first nonwhite thing on the line, | |
126 ;; add the c-brace-imaginary-offset. | |
127 (progn (skip-chars-backward " \t") | |
128 (if (bolp) 0 c-brace-imaginary-offset)) | |
129 ;; If the openbrace is preceded by a parenthesized exp, | |
130 ;; move to the beginning of that; possibly a different | |
131 ;; line | |
132 (progn | |
133 (if (eq (char-before) ?\)) | |
24282 | 134 (c-forward-sexp -1)) |
18720 | 135 ;; Get initial indentation of the line we are on. |
136 (current-indentation))))) | |
137 (- bocm-lossage curcol)))) | |
138 | |
139 | |
140 (defun cc-block-close-offset (langelem) | |
141 (save-excursion | |
142 (let* ((here (point)) | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
143 bracep |
18720 | 144 (curcol (progn |
145 (goto-char (cdr langelem)) | |
146 (current-column))) | |
147 (bocm-lossage (progn | |
148 (goto-char (cdr langelem)) | |
149 (if (eq (char-after) ?{) | |
150 (setq bracep t) | |
151 (goto-char here) | |
152 (beginning-of-line) | |
153 (backward-up-list 1) | |
154 (forward-char 1) | |
155 (c-forward-syntactic-ws)) | |
156 (current-column)))) | |
157 (- bocm-lossage curcol | |
158 (if bracep 0 c-indent-level))))) | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
159 |
18720 | 160 |
161 (defun cc-substatement-open-offset (langelem) | |
162 (+ c-continued-statement-offset c-continued-brace-offset)) | |
163 | |
164 | |
36920 | 165 (cc-provide 'cc-compat) |
52401 | 166 |
167 ;;; arch-tag: 564dab2f-e6ad-499c-a4a3-fedec3ecc192 | |
18720 | 168 ;;; cc-compat.el ends here |