[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/progmodes/cc-engine.el,v
From: |
Alan Mackenzie |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/progmodes/cc-engine.el,v |
Date: |
Thu, 08 Mar 2007 21:52:30 +0000 |
CVSROOT: /cvsroot/emacs
Module name: emacs
Changes by: Alan Mackenzie <acmacm> 07/03/08 21:52:30
Index: cc-engine.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-engine.el,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -b -r1.53 -r1.54
--- cc-engine.el 2 Feb 2007 23:06:41 -0000 1.53
+++ cc-engine.el 8 Mar 2007 21:52:30 -0000 1.54
@@ -1912,6 +1912,26 @@
)))
+;; Other whitespace tools
+(defun c-partial-ws-p (beg end)
+ ;; Is the region (beg end) WS, and is there WS (or BOB/EOB) next to the
+ ;; region? This is a "heuristic" function. .....
+ ;;
+ ;; The motivation for the second bit is to check whether the removal of this
+ ;; space is to check whether removing this region would coalesce two
+ ;; symbols.
+ ;;
+ ;; FIXME!!! This function doesn't check virtual semicolons in any way. Be
+ ;; careful about using this function for, e.g. AWK. (2007/3/7)
+ (save-excursion
+ (let ((end+1 (min (1+ end) (point-max))))
+ (or (progn (goto-char (max (point-min) (1- beg)))
+ (c-skip-ws-forward end)
+ (eq (point) end))
+ (progn (goto-char beg)
+ (c-skip-ws-forward end+1)
+ (eq (point) end+1))))))
+
;; A system for finding noteworthy parens before the point.
(defvar c-state-cache nil)
@@ -2491,12 +2511,13 @@
;; Move to the beginning of the current token. Do not move if not
;; in the middle of one. BACK-LIMIT may be used to bound the
;; backward search; if given it's assumed to be at the boundary
- ;; between two tokens.
+ ;; between two tokens. Return non-nil if the point is move, nil
+ ;; otherwise.
;;
;; This function might do hidden buffer changes.
+ (let ((start (point)))
(if (looking-at "\\w\\|\\s_")
(skip-syntax-backward "w_" back-limit)
- (let ((start (point)))
(when (< (skip-syntax-backward ".()" back-limit) 0)
(while (let ((pos (or (and (looking-at c-nonsymbol-token-regexp)
(match-end 0))
@@ -2507,8 +2528,8 @@
;; some earlier incorrect token.
(1+ (point)))))
(if (<= pos start)
- (goto-char pos))
- (< pos start)))))))
+ (goto-char pos))))))
+ (< (point) start)))
(defun c-end-of-current-token (&optional back-limit)
;; Move to the end of the current token. Do not move if not in the
@@ -3957,6 +3978,9 @@
;; file, and we only use this as a last resort in ambiguous cases (see
;; `c-forward-decl-or-cast-1').
;;
+;; Not every type need be in this cache. However, things which have
+;; ceased to be types must be removed from it.
+;;
;; Template types in C++ are added here too but with the template
;; arglist replaced with "<>" in references or "<" for the one in the
;; primary type. E.g. the type "Foo<A,B>::Bar<C>" is stored as
@@ -3990,6 +4014,10 @@
(unintern (substring type 0 -1) c-found-types)
(intern type c-found-types))))
+(defun c-unfind-type (name)
+ ;; Remove the "NAME" from c-found-types, if present.
+ (unintern name c-found-types))
+
(defsubst c-check-type (from to)
;; Return non-nil if the given region contains a type in
;; `c-found-types'.
@@ -4008,6 +4036,48 @@
c-found-types)
(sort type-list 'string-lessp)))
+(defun c-trim-found-types (beg end old-len)
+ ;; An after change function which, in conjunction with the info in
+ ;; c-maybe-stale-found-type (set in c-before-change), removes a type
+ ;; from `c-found-types', should this type have become stale. For
+ ;; example, this happens to "foo" when "foo \n bar();" becomes
+ ;; "foo(); \n bar();". Such stale types, if not removed, foul up
+ ;; the fontification.
+ ;;
+ ;; Have we, perhaps, added non-ws characters to the front/back of a found
+ ;; type?
+ (when (> end beg)
+ (save-excursion
+ (when (< end (point-max))
+ (goto-char end)
+ (if (and (c-beginning-of-current-token) ; only moves when we started in
the middle
+ (progn (goto-char end)
+ (c-end-of-current-token)))
+ (c-unfind-type (buffer-substring-no-properties
+ end (point)))))
+ (when (> beg (point-min))
+ (goto-char beg)
+ (if (and (c-end-of-current-token) ; only moves when we started in the
middle
+ (progn (goto-char beg)
+ (c-beginning-of-current-token)))
+ (c-unfind-type (buffer-substring-no-properties
+ (point) beg))))))
+
+ (if c-maybe-stale-found-type ; e.g. (c-decl-id-start "foo" 97 107 " (* ooka)
" "o")
+ (cond
+ ;; Changing the amount of (already existing) whitespace - don't do
anything.
+ ((and (c-partial-ws-p beg end)
+ (or (= beg end) ; removal of WS
+ ; (string-match "\\s *\\'" (nth 5 c-maybe-stale-found-type))
+ (string-match "^[ \t\n\r\f\v]*$" (nth 5
c-maybe-stale-found-type)))))
+
+ ;; The syntactic relationship which defined a "found type" has been
+ ;; destroyed.
+ ((eq (car c-maybe-stale-found-type) 'c-decl-id-start)
+ (c-unfind-type (cadr c-maybe-stale-found-type)))
+;; ((eq (car c-maybe-stale-found-type) 'c-decl-type-start) FIXME!!!
+ )))
+
;; Handling of small scale constructs like types and names.
- [Emacs-diffs] Changes to emacs/lisp/progmodes/cc-engine.el,v,
Alan Mackenzie <=