1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-04-27 08:43:40 -07:00

cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,

cc-defs.el, cc-engine.el, cc-fonts.el, cc-langs.el, cc-menus.el,
cc-mode.el, cc-styles.el, cc-subword.el, cc-vars.el:  Add 2006 to the
copyright statement.

cc-awk.el: (c-awk-after-change): Protect the match data with
save-match-data.  It was being corrupted when Font Lock was not enabled.
(ii): Fix a typo.

cc-cmds.el, cc-mode.el, cc-engine.el (c-update-modeline): Concatenate the
minor mode indicators directly onto mode-name, removing
c-submode-indicators.  Sometimes, c-s-i got separated from the mode name
on the mode line.

cc-cmds.el, cc-mode.el: Rename c-hungry-backspace to
c-hungry-delete-backwards, at the request of RMS.  Leave the old name as
an alias.

cc-cmds.el (c-electric-brace, c-electric-semi&comma, c-electric-colon):
Correct doc-strings: "/ln" -> "/la".

cc-cmds.el (c-electric-brace): Fix clean-up brace-else-brace (error due
to mbeg, mend being undefined).

cc-defs.el (c-version): Update to 5.31.3.

cc-defs.el: [Supersedes patch V1.38]: (top level): Check for a buggy
font-lock-compile-keywords ONLY in XEmacs.  GNU Emacs 22 now has a check
which would throw an error here.

cc-engine.el (c-beginning-of-statement-1): Clarify doc-string and
comments.  Distinguish real labels ("case 1:" or "foo:") from non-labels
("public:").

cc-engine.el (c-after-change-check-<>-operators): Remove save-match-data,
reversing change for V1.45.  save-match-data is now in c-after-change.

cc-engine.el (c-forward-objc-directive): Replace c-forward-token-2 with
crude coding; c-f-t-2 doesn't move over a token at EOB.  Objc Mode was
hanging after typing, e.g., "@implementation".

cc-langs.el (c-filter-ops): Made it available at runtime too to work when
`c-make-init-lang-vars-fun' needs to evaluate from source.

cc-langs.el (c-make-init-lang-vars-fun): Improved the error message when
there's an evaluation error to show whether it's loaded from source or
not.
(c-mode-menu): Add menu items for Electric Mode and Subword Mode.

cc-mode.el (c-after-change): Protect the match data with save-match-data.
It was getting corrupted by c-after-change-check-<>-operators.

cc-mode.el: File Local variables: Solve the problem where both `mode' and
c-file-offsets are specified: `mode' will overwrite c-f-o's settings:
(c-remove-any-local-eval-or-mode-variables): new function.
(c-postprocess-file-styles): call the above new function, within
c-tentative-buffer-change, to splat `mode' and `eval' before the second
hack-local-variables.
This commit is contained in:
Alan Mackenzie 2006-02-24 15:33:02 +00:00
parent 0d56691054
commit cb694ab730
13 changed files with 322 additions and 139 deletions

View file

@ -1,3 +1,93 @@
2006-02-24 Alan Mackenzie <bug-cc-mode@gnu.org>
* CC Mode Update to 5.31.3.
2006-02-24 Alan Mackenzie <bug-cc-mode@gnu.org>
* progmodes/cc-mode.el (c-postprocess-file-styles): bind
inhibit-read-only to t, around the call to
c-remove-any-local-eval-or-mode-variables, so that it works on a
RO file.
2006-02-24 Alan Mackenzie <bug-cc-mode@gnu.org>
* progmodes/cc-awk.el: Correct a typo.
2006-02-24 Alan Mackenzie <bug-cc-mode@gnu.org>
* progmodes/cc-cmds.el, cc-mode.el: Rename c-hungry-backspace to
c-hungry-delete-backwards, at the request of RMS. Leave the old
name as an alias.
2006-02-24 Alan Mackenzie <bug-cc-mode@gnu.org>
* progmodes/cc-mode.el: Correct a typo.
2006-02-24 Alan Mackenzie <bug-cc-mode@gnu.org>
* progmodes/cc-defs.el: Update the version number to 5.31.3.
2006-02-24 Alan Mackenzie <bug-cc-mode@gnu.org>
* progmodes/cc-cmds.el (c-electric-brace): Fix clean-up
brace-else-brace (error due to mbeg, mend being undefined).
2006-02-24 Alan Mackenzie <bug-cc-mode@gnu.org>
* progmodes/cc-mode.el: File Local variables: Solve the problem
where both `mode' and c-file-offsets are specified: `mode' will
overwrite c-f-o's settings:
(c-remove-any-local-eval-or-mode-variables): new function.
(c-postprocess-file-styles): call the above new function, within
c-tentative-buffer-change, to splat `mode' and `eval' before the
second hack-local-variables.
2006-02-24 Alan Mackenzie <bug-cc-mode@gnu.org>
* progmodes/cc-mode.el:
[Supersedes patch to cc-engine.el 2005-12-16T20:07:49Z!monnier@iro.umontreal.ca]
(c-after-change): Protect the match data with save-match-data. It
was getting corrupted by c-after-change-check-<>-operators.
* cc-defs.el: [Supersedes patch V1.38]:
(top level): Check for a buggy font-lock-compile-keywords ONLY in
XEmacs. GNU Emacs 22 now has a check which would throw an error
here.
* progmodes/cc-awk.el (c-awk-after-change): Protect the match data
with save-match-data. It was being corrupted when Font Lock was
not enabled.
2006-02-24 Alan Mackenzie <bug-cc-mode@gnu.org>
* progmodes/cc-langs.el (c-mode-menu): Add menu items for Electric
Mode and Subword Mode.
* progmodes/cc-engine.el (c-beginning-of-statment-1): Distinguish
real labels ("case 1:" or "foo:") from non-labels ("public:").
(c-forward-objc-directive): Replace c-forward-token-2 with crude
coding; c-f-t-2 doesn't move over a token at EOB.
* progmodes/cc-defs.el (c-version): Update version number to
5.31.2
* progmodes/cc-cmds.el, cc-mode.el, cc-engine.el
(c-update-modeline): Concatenate the minor mode indicators
directly onto mode-name, removing c-submode-indicators.
Sometimes, c-s-i got separated from the mode name on the mode
line.
* progmodes/cc-cmds.el (c-electric-brace, c-electric-semi&comma,
c-electric-colon): Correct doc-strings: "/ln" -> "/la".
2006-02-24 Martin Stjernholm <bug-cc-mode@gnu.org>
* progmodes/cc-langs.el (c-make-init-lang-vars-fun): Improved the
error message when there's an evaluation error to show whether
it's loaded from source or not.
(c-filter-ops): Made it available at runtime too to work when
`c-make-init-lang-vars-fun' needs to evaluate from source.
2006-02-24 Juanma Barranquero <lekktu@gmail.com>
* help.el (help): Revert last part of 2006-02-23 change (deletion

View file

@ -1,7 +1,7 @@
;;; cc-align.el --- custom indentation functions for CC Mode
;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006
;; Free Software Foundation, Inc.
;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006 Free Software
;; Foundation, Inc.
;; Authors: 1998- Martin Stjernholm
;; 1992-1999 Barry A. Warsaw

View file

@ -1,7 +1,7 @@
;;; cc-awk.el --- AWK specific code within cc-mode.
;; Copyright (C) 1988,94,96,2000, 2001, 2002, 2003, 2004, 2005, 2006
;; Free Software Foundation, Inc.
;; Copyright (C) 1988,94,96,2000, 2001, 2002, 2003, 2004, 2005, 2006 Free
;; Software Foundation, Inc.
;; Author: Alan Mackenzie <acm@muc.de> (originally based on awk-mode.el)
;; Maintainer: FSF
@ -804,7 +804,7 @@
(defun c-awk-end-of-change-region (beg end old-len)
;; Find the end of the region which needs to be font-locked after a change.
;; This is the end of the logical line on which the change happened, either
;; as it was before the change, or as it is now, which ever is later.
;; as it was before the change, or as it is now, whichever is later.
;; N.B. point is left undefined.
;;
;; This function might do hidden buffer changes.
@ -822,11 +822,12 @@
(unless (and (boundp 'font-lock-mode) font-lock-mode)
(save-restriction
(save-excursion
(setq end (c-awk-end-of-change-region beg end old-len))
(c-awk-beginning-of-logical-line beg)
(c-save-buffer-state nil ; So that read-only status isn't affected.
(save-match-data
(setq end (c-awk-end-of-change-region beg end old-len))
(c-awk-beginning-of-logical-line beg)
(c-save-buffer-state nil ; So that read-only status isn't affected.
; (e.g. when first loading the buffer)
(c-awk-set-syntax-table-properties end))))))
(c-awk-set-syntax-table-properties end)))))))
;; ACM 2002/5/25. When font-locking is invoked by a buffer change, the region
;; specified by the font-lock after-change function must be expanded to

View file

@ -1,7 +1,7 @@
;;; cc-bytecomp.el --- compile time setup for proper compilation
;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006
;; Free Software Foundation, Inc.
;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
;; Foundation, Inc.
;; Author: Martin Stjernholm
;; Maintainer: bug-cc-mode@gnu.org

View file

@ -1,7 +1,7 @@
;;; cc-cmds.el --- user level commands for CC Mode
;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006
;; Free Software Foundation, Inc.
;; Copyright (C) 1985, 1987, 1992-2003, 2004, 2005, 2006 Free Software
;; Foundation, Inc.
;; Authors: 1998- Martin Stjernholm
;; 1992-1999 Barry A. Warsaw
@ -262,10 +262,17 @@ With universal argument, inserts the analysis as a comment on that line."
(boundp 'c-subword-mode)
(symbol-value 'c-subword-mode))
"w"
""))))
(setq c-submode-indicators
"")))
(bare-mode-name (if (string-match "\\(^[^/]*\\)/" mode-name)
(substring mode-name (match-beginning 1) (match-end 1))
mode-name)))
;; (setq c-submode-indicators
;; (if (> (length fmt) 1)
;; fmt))
(setq mode-name
(if (> (length fmt) 1)
fmt))
(concat bare-mode-name fmt)
bare-mode-name))
(force-mode-line-update)))
(defun c-toggle-syntactic-indentation (&optional arg)
@ -365,9 +372,9 @@ inside a literal then the function in the variable
arg
(c-in-literal)))
(funcall c-backspace-function (prefix-numeric-value arg))
(c-hungry-backspace)))
(c-hungry-delete-backwards)))
(defun c-hungry-backspace ()
(defun c-hungry-delete-backwards ()
"Delete the preceding character or all preceding whitespace
back to the previous non-whitespace character.
See also \\[c-hungry-delete-forward]."
@ -378,6 +385,8 @@ See also \\[c-hungry-delete-forward]."
(delete-region (point) here)
(funcall c-backspace-function 1))))
(defalias 'c-hungry-backspace 'c-hungry-delete-backwards)
(defun c-electric-delete-forward (arg)
"Delete the following character or whitespace.
If `c-hungry-delete-key' is non-nil (indicated by \"/h\" on the mode
@ -396,7 +405,7 @@ is called."
(defun c-hungry-delete-forward ()
"Delete the following character or all following whitespace
up to the next non-whitespace character.
See also \\[c-hungry-backspace]."
See also \\[c-hungry-delete-backwards]."
(interactive)
(let ((here (point)))
(c-skip-ws-forward)
@ -436,7 +445,7 @@ function to control that."
(if (and (fboundp 'delete-forward-p)
(delete-forward-p))
(c-hungry-delete-forward)
(c-hungry-backspace)))
(c-hungry-delete-backwards)))
(defun c-electric-pound (arg)
"Insert a \"#\".
@ -648,7 +657,7 @@ If `c-electric-flag' is non-nil, the brace is not inside a literal and a
numeric ARG hasn't been supplied, the command performs several electric
actions:
\(a) If the auto-newline feature is turned on (indicated by \"/ln\" on
\(a) If the auto-newline feature is turned on (indicated by \"/la\" on
the mode line) newlines are inserted before and after the brace as
directed by the settings in `c-hanging-braces-alist'.
@ -752,7 +761,7 @@ settings of `c-cleanup-list' are done."
"{"
"\\=")
nil t))
(delete-region mbeg mend)
(delete-region (match-beginning 0) (match-end 0))
(insert-and-inherit "} else {"))
((and (memq 'brace-elseif-brace c-cleanup-list)
(progn
@ -886,7 +895,7 @@ If `c-electric-flag' is non-nil, point isn't inside a literal and a
numeric ARG hasn't been supplied, the command performs several electric
actions:
\(a) When the auto-newline feature is turned on (indicated by \"/ln\" on
\(a) When the auto-newline feature is turned on (indicated by \"/la\" on
the mode line) a newline might be inserted. See the variable
`c-hanging-semi&comma-criteria' for how newline insertion is determined.
@ -958,7 +967,7 @@ If `c-electric-flag' is non-nil, the colon is not inside a literal and a
numeric ARG hasn't been supplied, the command performs several electric
actions:
\(a) If the auto-newline feature is turned on (indicated by \"/ln\" on
\(a) If the auto-newline feature is turned on (indicated by \"/la\" on
the mode line) newlines are inserted before and after the colon based on
the settings in `c-hanging-colons-alist'.

View file

@ -1,7 +1,7 @@
;;; cc-compat.el --- cc-mode compatibility with c-mode.el confusion
;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006
;; Free Software Foundation, Inc.
;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006 Free Software
;; Foundation, Inc.
;; Authors: 1998- Martin Stjernholm
;; 1994-1999 Barry A. Warsaw

View file

@ -1,7 +1,7 @@
;;; cc-defs.el --- compile time definitions for CC Mode
;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006
;; Free Software Foundation, Inc.
;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006 Free Software
;; Foundation, Inc.
;; Authors: 1998- Martin Stjernholm
;; 1992-1999 Barry A. Warsaw
@ -71,10 +71,10 @@
(eval-after-load "font-lock"
'(if (and (not (featurep 'cc-fix)) ; only load the file once.
(featurep 'xemacs) ; There is now (2005/12) code in GNU Emacs CVS
; to make the call to f-l-c-k throw an error.
(let (font-lock-keywords)
(condition-case nil
(font-lock-compile-keywords '("\\<\\>"))
(error nil))
(font-lock-compile-keywords '("\\<\\>"))
font-lock-keywords)) ; did the previous call foul this up?
(load "cc-fix")))
@ -82,19 +82,18 @@
;; to ensure correct byte compilation.
(eval-when-compile
(if (and (not (featurep 'cc-fix))
(featurep 'xemacs)
(progn
(require 'font-lock)
(let (font-lock-keywords)
(condition-case nil
(font-lock-compile-keywords '("\\<\\>"))
(error nil))
(font-lock-compile-keywords '("\\<\\>"))
font-lock-keywords)))
(cc-load "cc-fix")))
;;; Variables also used at compile time.
(defconst c-version "5.31"
(defconst c-version "5.31.3"
"CC Mode version number.")
(defconst c-version-sym (intern c-version))
@ -2041,5 +2040,5 @@ quoted."
(cc-provide 'cc-defs)
;; arch-tag: 3bb2629d-dd84-4ff0-ad39-584be0fe3cda
;;; arch-tag: 3bb2629d-dd84-4ff0-ad39-584be0fe3cda
;;; cc-defs.el ends here

View file

@ -1,7 +1,7 @@
;;; cc-engine.el --- core syntax guessing engine for CC mode
;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006
;; Free Software Foundation, Inc.
;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006 Free Software Foundation,
;; Inc.
;; Authors: 1998- Martin Stjernholm
;; 1992-1999 Barry A. Warsaw
@ -179,8 +179,8 @@
(make-variable-buffer-local 'c-auto-newline)
;; Included in the mode line to indicate the active submodes.
(defvar c-submode-indicators nil)
(make-variable-buffer-local 'c-submode-indicators)
;; (defvar c-submode-indicators nil)
;; (make-variable-buffer-local 'c-submode-indicators)
(defun c-calculate-state (arg prevstate)
;; Calculate the new state of PREVSTATE, t or nil, based on arg. If
@ -525,14 +525,15 @@ also stop at a continuation clause.
Labels are treated as part of the following statements if
IGNORE-LABELS is non-nil. (FIXME: Doesn't work if we stop at a known
statement start keyword.)
statement start keyword.) Otherwise, each label is treated as a
separate statement.
Macros are ignored unless point is within one, in which case the
content of the macro is treated as normal code. Aside from any normal
statement starts found in it, stop at the first token of the content
in the macro, i.e. the expression of an \"#if\" or the start of the
definition in a \"#define\". Also stop at start of macros before
leaving them.
Macros are ignored \(i.e. skipped over) unless point is within one, in
which case the content of the macro is treated as normal code. Aside
from any normal statement starts found in it, stop at the first token
of the content in the macro, i.e. the expression of an \"#if\" or the
start of the definition in a \"#define\". Also stop at start of
macros before leaving them.
Return 'label if stopped at a label, 'same if stopped at the beginning
of the current statement, 'up if stepped to a containing statement,
@ -547,8 +548,9 @@ position if that is less ('same is returned in this case).
NOERROR turns off error logging to `c-parsing-error'.
Normally only ';' is considered to delimit statements, but if
COMMA-DELIM is non-nil then ',' is treated likewise.
Normally only ';' and virtual semicolons are considered to delimit
statements, but if COMMA-DELIM is non-nil then ',' is treated
as a delimiter too.
Note that this function might do hidden buffer changes. See the
comment at the start of cc-engine.el for more info."
@ -883,6 +885,7 @@ comment at the start of cc-engine.el for more info."
;; barriers in this round.
(sexp-loop-end-pos pos))
;; The following while goes back one sexp per iteration.
(while
(progn
(unless (c-safe (c-backward-sexp) t)
@ -954,7 +957,7 @@ comment at the start of cc-engine.el for more info."
;; Like a C "continue". Analyze the next sexp.
(throw 'loop t)))
sexp-loop-continue-pos)
sexp-loop-continue-pos) ; End of "go back a sexp" loop.
(goto-char sexp-loop-continue-pos)
(setq sexp-loop-end-pos sexp-loop-continue-pos
sexp-loop-continue-pos nil))))
@ -969,17 +972,26 @@ comment at the start of cc-engine.el for more info."
;; Handle labels.
(unless (eq ignore-labels t)
(when (numberp c-maybe-labelp)
;; `c-crosses-statement-barrier-p' has found a
;; colon, so we might be in a label now.
(if after-labels-pos
(if (not last-label-pos)
(setq last-label-pos (or tok start)))
(setq after-labels-pos (or tok start)))
(setq c-maybe-labelp t
label-good-pos nil))
;; `c-crosses-statement-barrier-p' has found a colon, so we
;; might be in a label now. Have we got a real label
;; (including a case label) or something like C++'s "public:"?
(if (or (not (looking-at c-nonlabel-token-key)) ; proper label
(save-excursion ; e.g. "case 'a':" ?
(and (c-safe (c-backward-sexp) t)
(looking-at "\\<case\\>")))) ; FIXME!!! this is
; wrong for AWK. 2006/1/14.
(progn
(if after-labels-pos ; Have we already encountered a label?
(if (not last-label-pos)
(setq last-label-pos (or tok start)))
(setq after-labels-pos (or tok start)))
(setq c-maybe-labelp t
label-good-pos nil))
(setq c-maybe-labelp nil))) ; bogus "label"
(when (and (not label-good-pos)
(looking-at c-nonlabel-token-key))
(when (and (not label-good-pos) ; i.e. no invalid "label"'s yet
; been found.
(looking-at c-nonlabel-token-key)) ; e.g. "while :"
;; We're in a potential label and it's the first
;; time we've found something that isn't allowed in
;; one.
@ -3993,36 +4005,35 @@ comment at the start of cc-engine.el for more info."
;;
;; This function might do hidden buffer changes.
(save-match-data
(save-excursion
(save-excursion
(goto-char beg)
(when (or (looking-at "[<>]")
(< (skip-chars-backward "<>") 0))
(goto-char beg)
(c-beginning-of-current-token)
(when (and (< (point) beg)
(looking-at c-<>-multichar-token-regexp)
(< beg (setq beg (match-end 0))))
(while (progn (skip-chars-forward "^<>" beg)
(< (point) beg))
(c-clear-char-property (point) 'syntax-table)
(forward-char))))
(when (< beg end)
(goto-char end)
(when (or (looking-at "[<>]")
(< (skip-chars-backward "<>") 0))
(goto-char beg)
(c-beginning-of-current-token)
(when (and (< (point) beg)
(looking-at c-<>-multichar-token-regexp)
(< beg (setq beg (match-end 0))))
(while (progn (skip-chars-forward "^<>" beg)
(< (point) beg))
(c-clear-char-property (point) 'syntax-table)
(forward-char))))
(when (< beg end)
(goto-char end)
(when (or (looking-at "[<>]")
(< (skip-chars-backward "<>") 0))
(goto-char end)
(c-beginning-of-current-token)
(when (and (< (point) end)
(looking-at c-<>-multichar-token-regexp)
(< end (setq end (match-end 0))))
(while (progn (skip-chars-forward "^<>" end)
(< (point) end))
(c-clear-char-property (point) 'syntax-table)
(forward-char))))))))
(c-beginning-of-current-token)
(when (and (< (point) end)
(looking-at c-<>-multichar-token-regexp)
(< end (setq end (match-end 0))))
(while (progn (skip-chars-forward "^<>" end)
(< (point) end))
(c-clear-char-property (point) 'syntax-table)
(forward-char)))))))
;; Dynamically bound variable that instructs `c-forward-type' to also
;; treat possible types (i.e. those that it normally returns 'maybe or
@ -5991,7 +6002,10 @@ y ;; True if there's a suffix match outside the outermost
;; Handle the name of the class itself.
(progn
(c-forward-token-2)
; (c-forward-token-2) ; 2006/1/13 This doesn't move if the token's
; at EOB.
(goto-char (match-end 0))
(c-skip-ws-forward)
(c-forward-type))
(catch 'break

View file

@ -1,7 +1,7 @@
;;; cc-langs.el --- language specific settings for CC Mode
;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006
;; Free Software Foundation, Inc.
;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006 Free Software
;; Foundation, Inc.
;; Authors: 1998- Martin Stjernholm
;; 1992-1999 Barry A. Warsaw
@ -177,7 +177,7 @@ the evaluated constant value at compile time."
'(def-edebug-spec c-lang-defvar
(&define name def-form &optional stringp)))
(eval-when-compile
(eval-and-compile
;; Some helper functions used when building the language constants.
(defun c-filter-ops (ops opgroup-filter op-filter &optional xlate)
@ -260,10 +260,14 @@ the evaluated constant value at compile time."
("Toggle..."
["Syntactic indentation" c-toggle-syntactic-indentation
:style toggle :selected c-syntactic-indentation]
["Auto newline" c-toggle-auto-newline
["Electric mode" c-toggle-electric-state
:style toggle :selected c-electric-flag]
["Auto newline" c-toggle-auto-newline
:style toggle :selected c-auto-newline]
["Hungry delete" c-toggle-hungry-state
:style toggle :selected c-hungry-delete-key])))
["Hungry delete" c-toggle-hungry-state
:style toggle :selected c-hungry-delete-key]
["Subword mode" c-subword-mode
:style toggle :selected c-subword-mode])))
;;; Syntax tables.
@ -2826,7 +2830,7 @@ accomplish that conveniently."
;; This let sets up the context for `c-mode-var' and similar
;; that could be in the result from `cl-macroexpand-all'.
(let ((c-buffer-is-cc-mode ',mode)
current-var)
current-var source-eval)
(condition-case err
(if (eq c-version-sym ',c-version-sym)
@ -2852,6 +2856,7 @@ accomplish that conveniently."
;; (put ',mode 'c-has-warned-lang-consts t))
(require 'cc-langs)
(setq source-eval t)
(let ((init (cdr c-lang-variable-inits)))
(while init
(setq current-var (caar init))
@ -2860,8 +2865,14 @@ accomplish that conveniently."
(error
(if current-var
(message "Eval error in the `c-lang-defvar' for `%s': %S"
current-var err)
(message "Eval error in the `c-lang-defvar' for `%s'%s: %S"
current-var
(if source-eval
(format "\
(fallback source eval - %s compiled with CC Mode %s but loaded with %s)"
',mode ,c-version c-version)
"")
err)
(signal (car err) (cdr err)))))))
;; Being evaluated from source. Always use the dynamic method to
@ -2881,8 +2892,9 @@ accomplish that conveniently."
(error
(if current-var
(message "Eval error in the `c-lang-defvar' for `%s': %S"
current-var err)
(message
"Eval error in the `c-lang-defvar' for `%s' (source eval): %S"
current-var err)
(signal (car err) (cdr err)))))))
))

View file

@ -1,7 +1,7 @@
;;; cc-menus.el --- imenu support for CC Mode
;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006
;; Free Software Foundation, Inc.
;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006 Free Software
;; Foundation, Inc.
;; Authors: 1998- Martin Stjernholm
;; 1992-1999 Barry A. Warsaw

View file

@ -1,7 +1,7 @@
;;; cc-mode.el --- major mode for editing C and similar languages
;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006
;; Free Software Foundation, Inc.
;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006 Free Software
;; Foundation, Inc.
;; Authors: 2003- Alan Mackenzie
;; 1998- Martin Stjernholm
@ -242,9 +242,9 @@ control). See \"cc-mode.el\" for more info."
(define-key c-mode-base-map (kbd "C-c C-<delete>")
'c-hungry-delete-forward)
(define-key c-mode-base-map (kbd "C-c C-<backspace>")
'c-hungry-backspace))
'c-hungry-delete-backwards))
(define-key c-mode-base-map (kbd "C-c C-<delete>")
'c-hungry-backspace)
'c-hungry-delete-backwards)
(define-key c-mode-base-map (kbd "C-c C-<backspace>")
'c-hungry-delete-forward)))
@ -304,10 +304,11 @@ control). See \"cc-mode.el\" for more info."
;; `c-electric-backspace'. The hungry variants are bound to the
;; same keys but prefixed with C-c. This implies that C-c C-d is
;; `c-hungry-delete-forward'. For consistency, we bind not only C-c
;; <backspace> to `c-hungry-backspace' but also C-c C-<backspace>,
;; so that the Ctrl key can be held down during the whole sequence
;; regardless of the direction. This in turn implies that we bind
;; C-c C-<delete> to `c-hungry-delete-forward', for the same reason.
;; <backspace> to `c-hungry-delete-backwards' but also
;; C-c C-<backspace>, so that the Ctrl key can be held down during
;; the whole sequence regardless of the direction. This in turn
;; implies that we bind C-c C-<delete> to `c-hungry-delete-forward',
;; for the same reason.
;; Bind the electric deletion functions to C-d and DEL. Emacs 21
;; automatically maps the [delete] and [backspace] keys to these two
@ -316,8 +317,8 @@ control). See \"cc-mode.el\" for more info."
(define-key c-mode-base-map "\C-d" 'c-electric-delete-forward)
(define-key c-mode-base-map "\177" 'c-electric-backspace)
(define-key c-mode-base-map "\C-c\C-d" 'c-hungry-delete-forward)
(define-key c-mode-base-map [?\C-c ?\d] 'c-hungry-backspace)
(define-key c-mode-base-map [?\C-c ?\C-\d] 'c-hungry-backspace)
(define-key c-mode-base-map [?\C-c ?\d] 'c-hungry-delete-backwards)
(define-key c-mode-base-map [?\C-c ?\C-\d] 'c-hungry-delete-backwards)
(define-key c-mode-base-map [?\C-c deletechar] 'c-hungry-delete-forward) ; C-c <delete> on a tty.
(define-key c-mode-base-map [?\C-c (control deletechar)] ; C-c C-<delete> on a tty.
'c-hungry-delete-forward)
@ -339,8 +340,10 @@ control). See \"cc-mode.el\" for more info."
(define-key c-mode-base-map [backspace] 'c-electric-backspace)
(define-key c-mode-base-map (kbd "C-c <delete>") 'c-hungry-delete)
(define-key c-mode-base-map (kbd "C-c C-<delete>") 'c-hungry-delete)
(define-key c-mode-base-map (kbd "C-c <backspace>") 'c-hungry-backspace)
(define-key c-mode-base-map (kbd "C-c C-<backspace>") 'c-hungry-backspace))
(define-key c-mode-base-map (kbd "C-c <backspace>")
'c-hungry-delete-backwards)
(define-key c-mode-base-map (kbd "C-c C-<backspace>")
'c-hungry-delete-backwards))
(define-key c-mode-base-map "#" 'c-electric-pound)
(define-key c-mode-base-map "{" 'c-electric-brace)
@ -414,23 +417,24 @@ preferably use the `c-mode-menu' language constant directly."
;; with regions outside the current narrowing. This has been
;; observed in Emacs 20.7.
(save-restriction
(widen)
(save-match-data ; c-recognize-<>-arglists changes match-data
(widen)
(when (> end (point-max))
;; Some emacsen might return positions past the end. This has been
;; observed in Emacs 20.7 when rereading a buffer changed on disk
;; (haven't been able to minimize it, but Emacs 21.3 appears to
;; work).
(setq end (point-max))
(when (> beg end)
(setq beg end)))
(when (> end (point-max))
;; Some emacsen might return positions past the end. This has been
;; observed in Emacs 20.7 when rereading a buffer changed on disk
;; (haven't been able to minimize it, but Emacs 21.3 appears to
;; work).
(setq end (point-max))
(when (> beg end)
(setq beg end)))
(c-invalidate-sws-region-after beg end)
(c-invalidate-state-cache beg)
(c-invalidate-find-decl-cache beg)
(c-invalidate-sws-region-after beg end)
(c-invalidate-state-cache beg)
(c-invalidate-find-decl-cache beg)
(when c-recognize-<>-arglists
(c-after-change-check-<>-operators beg end)))))
(when c-recognize-<>-arglists
(c-after-change-check-<>-operators beg end))))))
(defun c-basic-common-init (mode default-style)
"Do the necessary initialization for the syntax handling routines
@ -550,11 +554,12 @@ that requires a literal mode spec at compile time."
(make-local-variable 'comment-indent-function)
(setq comment-indent-function 'c-comment-indent)
;; Put submode indicators onto minor-mode-alist, but only once.
(or (assq 'c-submode-indicators minor-mode-alist)
(setq minor-mode-alist
(cons '(c-submode-indicators c-submode-indicators)
minor-mode-alist)))
;; ;; Put submode indicators onto minor-mode-alist, but only once.
;; (or (assq 'c-submode-indicators minor-mode-alist)
;; (setq minor-mode-alist
;; (cons '(c-submode-indicators c-submode-indicators)
;; minor-mode-alist)))
(c-update-modeline)
;; Install the functions that ensure that various internal caches
;; don't become invalid due to buffer changes.
@ -629,6 +634,51 @@ compatible with old code; callers should always specify it."
(and (cdr rfn)
(setq require-final-newline mode-require-final-newline)))))
(defun c-remove-any-local-eval-or-mode-variables ()
;; If the buffer specifies `mode' or `eval' in its File Local Variable list
;; or on the first line, remove all occurrences. See
;; `c-postprocess-file-styles' for justification. There is no need to save
;; point here, or even bother too much about the buffer contents.
;;
;; Most of the code here is derived from Emacs 21.3's `hack-local-variables'
;; in files.el.
(goto-char (point-max))
(search-backward "\n\^L" (max (- (point-max) 3000) (point-min)) 'move)
(let (lv-point (prefix "") (suffix ""))
(when (let ((case-fold-search t))
(search-forward "Local Variables:" nil t))
(setq lv-point (point))
;; The prefix is what comes before "local variables:" in its line.
;; The suffix is what comes after "local variables:" in its line.
(skip-chars-forward " \t")
(or (eolp)
(setq suffix (buffer-substring (point)
(progn (end-of-line) (point)))))
(goto-char (match-beginning 0))
(or (bolp)
(setq prefix
(buffer-substring (point)
(progn (beginning-of-line) (point)))))
(while (search-forward-regexp
(concat "^[ \t]*"
(regexp-quote prefix)
"\\(mode\\|eval\\):.*"
(regexp-quote suffix)
"$")
nil t)
(beginning-of-line)
(kill-line 1)))
;; Delete the first line, if we've got one, in case it contains a mode spec.
(unless (and lv-point
(progn (goto-char lv-point)
(forward-line 0)
(bobp)))
(goto-char (point-min))
(unless (eobp)
(kill-line 1)))))
(defun c-postprocess-file-styles ()
"Function that post processes relevant file local variables in CC Mode.
Currently, this function simply applies any style and offset settings
@ -656,12 +706,20 @@ Note that the style variables are always made local to the buffer."
;; overwritten this. So we run `hack-local-variables' again to remedy
;; this. There are no guarantees this will work properly, particularly as
;; we have no control over what the other hook functions on
;; `hack-local-variables-hook' would have done, or what any "eval"
;; expression will do when evaluated again. C'est la vie! ACM,
;; 2005/11/2.
;; `hack-local-variables-hook' would have done. We now (2006/2/1) remove
;; any `eval' or `mode' expressions before we evaluate again (see below).
;; ACM, 2005/11/2.
;;
;; Problem (bug reported by Gustav Broberg): if one of the variables is
;; `mode', this will invoke c-mode (etc.) again, setting up the style etc.
;; We prevent this by temporarily removing `mode' from the Local Variables
;; section.
(if (or c-file-style c-file-offsets)
(let ((hack-local-variables-hook nil))
(hack-local-variables)))))
(c-tentative-buffer-changes
(let ((hack-local-variables-hook nil))
(c-remove-any-local-eval-or-mode-variables)
(hack-local-variables))
nil))))
(add-hook 'hack-local-variables-hook 'c-postprocess-file-styles)

View file

@ -1,7 +1,7 @@
;;; cc-styles.el --- support for styles in CC Mode
;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006
;; Free Software Foundation, Inc.
;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006 Free Software
;; Foundation, Inc.
;; Authors: 1998- Martin Stjernholm
;; 1992-1999 Barry A. Warsaw

View file

@ -1,7 +1,7 @@
;;; cc-vars.el --- user customization variables for CC Mode
;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006
;; Free Software Foundation, Inc.
;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006 Free Software
;; Foundation, Inc.
;; Authors: 1998- Martin Stjernholm
;; 1992-1999 Barry A. Warsaw