;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to
-;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; along with this program; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
;;; Commentary:
(let ((open-paren (elt c-syntactic-element 2))
(paren-state (c-parse-state)))
(while (not (eq (car paren-state) open-paren))
- (goto-char (car paren-state))
+ (unless (consp (car paren-state)) ;; ignore matched braces
+ (goto-char (car paren-state)))
(setq paren-state (cdr paren-state)))))
(let ((start (point)) c)
;;(/= (point-max)
;; (save-excursion (skip-syntax-forward " ") (point))
(zerop (forward-line 1))
+ (bolp) ; forward-line has funny behavior at eob.
(not (looking-at "^[ \t]*$")))
'stop
nil)))
;; Copyright (C) 1988,94,96,2000,01,02,03 Free Software Foundation, Inc.
-;; Author: Alan Mackenzie (originally based on awk-mode.el)
+;; Author: Alan Mackenzie <acm@muc.de> (originally based on awk-mode.el)
;; Maintainer: FSF
;; Keywords: AWK, cc-mode, unix, languages
;; Matches any AWK regexp character which doesn't require special analysis.
(defconst c-awk-escaped-newlines*-re "\\(\\\\[\n\r]\\)*")
;; Matches a (possibly empty) sequence of escaped newlines.
+
+;; NOTE: In what follows, "[asdf]" in a regexp will be called a "character
+;; list", and "[:alpha:]" inside a character list will be known as a
+;; "character class". These terms for these things vary between regexp
+;; descriptions .
(defconst c-awk-regexp-char-class-re
+ "\\[:[a-z]+:\\]")
+ ;; Matches a character class spec (e.g. [:alpha:]).
+(defconst c-awk-regexp-char-list-re
(concat "\\[" c-awk-escaped-newlines*-re "^?" c-awk-escaped-newlines*-re "]?"
- "\\(" c-awk-esc-pair-re "\\|" "[^]\n\r]" "\\)*" "\\(]\\|$\\)"))
-;; Matches a regexp char class, up to (but not including) EOL if the ] is
+ "\\(" c-awk-esc-pair-re "\\|" c-awk-regexp-char-class-re
+ "\\|" "[^]\n\r]" "\\)*" "\\(]\\|$\\)"))
+;; Matches a regexp char list, up to (but not including) EOL if the ] is
;; missing.
(defconst c-awk-regexp-innards-re
- (concat "\\(" c-awk-esc-pair-re "\\|" c-awk-regexp-char-class-re
+ (concat "\\(" c-awk-esc-pair-re "\\|" c-awk-regexp-char-list-re
"\\|" c-awk-regexp-normal-re "\\)*"))
;; Matches the inside of an AWK regexp (i.e. without the enclosing /s)
(defconst c-awk-regexp-without-end-re
;; A "neutral" char(pair). Doesn't change the "state" of a subsequent /.
;; This is space/tab, braces, an auto-increment/decrement operator or an
;; escaped character. Or one of the (illegal) characters @ or `. But NOT an
-;; end of line (even if escpaed).
+;; end of line (even if escaped).
(defconst c-awk-neutrals*-re
(concat "\\(" c-awk-neutral-re "\\)*"))
;; A (possibly empty) string of neutral characters (or character pairs).
(delete-region (point) end)
(indent-to column 1)))
- (= (forward-line 1) 0))))
+ (zerop (forward-line 1)))
+ (bolp))) ; forward-line has funny behavior at eob.
;; Make sure there are backslashes with at least one space in
;; front of them.
(insert ?\\)
(insert ?\ ?\\)))
- (= (forward-line 1) 0)))))))
+ (zerop (forward-line 1)))
+ (bolp)))))) ; forward-line has funny behavior at eob.
(defun c-delete-backslashes-forward (to-mark point-pos)
;; This function does not do any hidden buffer changes.
(skip-chars-backward " \t" (if (>= (point) point-pos)
point-pos))
(point))))
- (= (forward-line 1) 0)))))
+ (zerop (forward-line 1)))
+ (bolp)))) ; forward-line has funny behavior at eob.
\f
\f
;;; Variables also used at compile time.
-(defconst c-version "5.30.9"
+(defconst c-version "5.30.10"
"CC Mode version number.")
(defconst c-version-sym (intern c-version))
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to
-;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; along with this program; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
;;; Commentary:
;; when font-lock refontifies the current line only.
(when (save-excursion
(and (= (forward-line 1) 0)
+ (bolp) ; forward-line has funny behavior at eob.
(or (< (c-point 'eol) cfd-limit)
(progn (backward-char)
(not (eq (char-before) ?\\))))))
;; operator token preceded by "operator".
(save-excursion
(and (c-safe (c-backward-sexp) t)
- (looking-at "operator\\([^_]\\|$\\)")))
+ (looking-at "operator\\>\\([^_]\\|$\\)")))
(and (eq (char-before) ?<)
(c-with-syntax-table c++-template-syntax-table
(if (c-safe (goto-char (c-up-list-forward (point))))
;; Note: We use the fact that lim is always after any
;; preceding brace sexp.
(while (and (zerop (c-backward-token-2 1 t lim))
- (not (looking-at "[;<,=]"))))
+ (or (not (looking-at "[;<,=]"))
+ (and c-overloadable-operators-regexp
+ (looking-at c-overloadable-operators-regexp)
+ (save-excursion
+ (zerop (c-backward-token-2 1 nil lim))
+ (looking-at "operator\\>[^_]"))))))
(or (memq (char-after) '(?, ?=))
(and (c-major-mode-is 'c++-mode)
(zerop (c-backward-token-2 1 nil lim))
;; CASE 5I: ObjC method definition.
((and c-opt-method-key
(looking-at c-opt-method-key))
- (c-beginning-of-statement-1 lim)
+ (c-beginning-of-statement-1 nil t)
+ (if (= (point) indent-point)
+ ;; Handle the case when it's the first (non-comment)
+ ;; thing in the buffer. Can't look for a 'same return
+ ;; value from cbos1 since ObjC directives currently
+ ;; aren't recognized fully, so that we get 'same
+ ;; instead of 'previous if it moved over a preceding
+ ;; directive.
+ (goto-char (point-min)))
(c-add-syntax 'objc-method-intro (c-point 'boi)))
;; CASE 5P: AWK pattern or function or continuation
;; thereof.
;; CASE 5K: we are at an ObjC method definition
;; continuation line.
((and c-opt-method-key
- (progn
+ (save-excursion
+ (goto-char indent-point)
(c-beginning-of-statement-1 lim)
(beginning-of-line)
- (looking-at c-opt-method-key)))
- (c-add-syntax 'objc-method-args-cont (point)))
+ (when (looking-at c-opt-method-key)
+ (setq placeholder (point)))))
+ (c-add-syntax 'objc-method-args-cont placeholder))
;; CASE 5L: we are at the first argument of a template
;; arglist that begins on the previous line.
((eq (char-before) ?<)
;; with array initializers. Otherwise stop at braces
;; to avoid going past full function and class blocks.
(and (if (and (eq got-init ?=)
- (= (c-forward-token-2) 0)
+ (= (c-forward-token-2 1 nil limit) 0)
(looking-at "{"))
(c-safe (c-forward-sexp) t)
t)
(c-lang-defvar c-brace-list-key (c-lang-const c-brace-list-key))
(c-lang-defconst c-other-block-decl-kwds
- "Keywords where the following block (if any) contain another
+ "Keywords where the following block (if any) contains another
declaration level that should not be considered a class.
If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to
-;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; along with this program; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
;;; Commentary:
(cc-require 'cc-align)
(cc-require 'cc-menus)
-;; SILENCE the compiler.
+;; Silence the compiler.
(cc-bytecomp-defvar comment-line-break-function) ; (X)Emacs 20+
(cc-bytecomp-defvar adaptive-fill-first-line-regexp) ; Emacs 20+
(cc-bytecomp-defun set-keymap-parents) ; XEmacs
+(cc-bytecomp-defun run-mode-hooks) ; Emacs 21.1+
+(cc-bytecomp-obsolete-fun make-local-hook) ; Marked obsolete in Emacs 21.1.
;; We set these variables during mode init, yet we don't require
;; font-lock.
(defun c-make-inherited-keymap ()
(let ((map (make-sparse-keymap)))
+ ;; Necessary to use `cc-bytecomp-fboundp' below since this
+ ;; function is called from top-level forms that are evaluated
+ ;; while cc-bytecomp is active when one does M-x eval-buffer.
(cond
;; XEmacs
- ((fboundp 'set-keymap-parents)
+ ((cc-bytecomp-fboundp 'set-keymap-parents)
(set-keymap-parents map c-mode-base-map))
;; Emacs
- ((fboundp 'set-keymap-parent)
+ ((cc-bytecomp-fboundp 'set-keymap-parent)
(set-keymap-parent map c-mode-base-map))
;; incompatible
(t (error "CC Mode is incompatible with this version of Emacs")))
(add-hook 'hack-local-variables-hook 'c-postprocess-file-styles)
+(defmacro c-run-mode-hooks (&rest hooks)
+ ;; Emacs 21.1 has introduced a system with delayed mode hooks that
+ ;; require the use of the new function `run-mode-hooks'.
+ (if (cc-bytecomp-fboundp 'run-mode-hooks)
+ `(run-mode-hooks ,@hooks)
+ `(progn ,@(mapcar (lambda (hook) `(run-hooks ,hook)) hooks))))
+
\f
;; Support for C
(c-common-init 'c-mode)
(easy-menu-add c-c-menu)
(cc-imenu-init cc-imenu-c-generic-expression)
- (run-mode-hooks 'c-mode-common-hook 'c-mode-hook)
+ (c-run-mode-hooks 'c-mode-common-hook 'c-mode-hook)
(c-update-modeline))
\f
(c-common-init 'c++-mode)
(easy-menu-add c-c++-menu)
(cc-imenu-init cc-imenu-c++-generic-expression)
- (run-mode-hooks 'c-mode-common-hook 'c++-mode-hook)
+ (c-run-mode-hooks 'c-mode-common-hook 'c++-mode-hook)
(c-update-modeline))
\f
(c-common-init 'objc-mode)
(easy-menu-add c-objc-menu)
(cc-imenu-init nil 'cc-imenu-objc-function)
- (run-mode-hooks 'c-mode-common-hook 'objc-mode-hook)
+ (c-run-mode-hooks 'c-mode-common-hook 'objc-mode-hook)
(c-update-modeline))
\f
(c-common-init 'java-mode)
(easy-menu-add c-java-menu)
(cc-imenu-init cc-imenu-java-generic-expression)
- (run-mode-hooks 'c-mode-common-hook 'java-mode-hook)
+ (c-run-mode-hooks 'c-mode-common-hook 'java-mode-hook)
(c-update-modeline))
\f
(c-common-init 'idl-mode)
(easy-menu-add c-idl-menu)
;;(cc-imenu-init cc-imenu-idl-generic-expression) ;TODO
- (run-mode-hooks 'c-mode-common-hook 'idl-mode-hook)
+ (c-run-mode-hooks 'c-mode-common-hook 'idl-mode-hook)
(c-update-modeline))
\f
(c-common-init 'pike-mode)
(easy-menu-add c-pike-menu)
;;(cc-imenu-init cc-imenu-pike-generic-expression) ;TODO
- (run-mode-hooks 'c-mode-common-hook 'pike-mode-hook)
+ (c-run-mode-hooks 'c-mode-common-hook 'pike-mode-hook)
(c-update-modeline))
\f
;; in cc-engine.el, just before (defun c-fast-in-literal ...
(defalias 'c-in-literal 'c-slow-in-literal)
- (run-mode-hooks 'c-mode-common-hook 'awk-mode-hook)
+ (c-run-mode-hooks 'c-mode-common-hook 'awk-mode-hook)
(c-update-modeline))
) ;; closes the (if (not (memq 'syntax-properties c-emacs-features))
;; Silence the compiler.
(cc-bytecomp-defvar adaptive-fill-first-line-regexp) ; Emacs
+(cc-bytecomp-obsolete-fun make-local-hook) ; Marked obsolete in Emacs 21.1.
\f
(defvar c-style-alist