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