(defconst c-version "5.25"
"CC Mode version number.")
(defvar c-buffer-is-cc-mode nil
"Non-nil for all buffers with a `major-mode' derived from CC Mode.
Otherwise, this variable is nil. I.e. this variable is non-nil for
`c-mode', `c++-mode', `objc-mode', `java-mode', `idl-mode',
`pike-mode', and any other non-CC Mode mode that calls
`c-initialize-cc-mode' (e.g. `awk-mode').")
(make-variable-buffer-local 'c-buffer-is-cc-mode)
(put 'c-buffer-is-cc-mode 'permanent-local t)
(eval-and-compile
(require 'cc-defs))
(require 'cc-menus)
(require 'cc-vars)
(require 'cc-engine)
(require 'cc-langs)
(require 'cc-align)
(require 'cc-styles)
(require 'cc-cmds)
(defun c-initialize-cc-mode ()
(setq c-buffer-is-cc-mode t)
(let ((initprop 'cc-mode-is-initialized)
c-initialization-ok)
(unless (get 'c-initialize-cc-mode initprop)
(put 'c-initialize-cc-mode initprop t)
(c-initialize-builtin-style)
(unwind-protect
(progn
(run-hooks 'c-initialization-hook)
(setq c-initialization-ok t))
(unless c-initialization-ok
(put 'c-initialize-cc-mode initprop nil))))
))
(defun c-mode ()
"Major mode for editing K&R and ANSI C code.
To submit a problem report, enter `\\[c-submit-bug-report]' from a
c-mode buffer. This automatically sets up a mail buffer with version
information already added. You just need to add a description of the
problem, including a reproducible test case and send the message.
To see what version of CC Mode you are running, enter `\\[c-version]'.
The hook variable `c-mode-hook' is run with no args, if that value is
bound and has a non-nil value. Also the hook `c-mode-common-hook' is
run first.
Key bindings:
\\{c-mode-map}"
(interactive)
(c-initialize-cc-mode)
(kill-all-local-variables)
(set-syntax-table c-mode-syntax-table)
(setq major-mode 'c-mode
mode-name "C"
local-abbrev-table c-mode-abbrev-table)
(use-local-map c-mode-map)
(c-common-init)
(setq comment-start "/* "
comment-end " */"
c-conditional-key c-C-conditional-key
c-class-key c-C-class-key
c-baseclass-key nil
c-comment-start-regexp c-C++-comment-start-regexp
imenu-generic-expression cc-imenu-c-generic-expression
imenu-case-fold-search nil
)
(run-hooks 'c-mode-common-hook)
(run-hooks 'c-mode-hook)
(c-update-modeline))
(defun c++-mode ()
"Major mode for editing C++ code.
To submit a problem report, enter `\\[c-submit-bug-report]' from a
c++-mode buffer. This automatically sets up a mail buffer with
version information already added. You just need to add a description
of the problem, including a reproducible test case, and send the
message.
To see what version of CC Mode you are running, enter `\\[c-version]'.
The hook variable `c++-mode-hook' is run with no args, if that
variable is bound and has a non-nil value. Also the hook
`c-mode-common-hook' is run first.
Key bindings:
\\{c++-mode-map}"
(interactive)
(c-initialize-cc-mode)
(kill-all-local-variables)
(set-syntax-table c++-mode-syntax-table)
(setq major-mode 'c++-mode
mode-name "C++"
local-abbrev-table c++-mode-abbrev-table)
(use-local-map c++-mode-map)
(c-common-init)
(setq comment-start "// "
comment-end ""
c-conditional-key c-C++-conditional-key
c-comment-start-regexp c-C++-comment-start-regexp
c-class-key c-C++-class-key
c-extra-toplevel-key c-C++-extra-toplevel-key
c-access-key c-C++-access-key
c-recognize-knr-p nil
imenu-generic-expression cc-imenu-c++-generic-expression
imenu-case-fold-search nil
)
(run-hooks 'c-mode-common-hook)
(run-hooks 'c++-mode-hook)
(c-update-modeline))
(defun objc-mode ()
"Major mode for editing Objective C code.
To submit a problem report, enter `\\[c-submit-bug-report]' from an
objc-mode buffer. This automatically sets up a mail buffer with
version information already added. You just need to add a description
of the problem, including a reproducible test case, and send the
message.
To see what version of CC Mode you are running, enter `\\[c-version]'.
The hook variable `objc-mode-hook' is run with no args, if that value
is bound and has a non-nil value. Also the hook `c-mode-common-hook'
is run first.
Key bindings:
\\{objc-mode-map}"
(interactive)
(c-initialize-cc-mode)
(kill-all-local-variables)
(set-syntax-table objc-mode-syntax-table)
(setq major-mode 'objc-mode
mode-name "ObjC"
local-abbrev-table objc-mode-abbrev-table)
(use-local-map objc-mode-map)
(c-common-init)
(setq comment-start "// "
comment-end ""
c-conditional-key c-C-conditional-key
c-comment-start-regexp c-C++-comment-start-regexp
c-class-key c-ObjC-class-key
c-baseclass-key nil
c-access-key c-ObjC-access-key
c-method-key c-ObjC-method-key
imenu-create-index-function 'cc-imenu-objc-function
imenu-case-fold-search nil
)
(run-hooks 'c-mode-common-hook)
(run-hooks 'objc-mode-hook)
(c-update-modeline))
(defun java-mode ()
"Major mode for editing Java code.
To submit a problem report, enter `\\[c-submit-bug-report]' from a
java-mode buffer. This automatically sets up a mail buffer with
version information already added. You just need to add a description
of the problem, including a reproducible test case and send the
message.
To see what version of CC Mode you are running, enter `\\[c-version]'.
The hook variable `java-mode-hook' is run with no args, if that value
is bound and has a non-nil value. Also the common hook
`c-mode-common-hook' is run first. Note that this mode automatically
sets the \"java\" style before calling any hooks so be careful if you
set styles in `c-mode-common-hook'.
Key bindings:
\\{java-mode-map}"
(interactive)
(c-initialize-cc-mode)
(kill-all-local-variables)
(set-syntax-table java-mode-syntax-table)
(setq major-mode 'java-mode
mode-name "Java"
local-abbrev-table java-mode-abbrev-table)
(use-local-map java-mode-map)
(c-common-init)
(setq comment-start "// "
comment-end ""
c-conditional-key c-Java-conditional-key
c-comment-start-regexp c-Java-comment-start-regexp
c-class-key c-Java-class-key
c-method-key nil
c-baseclass-key nil
c-recognize-knr-p nil
c-access-key c-Java-access-key
c-inexpr-class-key c-Java-inexpr-class-key
imenu-generic-expression cc-imenu-java-generic-expression
imenu-case-fold-search nil
)
(run-hooks 'c-mode-common-hook)
(run-hooks 'java-mode-hook)
(c-update-modeline))
(defun idl-mode ()
"Major mode for editing CORBA's IDL code.
To submit a problem report, enter `\\[c-submit-bug-report]' from an
idl-mode buffer. This automatically sets up a mail buffer with
version information already added. You just need to add a description
of the problem, including a reproducible test case, and send the
message.
To see what version of CC Mode you are running, enter `\\[c-version]'.
The hook variable `idl-mode-hook' is run with no args, if that
variable is bound and has a non-nil value. Also the hook
`c-mode-common-hook' is run first.
Key bindings:
\\{idl-mode-map}"
(interactive)
(c-initialize-cc-mode)
(kill-all-local-variables)
(set-syntax-table idl-mode-syntax-table)
(setq major-mode 'idl-mode
mode-name "IDL"
local-abbrev-table idl-mode-abbrev-table)
(use-local-map idl-mode-map)
(c-common-init)
(setq comment-start "// "
comment-end ""
c-conditional-key c-C++-conditional-key
c-comment-start-regexp c-C++-comment-start-regexp
c-class-key c-IDL-class-key
c-extra-toplevel-key c-IDL-extra-toplevel-key
c-access-key c-C++-access-key
c-recognize-knr-p nil
)
(run-hooks 'c-mode-common-hook)
(run-hooks 'idl-mode-hook)
(c-update-modeline))
(defun pike-mode ()
"Major mode for editing Pike code.
To submit a problem report, enter `\\[c-submit-bug-report]' from an
idl-mode buffer. This automatically sets up a mail buffer with
version information already added. You just need to add a description
of the problem, including a reproducible test case, and send the
message.
To see what version of CC Mode you are running, enter `\\[c-version]'.
The hook variable `pike-mode-hook' is run with no args, if that value
is bound and has a non-nil value. Also the common hook
`c-mode-common-hook' is run first.
Key bindings:
\\{pike-mode-map}"
(interactive)
(c-initialize-cc-mode)
(kill-all-local-variables)
(set-syntax-table pike-mode-syntax-table)
(setq major-mode 'pike-mode
mode-name "Pike"
local-abbrev-table pike-mode-abbrev-table)
(use-local-map pike-mode-map)
(c-common-init)
(setq comment-start "// "
comment-end ""
c-conditional-key c-Pike-conditional-key
c-class-key c-Pike-class-key
c-method-key nil
c-baseclass-key nil
c-recognize-knr-p nil
c-access-key c-Pike-access-key
c-lambda-key c-Pike-lambda-key
c-inexpr-block-key c-Pike-inexpr-block-key
c-special-brace-lists c-Pike-special-brace-lists
)
(run-hooks 'c-mode-common-hook)
(run-hooks 'pike-mode-hook)
(c-update-modeline))
(defconst c-mode-help-address
"bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org"
"Addresses for CC Mode bug reports.")
(defun c-version ()
"Echo the current version of CC Mode in the minibuffer."
(interactive)
(message "Using CC Mode version %s" c-version)
(c-keep-region-active))
(defun c-submit-bug-report ()
"Submit via mail a bug report on CC Mode."
(interactive)
(require 'reporter)
(require 'cc-vars)
(let ((reporter-prompt-for-summary-p t)
(reporter-dont-compact-list '(c-offsets-alist))
(style c-indentation-style)
(hook c-special-indent-hook)
(c-features c-emacs-features))
(and
(if (y-or-n-p "Do you want to submit a report on CC Mode? ")
t (message "") nil)
(require 'reporter)
(reporter-submit-bug-report
c-mode-help-address
(concat "CC Mode " c-version " ("
(cond ((eq major-mode 'c++-mode) "C++")
((eq major-mode 'c-mode) "C")
((eq major-mode 'objc-mode) "ObjC")
((eq major-mode 'java-mode) "Java")
((eq major-mode 'pike-mode) "Pike")
)
")")
(let ((vars (list
'c-basic-offset
'c-offsets-alist
'c-cleanup-list
'c-comment-only-line-offset
'c-backslash-column
'c-delete-function
'c-electric-pound-behavior
'c-hanging-braces-alist
'c-hanging-colons-alist
'c-hanging-comment-starter-p
'c-hanging-comment-ender-p
'c-indent-comments-syntactically-p
'c-tab-always-indent
'c-comment-continuation-stars
'c-label-minimum-indentation
'defun-prompt-regexp
'tab-width
'comment-column
'signal-error-on-buffer-boundary
)))
(if (not (boundp 'defun-prompt-regexp))
(delq 'defun-prompt-regexp vars)
vars))
(function
(lambda ()
(insert
"Buffer Style: " style "\n\n"
(if (and hook
(or (/= (length hook) 1)
(not (eq (car hook) 'c-gnu-impose-minimum))
))
(concat "\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"
"c-special-indent-hook is set to '"
(format "%s" hook)
".\nPerhaps this is your problem?\n"
"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\n")
"\n")
(format "c-emacs-features: %s\n" c-features)
)))
nil
"Dear Barry and Martin,"
))))
(provide 'cc-mode)