mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-23 07:19:15 +00:00
Installed CC Mode 5.25.
This commit is contained in:
parent
32348c138b
commit
0ec8351b95
@ -2,10 +2,11 @@
|
||||
|
||||
;; Copyright (C) 1985,87,92,93,94,95,96,97,98 Free Software Foundation, Inc.
|
||||
|
||||
;; Authors: 1992-1997 Barry A. Warsaw
|
||||
;; Authors: 1998 Barry A. Warsaw and Martin Stjernholm
|
||||
;; 1992-1997 Barry A. Warsaw
|
||||
;; 1987 Dave Detlefs and Stewart Clamen
|
||||
;; 1985 Richard M. Stallman
|
||||
;; Maintainer: cc-mode-help@python.org
|
||||
;; Maintainer: bug-cc-mode@gnu.org
|
||||
;; Created: 22-Apr-1997 (split from cc-mode.el)
|
||||
;; Version: See cc-mode.el
|
||||
;; Keywords: c languages oop
|
||||
@ -28,6 +29,7 @@
|
||||
;; Boston, MA 02111-1307, USA.
|
||||
|
||||
(eval-when-compile
|
||||
(require 'cc-defs)
|
||||
(require 'cc-vars)
|
||||
(require 'cc-engine)
|
||||
(require 'cc-langs))
|
||||
@ -57,7 +59,7 @@
|
||||
(beginning-of-line)
|
||||
(looking-at "[ \t]*)"))
|
||||
(progn (goto-char (match-end 0))
|
||||
(forward-sexp -1)
|
||||
(c-forward-sexp -1)
|
||||
(forward-char 1)
|
||||
(c-forward-syntactic-ws)
|
||||
(- (current-column) langelem-col))
|
||||
@ -111,9 +113,8 @@
|
||||
(let (opencol spec)
|
||||
(beginning-of-line)
|
||||
(backward-up-list 1)
|
||||
(setq spec (if (fboundp 'c-looking-at-special-brace-list)
|
||||
(c-looking-at-special-brace-list)))
|
||||
(if spec (goto-char (car spec)))
|
||||
(setq spec (c-looking-at-special-brace-list))
|
||||
(if spec (goto-char (car (car spec))))
|
||||
(setq opencol (current-column))
|
||||
(forward-char 1)
|
||||
(if spec (progn
|
||||
@ -194,9 +195,7 @@
|
||||
(beginning-of-line)
|
||||
(skip-chars-forward " \t")
|
||||
(if (and (eq (following-char) ?{)
|
||||
(condition-case nil
|
||||
(progn (forward-sexp) t)
|
||||
(error nil))
|
||||
(c-safe (progn (c-forward-sexp) t))
|
||||
(<= (point) eol)
|
||||
(eq (preceding-char) ?}))
|
||||
c-basic-offset
|
||||
@ -291,7 +290,11 @@
|
||||
(if (c-in-literal (cdr langelem))
|
||||
(forward-char 1)
|
||||
(setq donep t)))
|
||||
(if (not (eq (char-after) ?=))
|
||||
(if (or (not (eq (char-after) ?=))
|
||||
(save-excursion
|
||||
(forward-char 1)
|
||||
(c-forward-syntactic-ws (c-point 'eol))
|
||||
(eolp)))
|
||||
;; there's no equal sign on the line
|
||||
c-basic-offset
|
||||
;; calculate indentation column after equals and ws, unless
|
||||
@ -324,7 +327,7 @@
|
||||
(current-column)))
|
||||
(target-col (progn
|
||||
(forward-char)
|
||||
(forward-sexp)
|
||||
(c-forward-sexp)
|
||||
(skip-chars-forward " \t")
|
||||
(if (eolp)
|
||||
(+ open-bracket-col c-basic-offset)
|
||||
@ -373,6 +376,26 @@
|
||||
(+ curcol (- prev-col-column (current-column)))
|
||||
c-basic-offset)))))
|
||||
|
||||
(defun c-lineup-inexpr-block (langelem)
|
||||
;; This function lines up the block for the various constructs that
|
||||
;; uses a block inside an expression. For constructs matching
|
||||
;; c-lambda-key and c-inexpr-block-key, indentation to the column of
|
||||
;; the beginning of the match is added. For standalone statement
|
||||
;; blocks, indentation to the column of the opening brace is added.
|
||||
(save-excursion
|
||||
(back-to-indentation)
|
||||
(let ((res (or (c-looking-at-inexpr-block)
|
||||
(if (c-safe (backward-up-list 1)
|
||||
(eq (char-after) ?{))
|
||||
(c-looking-at-inexpr-block)))))
|
||||
(if (not res)
|
||||
0
|
||||
(goto-char (cdr res))
|
||||
(- (current-column)
|
||||
(progn
|
||||
(back-to-indentation)
|
||||
(current-column)))))))
|
||||
|
||||
(defun c-lineup-dont-change (langelem)
|
||||
;; Do not change the indentation of the current line
|
||||
(save-excursion
|
||||
@ -394,7 +417,7 @@ ACTION associated with `block-close' syntax."
|
||||
(setq langelem (assq 'block-close c-syntactic-context))
|
||||
(progn (goto-char (cdr langelem))
|
||||
(if (eq (char-after) ?{)
|
||||
(c-safe (forward-sexp -1)))
|
||||
(c-safe (c-forward-sexp -1)))
|
||||
(looking-at "\\<do\\>[^_]")))
|
||||
'(before)
|
||||
'(before after)))))
|
||||
|
@ -1,11 +1,12 @@
|
||||
;;; cc-cmds.el --- user level commands for CC Mode
|
||||
;;; cc-cmds.el --- user level commands for CC Mode
|
||||
|
||||
;; Copyright (C) 1985,87,92,93,94,95,96,97,98 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 1985,87,92,93,94,95,96,97,98 Free Softare Foundation, Inc.
|
||||
|
||||
;; Authors: 1992-1997 Barry A. Warsaw
|
||||
;; Authors: 1998 Barry A. Warsaw and Martin Stjernholm
|
||||
;; 1992-1997 Barry A. Warsaw
|
||||
;; 1987 Dave Detlefs and Stewart Clamen
|
||||
;; 1985 Richard M. Stallman
|
||||
;; Maintainer: cc-mode-help@python.org
|
||||
;; Maintainer: bug-cc-mode@gnu.org
|
||||
;; Created: 22-Apr-1997 (split from cc-mode.el)
|
||||
;; Version: See cc-mode.el
|
||||
;; Keywords: c languages oop
|
||||
@ -29,6 +30,9 @@
|
||||
|
||||
|
||||
|
||||
(eval-when-compile
|
||||
(require 'cc-defs))
|
||||
|
||||
(defun c-calculate-state (arg prevstate)
|
||||
;; Calculate the new state of PREVSTATE, t or nil, based on arg. If
|
||||
;; arg is nil or zero, toggle the state. If arg is negative, turn
|
||||
@ -128,8 +132,10 @@ consumed. If however an ARG is supplied, or `c-hungry-delete-key' is
|
||||
nil, or point is inside a literal then the function in the variable
|
||||
`c-delete-function' is called."
|
||||
(interactive "*P")
|
||||
(if (and (boundp 'delete-key-deletes-forward)
|
||||
delete-key-deletes-forward)
|
||||
(if (or (and (fboundp 'delete-forward-p) ;XEmacs 21
|
||||
(delete-forward-p))
|
||||
(and (boundp 'delete-key-deletes-forward) ;XEmacs 20
|
||||
delete-key-deletes-forward))
|
||||
(if (or (not c-hungry-delete-key)
|
||||
arg
|
||||
(c-in-literal))
|
||||
@ -148,9 +154,10 @@ Inserts a `#' character specially depending on the variable
|
||||
`c-electric-pound-behavior'. If a numeric ARG is supplied, or if
|
||||
point is inside a literal, nothing special happens."
|
||||
(interactive "*P")
|
||||
(if (or (c-in-literal)
|
||||
arg
|
||||
(not (memq 'alignleft c-electric-pound-behavior)))
|
||||
(if (or arg
|
||||
(not (memq 'alignleft c-electric-pound-behavior))
|
||||
(save-excursion (skip-chars-backward " \t") (not (bolp)))
|
||||
(c-in-literal))
|
||||
;; do nothing special
|
||||
(self-insert-command (prefix-numeric-value arg))
|
||||
;; place the pound character at the left edge
|
||||
@ -172,7 +179,10 @@ after braces based on the value of `c-hanging-braces-alist'.
|
||||
|
||||
Also, the line is re-indented unless a numeric ARG is supplied, there
|
||||
are non-whitespace characters present on the line after the brace, or
|
||||
the brace is inserted inside a literal."
|
||||
the brace is inserted inside a literal.
|
||||
|
||||
This function does various newline cleanups based on the value of
|
||||
`c-cleanup-list'."
|
||||
(interactive "*P")
|
||||
(let* ((c-state-cache (c-parse-state))
|
||||
(safepos (c-safe-position (point) c-state-cache))
|
||||
@ -180,8 +190,8 @@ the brace is inserted inside a literal."
|
||||
;; if we're in a literal, or we're not at the end of the line, or
|
||||
;; a numeric arg is provided, or auto-newlining is turned off,
|
||||
;; then just insert the character.
|
||||
(if (or literal arg
|
||||
; (not c-auto-newline)
|
||||
(if (or literal
|
||||
arg
|
||||
(not (looking-at "[ \t]*$")))
|
||||
(self-insert-command (prefix-numeric-value arg))
|
||||
(let* ((syms
|
||||
@ -191,11 +201,12 @@ the brace is inserted inside a literal."
|
||||
'(class-open class-close defun-open defun-close
|
||||
inline-open inline-close
|
||||
brace-list-open brace-list-close
|
||||
brace-list-intro brace-list-entry
|
||||
brace-list-intro brace-entry-open
|
||||
block-open block-close
|
||||
substatement-open statement-case-open
|
||||
extern-lang-open extern-lang-close
|
||||
namespace-open namespace-close
|
||||
inexpr-class-open inexpr-class-close
|
||||
))
|
||||
;; we want to inhibit blinking the paren since this will
|
||||
;; be most disruptive. we'll blink it ourselves later on
|
||||
@ -220,8 +231,32 @@ the brace is inserted inside a literal."
|
||||
(c-guess-basic-syntax)))
|
||||
(newlines (and
|
||||
c-auto-newline
|
||||
(or (c-lookup-lists syms syntax c-hanging-braces-alist)
|
||||
(or (c-lookup-lists
|
||||
syms
|
||||
;; Substitute inexpr-class and class-open
|
||||
;; or class-close with inexpr-class-open
|
||||
;; or inexpr-class-close.
|
||||
(if (assq 'inexpr-class syntax)
|
||||
(cond ((assq 'class-open syntax)
|
||||
'((inexpr-class-open)))
|
||||
((assq 'class-close syntax)
|
||||
'((inexpr-class-close)))
|
||||
(t syntax))
|
||||
syntax)
|
||||
c-hanging-braces-alist)
|
||||
'(ignore before after)))))
|
||||
;; Do not try to insert newlines around a special (Pike-style)
|
||||
;; brace list.
|
||||
(if (and c-special-brace-lists
|
||||
(c-intersect-lists '(brace-list-open brace-list-close
|
||||
brace-list-intro brace-entry-open)
|
||||
syntax)
|
||||
(save-excursion
|
||||
(c-safe (if (= (char-before) ?{)
|
||||
(forward-char -1)
|
||||
(c-forward-sexp -1))
|
||||
(c-looking-at-special-brace-list))))
|
||||
(setq newlines nil))
|
||||
;; If syntax is a function symbol, then call it using the
|
||||
;; defined semantics.
|
||||
(if (and (not (consp (cdr newlines)))
|
||||
@ -234,29 +269,26 @@ the brace is inserted inside a literal."
|
||||
;; we leave the newline we've put in there before,
|
||||
;; but we need to re-indent the line above
|
||||
(let ((pos (- (point-max) (point)))
|
||||
(here (point))
|
||||
(c-state-cache c-state-cache))
|
||||
(here (point)))
|
||||
(forward-line -1)
|
||||
;; we may need to update the cache. this should still be
|
||||
;; faster than recalculating the state in many cases
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(narrow-to-region here (point))
|
||||
(if (and (c-safe (progn (backward-up-list -1) t))
|
||||
(memq (char-before) '(?\) ?}))
|
||||
(progn (widen)
|
||||
(c-safe (progn (forward-sexp -1) t))))
|
||||
(setq c-state-cache
|
||||
(c-hack-state (point) 'open c-state-cache))
|
||||
(if (and (car c-state-cache)
|
||||
(not (consp (car c-state-cache)))
|
||||
(<= (point) (car c-state-cache)))
|
||||
(setq c-state-cache (cdr c-state-cache))
|
||||
))))
|
||||
(let ((here (point))
|
||||
(shift (c-indent-line)))
|
||||
(setq c-state-cache (c-adjust-state (c-point 'bol) here
|
||||
(- shift) c-state-cache)))
|
||||
(let ((c-state-cache (c-whack-state (point) c-state-cache)))
|
||||
;; we may need to update the cache. this should
|
||||
;; still be faster than recalculating the state
|
||||
;; in many cases
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(narrow-to-region here (point))
|
||||
(if (and (c-safe (progn (backward-up-list -1) t))
|
||||
(memq (char-before) '(?\) ?}))
|
||||
(progn (widen)
|
||||
(c-safe (progn (c-forward-sexp -1)
|
||||
t))))
|
||||
(setq c-state-cache
|
||||
(c-hack-state (point) 'open c-state-cache)))))
|
||||
(c-indent-line))
|
||||
(setq c-state-cache (c-adjust-state (c-point 'bol) here
|
||||
(- (point) (c-point 'bol))
|
||||
c-state-cache))
|
||||
(goto-char (- (point-max) pos))
|
||||
;; if the buffer has changed due to the indentation, we
|
||||
;; need to recalculate syntax for the current line, but
|
||||
@ -291,10 +323,11 @@ the brace is inserted inside a literal."
|
||||
;; now adjust the line's indentation. don't update the state
|
||||
;; cache since c-guess-basic-syntax isn't called when the
|
||||
;; syntax is passed to c-indent-line
|
||||
(let ((here (point))
|
||||
(shift (c-indent-line syntax)))
|
||||
(let* ((here (point)))
|
||||
(c-indent-line syntax)
|
||||
(setq c-state-cache (c-adjust-state (c-point 'bol) here
|
||||
(- shift) c-state-cache)))
|
||||
(- (c-point 'boi) (c-point 'bol))
|
||||
c-state-cache)))
|
||||
;; Do all appropriate clean ups
|
||||
(let ((here (point))
|
||||
(pos (- (point-max) (point)))
|
||||
@ -325,22 +358,6 @@ the brace is inserted inside a literal."
|
||||
(progn
|
||||
(delete-region mbeg mend)
|
||||
(insert "} else {")))
|
||||
;; clean up brace-elseif-brace
|
||||
(if (and c-auto-newline
|
||||
(memq 'brace-elseif-brace c-cleanup-list)
|
||||
(eq last-command-char ?\{)
|
||||
(re-search-backward "}[ \t\n]*else[ \t\n]+if[ \t\n]*" nil t)
|
||||
(save-excursion
|
||||
(goto-char (match-end 0))
|
||||
(c-safe (forward-sexp 1))
|
||||
(skip-chars-forward " \t\n")
|
||||
(setq mbeg (match-beginning 0)
|
||||
mend (match-end 0))
|
||||
(= here (1+ (point))))
|
||||
(not (c-in-literal)))
|
||||
(progn
|
||||
(delete-region mbeg mend)
|
||||
(insert "} else if ")))
|
||||
(goto-char (- (point-max) pos))
|
||||
)
|
||||
;; does a newline go after the brace?
|
||||
@ -359,7 +376,7 @@ the brace is inserted inside a literal."
|
||||
(c-backward-syntactic-ws safepos)
|
||||
(funcall old-blink-paren)))
|
||||
))))
|
||||
|
||||
|
||||
(defun c-electric-slash (arg)
|
||||
"Insert a slash character.
|
||||
|
||||
@ -422,7 +439,10 @@ is determined.
|
||||
|
||||
When semicolon is inserted, the line is re-indented unless a numeric
|
||||
arg is supplied, point is inside a literal, or there are
|
||||
non-whitespace characters on the line following the semicolon."
|
||||
non-whitespace characters on the line following the semicolon.
|
||||
|
||||
Based on the value of `c-cleanup-list', this function cleans up commas
|
||||
following brace lists and semicolons following defuns."
|
||||
(interactive "*P")
|
||||
(let* ((lim (c-most-enclosing-brace (c-parse-state)))
|
||||
(literal (c-in-literal lim))
|
||||
@ -435,9 +455,10 @@ non-whitespace characters on the line following the semicolon."
|
||||
(self-insert-command (prefix-numeric-value arg))
|
||||
;; do some special stuff with the character
|
||||
(self-insert-command (prefix-numeric-value arg))
|
||||
;; do all cleanups, reindentations, and newline insertions, but
|
||||
;; only if c-auto-newline is turned on
|
||||
(if (not c-auto-newline) nil
|
||||
;; do all cleanups and newline insertions if c-auto-newline is
|
||||
;; turned on
|
||||
(if (not c-auto-newline)
|
||||
(c-indent-line)
|
||||
;; clean ups
|
||||
(let ((pos (- (point-max) (point))))
|
||||
(if (and (or (and
|
||||
@ -524,10 +545,11 @@ value of `c-cleanup-list'."
|
||||
(or (c-lookup-lists '(case-label label access-label)
|
||||
syntax c-hanging-colons-alist)
|
||||
(c-lookup-lists '(member-init-intro inher-intro)
|
||||
(prog2
|
||||
(insert "\n")
|
||||
(c-guess-basic-syntax)
|
||||
(delete-char -1))
|
||||
(let ((buffer-undo-list t))
|
||||
(insert "\n")
|
||||
(unwind-protect
|
||||
(c-guess-basic-syntax)
|
||||
(delete-char -1)))
|
||||
c-hanging-colons-alist))))
|
||||
;; indent the current line
|
||||
(c-indent-line syntax)
|
||||
@ -554,13 +576,10 @@ value of `c-cleanup-list'."
|
||||
|
||||
(defun c-electric-lt-gt (arg)
|
||||
"Insert a less-than, or greater-than character.
|
||||
When the auto-newline feature is turned on, as evidenced by the \"/a\"
|
||||
or \"/ah\" string on the mode line, the line will be re-indented if
|
||||
the character inserted is the second of a C++ style stream operator
|
||||
and the buffer is in C++ mode.
|
||||
|
||||
The line will also not be re-indented if a numeric argument is
|
||||
supplied, or point is inside a literal."
|
||||
The line will be re-indented if the character inserted is the second
|
||||
of a C++ style stream operator and the buffer is in C++ mode.
|
||||
Exceptions are when a numeric argument is supplied, or point is inside
|
||||
a literal, in which case the line will not be re-indented."
|
||||
(interactive "*P")
|
||||
(let ((indentp (and (not arg)
|
||||
(eq (char-before) last-command-char)
|
||||
@ -571,6 +590,65 @@ supplied, or point is inside a literal."
|
||||
(if indentp
|
||||
(c-indent-line))))
|
||||
|
||||
(defun c-electric-paren (arg)
|
||||
"Insert a parenthesis.
|
||||
|
||||
If the auto-newline feature is turned on, as evidenced by the \"/a\"
|
||||
or \"/ah\" string on the mode line, some newline cleanups are done if
|
||||
appropriate; see the variable `c-cleanup-list'.
|
||||
|
||||
Also, the line is re-indented unless a numeric ARG is supplied, there
|
||||
are non-whitespace characters present on the line after the colon, or
|
||||
the colon is inserted inside a literal."
|
||||
(interactive "*P")
|
||||
(let (;; shut this up
|
||||
(c-echo-syntactic-information-p nil))
|
||||
(if (or arg
|
||||
(not (looking-at "[ \t]*$"))
|
||||
(c-in-literal (c-point 'bod)))
|
||||
(self-insert-command (prefix-numeric-value arg))
|
||||
;; do some special stuff with the character
|
||||
(let* (;; We want to inhibit blinking the paren since this will
|
||||
;; be most disruptive. We'll blink it ourselves
|
||||
;; afterwards.
|
||||
(old-blink-paren blink-paren-function)
|
||||
blink-paren-function)
|
||||
(self-insert-command (prefix-numeric-value arg))
|
||||
(c-indent-line)
|
||||
(when c-auto-newline
|
||||
;; Do all appropriate clean ups
|
||||
(let ((here (point))
|
||||
(pos (- (point-max) (point)))
|
||||
mbeg mend)
|
||||
;; clean up brace-elseif-brace
|
||||
(if (and (memq 'brace-elseif-brace c-cleanup-list)
|
||||
(eq last-command-char ?\()
|
||||
(re-search-backward "}[ \t\n]*else[ \t\n]+if[ \t\n]*("
|
||||
nil t)
|
||||
(save-excursion
|
||||
(setq mbeg (match-beginning 0)
|
||||
mend (match-end 0))
|
||||
(= mend here))
|
||||
(not (c-in-literal)))
|
||||
(progn
|
||||
(delete-region mbeg mend)
|
||||
(insert "} else if (")))
|
||||
;; clean up brace-catch-brace
|
||||
(if (and (memq 'brace-catch-brace c-cleanup-list)
|
||||
(eq last-command-char ?\()
|
||||
(re-search-backward "}[ \t\n]*catch[ \t\n]*(" nil t)
|
||||
(save-excursion
|
||||
(setq mbeg (match-beginning 0)
|
||||
mend (match-end 0))
|
||||
(= mend here))
|
||||
(not (c-in-literal)))
|
||||
(progn
|
||||
(delete-region mbeg mend)
|
||||
(insert "} catch (")))
|
||||
(goto-char (- (point-max) pos))
|
||||
))
|
||||
(funcall old-blink-paren)))))
|
||||
|
||||
|
||||
|
||||
;; better movement routines for ThisStyleOfVariablesCommonInCPlusPlus
|
||||
@ -639,6 +717,8 @@ Negative argument -N means move back to Nth preceding end of defun.
|
||||
An end of a defun occurs right after the close-parenthesis that matches
|
||||
the open-parenthesis that starts a defun; see `beginning-of-defun'."
|
||||
(interactive "p")
|
||||
(if (not arg)
|
||||
(setq arg 1))
|
||||
(if (< arg 0)
|
||||
(c-beginning-of-defun (- arg))
|
||||
(while (> arg 0)
|
||||
@ -646,9 +726,9 @@ the open-parenthesis that starts a defun; see `beginning-of-defun'."
|
||||
(while (and (c-safe (down-list 1) t)
|
||||
(not (eq (char-before) ?{)))
|
||||
(forward-char -1)
|
||||
(forward-sexp))
|
||||
(c-forward-sexp))
|
||||
(c-beginning-of-defun 1)
|
||||
(forward-sexp 1)
|
||||
(c-forward-sexp 1)
|
||||
(setq arg (1- arg)))
|
||||
(forward-line 1))
|
||||
(c-keep-region-active))
|
||||
@ -734,20 +814,13 @@ comment."
|
||||
;; perhaps they should be changed, but that'd likely break a
|
||||
;; lot in cc-engine.
|
||||
(goto-char here)
|
||||
;; Move out of any enclosing non-`{ }' parens.
|
||||
(let ((last (point)))
|
||||
(while (and (c-safe (progn (up-list 1) t))
|
||||
(/= (char-before) ?\}))
|
||||
(setq last (point)))
|
||||
(goto-char last))
|
||||
(if (> count 0)
|
||||
(if (condition-case nil
|
||||
;; Stop before `{' and after `;', `{', `}' and
|
||||
;; `};' when not followed by `}', but on the other
|
||||
;; side of the syntactic ws. Also stop before
|
||||
;; `}', but only to catch comments. Move by sexps
|
||||
;; and move into `{ }', but not into any other
|
||||
;; other type of paren.
|
||||
;; `};' when not followed by `}' or `)', but on
|
||||
;; the other side of the syntactic ws. Also stop
|
||||
;; before `}', but only to catch comments. Move
|
||||
;; by sexps and move into parens.
|
||||
(catch 'done
|
||||
(let (last)
|
||||
(while t
|
||||
@ -767,33 +840,37 @@ comment."
|
||||
((progn (backward-char)
|
||||
(looking-at "[;{}]"))
|
||||
(if (or (= here last)
|
||||
(= (char-after last) ?}))
|
||||
(memq (char-after last) '(?\) ?})))
|
||||
(if (and (= (char-before) ?})
|
||||
(= (char-after) ?\;))
|
||||
(backward-char))
|
||||
(goto-char last)
|
||||
(throw 'done t)))
|
||||
((or (= (char-syntax (char-after)) ?\))
|
||||
(= (char-syntax (char-after)) ?\"))
|
||||
((= (char-syntax (char-after)) ?\")
|
||||
(forward-char)
|
||||
(backward-sexp))
|
||||
(c-backward-sexp))
|
||||
))))
|
||||
(error
|
||||
(goto-char (point-min))
|
||||
t))
|
||||
(setq count (1- count)))
|
||||
(if (condition-case nil
|
||||
;; Stop before `{' and `}' and after `;', `}' and
|
||||
;; `};'. Also stop after `{', but only to catch
|
||||
;; comments. Move by sexps and move into `{ }', but
|
||||
;; not into any other other type of paren.
|
||||
;; Stop before `{' and `}', but on the other side of
|
||||
;; the syntactic ws, and after `;', `}' and `};'.
|
||||
;; Only stop before `{' if at top level or inside
|
||||
;; braces, though. Also stop after `{', but only to
|
||||
;; catch comments. Move by sexps and move into
|
||||
;; parens.
|
||||
(catch 'done
|
||||
(let (last)
|
||||
(while t
|
||||
(setq last (point))
|
||||
(c-forward-syntactic-ws)
|
||||
(cond ((= (char-after) ?{)
|
||||
(if (= here last)
|
||||
(if (or (= here last)
|
||||
(save-excursion
|
||||
(and (c-safe (progn (up-list -1) t))
|
||||
(/= (char-after) ?{))))
|
||||
(progn (forward-char)
|
||||
(throw 'done nil))
|
||||
(goto-char last)
|
||||
@ -805,9 +882,8 @@ comment."
|
||||
((looking-at ";\\|};?")
|
||||
(goto-char (match-end 0))
|
||||
(throw 'done t))
|
||||
((or (= (char-syntax (char-after)) ?\()
|
||||
(= (char-syntax (char-after)) ?\"))
|
||||
(forward-sexp))
|
||||
((= (char-syntax (char-after)) ?\")
|
||||
(c-forward-sexp))
|
||||
(t
|
||||
(forward-char))
|
||||
))))
|
||||
@ -855,7 +931,8 @@ comment."
|
||||
c-electric-star
|
||||
c-electric-semi&comma
|
||||
c-electric-lt-gt
|
||||
c-electric-colon))
|
||||
c-electric-colon
|
||||
c-electric-paren))
|
||||
(put 'c-electric-delete 'delete-selection 'supersede) ; delsel
|
||||
(put 'c-electric-delete 'pending-delete 'supersede) ; pending-del
|
||||
(put 'c-electric-backspace 'delete-selection 'supersede) ; delsel
|
||||
@ -883,13 +960,13 @@ comment."
|
||||
((or (looking-at "^#[ \t]*endif[ \t]*")
|
||||
(looking-at "^#[ \t]*else[ \t]*"))
|
||||
7)
|
||||
;; CASE 3: when comment-column is nil, calculate the offset
|
||||
;; according to c-offsets-alist. E.g. identical to hitting
|
||||
;; TAB.
|
||||
;; CASE 3: when c-indent-comments-syntactically-p is t,
|
||||
;; calculate the offset according to c-offsets-alist.
|
||||
;; E.g. identical to hitting TAB.
|
||||
((and c-indent-comments-syntactically-p
|
||||
(save-excursion
|
||||
(skip-chars-forward " \t")
|
||||
(or (looking-at comment-start)
|
||||
(or (looking-at c-comment-start-regexp)
|
||||
(eolp))))
|
||||
(let ((syntax (c-guess-basic-syntax)))
|
||||
;; BOGOSITY ALERT: if we're looking at the eol, its
|
||||
@ -944,7 +1021,8 @@ comment."
|
||||
(let ((literal (c-in-literal))
|
||||
at-comment-col)
|
||||
(cond
|
||||
((eq literal 'string))
|
||||
((eq literal 'string)
|
||||
(insert ?\n))
|
||||
((or (not c-comment-continuation-stars)
|
||||
(not literal))
|
||||
(indent-new-comment-line soft))
|
||||
@ -975,15 +1053,15 @@ comment."
|
||||
(c-indent-line))))))
|
||||
|
||||
;; advice for indent-new-comment-line for older Emacsen
|
||||
(if (boundp 'comment-line-break-function)
|
||||
nil
|
||||
(require 'advice)
|
||||
(defadvice indent-new-comment-line (around c-line-break-advice activate)
|
||||
(if (or (not c-buffer-is-cc-mode)
|
||||
(not (c-in-literal))
|
||||
(not c-comment-continuation-stars))
|
||||
ad-do-it
|
||||
(c-comment-line-break-function (ad-get-arg 0)))))
|
||||
(or (boundp 'comment-line-break-function)
|
||||
(defadvice indent-new-comment-line (around c-line-break-advice
|
||||
activate preactivate)
|
||||
"Calls c-comment-line-break-function if in a comment in CC Mode."
|
||||
(if (or (not c-buffer-is-cc-mode)
|
||||
(not (c-in-literal))
|
||||
(not c-comment-continuation-stars))
|
||||
ad-do-it
|
||||
(c-comment-line-break-function (ad-get-arg 0)))))
|
||||
|
||||
;; used by outline-minor-mode
|
||||
(defun c-outline-level ()
|
||||
@ -1093,7 +1171,7 @@ of the expression are preserved.
|
||||
just inserts a tab character, or the equivalent number of spaces,
|
||||
depending on the variable `indent-tabs-mode'."
|
||||
|
||||
(interactive "*P")
|
||||
(interactive "P")
|
||||
(let ((bod (c-point 'bod)))
|
||||
(if whole-exp
|
||||
;; If arg, always indent this line as C
|
||||
@ -1104,7 +1182,7 @@ of the expression are preserved.
|
||||
(if (eq c-tab-always-indent t)
|
||||
(beginning-of-line))
|
||||
(setq beg (point))
|
||||
(forward-sexp 1)
|
||||
(c-forward-sexp 1)
|
||||
(setq end (point))
|
||||
(goto-char beg)
|
||||
(forward-line 1)
|
||||
@ -1156,7 +1234,7 @@ Optional SHUTUP-P if non-nil, inhibits message printing and error checking."
|
||||
(memq (char-after) '(?\( ?\[ ?\{))
|
||||
(point)))))))
|
||||
;; find balanced expression end
|
||||
(setq end (and (c-safe (progn (forward-sexp 1) t))
|
||||
(setq end (and (c-safe (progn (c-forward-sexp 1) t))
|
||||
(point-marker)))
|
||||
;; sanity check
|
||||
(and (not start)
|
||||
@ -1247,18 +1325,18 @@ Optional SHUTUP-P if non-nil, inhibits message printing and error checking."
|
||||
(while (< (point) nextline)
|
||||
(condition-case nil
|
||||
(progn
|
||||
(forward-sexp 1)
|
||||
(c-forward-sexp 1)
|
||||
(setq sexpend (point)))
|
||||
(error (setq sexpend nil)
|
||||
(goto-char nextline)))
|
||||
(c-forward-syntactic-ws))
|
||||
(if sexpend
|
||||
(progn
|
||||
(progn
|
||||
;; make sure the sexp we found really starts on the
|
||||
;; current line and extends past it
|
||||
(goto-char sexpend)
|
||||
(setq sexpend (point-marker))
|
||||
(c-safe (backward-sexp 1))
|
||||
(c-safe (c-backward-sexp 1))
|
||||
(setq sexpbeg (point))))
|
||||
(if (and sexpbeg (< sexpbeg fence))
|
||||
(setq sexpbeg fence)))
|
||||
@ -1295,30 +1373,68 @@ Optional SHUTUP-P if non-nil, inhibits message printing and error checking."
|
||||
))))
|
||||
|
||||
(defun c-mark-function ()
|
||||
"Put mark at end of a C, C++, or Objective-C defun, point at beginning."
|
||||
"Put mark at end of current top-level defun, point at beginning."
|
||||
(interactive)
|
||||
(let ((here (point))
|
||||
;; there should be a c-point position for 'eod
|
||||
(eod (save-excursion (end-of-defun) (point)))
|
||||
(state (c-parse-state))
|
||||
brace)
|
||||
(while state
|
||||
(setq brace (car state))
|
||||
(if (consp brace)
|
||||
(goto-char (cdr brace))
|
||||
(goto-char brace))
|
||||
(setq state (cdr state)))
|
||||
(if (eq (char-after) ?{)
|
||||
(progn
|
||||
(forward-line -1)
|
||||
(while (not (or (bobp)
|
||||
(looking-at "[ \t]*$")))
|
||||
(forward-line -1)))
|
||||
(forward-line 1)
|
||||
(skip-chars-forward " \t\n"))
|
||||
(eod (c-point 'eod))
|
||||
(state (c-parse-state)))
|
||||
;; Are we sitting at the top level, someplace between either the
|
||||
;; beginning of buffer, or the nearest preceding defun? If so,
|
||||
;; try first to figure out whether we're sitting on the
|
||||
;; introduction to a top-level defun, in which case we want to
|
||||
;; mark the entire defun we're sitting on.
|
||||
;;
|
||||
;; If we're sitting on anything else at the top-level, we want to
|
||||
;; just mark the statement that we're on
|
||||
(if (or (and (consp (car state))
|
||||
(= (length state) 1))
|
||||
(null state))
|
||||
;; Are we in the whitespace after the nearest preceding defun?
|
||||
(if (and state
|
||||
(looking-at "[ \t]*$")
|
||||
(= (save-excursion
|
||||
(c-backward-syntactic-ws)
|
||||
(skip-chars-backward ";")
|
||||
(point))
|
||||
(cdar state)))
|
||||
(progn
|
||||
(setq eod (point))
|
||||
(goto-char (caar state))
|
||||
(c-beginning-of-statement-1))
|
||||
(if (= ?{ (save-excursion
|
||||
(c-end-of-statement-1)
|
||||
(char-before)))
|
||||
;; We must be in a defuns's introduction
|
||||
(progn
|
||||
(c-end-of-statement-1)
|
||||
(skip-chars-backward "{")
|
||||
(c-beginning-of-statement-1)
|
||||
(c-forward-syntactic-ws))
|
||||
;; Just mark the statement
|
||||
(c-end-of-statement-1)
|
||||
(forward-line 1)
|
||||
(setq eod (point))
|
||||
(c-beginning-of-statement-1)))
|
||||
;; We are inside some enclosing brace structure, so we first
|
||||
;; need to find our way to the least enclosing brace. Then, in
|
||||
;; both cases, we to mark the region from the beginning of the
|
||||
;; current statement, until the end of the next following defun
|
||||
(while (and state)
|
||||
(or (consp (car state))
|
||||
(goto-char (car state)))
|
||||
(setq state (cdr state)))
|
||||
(c-beginning-of-statement-1))
|
||||
(push-mark here)
|
||||
(push-mark eod nil t)))
|
||||
|
||||
(defun c-indent-line-or-region ()
|
||||
"When the region is active, indent it. Otherwise indent the current line."
|
||||
;; Emacs has a variable called mark-active, XEmacs uses region-active-p
|
||||
(interactive)
|
||||
(if (c-region-is-active-p)
|
||||
(c-indent-region (region-beginning) (region-end))
|
||||
(c-indent-command)))
|
||||
|
||||
|
||||
;; for progress reporting
|
||||
(defvar c-progress-info nil)
|
||||
@ -1384,7 +1500,7 @@ With an argument, deletes the backslashes.
|
||||
This function does not modify blank lines at the start of the region.
|
||||
If the region ends at the start of a line, it always deletes the
|
||||
backslash (if any) at the end of the previous line.
|
||||
|
||||
|
||||
You can put the region around an entire macro definition and use this
|
||||
command to conveniently insert and align the necessary backslashes."
|
||||
(interactive "*r\nP")
|
||||
@ -1548,65 +1664,69 @@ Optional prefix ARG means justify paragraph as well."
|
||||
t)))
|
||||
;; Inside a comment: fill one comment paragraph.
|
||||
(let ((fill-prefix
|
||||
;; The prefix for each line of this paragraph
|
||||
;; is the appropriate part of the start of this line,
|
||||
;; up to the column at which text should be indented.
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(if (looking-at ".*/\\*.*\\*/")
|
||||
(progn (re-search-forward comment-start-skip)
|
||||
(make-string (current-column) ?\ ))
|
||||
(if first-line
|
||||
(forward-line 1)
|
||||
(if (and (looking-at "[ \t]*\\*/")
|
||||
(not (save-excursion
|
||||
(forward-line -1)
|
||||
(looking-at ".*/\\*"))))
|
||||
(forward-line -1)))
|
||||
(or
|
||||
;; Keep user set fill prefix if any.
|
||||
fill-prefix
|
||||
;; The prefix for each line of this paragraph
|
||||
;; is the appropriate part of the start of this line,
|
||||
;; up to the column at which text should be indented.
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(if (looking-at ".*/\\*.*\\*/")
|
||||
(progn (re-search-forward comment-start-skip)
|
||||
(make-string (current-column) ?\ ))
|
||||
(if first-line
|
||||
(forward-line 1)
|
||||
(if (and (looking-at "[ \t]*\\*/")
|
||||
(not (save-excursion
|
||||
(forward-line -1)
|
||||
(looking-at ".*/\\*"))))
|
||||
(forward-line -1)))
|
||||
|
||||
(let ((line-width (progn (end-of-line) (current-column))))
|
||||
(beginning-of-line)
|
||||
(prog1
|
||||
(buffer-substring
|
||||
(point)
|
||||
(let ((line-width (progn (end-of-line)
|
||||
(current-column))))
|
||||
(beginning-of-line)
|
||||
(prog1
|
||||
(buffer-substring
|
||||
(point)
|
||||
|
||||
;; How shall we decide where the end of the
|
||||
;; fill-prefix is?
|
||||
(progn
|
||||
(skip-chars-forward " \t*" (c-point 'eol))
|
||||
;; kludge alert, watch out for */, in
|
||||
;; which case fill-prefix should *not*
|
||||
;; be "*"!
|
||||
(if (and (eq (char-after) ?/)
|
||||
(eq (char-before) ?*))
|
||||
(forward-char -1))
|
||||
(point)))
|
||||
;; How shall we decide where the end of the
|
||||
;; fill-prefix is?
|
||||
(progn
|
||||
(skip-chars-forward " \t*" (c-point 'eol))
|
||||
;; kludge alert, watch out for */, in
|
||||
;; which case fill-prefix should *not*
|
||||
;; be "*"!
|
||||
(if (and (eq (char-after) ?/)
|
||||
(eq (char-before) ?*))
|
||||
(forward-char -1))
|
||||
(point)))
|
||||
|
||||
;; If the comment is only one line followed
|
||||
;; by a blank line, calling move-to-column
|
||||
;; above may have added some spaces and tabs
|
||||
;; to the end of the line; the fill-paragraph
|
||||
;; function will then delete it and the
|
||||
;; newline following it, so we'll lose a
|
||||
;; blank line when we shouldn't. So delete
|
||||
;; anything move-to-column added to the end
|
||||
;; of the line. We record the line width
|
||||
;; instead of the position of the old line
|
||||
;; end because move-to-column might break a
|
||||
;; tab into spaces, and the new characters
|
||||
;; introduced there shouldn't be deleted.
|
||||
;; If the comment is only one line followed
|
||||
;; by a blank line, calling move-to-column
|
||||
;; above may have added some spaces and tabs
|
||||
;; to the end of the line; the fill-paragraph
|
||||
;; function will then delete it and the
|
||||
;; newline following it, so we'll lose a
|
||||
;; blank line when we shouldn't. So delete
|
||||
;; anything move-to-column added to the end
|
||||
;; of the line. We record the line width
|
||||
;; instead of the position of the old line
|
||||
;; end because move-to-column might break a
|
||||
;; tab into spaces, and the new characters
|
||||
;; introduced there shouldn't be deleted.
|
||||
|
||||
;; If you can see a better way to do this,
|
||||
;; please make the change. This seems very
|
||||
;; messy to me.
|
||||
(delete-region (progn (move-to-column line-width)
|
||||
(point))
|
||||
(progn (end-of-line) (point))))))))
|
||||
;; If you can see a better way to do this,
|
||||
;; please make the change. This seems very
|
||||
;; messy to me.
|
||||
(delete-region (progn (move-to-column line-width)
|
||||
(point))
|
||||
(progn (end-of-line) (point)))))))))
|
||||
|
||||
;; Lines containing just a comment start or just an end
|
||||
;; should not be filled into paragraphs they are next
|
||||
;; to.
|
||||
(paragraph-start (if (eq major-mode 'java-mode)
|
||||
(paragraph-start (if (c-major-mode-is 'java-mode)
|
||||
(concat paragraph-start
|
||||
re1 "\\("
|
||||
c-Java-javadoc-paragraph-start
|
||||
@ -1695,8 +1815,7 @@ Optional prefix ARG means justify paragraph as well."
|
||||
(goto-char (car limits))
|
||||
(end-of-line)
|
||||
(< (point) (cdr limits))))
|
||||
(let (fill-prefix
|
||||
fill-paragraph-function)
|
||||
(let (fill-paragraph-function)
|
||||
(save-restriction
|
||||
(narrow-to-region (save-excursion
|
||||
(goto-char (1+ (car limits)))
|
||||
|
@ -1,9 +1,9 @@
|
||||
;;; cc-compat.el --- cc-mode compatibility with c-mode.el confusion
|
||||
|
||||
;; Copyright (C) 1985,87,92,93,94,95,96,97 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 1985,87,92,93,94,95,96,97,98 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: 1994-1997 Barry A. Warsaw
|
||||
;; Maintainer: cc-mode-help@python.org
|
||||
;; Maintainer: bug-cc-mode@gnu.org
|
||||
;; Created: August 1994, split from cc-mode.el
|
||||
;; Version: See cc-mode.el
|
||||
;; Keywords: c languages oop
|
||||
@ -40,6 +40,7 @@
|
||||
;;; Code:
|
||||
|
||||
(eval-when-compile
|
||||
(require 'cc-defs)
|
||||
(require 'cc-styles)
|
||||
(require 'cc-engine))
|
||||
|
||||
@ -114,7 +115,7 @@ This is in addition to c-continued-statement-offset.")
|
||||
;; line
|
||||
(progn
|
||||
(if (eq (char-before) ?\))
|
||||
(forward-sexp -1))
|
||||
(c-forward-sexp -1))
|
||||
;; Get initial indentation of the line we are on.
|
||||
(current-indentation)))))
|
||||
(- bocm-lossage curcol))))
|
||||
|
@ -2,10 +2,11 @@
|
||||
|
||||
;; Copyright (C) 1985,87,92,93,94,95,96,97,98 Free Software Foundation, Inc.
|
||||
|
||||
;; Authors: 1992-1997 Barry A. Warsaw
|
||||
;; Authors: 1998 Barry A. Warsaw and Martin Stjernholm
|
||||
;; 1992-1997 Barry A. Warsaw
|
||||
;; 1987 Dave Detlefs and Stewart Clamen
|
||||
;; 1985 Richard M. Stallman
|
||||
;; Maintainer: cc-mode-help@python.org
|
||||
;; Maintainer: bug-cc-mode@gnu.org
|
||||
;; Created: 22-Apr-1997 (split from cc-mode.el)
|
||||
;; Version: See cc-mode.el
|
||||
;; Keywords: c languages oop
|
||||
@ -27,6 +28,25 @@
|
||||
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;; Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
;; Get all the necessary compile time definitions.
|
||||
(require 'custom)
|
||||
(require 'cc-menus)
|
||||
(require 'derived) ;only necessary in Emacs 20
|
||||
|
||||
;; cc-mode-19.el contains compatibility macros that should be compiled
|
||||
;; in if needed.
|
||||
(if (or (not (fboundp 'functionp))
|
||||
(not (condition-case nil
|
||||
(progn (char-before) t)
|
||||
(error nil)))
|
||||
(not (condition-case nil
|
||||
(progn (char-after) t)
|
||||
(error nil)))
|
||||
(not (fboundp 'when))
|
||||
(not (fboundp 'unless)))
|
||||
(require 'cc-mode-19))
|
||||
|
||||
|
||||
(defsubst c-point (position)
|
||||
;; Returns the value of point at certain commonly referenced POSITIONs.
|
||||
@ -35,6 +55,7 @@
|
||||
;; bol -- beginning of line
|
||||
;; eol -- end of line
|
||||
;; bod -- beginning of defun
|
||||
;; eod -- end of defun
|
||||
;; boi -- back to indentation
|
||||
;; ionl -- indentation of next line
|
||||
;; iopl -- indentation of previous line
|
||||
@ -55,14 +76,14 @@
|
||||
((eq position 'ionl)
|
||||
(forward-line 1)
|
||||
(back-to-indentation))
|
||||
((eq position 'eod) (c-end-of-defun))
|
||||
((eq position 'bod)
|
||||
(if (and (fboundp 'buffer-syntactic-context-depth)
|
||||
c-enable-xemacs-performance-kludge-p)
|
||||
;; XEmacs only. This can improve the performance of
|
||||
;; c-parse-state to between 3 and 60 times faster when
|
||||
;; braces are hung. It can cause c-parse-state to be
|
||||
;; slightly slower when braces are not hung, but general
|
||||
;; editing appears to be still about as fast.
|
||||
;; braces are hung. It can also degrade performance by
|
||||
;; about as much when braces are not hung.
|
||||
(let (pos)
|
||||
(while (not pos)
|
||||
(save-restriction
|
||||
@ -106,12 +127,31 @@
|
||||
(point)
|
||||
(goto-char here))))
|
||||
|
||||
|
||||
(defmacro c-safe (&rest body)
|
||||
;; safely execute BODY, return nil if an error occurred
|
||||
(` (condition-case nil
|
||||
(progn (,@ body))
|
||||
(error nil))))
|
||||
|
||||
(defmacro c-forward-sexp (&optional arg)
|
||||
;; like forward-sexp except
|
||||
;; 1. this is much stripped down from the XEmacs version
|
||||
;; 2. this cannot be used as a command, so we're insulated from
|
||||
;; XEmacs' losing efforts to make forward-sexp more user
|
||||
;; friendly
|
||||
;; 3. Preserves the semantics most of CC Mode is based on
|
||||
(or arg (setq arg 1))
|
||||
`(goto-char (or (scan-sexps (point) ,arg)
|
||||
,(if (numberp arg)
|
||||
(if (> arg 0) `(point-max) `(point-min))
|
||||
`(if (> ,arg 0) (point-max) (point-min))))))
|
||||
|
||||
(defmacro c-backward-sexp (&optional arg)
|
||||
;; See c-forward-sexp and reverse directions
|
||||
(or arg (setq arg 1))
|
||||
`(c-forward-sexp ,(if (numberp arg) (- arg) `(- ,arg))))
|
||||
|
||||
(defmacro c-add-syntax (symbol &optional relpos)
|
||||
;; a simple macro to append the syntax in symbol to the syntax list.
|
||||
;; try to increase performance by using this macro
|
||||
@ -163,6 +203,22 @@
|
||||
(and (boundp 'zmacs-region-stays)
|
||||
(setq zmacs-region-stays t)))
|
||||
|
||||
(defsubst c-region-is-active-p ()
|
||||
;; Return t when the region is active. The determination of region
|
||||
;; activeness is different in both Emacs and XEmacs.
|
||||
(cond
|
||||
;; XEmacs
|
||||
((and (fboundp 'region-active-p)
|
||||
zmacs-regions)
|
||||
(region-active-p))
|
||||
;; Emacs
|
||||
((boundp 'mark-active) mark-active)
|
||||
;; fallback; shouldn't get here
|
||||
(t (mark t))))
|
||||
|
||||
(defsubst c-major-mode-is (mode)
|
||||
(eq (derived-mode-class major-mode) mode))
|
||||
|
||||
|
||||
(provide 'cc-defs)
|
||||
;;; cc-defs.el ends here
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -2,10 +2,11 @@
|
||||
|
||||
;; Copyright (C) 1985,87,92,93,94,95,96,97,98 Free Software Foundation, Inc.
|
||||
|
||||
;; Authors: 1992-1997 Barry A. Warsaw
|
||||
;; Authors: 1998 Barry A. Warsaw and Martin Stjernholm
|
||||
;; 1992-1997 Barry A. Warsaw
|
||||
;; 1987 Dave Detlefs and Stewart Clamen
|
||||
;; 1985 Richard M. Stallman
|
||||
;; Maintainer: cc-mode-help@python.org
|
||||
;; Maintainer: bug-cc-mode@gnu.org
|
||||
;; Created: 22-Apr-1997 (split from cc-mode.el)
|
||||
;; Version: See cc-mode.el
|
||||
;; Keywords: c languages oop
|
||||
@ -29,7 +30,8 @@
|
||||
|
||||
|
||||
|
||||
(require 'cc-defs)
|
||||
(eval-when-compile
|
||||
(require 'cc-defs))
|
||||
|
||||
;; Regular expressions and other values which must be parameterized on
|
||||
;; a per-language basis.
|
||||
@ -54,8 +56,10 @@
|
||||
;; keywords introducing class definitions. language specific
|
||||
(defconst c-C-class-key "\\(struct\\|union\\)")
|
||||
(defconst c-C++-class-key "\\(class\\|struct\\|union\\)")
|
||||
(defconst c-C-extra-toplevel-key "\\(extern\\)[^_]")
|
||||
(defconst c-C++-extra-toplevel-key "\\(extern\\|namespace\\)[^_]")
|
||||
(defconst c-IDL-class-key "\\(class\\|struct\\|union\\|interface\\)")
|
||||
(defconst c-C-extra-toplevel-key "\\(extern\\)")
|
||||
(defconst c-C++-extra-toplevel-key "\\(extern\\|namespace\\)")
|
||||
(defconst c-IDL-extra-toplevel-key "\\(module\\)")
|
||||
|
||||
(defconst c-ObjC-class-key
|
||||
(concat
|
||||
@ -70,10 +74,12 @@
|
||||
"\\(" c-protection-key "\\s +\\)?"
|
||||
"\\(interface\\|class\\)\\s +"
|
||||
c-symbol-key ;name of the class
|
||||
"\\(\\s *extends\\s *" c-symbol-key "\\)?" ;maybe followed by superclass
|
||||
"\\(\\s *extends\\s *" c-symbol-key "\\)?" ;maybe followed by superclass
|
||||
;;"\\(\\s *implements *[^{]+{\\)?" ;maybe the adopted protocols list
|
||||
))
|
||||
|
||||
(defconst c-Pike-class-key "class")
|
||||
|
||||
(defvar c-class-key c-C-class-key)
|
||||
(make-variable-buffer-local 'c-class-key)
|
||||
|
||||
@ -87,12 +93,14 @@
|
||||
(defconst c-C++-access-key (concat c-protection-key "[ \t]*:"))
|
||||
(defconst c-ObjC-access-key (concat "@" c-protection-key))
|
||||
(defconst c-Java-access-key nil)
|
||||
(defconst c-Pike-access-key nil)
|
||||
|
||||
|
||||
;; keywords introducing conditional blocks
|
||||
(defconst c-C-conditional-key nil)
|
||||
(defconst c-C++-conditional-key nil)
|
||||
(defconst c-Java-conditional-key nil)
|
||||
(defconst c-Pike-conditional-key nil)
|
||||
|
||||
(let ((all-kws "for\\|if\\|do\\|else\\|while\\|switch")
|
||||
(exc-kws "\\|try\\|catch")
|
||||
@ -101,7 +109,8 @@
|
||||
(back "\\)\\b[^_]"))
|
||||
(setq c-C-conditional-key (concat front all-kws back)
|
||||
c-C++-conditional-key (concat front all-kws exc-kws back)
|
||||
c-Java-conditional-key (concat front all-kws exc-kws thr-kws back)))
|
||||
c-Java-conditional-key (concat front all-kws exc-kws thr-kws back)
|
||||
c-Pike-conditional-key (concat front all-kws "\\|foreach" back)))
|
||||
|
||||
(defvar c-conditional-key c-C-conditional-key)
|
||||
(make-variable-buffer-local 'c-conditional-key)
|
||||
@ -166,6 +175,30 @@
|
||||
(defconst c-Java-javadoc-paragraph-start
|
||||
"@\\(author\\|exception\\|param\\|return\\|see\\|version\\)")
|
||||
|
||||
;; Regexp that starts lambda constructs.
|
||||
(defvar c-lambda-key nil)
|
||||
(make-variable-buffer-local 'c-lambda-key)
|
||||
(defconst c-Pike-lambda-key "\\<lambda\\>")
|
||||
|
||||
;; Regexp that are followed by a statement block in expressions.
|
||||
(defvar c-inexpr-block-key nil)
|
||||
(make-variable-buffer-local 'c-inexpr-block-key)
|
||||
(defconst c-Pike-inexpr-block-key "\\<\\(catch\\|gauge\\)\\>")
|
||||
|
||||
;; Regexp that may be followed by an anonymous class in expressions.
|
||||
(defvar c-inexpr-class-key nil)
|
||||
(make-variable-buffer-local 'c-inexpr-class-key)
|
||||
(defconst c-Java-inexpr-class-key "\\<new\\>")
|
||||
|
||||
;; List of open- and close-chars that makes up a pike-style brace
|
||||
;; list, ie for a `([ ])' list there should be a cons (?\[ . ?\]) in
|
||||
;; this list.
|
||||
(defvar c-special-brace-lists nil)
|
||||
(make-variable-buffer-local 'c-special-brace-lists)
|
||||
(defconst c-Pike-special-brace-lists '((?{ . ?})
|
||||
(?\[ . ?\])
|
||||
(?< . ?>)))
|
||||
|
||||
|
||||
|
||||
;; internal state variables
|
||||
@ -188,11 +221,6 @@
|
||||
|
||||
|
||||
|
||||
(defun c-use-java-style ()
|
||||
"Institutes `java' indentation style.
|
||||
For use with the variable `java-mode-hook'."
|
||||
(c-set-style "java"))
|
||||
|
||||
(defun c-common-init ()
|
||||
;; Common initializations for all modes.
|
||||
;; these variables should always be buffer local; they do not affect
|
||||
@ -212,6 +240,7 @@ For use with the variable `java-mode-hook'."
|
||||
(make-local-variable 'outline-regexp)
|
||||
(make-local-variable 'outline-level)
|
||||
(make-local-variable 'adaptive-fill-regexp)
|
||||
(make-local-variable 'adaptive-fill-mode)
|
||||
(make-local-variable 'imenu-generic-expression) ;set in the mode functions
|
||||
;; X/Emacs 20 only
|
||||
(and (boundp 'comment-line-break-function)
|
||||
@ -235,7 +264,8 @@ For use with the variable `java-mode-hook'."
|
||||
comment-start-skip "/\\*+ *\\|// *"
|
||||
comment-multi-line nil
|
||||
comment-line-break-function 'c-comment-line-break-function
|
||||
adaptive-fill-regexp nil)
|
||||
adaptive-fill-regexp nil
|
||||
adaptive-fill-mode nil)
|
||||
;; we have to do something special for c-offsets-alist so that the
|
||||
;; buffer local value has its own alist structure.
|
||||
(setq c-offsets-alist (copy-alist c-offsets-alist))
|
||||
@ -249,7 +279,17 @@ For use with the variable `java-mode-hook'."
|
||||
(or (assq 'c-auto-hungry-string minor-mode-alist)
|
||||
(setq minor-mode-alist
|
||||
(cons '(c-auto-hungry-string c-auto-hungry-string)
|
||||
minor-mode-alist))))
|
||||
minor-mode-alist)))
|
||||
;; now set the mode style based on c-default-style
|
||||
(c-set-style (if (stringp c-default-style)
|
||||
(if (c-major-mode-is 'java-mode)
|
||||
"java"
|
||||
c-default-style)
|
||||
(or (cdr (assq major-mode c-default-style))
|
||||
(cdr (assq 'other c-default-style))
|
||||
"gnu")))
|
||||
)
|
||||
|
||||
|
||||
(defun c-postprocess-file-styles ()
|
||||
"Function that post processes relevant file local variables.
|
||||
@ -277,6 +317,9 @@ Note that the style variables are always made local to the buffer."
|
||||
(add-hook 'hack-local-variables-hook 'c-postprocess-file-styles)
|
||||
|
||||
|
||||
(defvar c-mode-base-map ()
|
||||
"Keymap shared by all CC Mode related modes.")
|
||||
|
||||
;; Common routines
|
||||
(defun c-make-inherited-keymap ()
|
||||
(let ((map (make-sparse-keymap)))
|
||||
@ -325,9 +368,6 @@ Note that the style variables are always made local to the buffer."
|
||||
(modify-syntax-entry ?\^m "> b" table))
|
||||
|
||||
|
||||
(defvar c-mode-base-map ()
|
||||
"Keymap shared by all CC Mode related modes.")
|
||||
|
||||
(if c-mode-base-map
|
||||
nil
|
||||
;; TBD: should we even worry about naming this keymap. My vote: no,
|
||||
@ -340,6 +380,8 @@ Note that the style variables are always made local to the buffer."
|
||||
(define-key c-mode-base-map ";" 'c-electric-semi&comma)
|
||||
(define-key c-mode-base-map "#" 'c-electric-pound)
|
||||
(define-key c-mode-base-map ":" 'c-electric-colon)
|
||||
(define-key c-mode-base-map "(" 'c-electric-paren)
|
||||
(define-key c-mode-base-map ")" 'c-electric-paren)
|
||||
;; Separate M-BS from C-M-h. The former should remain
|
||||
;; backward-kill-word.
|
||||
(define-key c-mode-base-map [(control meta h)] 'c-mark-function)
|
||||
@ -396,26 +438,27 @@ Note that the style variables are always made local to the buffer."
|
||||
(defvar c-c++-menu nil)
|
||||
(defvar c-objc-menu nil)
|
||||
(defvar c-java-menu nil)
|
||||
(defvar c-pike-menu nil)
|
||||
|
||||
(defun c-mode-menu (modestr)
|
||||
(let ((m
|
||||
'(["Comment Out Region" comment-region (mark t)]
|
||||
'(["Comment Out Region" comment-region (c-region-is-active-p)]
|
||||
["Uncomment Region"
|
||||
(comment-region (region-beginning) (region-end) '(4))
|
||||
(mark t)]
|
||||
(c-region-is-active-p)]
|
||||
["Fill Comment Paragraph" c-fill-paragraph t]
|
||||
"---"
|
||||
["Indent Expression" c-indent-exp
|
||||
(memq (char-after) '(?\( ?\[ ?\{))]
|
||||
["Indent Line" c-indent-command t]
|
||||
["Indent Line or Region" c-indent-line-or-region t]
|
||||
["Up Conditional" c-up-conditional t]
|
||||
["Backward Conditional" c-backward-conditional t]
|
||||
["Forward Conditional" c-forward-conditional t]
|
||||
["Backward Statement" c-beginning-of-statement t]
|
||||
["Forward Statement" c-end-of-statement t]
|
||||
"---"
|
||||
["Macro Expand Region" c-macro-expand (mark t)]
|
||||
["Backslashify" c-backslash-region (mark t)]
|
||||
["Macro Expand Region" c-macro-expand (c-region-is-active-p)]
|
||||
["Backslashify" c-backslash-region (c-region-is-active-p)]
|
||||
)))
|
||||
(cons modestr m)))
|
||||
|
||||
@ -564,6 +607,33 @@ Note that the style variables are always made local to the buffer."
|
||||
(easy-menu-define c-idl-menu idl-mode-map "IDL Mode Commands"
|
||||
(c-mode-menu "IDL"))
|
||||
|
||||
|
||||
;; Support for Pike
|
||||
|
||||
(defvar pike-mode-abbrev-table nil
|
||||
"Abbreviation table used in pike-mode buffers.")
|
||||
(define-abbrev-table 'pike-mode-abbrev-table ())
|
||||
|
||||
(defvar pike-mode-map ()
|
||||
"Keymap used in pike-mode buffers.")
|
||||
(if pike-mode-map
|
||||
nil
|
||||
(setq pike-mode-map (c-make-inherited-keymap))
|
||||
;; additional bindings
|
||||
(define-key pike-mode-map "\C-c\C-e" 'c-macro-expand))
|
||||
|
||||
;;;###autoload
|
||||
(defvar pike-mode-syntax-table nil
|
||||
"Syntax table used in pike-mode buffers.")
|
||||
(if pike-mode-syntax-table
|
||||
()
|
||||
(setq pike-mode-syntax-table (make-syntax-table))
|
||||
(c-populate-syntax-table pike-mode-syntax-table)
|
||||
(modify-syntax-entry ?@ "." pike-mode-syntax-table))
|
||||
|
||||
(easy-menu-define c-pike-menu pike-mode-map "Pike Mode Commands"
|
||||
(c-mode-menu "Pike"))
|
||||
|
||||
|
||||
|
||||
(provide 'cc-langs)
|
||||
|
@ -2,10 +2,11 @@
|
||||
|
||||
;; Copyright (C) 1985,87,92,93,94,95,96,97,98 Free Software Foundation, Inc.
|
||||
|
||||
;; Authors: 1992-1997 Barry A. Warsaw
|
||||
;; Authors: 1998 Barry A. Warsaw and Martin Stjernholm
|
||||
;; 1992-1997 Barry A. Warsaw
|
||||
;; 1987 Dave Detlefs and Stewart Clamen
|
||||
;; 1985 Richard M. Stallman
|
||||
;; Maintainer: cc-mode-help@python.org
|
||||
;; Maintainer: bug-cc-mode@gnu.org
|
||||
;; Created: 22-Apr-1997 (split from cc-mode.el)
|
||||
;; Version: See cc-mode.el
|
||||
;; Keywords: c languages oop
|
||||
@ -27,10 +28,14 @@
|
||||
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;; Boston, MA 02111-1307, USA.
|
||||
|
||||
;; Pull in Imenu when compiling, if it exists
|
||||
(eval-when-compile
|
||||
(condition-case nil
|
||||
(require 'imenu)
|
||||
(error nil)))
|
||||
|
||||
|
||||
;; imenu integration
|
||||
(eval-when-compile (require 'imenu))
|
||||
|
||||
(defvar cc-imenu-c-prototype-macro-regexp nil
|
||||
"RE matching macro names used to conditionally specify function prototypes.
|
||||
|
||||
@ -117,7 +122,10 @@ A sample value might look like: `\\(_P\\|_PROTO\\)'.")
|
||||
"^" ; beginning of line is required
|
||||
"\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a `template <...>'
|
||||
"class[ \t]+"
|
||||
"\\([a-zA-Z0-9_]+\\)" ; the string we want to get
|
||||
"\\(" ; the string we want to get
|
||||
"[a-zA-Z0-9_]+" ; class name
|
||||
"\\(<[^>]+>\\)?" ; possibly explicitely specialized
|
||||
"\\)"
|
||||
"[ \t]*[:{]"
|
||||
)) 2)))
|
||||
"Imenu generic expression for C++ mode. See `imenu-generic-expression'.")
|
||||
@ -137,8 +145,8 @@ A sample value might look like: `\\(_P\\|_PROTO\\)'.")
|
||||
"\\([A-Za-z0-9_-]+[ \t]*[[]?[]]?\\)"
|
||||
"\\([ \t]\\)"
|
||||
"\\([A-Za-z0-9_-]+\\)" ; the string we want to get
|
||||
"\\([ \t]*\\)("
|
||||
"\\([][a-zA-Z,_1-9\n \t]*\\)" ; arguments
|
||||
"\\([ \t]*\\)+("
|
||||
"\\([a-zA-Z,_1-9\n \t]*[[]?[]]?\\)*" ; arguments
|
||||
")[ \t]*"
|
||||
; "[^;(]"
|
||||
"[,a-zA-Z_1-9\n \t]*{"
|
||||
@ -307,7 +315,7 @@ Example:
|
||||
(if (fboundp 'buffer-substring-no-properties)
|
||||
'buffer-substring-no-properties
|
||||
'buffer-substring)))
|
||||
(goto-char (point-max))
|
||||
(goto-char (point-max))
|
||||
(imenu-progress-message stupid 0)
|
||||
;;
|
||||
(while (re-search-backward cc-imenu-objc-generic-expression nil t)
|
||||
@ -386,6 +394,10 @@ Example:
|
||||
toplist
|
||||
))
|
||||
|
||||
;(defvar cc-imenu-pike-generic-expression
|
||||
; ())
|
||||
; FIXME: Please contribute one!
|
||||
|
||||
|
||||
(provide 'cc-menus)
|
||||
;;; cc-menus.el ends here
|
||||
|
@ -2,14 +2,15 @@
|
||||
|
||||
;; Copyright (C) 1985,87,92,93,94,95,96,97,98 Free Software Foundation, Inc.
|
||||
|
||||
;; Authors: 1992-1997 Barry A. Warsaw
|
||||
;; Authors: 1998 Barry A. Warsaw and Martin Stjernholm
|
||||
;; 1992-1997 Barry A. Warsaw
|
||||
;; 1987 Dave Detlefs and Stewart Clamen
|
||||
;; 1985 Richard M. Stallman
|
||||
;; Maintainer: cc-mode-help@python.org
|
||||
;; Maintainer: bug-cc-mode@gnu.org
|
||||
;; Created: a long, long, time ago. adapted from the original c-mode.el
|
||||
;; Keywords: c languages oop
|
||||
|
||||
(defconst c-version "5.21"
|
||||
(defconst c-version "5.25"
|
||||
"CC Mode version number.")
|
||||
|
||||
;; NOTE: Read the commentary below for the right way to submit bug reports!
|
||||
@ -35,13 +36,15 @@
|
||||
;;; Commentary:
|
||||
|
||||
;; This package provides GNU Emacs major modes for editing C, C++,
|
||||
;; Objective-C, Java and IDL code. As of the latest Emacs and XEmacs
|
||||
;; releases, it is the default package for editing these languages.
|
||||
;; This package is called "CC Mode", and should be spelled exactly
|
||||
;; this way. It supports K&R and ANSI C, ANSI C++, Objective-C, Java,
|
||||
;; and CORBA's IDL with a consistent indentation model across all
|
||||
;; modes. This indentation model is intuitive and very flexible, so
|
||||
;; that almost any desired style of indentation can be supported.
|
||||
;; Objective-C, Java, IDL and Pike code. As of the latest Emacs and
|
||||
;; XEmacs releases, it is the default package for editing these
|
||||
;; languages. This package is called "CC Mode", and should be spelled
|
||||
;; exactly this way.
|
||||
|
||||
;; CC Mode supports K&R and ANSI C, ANSI C++, Objective-C, Java,
|
||||
;; CORBA's IDL, and Pike with a consistent indentation model across
|
||||
;; all modes. This indentation model is intuitive and very flexible,
|
||||
;; so that almost any desired style of indentation can be supported.
|
||||
;; Installation, usage, and programming details are contained in an
|
||||
;; accompanying texinfo manual.
|
||||
|
||||
@ -51,17 +54,20 @@
|
||||
;; NOTE: This mode does not perform font-locking (a.k.a syntactic
|
||||
;; coloring, keyword highlighting, etc.) for any of the supported
|
||||
;; modes. Typically this is done by a package called font-lock.el
|
||||
;; which I do *not* maintain. You should contact the Emacs
|
||||
;; which we do *not* maintain. You should contact the Emacs or XEmacs
|
||||
;; maintainers for questions about coloring or highlighting in any
|
||||
;; language mode.
|
||||
|
||||
;; To submit bug reports, type "C-c C-b". These will be sent to
|
||||
;; bug-gnu-emacs@prep.ai.mit.edu as well as cc-mode-help@python.org,
|
||||
;; and I'll read about them there (the former is mirrored as the
|
||||
;; Usenet newsgroup gnu.emacs.bug). Questions can sent to
|
||||
;; help-gnu-emacs@prep.ai.mit.edu (mirrored as gnu.emacs.help) and/or
|
||||
;; cc-mode-help@python.org. Please do not send bugs or questions to
|
||||
;; my personal account.
|
||||
;; bug-gnu-emacs@gnu.org (mirrored as the Usenet newsgroup
|
||||
;; gnu.emacs.bug) as well as bug-cc-mode@gnu.org, which directly
|
||||
;; contacts the CC Mode maintainers. Questions can sent to
|
||||
;; help-gnu-emacs@gnu.org (mirrored as gnu.emacs.help) and/or
|
||||
;; bug-cc-mode@gnu.org. The old CC Mode contact address,
|
||||
;; cc-mode-help@python.org is currently still active, but its use is
|
||||
;; discouraged. Please use bug-cc-mode@gnu.org instead. Please do
|
||||
;; not send bugs or questions to our personal accounts; we reserve the
|
||||
;; right to ignore such email!
|
||||
|
||||
;; Many, many thanks go out to all the folks on the beta test list.
|
||||
;; Without their patience, testing, insight, code contributions, and
|
||||
@ -70,27 +76,27 @@
|
||||
;; You can get the latest version of CC Mode, including PostScript
|
||||
;; documentation and separate individual files from:
|
||||
;;
|
||||
;; http://www.python.org/ftp/emacs/
|
||||
|
||||
;; Or if you don't have access to the World Wide Web, through
|
||||
;; anonymous ftp from:
|
||||
;; http://www.python.org/emacs/cc-mode/
|
||||
;;
|
||||
;; ftp://ftp.python.org/pub/emacs
|
||||
;; You can join a moderated CC Mode announcement-only mailing list by
|
||||
;; visiting
|
||||
;;
|
||||
;; http://www.python.org/mailman/listinfo/cc-mode-announce
|
||||
|
||||
;;; Code:
|
||||
|
||||
|
||||
(require 'cc-defs)
|
||||
|
||||
;; sigh. give in to the pressure, but make really sure all the
|
||||
;; definitions we need are here
|
||||
(if (or (not (fboundp 'functionp))
|
||||
(not (fboundp 'char-before))
|
||||
(not (c-safe (char-after) t))
|
||||
(not (fboundp 'when))
|
||||
(not (fboundp 'unless)))
|
||||
(require 'cc-mode-19))
|
||||
(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)
|
||||
@ -99,15 +105,6 @@
|
||||
(require 'cc-styles)
|
||||
(require 'cc-cmds)
|
||||
|
||||
(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', 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)
|
||||
|
||||
|
||||
|
||||
;; Other modes and packages which depend on CC Mode should do the
|
||||
@ -118,16 +115,20 @@ other non-CC Mode mode that calls `c-initialize-cc-mode'
|
||||
;; (c-initialize-cc-mode)
|
||||
|
||||
;;;###autoload
|
||||
(defun c-initialize-cc-mode (&optional skip-styles)
|
||||
(defun c-initialize-cc-mode ()
|
||||
(setq c-buffer-is-cc-mode t)
|
||||
(let ((initprop 'cc-mode-is-initialized))
|
||||
;; run the initialization hook, but only once
|
||||
(or (get 'c-initialize-cc-mode initprop)
|
||||
(progn
|
||||
(or skip-styles
|
||||
(c-initialize-builtin-style))
|
||||
(run-hooks 'c-initialization-hook)
|
||||
(put 'c-initialize-cc-mode initprop 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))
|
||||
;; Will try initialization hooks again if they failed.
|
||||
(unless c-initialization-ok
|
||||
(put 'c-initialize-cc-mode initprop nil))))
|
||||
))
|
||||
|
||||
|
||||
@ -163,7 +164,8 @@ Key bindings:
|
||||
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)
|
||||
imenu-case-fold-search nil
|
||||
)
|
||||
(run-hooks 'c-mode-common-hook)
|
||||
(run-hooks 'c-mode-hook)
|
||||
(c-update-modeline))
|
||||
@ -200,10 +202,12 @@ Key bindings:
|
||||
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)
|
||||
imenu-case-fold-search nil
|
||||
)
|
||||
(run-hooks 'c-mode-common-hook)
|
||||
(run-hooks 'c++-mode-hook)
|
||||
(c-update-modeline))
|
||||
@ -288,11 +292,11 @@ Key bindings:
|
||||
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
|
||||
;defun-prompt-regexp c-Java-defun-prompt-regexp
|
||||
imenu-generic-expression cc-imenu-java-generic-expression
|
||||
imenu-case-fold-search nil
|
||||
imenu-case-fold-search nil
|
||||
)
|
||||
(c-set-style "java")
|
||||
(run-hooks 'c-mode-common-hook)
|
||||
(run-hooks 'java-mode-hook)
|
||||
(c-update-modeline))
|
||||
@ -328,7 +332,8 @@ Key bindings:
|
||||
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-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
|
||||
;; imenu-generic-expression cc-imenu-c++-generic-expression
|
||||
@ -338,12 +343,57 @@ Key bindings:
|
||||
(run-hooks 'idl-mode-hook)
|
||||
(c-update-modeline))
|
||||
|
||||
|
||||
;;;###autoload
|
||||
(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
|
||||
;imenu-generic-expression cc-imenu-java-generic-expression ;FIXME
|
||||
;imenu-case-fold-search nil ;FIXME
|
||||
)
|
||||
(run-hooks 'c-mode-common-hook)
|
||||
(run-hooks 'pike-mode-hook)
|
||||
(c-update-modeline))
|
||||
|
||||
|
||||
;; bug reporting
|
||||
|
||||
(defconst c-mode-help-address
|
||||
"bug-gnu-emacs@prep.ai.mit.edu, cc-mode-help@python.org"
|
||||
"Address for CC Mode bug reports.")
|
||||
"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."
|
||||
@ -373,6 +423,7 @@ Key bindings:
|
||||
((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
|
||||
@ -394,6 +445,10 @@ Key bindings:
|
||||
'c-label-minimum-indentation
|
||||
'defun-prompt-regexp
|
||||
'tab-width
|
||||
'comment-column
|
||||
;; A brain-damaged XEmacs only variable that, if
|
||||
;; set to nil can cause all kinds of chaos.
|
||||
'signal-error-on-buffer-boundary
|
||||
)))
|
||||
(if (not (boundp 'defun-prompt-regexp))
|
||||
(delq 'defun-prompt-regexp vars)
|
||||
@ -402,7 +457,10 @@ Key bindings:
|
||||
(lambda ()
|
||||
(insert
|
||||
"Buffer Style: " style "\n\n"
|
||||
(if hook
|
||||
(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)
|
||||
|
@ -2,10 +2,11 @@
|
||||
|
||||
;; Copyright (C) 1985,87,92,93,94,95,96,97,98 Free Software Foundation, Inc.
|
||||
|
||||
;; Authors: 1992-1997 Barry A. Warsaw
|
||||
;; Authors: 1998 Barry A. Warsaw and Martin Stjernholm
|
||||
;; 1992-1997 Barry A. Warsaw
|
||||
;; 1987 Dave Detlefs and Stewart Clamen
|
||||
;; 1985 Richard M. Stallman
|
||||
;; Maintainer: cc-mode-help@python.org
|
||||
;; Maintainer: bug-cc-mode@gnu.org
|
||||
;; Created: 22-Apr-1997 (split from cc-mode.el)
|
||||
;; Version: See cc-mode.el
|
||||
;; Keywords: c languages oop
|
||||
@ -28,7 +29,12 @@
|
||||
;; Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
;; explicit compile-time dependencies
|
||||
(eval-when-compile
|
||||
(require 'cc-defs))
|
||||
|
||||
|
||||
;; Warning: don't eval-defun this constant or you'll break style inheritance.
|
||||
(defconst c-style-alist
|
||||
'(("gnu"
|
||||
(c-basic-offset . 2)
|
||||
@ -41,6 +47,7 @@
|
||||
(statement-cont . +)
|
||||
(arglist-intro . c-lineup-arglist-intro-after-paren)
|
||||
(arglist-close . c-lineup-arglist)
|
||||
(inline-open . 0)
|
||||
))
|
||||
(c-special-indent-hook . c-gnu-impose-minimum)
|
||||
(c-comment-continuation-stars . "")
|
||||
@ -104,6 +111,7 @@
|
||||
(c-basic-offset . 8)
|
||||
(c-comment-only-line-offset . 0)
|
||||
(c-hanging-braces-alist . ((brace-list-open)
|
||||
(brace-entry-open)
|
||||
(substatement-open after)
|
||||
(block-close . c-snug-do-while)))
|
||||
(c-cleanup-list . (brace-else-brace))
|
||||
@ -126,6 +134,7 @@
|
||||
(c-hanging-braces-alist . ((brace-list-open)
|
||||
(brace-list-intro)
|
||||
(brace-list-close)
|
||||
(brace-entry-open)
|
||||
(substatement-open after)
|
||||
(block-close . c-snug-do-while)
|
||||
))
|
||||
@ -284,7 +293,7 @@ STYLE using `c-set-style' if the optional SET-P flag is non-nil."
|
||||
|
||||
|
||||
(defconst c-offsets-alist
|
||||
'((string . -1000)
|
||||
'((string . c-lineup-dont-change)
|
||||
(c . c-lineup-C-comments)
|
||||
(defun-open . 0)
|
||||
(defun-close . 0)
|
||||
@ -308,6 +317,7 @@ STYLE using `c-set-style' if the optional SET-P flag is non-nil."
|
||||
(brace-list-close . 0)
|
||||
(brace-list-intro . +)
|
||||
(brace-list-entry . 0)
|
||||
(brace-entry-open . 0)
|
||||
(statement . 0)
|
||||
;; some people might prefer
|
||||
;;(statement . c-lineup-runin-statements)
|
||||
@ -324,6 +334,7 @@ STYLE using `c-set-style' if the optional SET-P flag is non-nil."
|
||||
(label . 2)
|
||||
(do-while-closure . 0)
|
||||
(else-clause . 0)
|
||||
(catch-clause . 0)
|
||||
(comment-intro . c-lineup-comment)
|
||||
(arglist-intro . +)
|
||||
(arglist-cont . 0)
|
||||
@ -344,6 +355,10 @@ STYLE using `c-set-style' if the optional SET-P flag is non-nil."
|
||||
(namespace-close . 0)
|
||||
(innamespace . +)
|
||||
(template-args-cont . +)
|
||||
(inlambda . c-lineup-inexpr-block)
|
||||
(lambda-intro-cont . +)
|
||||
(inexpr-statement . 0)
|
||||
(inexpr-class . +)
|
||||
)
|
||||
"Association list of syntactic element symbols and indentation offsets.
|
||||
As described below, each cons cell in this list has the form:
|
||||
@ -380,6 +395,13 @@ is called with a single argument containing the cons of the syntactic
|
||||
element symbol and the relative indent point. The function should
|
||||
return an integer offset.
|
||||
|
||||
OFFSET can also be a list, in which case it is recursively evaluated
|
||||
using the semantics described above. The first element of the list to
|
||||
return a non-nil value succeeds. If none of the elements returns a
|
||||
non-nil value, then what happends depends on the value of
|
||||
`c-strict-syntax-p'. When `c-strict-syntax-p' is nil, then an offset
|
||||
of zero is used, otherwise an error is generated.
|
||||
|
||||
Here is the current list of valid syntactic element symbols:
|
||||
|
||||
string -- inside multi-line string
|
||||
@ -411,6 +433,8 @@ Here is the current list of valid syntactic element symbols:
|
||||
brace-list-close -- close brace of an enum or static array list
|
||||
brace-list-intro -- first line in an enum or static array list
|
||||
brace-list-entry -- subsequent lines in an enum or static array list
|
||||
brace-entry-open -- subsequent lines in an enum or static array
|
||||
list that start with an open brace.
|
||||
statement -- a C (or like) statement
|
||||
statement-cont -- a continuation of a C (or like) statement
|
||||
statement-block-intro -- the first line in a new statement block
|
||||
@ -423,6 +447,7 @@ Here is the current list of valid syntactic element symbols:
|
||||
label -- any ordinary label
|
||||
do-while-closure -- the `while' that ends a do/while construct
|
||||
else-clause -- the `else' of an if/else construct
|
||||
catch-clause -- the `catch' or `finally' of a try/catch construct
|
||||
comment-intro -- a line containing only a comment introduction
|
||||
arglist-intro -- the first line in an argument list
|
||||
arglist-cont -- subsequent argument list lines when no
|
||||
@ -450,8 +475,38 @@ Here is the current list of valid syntactic element symbols:
|
||||
innamespace -- analogous to `inextern-lang' syntactic
|
||||
symbol, but used inside C++ namespace constructs
|
||||
template-args-cont -- C++ template argument list continuations
|
||||
inlambda -- in the header or body of a lambda function
|
||||
lambda-intro-cont -- continuation of the header of a lambda function
|
||||
inexpr-statement -- the statement is inside an expression
|
||||
inexpr-class -- the class is inside an expression
|
||||
")
|
||||
|
||||
(defun c-evaluate-offset (offset langelem symbol)
|
||||
;; offset can be a number, a function, a variable, a list, or one of
|
||||
;; the symbols + or -
|
||||
(cond
|
||||
((eq offset '+) (setq offset c-basic-offset))
|
||||
((eq offset '-) (setq offset (- c-basic-offset)))
|
||||
((eq offset '++) (setq offset (* 2 c-basic-offset)))
|
||||
((eq offset '--) (setq offset (* 2 (- c-basic-offset))))
|
||||
((eq offset '*) (setq offset (/ c-basic-offset 2)))
|
||||
((eq offset '/) (setq offset (/ (- c-basic-offset) 2)))
|
||||
((functionp offset) (setq offset (funcall offset langelem)))
|
||||
((listp offset)
|
||||
(setq offset
|
||||
(let (done)
|
||||
(while (and (not done) offset)
|
||||
(setq done (c-evaluate-offset (car offset) langelem symbol)
|
||||
offset (cdr offset)))
|
||||
(if (not done)
|
||||
(if c-strict-syntax-p
|
||||
(error "No offset found for syntactic symbol %s" symbol)
|
||||
0)
|
||||
done))))
|
||||
((not (numberp offset)) (setq offset (symbol-value offset)))
|
||||
)
|
||||
offset)
|
||||
|
||||
(defun c-get-offset (langelem)
|
||||
;; Get offset from LANGELEM which is a cons cell of the form:
|
||||
;; (SYMBOL . RELPOS). The symbol is matched against
|
||||
@ -462,30 +517,20 @@ Here is the current list of valid syntactic element symbols:
|
||||
(relpos (cdr langelem))
|
||||
(match (assq symbol c-offsets-alist))
|
||||
(offset (cdr-safe match)))
|
||||
;; offset can be a number, a function, a variable, or one of the
|
||||
;; symbols + or -
|
||||
(cond
|
||||
((not match)
|
||||
(if c-strict-syntax-p
|
||||
(error "don't know how to indent a %s" symbol)
|
||||
(setq offset 0
|
||||
relpos 0)))
|
||||
((eq offset '+) (setq offset c-basic-offset))
|
||||
((eq offset '-) (setq offset (- c-basic-offset)))
|
||||
((eq offset '++) (setq offset (* 2 c-basic-offset)))
|
||||
((eq offset '--) (setq offset (* 2 (- c-basic-offset))))
|
||||
((eq offset '*) (setq offset (/ c-basic-offset 2)))
|
||||
((eq offset '/) (setq offset (/ (- c-basic-offset) 2)))
|
||||
((functionp offset) (setq offset (funcall offset langelem)))
|
||||
((not (numberp offset)) (setq offset (symbol-value offset)))
|
||||
)
|
||||
(if (not match)
|
||||
(if c-strict-syntax-p
|
||||
(error "No offset found for syntactic symbol %s" symbol)
|
||||
(setq offset 0
|
||||
relpos 0))
|
||||
(setq offset (c-evaluate-offset offset langelem symbol)))
|
||||
(+ (if (and relpos
|
||||
(< relpos (c-point 'bol)))
|
||||
(save-excursion
|
||||
(goto-char relpos)
|
||||
(current-column))
|
||||
0)
|
||||
offset)))
|
||||
(c-evaluate-offset offset langelem symbol))
|
||||
))
|
||||
|
||||
|
||||
(defvar c-read-offset-history nil)
|
||||
@ -493,12 +538,13 @@ Here is the current list of valid syntactic element symbols:
|
||||
(defun c-read-offset (langelem)
|
||||
;; read new offset value for LANGELEM from minibuffer. return a
|
||||
;; legal value only
|
||||
(let* ((oldoff (cdr-safe (assq langelem c-offsets-alist)))
|
||||
(defstr (format "(default %s): " oldoff))
|
||||
(errmsg (concat "Offset must be int, func, var, "
|
||||
"or in [+,-,++,--,*,/] "
|
||||
defstr))
|
||||
(prompt (concat "Offset " defstr))
|
||||
(let* ((oldoff (cdr-safe (assq langelem c-offsets-alist)))
|
||||
(symname (symbol-name langelem))
|
||||
(defstr (format "(default %s): " oldoff))
|
||||
(errmsg (concat "Offset must be int, func, var, list, "
|
||||
"or [+,-,++,--,*,/] "
|
||||
defstr))
|
||||
(prompt (concat symname " offset " defstr))
|
||||
offset input interned raw)
|
||||
(while (not offset)
|
||||
(setq input (completing-read prompt obarray 'fboundp nil nil
|
||||
@ -563,8 +609,9 @@ offset for that syntactic element. Optional ADD says to add SYMBOL to
|
||||
(eq offset '/)
|
||||
(integerp offset)
|
||||
(functionp offset)
|
||||
(listp offset)
|
||||
(boundp offset)
|
||||
(error "Offset must be int, func, var, or in [+,-,++,--,*,/]: %s"
|
||||
(error "Offset must be int, func, var, list, or in [+,-,++,--,*,/]: %s"
|
||||
offset))
|
||||
(let ((entry (assq symbol c-offsets-alist)))
|
||||
(if entry
|
||||
@ -574,50 +621,46 @@ offset for that syntactic element. Optional ADD says to add SYMBOL to
|
||||
(error "%s is not a valid syntactic symbol." symbol))))
|
||||
(c-keep-region-active))
|
||||
|
||||
|
||||
|
||||
(defun c-copy-tree (tree)
|
||||
(if (consp tree)
|
||||
(cons (c-copy-tree (car tree))
|
||||
(c-copy-tree (cdr tree)))
|
||||
tree))
|
||||
|
||||
(defun c-initialize-builtin-style ()
|
||||
;; Dynamically append the default value of most variables. This is
|
||||
;; crucial because future c-set-style calls will always reset the
|
||||
;; variables first to the `cc-mode' style before instituting the new
|
||||
;; style. Only do this once!
|
||||
(c-initialize-cc-mode t)
|
||||
(or (assoc "cc-mode" c-style-alist)
|
||||
(assoc "user" c-style-alist)
|
||||
(progn
|
||||
(c-add-style "user"
|
||||
(mapcar
|
||||
(function
|
||||
(lambda (var)
|
||||
(let ((val (symbol-value var)))
|
||||
(cons var (c-copy-tree val)))))
|
||||
'(c-backslash-column
|
||||
c-basic-offset
|
||||
c-cleanup-list
|
||||
c-comment-only-line-offset
|
||||
c-electric-pound-behavior
|
||||
c-hanging-braces-alist
|
||||
c-hanging-colons-alist
|
||||
c-hanging-comment-starter-p
|
||||
c-hanging-comment-ender-p
|
||||
c-offsets-alist
|
||||
)))
|
||||
(c-add-style "cc-mode" '("user"))
|
||||
;; the default style is now GNU. This can be overridden in
|
||||
;; c-mode-common-hook or {c,c++,objc,java}-mode-hook.
|
||||
(c-set-style c-default-style)))
|
||||
(if c-style-variables-are-local-p
|
||||
(c-make-styles-buffer-local)))
|
||||
(unless (get 'c-initialize-builtin-style 'is-run)
|
||||
(put 'c-initialize-builtin-style 'is-run t)
|
||||
(c-initialize-cc-mode)
|
||||
(or (assoc "cc-mode" c-style-alist)
|
||||
(assoc "user" c-style-alist)
|
||||
(progn
|
||||
(c-add-style "user"
|
||||
(mapcar
|
||||
(function
|
||||
(lambda (var)
|
||||
(let ((val (symbol-value var)))
|
||||
(cons var (c-copy-tree val)))))
|
||||
'(c-backslash-column
|
||||
c-basic-offset
|
||||
c-cleanup-list
|
||||
c-comment-only-line-offset
|
||||
c-electric-pound-behavior
|
||||
c-hanging-braces-alist
|
||||
c-hanging-colons-alist
|
||||
c-hanging-comment-starter-p
|
||||
c-hanging-comment-ender-p
|
||||
c-offsets-alist
|
||||
)))
|
||||
(c-add-style "cc-mode" '("user"))
|
||||
))
|
||||
(if c-style-variables-are-local-p
|
||||
(c-make-styles-buffer-local))))
|
||||
|
||||
(defun c-copy-tree (tree)
|
||||
(if (consp tree)
|
||||
(if (consp (cdr tree))
|
||||
(cons (c-copy-tree (car tree))
|
||||
(cons (c-copy-tree (cadr tree))
|
||||
(c-copy-tree (cddr tree))))
|
||||
(cons (c-copy-tree (car tree))
|
||||
(c-copy-tree (cdr tree))))
|
||||
tree))
|
||||
|
||||
(defun c-make-styles-buffer-local (&optional this-buf-only-p)
|
||||
"Make all CC Mode style variables buffer local.
|
||||
|
@ -2,10 +2,11 @@
|
||||
|
||||
;; Copyright (C) 1985,87,92,93,94,95,96,97,98 Free Software Foundation, Inc.
|
||||
|
||||
;; Authors: 1992-1997 Barry A. Warsaw
|
||||
;; Authors: 1998 Barry A. Warsaw and Martin Stjernholm
|
||||
;; 1992-1997 Barry A. Warsaw
|
||||
;; 1987 Dave Detlefs and Stewart Clamen
|
||||
;; 1985 Richard M. Stallman
|
||||
;; Maintainer: cc-mode-help@python.org
|
||||
;; Maintainer: bug-cc-mode@gnu.org
|
||||
;; Created: 22-Apr-1997 (split from cc-mode.el)
|
||||
;; Version: See cc-mode.el
|
||||
;; Keywords: c languages oop
|
||||
@ -27,14 +28,18 @@
|
||||
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;; Boston, MA 02111-1307, USA.
|
||||
|
||||
(eval-when-compile
|
||||
(require 'cc-defs))
|
||||
|
||||
(require 'custom)
|
||||
|
||||
|
||||
(defcustom c-strict-syntax-p nil
|
||||
"*If non-nil, all syntactic symbols must be found in `c-offsets-alist'.
|
||||
If the syntactic symbol for a particular line does not match a symbol
|
||||
in the offsets alist, an error is generated, otherwise no error is
|
||||
reported and the syntactic symbol is ignored."
|
||||
in the offsets alist, or if no non-nil offset value can be determined
|
||||
for a symbol, an error is generated, otherwise no error is reported
|
||||
and the syntactic symbol is ignored."
|
||||
:type 'boolean
|
||||
:group 'c)
|
||||
|
||||
@ -48,14 +53,23 @@ reported and the syntactic symbol is ignored."
|
||||
:type 'integer
|
||||
:group 'c)
|
||||
|
||||
;; This widget will show up in newer versions of the Custom library
|
||||
(or (get 'other 'widget-type)
|
||||
(define-widget 'other 'sexp
|
||||
"Matches everything, but doesn't let the user edit the value.
|
||||
Useful as last item in a `choice' widget."
|
||||
:tag "Other"
|
||||
:format "%t%n"
|
||||
:value 'other))
|
||||
|
||||
(defcustom c-tab-always-indent t
|
||||
"*Controls the operation of the TAB key.
|
||||
If t, hitting TAB always just indents the current line. If nil,
|
||||
hitting TAB indents the current line if point is at the left margin or
|
||||
in the line's indentation, otherwise it insert a `real' tab character
|
||||
\(see note\). If other than nil or t, then tab is inserted only
|
||||
within literals -- defined as comments and strings -- and inside
|
||||
preprocessor directives, but line is always reindented.
|
||||
\(see note\). If the symbol `other', then tab is inserted only within
|
||||
literals -- defined as comments and strings -- and inside preprocessor
|
||||
directives, but the line is always reindented.
|
||||
|
||||
Note: The value of `indent-tabs-mode' will determine whether a real
|
||||
tab character will be inserted, or the equivalent number of space.
|
||||
@ -69,7 +83,7 @@ by the `c-comment-only-line-offset' variable."
|
||||
:format "%{C Tab Always Indent%}:\n The TAB key:\n%v"
|
||||
(const :tag "always indents, never inserts TAB" t)
|
||||
(const :tag "indents in left margin, otherwise inserts TAB" nil)
|
||||
(const :tag "inserts TAB in literals, otherwise indent" other))
|
||||
(other :tag "inserts TAB in literals, otherwise indent" other))
|
||||
:group 'c)
|
||||
|
||||
(defcustom c-insert-tab-function 'insert-tab
|
||||
@ -129,7 +143,11 @@ mode name. Valid symbols are:
|
||||
Clean up occurs when the open-brace after the
|
||||
`else' is typed.
|
||||
brace-elseif-brace -- similar to brace-else-brace, but cleans up
|
||||
`} else if {' constructs.
|
||||
`} else if (...) {' constructs. Clean up occurs
|
||||
both after the open parenthesis and after the
|
||||
open brace.
|
||||
brace-catch-brace -- similar to brace-elseif-brace, but cleans up
|
||||
`} catch (...) {' constructs.
|
||||
empty-defun-braces -- cleans up empty defun braces by placing the
|
||||
braces on the same line. Clean up occurs when
|
||||
the defun closing brace is typed.
|
||||
@ -150,16 +168,20 @@ mode name. Valid symbols are:
|
||||
:type '(set
|
||||
:extra-offset 8
|
||||
(const :tag "Put `} else {' on one line" brace-else-brace)
|
||||
(const :tag "Put `} else if {' on one line" brace-elseif-brace)
|
||||
(const :tag "Put `} else if (...) {' on one line" brace-elseif-brace)
|
||||
(const :tag "Put `} catch (...) {' on one line" brace-catch-brace)
|
||||
(const :tag "Put empty defun braces on one line" empty-defun-braces)
|
||||
(const :tag "Put `},' in aggregates on one line" list-close-comma)
|
||||
(const :tag "Put C++ style `::' on one line" scope-operator))
|
||||
:group 'c)
|
||||
|
||||
(defcustom c-hanging-braces-alist '((brace-list-open)
|
||||
(brace-entry-open)
|
||||
(substatement-open after)
|
||||
(block-close . c-snug-do-while)
|
||||
(extern-lang-open after)
|
||||
(inexpr-class-open after)
|
||||
(inexpr-class-close before)
|
||||
)
|
||||
"*Controls the insertion of newlines before and after braces.
|
||||
This variable contains an association list with elements of the
|
||||
@ -175,8 +197,12 @@ SYNTACTIC-SYMBOL can be any of: defun-open, defun-close, class-open,
|
||||
class-close, inline-open, inline-close, block-open, block-close,
|
||||
substatement-open, statement-case-open, extern-lang-open,
|
||||
extern-lang-close, brace-list-open, brace-list-close,
|
||||
brace-list-intro, or brace-list-entry. See `c-offsets-alist' for
|
||||
details.
|
||||
brace-list-intro, brace-entry-open, inexpr-class-open, or
|
||||
inexpr-class-close. See `c-offsets-alist' for details, except for
|
||||
inexpr-class-open and inexpr-class-close, which doesn't have any
|
||||
corresponding symbols there. Those two symbols are used for the
|
||||
opening and closing braces, respectively, of anonymous inner classes
|
||||
in Java.
|
||||
|
||||
ACTION can be either a function symbol or a list containing any
|
||||
combination of the symbols `before' or `after'. If the list is empty,
|
||||
@ -198,7 +224,8 @@ syntactic context for the brace line."
|
||||
(const substatement-open) (const statement-case-open)
|
||||
(const extern-lang-open) (const extern-lang-close)
|
||||
(const brace-list-open) (const brace-list-close)
|
||||
(const brace-list-intro) (const brace-list-entry))
|
||||
(const brace-list-intro) (const brace-entry-open)
|
||||
(const inexpr-class-open) (const inexpr-class-close))
|
||||
(choice :tag "Action"
|
||||
(set :format "Insert a newline %v"
|
||||
:extra-offset 38
|
||||
@ -310,19 +337,42 @@ this variable to nil."
|
||||
:group 'c)
|
||||
|
||||
(defcustom c-default-style "gnu"
|
||||
"*Style which gets installed by default.
|
||||
"*Style which gets installed by default when a file is visited.
|
||||
|
||||
The value of this variable can be any style defined in
|
||||
`c-style-alist', including styles you add, if you add them before CC
|
||||
Mode gets initialized. Note that if you set any CC Mode variables in
|
||||
the top-level of your .emacs file (i.e. *not* in a hook), these get
|
||||
incorporated into the `user' style so you would need to add:
|
||||
`c-style-alist', including styles you add. The value can also be an
|
||||
association list of major mode symbols to style names.
|
||||
|
||||
(setq c-default-style \"user\")
|
||||
When the value is a string, all CC Mode major modes will install this
|
||||
style by default, except `java-mode', which always installs the
|
||||
\"java\" style (this is for backwards compatibility).
|
||||
|
||||
When the value is an alist, the named style is installed. If the
|
||||
major mode is not listed in the alist, then the symbol `other' is
|
||||
looked up in the alist, and if found, the associated style is used.
|
||||
If `other' is not found in the alist, then \"gnu\" style is used.
|
||||
|
||||
Note that if you set any CC Mode variables in the top-level of your
|
||||
.emacs file (i.e. *not* in a hook), these get incorporated into the
|
||||
`user' style, so you would need to add:
|
||||
|
||||
(setq c-default-style '((other . \"user\")))
|
||||
|
||||
to see your customizations. This is also true if you use the Custom
|
||||
interface -- be sure to set the default style to `user'."
|
||||
:type 'string
|
||||
interface -- be sure to set the default style to `user'.
|
||||
|
||||
Finally, the default style gets installed before your mode hooks run,
|
||||
so you can always override the use of `c-default-style' by making
|
||||
calls to `c-set-style' in the appropriate mode hook."
|
||||
:type '(choice string
|
||||
(repeat :tag "" :menu-tag "Major mode list"
|
||||
(cons :tag ""
|
||||
(choice :tag "Mode"
|
||||
(const c-mode) (const c++-mode) (const objc-mode)
|
||||
(const java-mode) (const idl-mode)
|
||||
(const pike-mode) (const other))
|
||||
(string :tag "Style")
|
||||
)))
|
||||
:group 'c)
|
||||
|
||||
(defcustom c-style-variables-are-local-p nil
|
||||
@ -387,15 +437,14 @@ This hook is only run once per Emacs session and can be used as a
|
||||
:type 'hook
|
||||
:group 'c)
|
||||
|
||||
(defcustom c-enable-xemacs-performance-kludge-p t
|
||||
(defcustom c-enable-xemacs-performance-kludge-p nil
|
||||
"*Enables a XEmacs only hack that may improve speed for some coding styles.
|
||||
For styles that hang top-level opening braces (as is common with JDK
|
||||
Java coding styles) this can improve performance between 3 and 60
|
||||
times for core indentation functions (e.g. `c-parse-state'). For
|
||||
styles that conform to the Emacs recommendation of putting these
|
||||
braces in column zero, this may slightly degrade performance in some
|
||||
situations, but only by a few percentage points. This variable only
|
||||
has effect in XEmacs.")
|
||||
braces in column zero, this can degrade performance about as much.
|
||||
This variable only has effect in XEmacs.")
|
||||
|
||||
|
||||
;; Non-customizable variables, still part of the interface to CC Mode
|
||||
|
Loading…
Reference in New Issue
Block a user