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

Merge some of the differences from the standalone CC-mode.

The main change is to only use the `category' text-property only when
available.  For that many calls are changed to use c-get-char-property,
c-next-single-property-change, c-sc-scan-lists,
c-sc-parse-partial-sexp, c-unmark-<->-as-paren.

* lisp/progmodes/cc-align.el (c-lineup-respect-col-0): New function.

* lisp/progmodes/cc-cmds.el (c-forward-into-nomenclature)
(c-backward-into-nomenclature): Use cc-subword if subword-mode is
not available.
(c-beginning-of-defun, c-end-of-defun, c-mark-function)
(c-indent-line-or-region): Use c-region-is-active-p.

* lisp/progmodes/cc-defs.el (c-version): Bump up to 5.33.
(c-use-category): New const.
(c-next-single-property-change): New macro.
(c-region-is-active-p): Prefer region-active-p when available.
(c-search-backward-char-property): Fix old min/max typo; probably
a copy/paste error.
(c-mark-<-as-paren, c-mark->-as-paren, c-unmark-<->-as-paren):
Turn them into macros that obey c-use-category.
(c-sc-scan-lists-no-category+1+1, c-sc-scan-lists-no-category+1-1)
(c-sc-scan-lists-no-category-1+1, c-sc-scan-lists-no-category-1-1)
(c-sc-scan-lists, c-sc-parse-partial-sexp)
(c-looking-at-non-alphnumspace): New macros.
(c-sc-parse-partial-sexp-no-category): New function.
(c-emacs-features): Add `category-properties' element.

* lisp/progmodes/cc-engine.el (c-invalidate-state-cache, c-parse-state):
Handle the case where categories are not available.
(c-record-parse-state-state, c-replay-parse-state-state):
Handle marker values.
(c-before-change-check-<>-operators): Look for the `syntax-table'
property rather than for the corresponding `category'.
(c-looking-at-decl-block): Remove unused var
`c-disallow-comma-in-<>-arglists'.
(c-forward-<>-arglist-recur): Remove unused var
`orig-record-found-types'.

* lisp/progmodes/cc-langs.el (c-modified-constant): New lang var.
(c-known-type-key): Don't make a list just to throw it away.

* lisp/progmodes/cc-bytecomp.el (cc-bytecomp-unbound-variables)
(cc-bytecomp-original-functions, cc-bytecomp-original-properties)
(cc-bytecomp-loaded-files): Re-set each time the file is loaded.
(cc-bytecomp-obsolete-var, cc-bytecomp-ignore-obsolete)
(cc-bytecomp-obsolete-fun): Delete unused functions.

* lisp/progmodes/cc-mode.el (c-just-done-before-change): New var.
(c-basic-common-init): Initialize it.
(c-common-init): Only use mode-require-final-newline when available.
(c-before-change): Check and set c-just-done-before-change.
(c-after-change): Re-set c-just-done-before-change.
(c-advise-fl-for-region): New macro.
(lazy-lock-defer-rest-after-change, lazy-lock-defer-line-after-change)
(font-lock-after-change-function, jit-lock-after-change):
Advise if needed.
parent 808699f1
2014-12-01 Lars Magne Ingebrigtsen <larsi@gnus.org>
2014-12-01 Stefan Monnier <monnier@iro.umontreal.ca>
* net/shr.el (shr-dom-print): Fix up `shr-dom-print' after the
dom.el changes.
Merge some of the differences from the standalone CC-mode.
The main change is to only use the `category' text-property only when
available. For that many calls are changed to use c-get-char-property,
c-next-single-property-change, c-sc-scan-lists,
c-sc-parse-partial-sexp, c-unmark-<->-as-paren.
* progmodes/cc-mode.el (c-just-done-before-change): New var.
(c-basic-common-init): Initialize it.
(c-common-init): Only use mode-require-final-newline when available.
(c-before-change): Check and set c-just-done-before-change.
(c-after-change): Re-set c-just-done-before-change.
(c-advise-fl-for-region): New macro.
(lazy-lock-defer-rest-after-change, lazy-lock-defer-line-after-change)
(font-lock-after-change-function, jit-lock-after-change):
Advise if needed.
* progmodes/cc-langs.el (c-modified-constant): New lang var.
(c-known-type-key): Don't make a list just to throw it away.
* progmodes/cc-engine.el (c-invalidate-state-cache, c-parse-state):
Handle the case where categories are not available.
(c-record-parse-state-state, c-replay-parse-state-state):
Handle marker values.
(c-before-change-check-<>-operators): Look for the `syntax-table'
property rather than for the corresponding `category'.
(c-looking-at-decl-block): Remove unused var
`c-disallow-comma-in-<>-arglists'.
(c-forward-<>-arglist-recur): Remove unused var
`orig-record-found-types'.
* progmodes/cc-defs.el (c-version): Bump up to 5.33.
(c-use-category): New const.
(c-next-single-property-change): New macro.
(c-region-is-active-p): Prefer region-active-p when available.
(c-search-backward-char-property): Fix old min/max typo; probably
a copy/paste error.
(c-mark-<-as-paren, c-mark->-as-paren, c-unmark-<->-as-paren):
Turn them into macros that obey c-use-category.
(c-sc-scan-lists-no-category+1+1, c-sc-scan-lists-no-category+1-1)
(c-sc-scan-lists-no-category-1+1, c-sc-scan-lists-no-category-1-1)
(c-sc-scan-lists, c-sc-parse-partial-sexp)
(c-looking-at-non-alphnumspace): New macros.
(c-sc-parse-partial-sexp-no-category): New function.
(c-emacs-features): Add `category-properties' element.
* progmodes/cc-cmds.el (c-forward-into-nomenclature)
(c-backward-into-nomenclature): Use cc-subword if subword-mode is
not available.
(c-beginning-of-defun, c-end-of-defun, c-mark-function)
(c-indent-line-or-region): Use c-region-is-active-p.
* progmodes/cc-bytecomp.el (cc-bytecomp-unbound-variables)
(cc-bytecomp-original-functions, cc-bytecomp-original-properties)
(cc-bytecomp-loaded-files): Re-set each time the file is loaded.
(cc-bytecomp-obsolete-var, cc-bytecomp-ignore-obsolete)
(cc-bytecomp-obsolete-fun): Delete unused functions.
* progmodes/cc-align.el (c-lineup-respect-col-0): New function.
2014-12-01 Stefan Monnier <monnier@iro.umontreal.ca>
......
......@@ -1229,6 +1229,18 @@ Works with: Any syntactic symbol."
(back-to-indentation)
(vector (current-column))))
(defun c-lineup-respect-col-0 (langelem)
"If the current line starts at column 0, return [0]. Otherwise return nil.
This can be used for comments (in conjunction with, say,
`c-lineup-comment'), to keep comments already at column 0
anchored there, but reindent other comments."
(save-excursion
(back-to-indentation)
(if (eq (current-column) 0)
[0]
nil)))
(defun c-snug-do-while (syntax pos)
"Dynamically calculate brace hanginess for do-while statements.
......@@ -1333,4 +1345,8 @@ For other semicolon contexts, no determination is made."
(cc-provide 'cc-align)
;;; Local Variables:
;;; indent-tabs-mode: t
;;; tab-width: 8
;;; End:
;;; cc-align.el ends here
......@@ -1146,4 +1146,8 @@ comment at the start of cc-engine.el for more info."
(cc-provide 'cc-awk) ; Changed from 'awk-mode, ACM 2002/5/21
;;; Local Variables:
;;; indent-tabs-mode: t
;;; tab-width: 8
;;; End:
;;; awk-mode.el ends here
......@@ -65,8 +65,7 @@
;; elsewhere in the load path.
;;
;; To suppress byte compiler warnings, use the macros
;; `cc-bytecomp-defun', `cc-bytecomp-defvar',
;; `cc-bytecomp-obsolete-fun', and `cc-bytecomp-obsolete-var'.
;; `cc-bytecomp-defun' and `cc-bytecomp-defvar'.
;;
;; This file is not used at all after the package has been byte
;; compiled. It is however necessary when running uncompiled.
......@@ -78,6 +77,12 @@
(defvar cc-bytecomp-original-functions nil)
(defvar cc-bytecomp-original-properties nil)
(defvar cc-bytecomp-loaded-files nil)
(setq cc-bytecomp-unbound-variables nil)
(setq cc-bytecomp-original-functions nil)
(setq cc-bytecomp-original-properties nil)
(setq cc-bytecomp-loaded-files nil)
(defvar cc-bytecomp-environment-set nil)
(defmacro cc-bytecomp-debug-msg (&rest args)
......@@ -370,33 +375,6 @@ the file. Don't use outside `eval-when-compile'."
"cc-bytecomp-put: Bound property %s for %s to %s"
,propname ,symbol ,value)))
(defmacro cc-bytecomp-obsolete-var (symbol)
"Suppress warnings that the given symbol is an obsolete variable.
Don't use within `eval-when-compile'."
`(eval-when-compile
(if (get ',symbol 'byte-obsolete-variable)
(cc-bytecomp-put ',symbol 'byte-obsolete-variable nil)
;; This avoids a superfluous compiler warning
;; about calling `get' for effect.
t)))
(defun cc-bytecomp-ignore-obsolete (form)
;; Wraps a call to `byte-compile-obsolete' that suppresses the warning.
(let ((byte-compile-warnings byte-compile-warnings))
(byte-compile-disable-warning 'obsolete)
(byte-compile-obsolete form)))
(defmacro cc-bytecomp-obsolete-fun (symbol)
"Suppress warnings that the given symbol is an obsolete function.
Don't use within `eval-when-compile'."
`(eval-when-compile
(if (eq (get ',symbol 'byte-compile) 'byte-compile-obsolete)
(cc-bytecomp-put ',symbol 'byte-compile
'cc-bytecomp-ignore-obsolete)
;; This avoids a superfluous compiler warning
;; about calling `get' for effect.
t)))
(defmacro cc-bytecomp-boundp (symbol)
"Return non-nil if the given symbol is bound as a variable outside
the compilation. This is the same as using `boundp' but additionally
......@@ -423,4 +401,8 @@ exclude any functions that have been bound during compilation with
(provide 'cc-bytecomp)
;;; Local Variables:
;;; indent-tabs-mode: t
;;; tab-width: 8
;;; End:
;;; cc-bytecomp.el ends here
......@@ -1308,16 +1308,28 @@ keyword on the line, the keyword is not inserted inside a literal, and
(defun c-forward-into-nomenclature (&optional arg)
"Compatibility alias for `c-forward-subword'."
(interactive "p")
(require 'subword)
(subword-forward arg))
(make-obsolete 'c-forward-into-nomenclature 'subword-forward "23.2")
(if (fboundp 'subword-mode)
(progn
(require 'subword)
(subword-forward arg))
(require 'cc-subword)
(c-forward-subword arg)))
(make-obsolete 'c-forward-into-nomenclature
(if (fboundp 'subword-mode) 'subword-forward 'c-forward-subword)
"23.2")
(defun c-backward-into-nomenclature (&optional arg)
"Compatibility alias for `c-backward-subword'."
(interactive "p")
(require 'subword)
(subword-backward arg))
(make-obsolete 'c-backward-into-nomenclature 'subword-backward "23.2")
(if (fboundp 'subword-mode)
(progn
(require 'subword)
(subword-backward arg))
(require 'cc-subword)
(c-backward-subword arg)))
(make-obsolete
'c-backward-into-nomenclature
(if (fboundp 'subword-mode) 'subword-backward 'c-backward-subword) "23.2")
(defun c-scope-operator ()
"Insert a double colon scope operator at point.
......@@ -1585,7 +1597,7 @@ defun."
(or (not (eq this-command 'c-beginning-of-defun))
(eq last-command 'c-beginning-of-defun)
(and transient-mark-mode mark-active)
(c-region-is-active-p)
(push-mark))
(c-save-buffer-state
......@@ -1709,7 +1721,7 @@ the open-parenthesis that starts a defun; see `beginning-of-defun'."
(or (not (eq this-command 'c-end-of-defun))
(eq last-command 'c-end-of-defun)
(and transient-mark-mode mark-active)
(c-region-is-active-p)
(push-mark))
(c-save-buffer-state
......@@ -1813,7 +1825,7 @@ with a brace block."
(looking-at c-symbol-key))
(match-string-no-properties 0))
((looking-at "DEFUN\\_>")
((looking-at "DEFUN\\s-*(") ;"DEFUN\\_>") think of XEmacs!
;; DEFUN ("file-name-directory", Ffile_name_directory, Sfile_name_directory, ...) ==> Ffile_name_directory
;; DEFUN(POSIX::STREAM-LOCK, stream lockp &key BLOCK SHARED START LENGTH) ==> POSIX::STREAM-LOCK
(down-list 1)
......@@ -2006,7 +2018,7 @@ function does not require the declaration to contain a brace block."
(eq last-command 'c-mark-function)))
(push-mark-p (and (eq this-command 'c-mark-function)
(not extend-region-p)
(not (and transient-mark-mode mark-active)))))
(not (c-region-is-active-p)))))
(if push-mark-p (push-mark (point)))
(if extend-region-p
(progn
......@@ -3343,7 +3355,7 @@ Otherwise, with a prefix argument, rigidly reindent the expression
starting on the current line.
Otherwise reindent just the current line."
(interactive
(list current-prefix-arg (use-region-p)))
(list current-prefix-arg (c-region-is-active-p)))
(if region
(c-indent-region (region-beginning) (region-end))
(c-indent-command arg)))
......@@ -4732,4 +4744,8 @@ normally bound to C-o. See `c-context-line-break' for the details."
(cc-provide 'cc-cmds)
;;; Local Variables:
;;; indent-tabs-mode: t
;;; tab-width: 8
;;; End:
;;; cc-cmds.el ends here
......@@ -64,15 +64,14 @@
(not (fboundp 'push)))
(cc-load "cc-fix")))
; (eval-after-load "font-lock" ; 2006-07-09. font-lock is now preloaded
; '
(if (and (featurep 'xemacs) ; There is now (2005/12) code in GNU Emacs CVS
; to make the call to f-l-c-k throw an error.
(not (featurep 'cc-fix)) ; only load the file once.
(let (font-lock-keywords)
(font-lock-compile-keywords '("\\<\\>"))
font-lock-keywords)) ; did the previous call foul this up?
(load "cc-fix")) ;)
(when (featurep 'xemacs) ; There is now (2005/12) code in GNU Emacs CVS
; to make the call to f-l-c-k throw an error.
(eval-after-load "font-lock"
'(if (and (not (featurep 'cc-fix)) ; only load the file once.
(let (font-lock-keywords)
(font-lock-compile-keywords '("\\<\\>"))
font-lock-keywords)) ; did the previous call foul this up?
(load "cc-fix"))))
;; The above takes care of the delayed loading, but this is necessary
;; to ensure correct byte compilation.
......@@ -94,7 +93,7 @@
;;; Variables also used at compile time.
(defconst c-version "5.32.5"
(defconst c-version "5.33"
"CC Mode version number.")
(defconst c-version-sym (intern c-version))
......@@ -336,16 +335,42 @@ to it is returned. This function does not modify the point or the mark."
(t (error "Unknown buffer position requested: %s" position))))
(point))))
(eval-and-compile
;; Constant to decide at compilation time whether to use category
;; properties. Currently (2010-03) they're available only on GNU Emacs.
(defconst c-use-category
(with-temp-buffer
(let ((parse-sexp-lookup-properties t)
(lookup-syntax-properties t))
(set-syntax-table (make-syntax-table))
(insert "<()>")
(put-text-property (point-min) (1+ (point-min))
'category 'c-<-as-paren-syntax)
(put-text-property (+ 3 (point-min)) (+ 4 (point-min))
'category 'c->-as-paren-syntax)
(goto-char (point-min))
(forward-sexp)
(= (point) (+ 4 (point-min)))))))
(defvar c-use-extents)
(defmacro c-next-single-property-change (position prop &optional object limit)
;; See the doc string for either of the defuns expanded to.
(if (and c-use-extents
(fboundp 'next-single-char-property-change))
;; XEmacs >= 2005-01-25
`(next-single-char-property-change ,position ,prop ,object ,limit)
;; Emacs and earlier XEmacs
`(next-single-property-change ,position ,prop ,object ,limit)))
(defmacro c-region-is-active-p ()
;; Return t when the region is active. The determination of region
;; activeness is different in both Emacs and XEmacs.
;; FIXME? Emacs has region-active-p since 23.1, so maybe this test
;; should be updated.
(if (cc-bytecomp-boundp 'mark-active)
;; Emacs.
'mark-active
;; XEmacs.
'(region-active-p)))
(if (cc-bytecomp-fboundp 'region-active-p)
;; XEmacs.
'(region-active-p)
;; Old Emacs.
'mark-active))
(defmacro c-set-region-active (activate)
;; Activate the region if ACTIVE is non-nil, deactivate it
......@@ -1061,8 +1086,8 @@ nil; point is then left undefined."
(while
(and
(< place ,(or limit '(point-max)))
(not (equal (get-text-property place ,property) ,value)))
(setq place (next-single-property-change
(not (equal (c-get-char-property place ,property) ,value)))
(setq place (c-next-single-property-change
place ,property nil ,(or limit '(point-max)))))
(when (< place ,(or limit '(point-max)))
(goto-char place)
......@@ -1080,10 +1105,15 @@ point is then left undefined."
(while
(and
(> place ,(or limit '(point-min)))
(not (equal (get-text-property (1- place) ,property) ,value)))
(setq place (previous-single-property-change
(not (equal (c-get-char-property (1- place) ,property) ,value)))
(setq place (,(if (and c-use-extents
(fboundp 'previous-single-char-property-change))
;; XEmacs > 2005-01-25.
'previous-single-char-property-change
;; Emacs and earlier XEmacs.
'previous-single-property-change)
place ,property nil ,(or limit '(point-min)))))
(when (> place ,(or limit '(point-max)))
(when (> place ,(or limit '(point-min)))
(goto-char place)
(search-backward-regexp ".") ; to set the match-data.
(point))))
......@@ -1100,9 +1130,9 @@ been put there by c-put-char-property. POINT remains unchanged."
(and
(< place to)
(not (equal (get-text-property place property) value)))
(setq place (next-single-property-change place property nil to)))
(setq place (c-next-single-property-change place property nil to)))
(< place to))
(setq end-place (next-single-property-change place property nil to))
(setq end-place (c-next-single-property-change place property nil to))
(remove-text-properties place end-place (cons property nil))
;; Do we have to do anything with stickiness here?
(setq place end-place))))
......@@ -1119,7 +1149,7 @@ been put there by c-put-char-property. POINT remains unchanged."
(if (equal (extent-property ext -property-) val)
(delete-extent ext)))
nil ,from ,to ,value nil -property-))
;; Gnu Emacs
;; GNU Emacs
`(c-clear-char-property-with-value-function ,from ,to ,property ,value)))
;; Macros to put overlays (Emacs) or extents (XEmacs) on buffer text.
......@@ -1203,36 +1233,43 @@ been put there by c-put-char-property. POINT remains unchanged."
(if (< (point) start)
(goto-char (point-max)))))
(defsubst c-mark-<-as-paren (pos)
(defmacro c-mark-<-as-paren (pos)
;; Mark the "<" character at POS as a template opener using the
;; `syntax-table' property via the `category' property.
;; `syntax-table' property either directly (XEmacs) or via a `category'
;; property (GNU Emacs).
;;
;; This function does a hidden buffer change. Note that we use
;; indirection through the `category' text property. This allows us to
;; toggle the property in all template brackets simultaneously and
;; cheaply. We use this, for instance, in `c-parse-state'.
(c-put-char-property pos 'category 'c-<-as-paren-syntax))
(if c-use-category
`(c-put-char-property ,pos 'category 'c-<-as-paren-syntax)
`(c-put-char-property ,pos 'syntax-table c-<-as-paren-syntax)))
(defsubst c-mark->-as-paren (pos)
(defmacro c-mark->-as-paren (pos)
;; Mark the ">" character at POS as an sexp list closer using the
;; syntax-table property.
;; `syntax-table' property either directly (XEmacs) or via a `category'
;; property (GNU Emacs).
;;
;; This function does a hidden buffer change. Note that we use
;; indirection through the `category' text property. This allows us to
;; toggle the property in all template brackets simultaneously and
;; cheaply. We use this, for instance, in `c-parse-state'.
(c-put-char-property pos 'category 'c->-as-paren-syntax))
(defsubst c-unmark-<->-as-paren (pos)
;; Unmark the "<" or "<" character at POS as an sexp list opener using
;; the syntax-table property indirectly through the `category' text
;; property.
(if c-use-category
`(c-put-char-property ,pos 'category 'c->-as-paren-syntax)
`(c-put-char-property ,pos 'syntax-table c->-as-paren-syntax)))
(defmacro c-unmark-<->-as-paren (pos)
;; Unmark the "<" or "<" character at POS as an sexp list opener using the
;; `syntax-table' property either directly or indirectly through a
;; `category' text property.
;;
;; This function does a hidden buffer change. Note that we use
;; This function does a hidden buffer change. Note that we try to use
;; indirection through the `category' text property. This allows us to
;; toggle the property in all template brackets simultaneously and
;; cheaply. We use this, for instance, in `c-parse-state'.
(c-clear-char-property pos 'category))
`(c-clear-char-property ,pos ,(if c-use-category ''category ''syntax-table)))
(defsubst c-suppress-<->-as-parens ()
;; Suppress the syntactic effect of all marked < and > as parens. Note
......@@ -1313,6 +1350,124 @@ been put there by c-put-char-property. POINT remains unchanged."
(widen)
(c-set-cpp-delimiters ,beg ,end)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; The following macros are to be used only in `c-parse-state' and its
;; subroutines. Their main purpose is to simplify the handling of C++/Java
;; template delimiters and CPP macros. In GNU Emacs, this is done slickly by
;; the judicious use of 'category properties. These don't exist in XEmacs.
;;
;; Note: in the following macros, there is no special handling for parentheses
;; inside CPP constructs. That is because CPPs are always syntactically
;; balanced, thanks to `c-neutralize-CPP-line' in cc-mode.el.
(defmacro c-sc-scan-lists-no-category+1+1 (from)
;; Do a (scan-lists FROM 1 1). Any finishing position which either (i) is
;; determined by and angle bracket; or (ii) is inside a macro whose start
;; isn't POINT-MACRO-START doesn't count as a finishing position.
`(let ((here (point))
(pos (scan-lists ,from 1 1)))
(while (eq (char-before pos) ?>)
(setq pos (scan-lists pos 1 1)))
pos))
(defmacro c-sc-scan-lists-no-category+1-1 (from)
;; Do a (scan-lists FROM 1 -1). Any finishing position which either (i) is
;; determined by an angle bracket; or (ii) is inside a macro whose start
;; isn't POINT-MACRO-START doesn't count as a finishing position.
`(let ((here (point))
(pos (scan-lists ,from 1 -1)))
(while (eq (char-before pos) ?<)
(setq pos (scan-lists pos 1 1))
(setq pos (scan-lists pos 1 -1)))
pos))
(defmacro c-sc-scan-lists-no-category-1+1 (from)
;; Do a (scan-lists FROM -1 1). Any finishing position which either (i) is
;; determined by and angle bracket; or (ii) is inside a macro whose start
;; isn't POINT-MACRO-START doesn't count as a finishing position.
`(let ((here (point))
(pos (scan-lists ,from -1 1)))
(while (eq (char-after pos) ?<)
(setq pos (scan-lists pos -1 1)))
pos))
(defmacro c-sc-scan-lists-no-category-1-1 (from)
;; Do a (scan-lists FROM -1 -1). Any finishing position which either (i) is
;; determined by and angle bracket; or (ii) is inside a macro whose start
;; isn't POINT-MACRO-START doesn't count as a finishing position.
`(let ((here (point))
(pos (scan-lists ,from -1 -1)))
(while (eq (char-after pos) ?>)
(setq pos (scan-lists pos -1 1))
(setq pos (scan-lists pos -1 -1)))
pos))
(defmacro c-sc-scan-lists (from count depth)
(if c-use-category
`(scan-lists ,from ,count ,depth)
(cond
((and (eq count 1) (eq depth 1))
`(c-sc-scan-lists-no-category+1+1 ,from))
((and (eq count 1) (eq depth -1))
`(c-sc-scan-lists-no-category+1-1 ,from))
((and (eq count -1) (eq depth 1))
`(c-sc-scan-lists-no-category-1+1 ,from))
((and (eq count -1) (eq depth -1))
`(c-sc-scan-lists-no-category-1-1 ,from))
(t (error "Invalid parameter(s) to c-sc-scan-lists")))))
(defun c-sc-parse-partial-sexp-no-category (from to targetdepth stopbefore
oldstate)
;; Do a parse-partial-sexp using the supplied arguments, disregarding
;; template/generic delimiters < > and disregarding macros other than the
;; one at POINT-MACRO-START.
;;
;; NOTE that STOPBEFORE must be nil. TARGETDEPTH should be one less than
;; the depth in OLDSTATE. This function is thus a SPECIAL PURPOSE variation
;; on parse-partial-sexp, designed for calling from
;; `c-remove-stale-state-cache'.
;;
;; Any finishing position which is determined by an angle bracket delimiter
;; doesn't count as a finishing position.
;;
;; Note there is no special handling of CPP constructs here, since these are
;; always syntactically balanced (thanks to `c-neutralize-CPP-line').
(let ((state
(parse-partial-sexp from to targetdepth stopbefore oldstate)))
(while
(and (< (point) to)
;; We must have hit targetdepth.
(or (eq (char-before) ?<)
(eq (char-before) ?>)))
(setcar state
(if (memq (char-before) '(?> ?\) ?\} ?\]))
(1+ (car state))
(1- (car state))))
(setq state
(parse-partial-sexp (point) to targetdepth stopbefore oldstate)))
state))
(defmacro c-sc-parse-partial-sexp (from to &optional targetdepth stopbefore
oldstate)
(if c-use-category
`(parse-partial-sexp ,from ,to ,targetdepth ,stopbefore ,oldstate)
`(c-sc-parse-partial-sexp-no-category ,from ,to ,targetdepth ,stopbefore
,oldstate)))
(defvar c-emacs-features)
(defmacro c-looking-at-non-alphnumspace ()
"Are we looking at a character which isn't alphanumeric or space?"
(if (memq 'gen-comment-delim c-emacs-features)
`(looking-at
"\\([;#]\\|\\'\\|\\s(\\|\\s)\\|\\s\"\\|\\s\\\\|\\s$\\|\\s<\\|\\s>\\|\\s!\\)")
`(or (looking-at
"\\([;#]\\|\\'\\|\\s(\\|\\s)\\|\\s\"\\|\\s\\\\|\\s$\\|\\s<\\|\\s>\\)"
(let ((prop (c-get-char-property (point) 'syntax-table)))
(eq prop '(14))))))) ; '(14) is generic comment delimiter.
(defsubst c-intersect-lists (list alist)
;; return the element of ALIST that matches the first element found
;; in LIST. Uses assq.
......@@ -1614,6 +1769,9 @@ non-nil, a caret is prepended to invert the set."
(not (end-of-defun))))
(setq list (cons 'argumentative-bod-function list))))
;; Record whether the `category' text property works.
(if c-use-category (setq list (cons 'category-properties list)))
(let ((buf (generate-new-buffer " test"))
parse-sexp-lookup-properties
parse-sexp-ignore-comments
......@@ -1719,6 +1877,8 @@ might be present:
in the buffer with the 'syntax-table property. It's
always set - CC Mode no longer works in emacsen without
this feature.
'category-properties Syntax routines can add a level of indirection to text
properties using the 'category property.
'gen-comment-delim Generic comment delimiters work
(i.e. the syntax class `!').
'gen-string-delim Generic string delimiters work
......@@ -2277,4 +2437,8 @@ fallback definition for all modes, to break the cycle).")
(cc-provide 'cc-defs)
;;; Local Variables:
;;; indent-tabs-mode: t
;;; tab-width: 8
;;; End:
;;; cc-defs.el ends here
This diff is collapsed.
......@@ -266,7 +266,7 @@
;; This function might do hidden buffer changes.
(when (c-got-face-at (point) c-literal-faces)
(while (progn
(goto-char (next-single-property-change
(goto-char (c-next-single-property-change
(point) 'face nil limit))
(and (< (point) limit)
(c-got-face-at (point) c-literal-faces))))
......@@ -559,8 +559,7 @@ stuff. Used on level 1 and higher."
(progn
(c-mark-<-as-paren beg)
(c-mark->-as-paren end))
;; (c-clear-char-property beg 'syntax-table)
(c-clear-char-property beg 'category)))
(c-unmark-<->-as-paren beg)))
nil)))))))
;; #define.
......@@ -2702,4 +2701,8 @@ need for `pike-font-lock-extra-types'.")
;; 2006-07-10: awk-font-lock-keywords has been moved back to cc-awk.el.
(cc-provide 'cc-fonts)