*** semantic-edit.el.ori	Sat Sep  7 08:35:31 2002
--- semantic-edit.el	Sat Sep  7 14:41:10 2002
***************
*** 245,251 ****
  		   start end))))
      ;; A leaf is always first in this list
      (if (and tokens
! 	     (< (semantic-token-start (car tokens)) start)
  	     (> (semantic-token-end (car tokens)) end))
  	;; Ok, we have a match.  If this token has children,
  	;; we have to do more tests.
--- 245,251 ----
  		   start end))))
      ;; A leaf is always first in this list
      (if (and tokens
! 	     (<= (semantic-token-start (car tokens)) start)
  	     (> (semantic-token-end (car tokens)) end))
  	;; Ok, we have a match.  If this token has children,
  	;; we have to do more tests.
***************
*** 530,558 ****
                            parent-token
                            (car (semantic-find-nonterminal-by-overlay
                                  parse-start)))
!                     (cond ((> (semantic-token-start (car cache-list))
!                               (semantic-overlay-end (car changes)))
!                            ;; A change at the beginning of the
!                            ;; buffer.
!                            (setq parse-start
!                                  ;; Don't worry about parents since
!                                  ;; there there would be an exact
!                                  ;; match in the token list otherwise
!                                  ;; and the routine would fail.
!                                  (point-min)
!                                  parse-end
!                                  (semantic-token-start (car cache-list))))
!                           ((not (car (cdr cache-list)))
!                            ;; A change at the end of the buffer.
!                            (setq parse-start (semantic-token-end
!                                               (car cache-list))
!                                  parse-end (point-max)))
!                           (t
!                            (setq parse-start
!                                  (semantic-token-end (car cache-list))
!                                  parse-end
!                                  (semantic-token-start (car (cdr cache-list)))
!                                  ))))
  
  ;;;; Did the change completely overlap some number of tokens?
                     ((setq tmp (semantic-edits-change-over-tokens
--- 530,571 ----
                            parent-token
                            (car (semantic-find-nonterminal-by-overlay
                                  parse-start)))
!                     (cond
!                       ;; A change at the beginning of the buffer.
!                      ((> (semantic-token-start (car cache-list))
!                          (semantic-overlay-end (car changes)))
!                       (setq parse-start
!                             ;; Don't worry about parents since
!                             ;; there there would be an exact
!                             ;; match in the token list otherwise
!                             ;; and the routine would fail.
!                             (point-min)
!                             parse-end
!                             (semantic-token-start (car cache-list)))
!                       )
!                      ;; A change stuck on the first surrounding token.
!                      ((= (semantic-token-end (car cache-list))
!                          (semantic-overlay-start (car changes)))
!                       ;; Reparse that first token.
!                       (setq parse-start
!                             (semantic-token-start (car cache-list))
!                             parse-end
!                             (semantic-overlay-end (car changes))
!                             tokens
!                             (list (car cache-list)))
!                       )
!                      ;; A change at the end of the buffer.
!                      ((not (car (cdr cache-list)))
!                       (setq parse-start (semantic-token-end
!                                          (car cache-list))
!                             parse-end (point-max))
!                       )
!                      (t
!                       (setq parse-start
!                             (semantic-token-end (car cache-list))
!                             parse-end
!                             (semantic-token-start (car (cdr cache-list)))
!                             ))))
  
  ;;;; Did the change completely overlap some number of tokens?
                     ((setq tmp (semantic-edits-change-over-tokens
***************
*** 614,621 ****
              ;; some parent.  They should all have the same start symbol
              ;; since that is how the multi-token parser works.  Grab
              ;; the reparse symbol from the first of the returned tokens.
!             (setq reparse-symbol (semantic-token-get
!                                   (car tokens) 'reparse-symbol))
              ;; Find a parent if not provided.
              (and (not parent-token) tokens
                   (setq parent-token
--- 627,635 ----
              ;; some parent.  They should all have the same start symbol
              ;; since that is how the multi-token parser works.  Grab
              ;; the reparse symbol from the first of the returned tokens.
!             (setq reparse-symbol
!                   (semantic-token-get (car (or tokens cache-list))
!                                       'reparse-symbol))
              ;; Find a parent if not provided.
              (and (not parent-token) tokens
                   (setq parent-token
*** semantic-grammar.el.ori	Thu Sep  5 15:27:39 2002
--- semantic-grammar.el	Sat Sep  7 13:20:27 2002
***************
*** 541,546 ****
--- 541,559 ----
     (nonterminal-children      . semantic-grammar-nonterminal-children)
     )
   t 'semantic-grammar-mode)
+ 
+ (defun semantic-grammar-edits-new-change-hook-fcn (overlay)
+   "Function set into `semantic-edits-new-change-hook'.
+ Argument OVERLAY is the overlay created to mark the change.
+ When OVERLAY marks a change in the scope of a nonterminal token extend
+ the change bounds to encompass the whole nonterminal token."
+   (let ((outer (car (semantic-find-nonterminal-by-overlay-in-region
+                      (semantic-edits-os overlay)
+                      (semantic-edits-oe overlay)))))
+     (if (eq 'nonterminal (semantic-token-token outer))
+         (semantic-overlay-move overlay
+                                (semantic-token-start outer)
+                                (semantic-token-end outer)))))
  
  ;;;; 
  ;;;; Semantic action expansion
***************
*** 1165,1170 ****
--- 1178,1187 ----
            ((?_ . "w") (?- . "w"))))
    ;; Set up Semantic environment
    (semantic-grammar-setup-semantic)
+   (semantic-make-local-hook 'semantic-edits-new-change-hooks)
+   (add-hook 'semantic-edits-new-change-hooks
+             'semantic-grammar-edits-new-change-hook-fcn
+             nil t)
    (run-hooks 'semantic-grammar-mode-hook))
  
  ;;;;
