+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
;;; 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
;;; 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
(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.
(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
;;; 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
;;; 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
(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)
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]."
(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
(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)
(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 \"#\".
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'.
"{"
"\\=")
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
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.
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'.
;;; 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
;;; 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
(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")))
;; 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")))
\f
;;; 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))
\f
(cc-provide 'cc-defs)
-;; arch-tag: 3bb2629d-dd84-4ff0-ad39-584be0fe3cda
+;;; arch-tag: 3bb2629d-dd84-4ff0-ad39-584be0fe3cda
;;; cc-defs.el ends here
;;; 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
(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
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,
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."
;; 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)
;; 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))))
;; 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))
-
- (when (and (not label-good-pos)
- (looking-at c-nonlabel-token-key))
+ ;; `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) ; 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.
;;
;; 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)
+ (goto-char end)
(c-beginning-of-current-token)
- (when (and (< (point) beg)
+ (when (and (< (point) end)
(looking-at c-<>-multichar-token-regexp)
- (< beg (setq beg (match-end 0))))
- (while (progn (skip-chars-forward "^<>" beg)
- (< (point) beg))
+ (< end (setq end (match-end 0))))
+ (while (progn (skip-chars-forward "^<>" end)
+ (< (point) end))
(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))))))))
+ (forward-char)))))))
;; Dynamically bound variable that instructs `c-forward-type' to also
;; treat possible types (i.e. those that it normally returns 'maybe or
;; 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
;;; 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
'(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)
("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])))
\f
;;; Syntax tables.
;; 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)
;; (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))
(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
(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)))))))
))
;;; 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
;;; 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
(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)))
;; `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
(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)
(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)
;; 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
(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.
(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
;; 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)
;;; 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
;;; 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