Commit 47003633 authored by Stefan Monnier's avatar Stefan Monnier
Browse files

CC-mode: Set open-paren-in-column-0-is-defun-start to nil;

plus misc cleanup.
* lisp/progmodes/cc-mode.el (c-basic-common-init):
Set open-paren-in-column-0-is-defun-start.
(adaptive-fill-first-line-regexp, font-lock-syntactic-keywords):
Remove declarations, unused.
(run-mode-hooks): Remove declaration.
(font-lock-defaults): Use plain `defvar' to declare.
(c-run-mode-hooks): Test existence of run-mode-hooks with fboundp.
* lisp/progmodes/cc-langs.el (c-filter-ops): Avoid `setq'.
(c-make-mode-syntax-table): Don't micro-optimize.
(c-keywords, c-keyword-member-alist): Simplify.
(c-kwds-lang-consts): Don't eval at compile-time.
(c-primary-expr-regexp): Comment out unused vars.
* lisp/progmodes/cc-fonts.el (c-font-lock-context): Declare at top-level.
(c-font-byte-compile): New var.
(c--compile): New function.  Use it instead of `byte-compile'.
(c-cpp-matchers): Quote the value returned by
`c-make-syntactic-matcher' in case it's not self-evaluating.
(c-basic-matchers-before): Avoid a plain MATCHER as keyword, wrap it in
parentheses instead (in case MATCHER happens to be a list).
(c-font-lock-enum-tail): Remove unused var `start'.
(c-font-lock-objc-methods): Silence byte-compiler warnings.
* lisp/progmodes/cc-engine.el (c-syntactic-re-search-forward): Sink an `if'
test into an argument.
* lisp/progmodes/cc-defs.el (c-point, c-major-mode-is, c-put-char-property)
(c-get-char-property): Don't use `eval' just to unquote a constant.
(c-use-extents): Remove.  Use (featurep 'xemacs), compiled
more efficiently.
(c-put-char-property-fun): Don't call `byte-compile' by hand.
(c-clear-char-property, c-clear-char-properties): Check that `property'
is a quoted constant.
(c-emacs-features): Remove `infodock', `syntax-properties', and
`pps-extended-state' (never used), `8-bit' and `1-bit' (use (featurep
'xemacs) instead).  Use `with-temp-buffer' and let-bind vars after
changing buffer, so we don't have to setq them again afterwards.
(c-lang-const): Remove redundant symbolp assertions.
(c-find-assignment-for-mode): Use `or'.
* lisp/Makefile.in (compile-one-process): Remove cc-mode dependency.
parent a2dcba1c
2014-09-10 Stefan Monnier <monnier@iro.umontreal.ca>
CC-mode: Set open-paren-in-column-0-is-defun-start to nil;
plus misc cleanup.
* progmodes/cc-mode.el (c-basic-common-init):
Set open-paren-in-column-0-is-defun-start.
(adaptive-fill-first-line-regexp, font-lock-syntactic-keywords):
Remove declarations, unused.
(run-mode-hooks): Remove declaration.
(font-lock-defaults): Use plain `defvar' to declare.
(c-run-mode-hooks): Test existence of run-mode-hooks with fboundp.
* progmodes/cc-langs.el (c-filter-ops): Avoid `setq'.
(c-make-mode-syntax-table): Don't micro-optimize.
(c-keywords, c-keyword-member-alist): Simplify.
(c-kwds-lang-consts): Don't eval at compile-time.
(c-primary-expr-regexp): Comment out unused vars.
* progmodes/cc-fonts.el (c-font-lock-context): Declare at top-level.
(c-font-byte-compile): New var.
(c--compile): New function. Use it instead of `byte-compile'.
(c-cpp-matchers): Quote the value returned by
`c-make-syntactic-matcher' in case it's not self-evaluating.
(c-basic-matchers-before): Avoid a plain MATCHER as keyword, wrap it in
parentheses instead (in case MATCHER happens to be a list).
(c-font-lock-enum-tail): Remove unused var `start'.
(c-font-lock-objc-methods): Silence byte-compiler warnings.
* progmodes/cc-engine.el (c-syntactic-re-search-forward): Sink an `if'
test into an argument.
* progmodes/cc-defs.el (c-point, c-major-mode-is, c-put-char-property)
(c-get-char-property): Don't use `eval' just to unquote a constant.
(c-use-extents): Remove. Use (featurep 'xemacs), compiled
more efficiently.
(c-put-char-property-fun): Don't call `byte-compile' by hand.
(c-clear-char-property, c-clear-char-properties): Check that `property'
is a quoted constant.
(c-emacs-features): Remove `infodock', `syntax-properties', and
`pps-extended-state' (never used), `8-bit' and `1-bit' (use (featurep
'xemacs) instead). Use `with-temp-buffer' and let-bind vars after
changing buffer, so we don't have to setq them again afterwards.
(c-lang-const): Remove redundant symbolp assertions.
(c-find-assignment-for-mode): Use `or'.
* Makefile.in (compile-one-process): Remove cc-mode dependency.
2014-09-09 Sam Steingold <sds@gnu.org>
 
* progmodes/sql.el (sql-default-directory): Fix type annotation.
......
......@@ -387,7 +387,7 @@ compile-after-backup: backup-compiled-files compile-always
# There is no reason to use this rule unless you only have a single
# core and CPU time is an issue.
.PHONY: compile-one-process
compile-one-process: $(LOADDEFS) compile-first $(lisp)/progmodes/cc-mode.elc
compile-one-process: $(LOADDEFS) compile-first
$(emacs) $(BYTE_COMPILE_FLAGS) \
--eval "(batch-byte-recompile-directory 0)" $(lisp)
......
......@@ -195,7 +195,7 @@ If the referenced position doesn't exist, the closest accessible point
to it is returned. This function does not modify the point or the mark."
(if (eq (car-safe position) 'quote)
(let ((position (eval position)))
(let ((position (nth 1 position)))
(cond
((eq position 'bol)
......@@ -885,7 +885,7 @@ MODE is either a mode symbol or a list of mode symbols."
`(c-lang-major-mode-is ,mode)
(if (eq (car-safe mode) 'quote)
(let ((mode (eval mode)))
(let ((mode (nth 1 mode)))
(if (listp mode)
`(memq c-buffer-is-cc-mode ',mode)
`(eq c-buffer-is-cc-mode ',mode)))
......@@ -900,26 +900,10 @@ MODE is either a mode symbol or a list of mode symbols."
;; properties set on a single character and that never spread to any
;; other characters.
(eval-and-compile
;; Constant used at compile time to decide whether or not to use
;; XEmacs extents. Check all the extent functions we'll use since
;; some packages might add compatibility aliases for some of them in
;; Emacs.
(defconst c-use-extents (and (cc-bytecomp-fboundp 'extent-at)
(cc-bytecomp-fboundp 'set-extent-property)
(cc-bytecomp-fboundp 'set-extent-properties)
(cc-bytecomp-fboundp 'make-extent)
(cc-bytecomp-fboundp 'extent-property)
(cc-bytecomp-fboundp 'delete-extent)
(cc-bytecomp-fboundp 'map-extents))))
;; `c-put-char-property' is complex enough in XEmacs and Emacs < 21 to
;; make it a function.
(defalias 'c-put-char-property-fun
(cc-eval-when-compile
(cond (c-use-extents
;; XEmacs.
(byte-compile
(cond ((featurep 'xemacs)
(lambda (pos property value)
(let ((ext (extent-at pos nil property)))
(if ext
......@@ -928,20 +912,19 @@ MODE is either a mode symbol or a list of mode symbols."
(cons property
(cons value
'(start-open t
end-open t)))))))))
end-open t))))))))
((not (cc-bytecomp-boundp 'text-property-default-nonsticky))
;; In Emacs < 21 we have to mess with the `rear-nonsticky' property.
(byte-compile
(lambda (pos property value)
(put-text-property pos (1+ pos) property value)
(let ((prop (get-text-property pos 'rear-nonsticky)))
(or (memq property prop)
(put-text-property pos (1+ pos)
'rear-nonsticky
(cons property prop)))))))
(cons property prop))))))
;; This won't be used for anything.
(t 'ignore))))
(t #'ignore)))
(cc-bytecomp-defun c-put-char-property-fun) ; Make it known below.
(defmacro c-put-char-property (pos property value)
......@@ -956,42 +939,38 @@ MODE is either a mode symbol or a list of mode symbols."
;; 21) then it's assumed that the property is present on it.
;;
;; This macro does a hidden buffer change.
(setq property (eval property))
(if (or c-use-extents
(if (or (featurep 'xemacs)
(not (cc-bytecomp-boundp 'text-property-default-nonsticky)))
;; XEmacs and Emacs < 21.
`(c-put-char-property-fun ,pos ',property ,value)
`(c-put-char-property-fun ,pos ,property ,value)
;; In Emacs 21 we got the `rear-nonsticky' property covered
;; by `text-property-default-nonsticky'.
`(let ((-pos- ,pos))
(put-text-property -pos- (1+ -pos-) ',property ,value))))
(put-text-property -pos- (1+ -pos-) ,property ,value))))
(defmacro c-get-char-property (pos property)
;; Get the value of the given property on the character at POS if
;; it's been put there by `c-put-char-property'. PROPERTY is
;; assumed to be constant.
(setq property (eval property))
(if c-use-extents
(if (featurep 'xemacs)
;; XEmacs.
`(let ((ext (extent-at ,pos nil ',property)))
(if ext (extent-property ext ',property)))
`(let ((ext (extent-at ,pos nil ,property)))
(if ext (extent-property ext ,property)))
;; Emacs.
`(get-text-property ,pos ',property)))
`(get-text-property ,pos ,property)))
;; `c-clear-char-property' is complex enough in Emacs < 21 to make it
;; a function, since we have to mess with the `rear-nonsticky' property.
(defalias 'c-clear-char-property-fun
(cc-eval-when-compile
(unless (or c-use-extents
(unless (or (featurep 'xemacs)
(cc-bytecomp-boundp 'text-property-default-nonsticky))
(byte-compile
(lambda (pos property)
(when (get-text-property pos property)
(remove-text-properties pos (1+ pos) (list property nil))
(put-text-property pos (1+ pos)
'rear-nonsticky
(delq property (get-text-property
pos 'rear-nonsticky)))))))))
pos 'rear-nonsticky)))))))
(cc-bytecomp-defun c-clear-char-property-fun) ; Make it known below.
(defmacro c-clear-char-property (pos property)
......@@ -1000,8 +979,10 @@ MODE is either a mode symbol or a list of mode symbols."
;; constant.
;;
;; This macro does a hidden buffer change.
(setq property (eval property))
(cond (c-use-extents
(if (eq 'quote (car-safe property))
(setq property (nth 1 property))
(error "`property' should be a quoted constant"))
(cond ((featurep 'xemacs)
;; XEmacs.
`(let ((ext (extent-at ,pos nil ',property)))
(if ext (delete-extent ext))))
......@@ -1026,8 +1007,10 @@ MODE is either a mode symbol or a list of mode symbols."
;; `syntax-table'.
;;
;; This macro does hidden buffer changes.
(setq property (eval property))
(if c-use-extents
(if (eq 'quote (car-safe property))
(setq property (nth 1 property))
(error "`property' should be a quoted constant"))
(if (featurep 'xemacs)
;; XEmacs.
`(map-extents (lambda (ext ignored)
(delete-extent ext))
......@@ -1097,7 +1080,7 @@ been put there by c-put-char-property. POINT remains unchanged."
which have the value VALUE, as tested by `equal'. These
properties are assumed to be over individual characters, having
been put there by c-put-char-property. POINT remains unchanged."
(if c-use-extents
(if (featurep 'xemacs)
;; XEmacs
`(let ((-property- ,property))
(map-extents (lambda (ext val)
......@@ -1561,32 +1544,6 @@ non-nil, a caret is prepended to invert the set."
(defconst c-emacs-features
(let (list)
(if (boundp 'infodock-version)
;; I've no idea what this actually is, but it's legacy. /mast
(setq list (cons 'infodock list)))
;; XEmacs uses 8-bit modify-syntax-entry flags.
;; Emacs uses a 1-bit flag. We will have to set up our
;; syntax tables differently to handle this.
(let ((table (copy-syntax-table))
entry)
(modify-syntax-entry ?a ". 12345678" table)
(cond
;; Emacs
((arrayp table)
(setq entry (aref table ?a))
;; In Emacs, table entries are cons cells
(if (consp entry) (setq entry (car entry))))
;; XEmacs
((fboundp 'get-char-table)
(setq entry (get-char-table ?a table)))
;; incompatible
(t (error "CC Mode is incompatible with this version of Emacs")))
(setq list (cons (if (= (logand (lsh entry -16) 255) 255)
'8-bit
'1-bit)
list)))
;; Check whether beginning/end-of-defun call
;; beginning/end-of-defun-function nicely, passing through the
;; argument and respecting the return code.
......@@ -1609,35 +1566,12 @@ non-nil, a caret is prepended to invert the set."
(not (end-of-defun))))
(setq list (cons 'argumentative-bod-function list))))
(let ((buf (generate-new-buffer " test"))
parse-sexp-lookup-properties
parse-sexp-ignore-comments
lookup-syntax-properties) ; XEmacs
(with-current-buffer buf
(with-temp-buffer
(let ((parse-sexp-lookup-properties t)
(parse-sexp-ignore-comments t)
(lookup-syntax-properties t)) ; XEmacs
(set-syntax-table (make-syntax-table))
;; For some reason we have to set some of these after the
;; buffer has been made current. (Specifically,
;; `parse-sexp-ignore-comments' in Emacs 21.)
(setq parse-sexp-lookup-properties t
parse-sexp-ignore-comments t
lookup-syntax-properties t)
;; Find out if the `syntax-table' text property works.
(modify-syntax-entry ?< ".")
(modify-syntax-entry ?> ".")
(insert "<()>")
(c-mark-<-as-paren (point-min))
(c-mark->-as-paren (+ 3 (point-min)))
(goto-char (point-min))
(c-forward-sexp)
(if (= (point) (+ 4 (point-min)))
(setq list (cons 'syntax-properties list))
(error (concat
"CC Mode is incompatible with this version of Emacs - "
"support for the `syntax-table' text property "
"is required.")))
;; Find out if generic comment delimiters work.
(c-safe
(modify-syntax-entry ?x "!")
......@@ -1674,11 +1608,11 @@ non-nil, a caret is prepended to invert the set."
(cond
;; XEmacs. Afaik this is currently an Emacs-only
;; feature, but it's good to be prepared.
((memq '8-bit list)
((featurep 'xemacs)
(modify-syntax-entry ?/ ". 1456")
(modify-syntax-entry ?* ". 23"))
;; Emacs
((memq '1-bit list)
(t
(modify-syntax-entry ?/ ". 124b")
(modify-syntax-entry ?* ". 23")))
(modify-syntax-entry ?\n "> b")
......@@ -1687,16 +1621,7 @@ non-nil, a caret is prepended to invert the set."
(if (bobp)
(setq list (cons 'col-0-paren list)))))
(set-buffer-modified-p nil))
(kill-buffer buf))
;; See if `parse-partial-sexp' returns the eighth element.
(if (c-safe (>= (length (save-excursion (parse-partial-sexp (point) (point))))
10))
(setq list (cons 'pps-extended-state list))
(error (concat
"CC Mode is incompatible with this version of Emacs - "
"`parse-partial-sexp' has to return at least 10 elements.")))
(set-buffer-modified-p nil)))
;;(message "c-emacs-features: %S" list)
list)
......@@ -1705,29 +1630,16 @@ There are many flavors of Emacs out there, each with different
features supporting those needed by CC Mode. The following values
might be present:
'8-bit 8 bit syntax entry flags (XEmacs style).
'1-bit 1 bit syntax entry flags (Emacs style).
'argumentative-bod-function beginning-of-defun passes ARG through
to a non-null beginning-of-defun-function. It is assumed
the end-of-defun does the same thing.
'syntax-properties It works to override the syntax for specific characters
in the buffer with the 'syntax-table property. It's
always set - CC Mode no longer works in emacsen without
this feature.
'gen-comment-delim Generic comment delimiters work
`argumentative-bod-function' `beginning-of-defun' passes ARG through
to a non-null `beginning-of-defun-function.' It is assumed
that `end-of-defun' does the same thing.
`gen-comment-delim' Generic comment delimiters work
(i.e. the syntax class `!').
'gen-string-delim Generic string delimiters work
`gen-string-delim' Generic string delimiters work
(i.e. the syntax class `|').
'pps-extended-state `parse-partial-sexp' returns a list with at least 10
elements, i.e. it contains the position of the start of
the last comment or string. It's always set - CC Mode
no longer works in emacsen without this feature.
'posix-char-classes The regexp engine understands POSIX character classes.
'col-0-paren It's possible to turn off the ad-hoc rule that a paren
in column zero is the start of a defun.
'infodock This is Infodock (based on XEmacs).
'8-bit and '1-bit are mutually exclusive.")
`posix-char-classes' The regexp engine understands POSIX character classes.
`col-0-paren' It's possible to turn off the ad-hoc rule that a paren
in column zero is the start of a defun.")
;;; Some helper constants.
......@@ -2023,11 +1935,6 @@ LANG is the name of the language, i.e. the mode name without the
language. NAME and LANG are not evaluated so they should not be
quoted."
(or (symbolp name)
(error "Not a symbol: %S" name))
(or (symbolp lang)
(error "Not a symbol: %S" lang))
(let ((sym (intern (symbol-name name) c-lang-constants))
(mode (when lang (intern (concat (symbol-name lang) "-mode")))))
......@@ -2188,57 +2095,56 @@ fallback definition for all modes, to break the cycle).")
value))))
(defun c-find-assignment-for-mode (source-pos mode match-any-lang _name)
;; Find the first assignment entry that applies to MODE at or after
;; SOURCE-POS. If MATCH-ANY-LANG is non-nil, entries with `t' as
;; the language list are considered to match, otherwise they don't.
;; On return SOURCE-POS is updated to point to the next assignment
;; after the returned one. If no assignment is found,
;; `c-lang--novalue' is returned as a magic value.
;;
;; SOURCE-POS is a vector that points out a specific assignment in
;; the double alist that's used in the `source' property. The first
;; element is the position in the top alist which is indexed with
;; the source files, and the second element is the position in the
;; nested bindings alist.
;;
;; NAME is only used for error messages.
"Find the first assignment entry that applies to MODE at or after
SOURCE-POS. If MATCH-ANY-LANG is non-nil, entries with `t' as
the language list are considered to match, otherwise they don't.
On return SOURCE-POS is updated to point to the next assignment
after the returned one. If no assignment is found,
`c-lang--novalue' is returned as a magic value.
SOURCE-POS is a vector that points out a specific assignment in
the double alist that's used in the `source' property. The first
element is the position in the top alist which is indexed with
the source files, and the second element is the position in the
nested bindings alist.
NAME is only used for error messages."
(catch 'found
(let ((file-entry (elt source-pos 0))
(assignment-entry (elt source-pos 1))
assignment)
(while (if assignment-entry
t
;; Handled the last assignment from one file, begin on the
;; next. Due to the check in `c-lang-defconst', we know
;; there's at least one.
(when file-entry
(unless (aset source-pos 1
(setq assignment-entry (cdar file-entry)))
;; The file containing the source definitions has not
;; been loaded.
(let ((file (symbol-name (caar file-entry)))
(c-lang-constants-under-evaluation nil))
;;(message (concat "Loading %s to get the source "
;; "value for language constant %s")
;; file name)
(load file nil t))
(unless (setq assignment-entry (cdar file-entry))
;; The load didn't fill in the source for the
;; constant as expected. The situation is
;; probably that a derived mode was written for
;; and compiled with another version of CC Mode,
;; and the requested constant isn't in the
;; currently loaded one. Put in a dummy
;; assignment that matches no language.
(setcdr (car file-entry)
(setq assignment-entry (list (list nil))))))
(aset source-pos 0 (setq file-entry (cdr file-entry)))
t))
(while (or assignment-entry
;; Handled the last assignment from one file, begin on the
;; next. Due to the check in `c-lang-defconst', we know
;; there's at least one.
(when file-entry
(unless (aset source-pos 1
(setq assignment-entry (cdar file-entry)))
;; The file containing the source definitions has not
;; been loaded.
(let ((file (symbol-name (caar file-entry)))
(c-lang-constants-under-evaluation nil))
;;(message (concat "Loading %s to get the source "
;; "value for language constant %s")
;; file name)
(load file nil t))
(unless (setq assignment-entry (cdar file-entry))
;; The load didn't fill in the source for the
;; constant as expected. The situation is
;; probably that a derived mode was written for
;; and compiled with another version of CC Mode,
;; and the requested constant isn't in the
;; currently loaded one. Put in a dummy
;; assignment that matches no language.
(setcdr (car file-entry)
(setq assignment-entry (list (list nil))))))
(aset source-pos 0 (setq file-entry (cdr file-entry)))
t))
(setq assignment (car assignment-entry))
(aset source-pos 1
......
......@@ -2222,6 +2222,8 @@ comment at the start of cc-engine.el for more info."
((and (not not-in-delimiter) ; inside a comment starter
(not (bobp))
(progn (backward-char)
;; FIXME: We never add category-properties to
;; c-emacs-features!
(and (not (and (memq 'category-properties c-emacs-features)
(looking-at "\\s!")))
(looking-at c-comment-start-regexp))))
......@@ -4119,10 +4121,10 @@ comment at the start of cc-engine.el for more info."
(c-end-of-current-token last-token-end-pos))
(setq last-token-end-pos (point))))))
;; Inside a token.
(if lookbehind-submatch
;; See the NOTE above.
(goto-char state-pos)
(goto-char (min last-token-end-pos bound))))
(goto-char (if lookbehind-submatch
;; See the NOTE above.
state-pos
(min last-token-end-pos bound))))
(t
;; A real match.
......
......@@ -201,17 +201,18 @@
:version "24.1"
:group 'c)
;; This indicates the "font locking context", and is set just before
;; fontification is done. If non-nil, it says, e.g., point starts
;; from within a #if preprocessor construct.
(defvar c-font-lock-context nil)
(make-variable-buffer-local 'c-font-lock-context)
(cc-bytecomp-defvar c-font-lock-context)
(eval-and-compile
;; We need the following definitions during compilation since they're
;; used when the `c-lang-defconst' initializers are evaluated. Define
;; them at runtime too for the sake of derived modes.
;; This indicates the "font locking context", and is set just before
;; fontification is done. If non-nil, it says, e.g., point starts
;; from within a #if preprocessor construct.
(defvar c-font-lock-context nil)
(make-variable-buffer-local 'c-font-lock-context)
(defmacro c-put-font-lock-face (from to face)
;; Put a face on a region (overriding any existing face) in the way
;; font-lock would do it. In XEmacs that means putting an
......@@ -272,18 +273,29 @@
(c-got-face-at (point) c-literal-faces))))
t))
(defvar c-font-byte-compile t
"If non-nil, byte-compile the dynamically-generated functions.")
(defun c--compile (exp)
(cond
((byte-code-function-p exp) (error "Already byte-compiled: %S" exp))
((not (eq (car-safe exp) 'lambda))
(error "Expected a (lambda ..): %S" exp))
(c-font-byte-compile (byte-compile exp))
(t (eval (macroexpand-all exp)))))
(defun c-make-syntactic-matcher (regexp)
;; Returns a byte compiled function suitable for use in place of a
;; regexp string in a `font-lock-keywords' matcher, except that
;; only matches outside comments and string literals count.
;;
;; This function does not do any hidden buffer changes, but the
;; generated functions will. (They are however used in places
;; covered by the font-lock context.)
(byte-compile
"Return a function suitable for use in place of a
regexp string in a `font-lock-keywords' matcher, except that
only matches outside comments and string literals count.
This function does not do any hidden buffer changes, but the
generated functions will. (They are however used in places
covered by the font-lock context.)"
(c--compile
`(lambda (limit)
(let (res)
(while (and (setq res (re-search-forward ,regexp limit t))
(while (and (setq res (re-search-forward ,regexp limit t))
(progn
(goto-char (match-beginning 0))
(or (c-skip-comments-and-strings limit)
......@@ -332,34 +344,34 @@
highlights))))
(defun c-make-font-lock-search-function (regexp &rest highlights)
;; This function makes a byte compiled function that works much like
;; a matcher element in `font-lock-keywords'. It cuts out a little
;; bit of the overhead compared to a real matcher. The main reason
;; is however to pass the real search limit to the anchored
;; matcher(s), since most (if not all) font-lock implementations
;; arbitrarily limit anchored matchers to the same line, and also
;; to insulate against various other irritating differences between
;; the different (X)Emacs font-lock packages.
;;
;; REGEXP is the matcher, which must be a regexp. Only matches
;; where the beginning is outside any comment or string literal are
;; significant.
;;
;; HIGHLIGHTS is a list of highlight specs, just like in
;; `font-lock-keywords', with these limitations: The face is always
;; overridden (no big disadvantage, since hits in comments etc are
;; filtered anyway), there is no "laxmatch", and an anchored matcher
;; is always a form which must do all the fontification directly.
;; `limit' is a variable bound to the real limit in the context of
;; the anchored matcher forms.
;;
;; This function does not do any hidden buffer changes, but the
;; generated functions will. (They are however used in places
;; covered by the font-lock context.)
;; Note: Replace `byte-compile' with `eval' to debug the generated
"This function makes a byte compiled function that works much like
a matcher element in `font-lock-keywords'. It cuts out a little
bit of the overhead compared to a real matcher. The main reason
is however to pass the real search limit to the anchored
matcher(s), since most (if not all) font-lock implementations
arbitrarily limit anchored matchers to the same line, and also
to insulate against various other irritating differences between
the different (X)Emacs font-lock packages.
REGEXP is the matcher, which must be a regexp. Only matches
where the beginning is outside any comment or string literal are
significant.
HIGHLIGHTS is a list of highlight specs, just like in
`font-lock-keywords', with these limitations: The face is always
overridden (no big disadvantage, since hits in comments etc are
filtered anyway), there is no \"laxmatch\", and an anchored matcher
is always a form which must do all the fontification directly.
`limit' is a variable bound to the real limit in the context of
the anchored matcher forms.
This function does not do any hidden buffer changes, but the
generated functions will. (They are however used in places
covered by the font-lock context.)"
;; Note: Set c-font-byte-compile to nil to debug the generated
;; lambda more easily.
(byte-compile
(c--compile
`(lambda (limit)
(let ( ;; The font-lock package in Emacs is known to clobber
;; `parse-sexp-lookup-properties' (when it exists).
......@@ -402,44 +414,44 @@
nil)))
(defun c-make-font-lock-BO-decl-search-function (regexp &rest highlights)
;; This function makes a byte compiled function that first moves back
;; to the beginning of the current declaration (if any), then searches
;; forward for matcher elements (as in `font-lock-keywords') and
;; fontifies them.
;;
;; The motivation for moving back to the declaration start is to
;; establish a context for the current text when, e.g., a character