]> code.delx.au - gnu-emacs/blobdiff - lisp/cedet/semantic/edit.el
Update copyright year to 2015
[gnu-emacs] / lisp / cedet / semantic / edit.el
index 3e7ccd387d8c1a5bb2478ea96b7b6c4794732f6e..f207fced2916d339a649c5a4ca77151d52fc66db 100644 (file)
@@ -1,7 +1,6 @@
 ;;; semantic/edit.el --- Edit Management for Semantic
 
-;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-;;   2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2015 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <zappo@gnu.org>
 
@@ -73,7 +72,9 @@ updated in the current buffer.
 
 For language specific hooks, make sure you define this as a local hook.")
 
-(defvar semantic-change-hooks
+(define-obsolete-variable-alias 'semantic-change-hooks
+  'semantic-change-functions "24.3")
+(defvar semantic-change-functions
   '(semantic-edits-change-function-handle-changes)
   "Abnormal hook run when semantic detects a change in a buffer.
 Each hook function must take three arguments, identical to the
@@ -90,11 +91,15 @@ If the hook returns non-nil, then declare that a reparse is needed.
 For language specific hooks, make sure you define this as a local hook.
 Not used yet; part of the next generation reparse mechanism.")
 
-(defvar semantic-edits-new-change-hooks nil
+(define-obsolete-variable-alias 'semantic-edits-new-change-hooks
+  'semantic-edits-new-change-functions "24.3")
+(defvar semantic-edits-new-change-functions nil
   "Abnormal hook run when a new change is found.
 Functions must take one argument representing an overlay on that change.")
 
-(defvar semantic-edits-delete-change-hooks nil
+(define-obsolete-variable-alias 'semantic-edits-delete-change-hooks
+  'semantic-edits-delete-change-functions "24.3")
+(defvar semantic-edits-delete-change-functions nil
   "Abnormal hook run before a change overlay is deleted.
 Deleted changes occur when multiple changes are merged.
 Functions must take one argument representing an overlay being deleted.")
@@ -105,7 +110,9 @@ Changes move when a new change overlaps an old change.  The old change
 will be moved.
 Functions must take one argument representing an overlay being moved.")
 
-(defvar semantic-edits-reparse-change-hooks nil
+(define-obsolete-variable-alias 'semantic-edits-reparse-change-hooks
+  'semantic-edits-reparse-change-functions "24.3")
+(defvar semantic-edits-reparse-change-functions nil
   "Abnormal hook run after a change results in a reparse.
 Functions are called before the overlay is deleted, and after the
 incremental reparse.")
@@ -134,8 +141,9 @@ Argument START, END, and LENGTH specify the bounds of the change."
    (setq semantic-unmatched-syntax-cache-check t)
    (let ((inhibit-point-motion-hooks t)
         )
-     (run-hook-with-args 'semantic-change-hooks start end length)
-     ))
+     (save-match-data
+       (run-hook-with-args 'semantic-change-functions start end length)
+       )))
 
 (defun semantic-changes-in-region (start end &optional buffer)
   "Find change overlays which exist in whole or in part between START and END.
@@ -169,7 +177,7 @@ Argument START, END, and LENGTH specify the bounds of the change."
          ;; function will be removed from the list of active change
          ;; functions.
          (condition-case nil
-             (run-hook-with-args 'semantic-edits-new-change-hooks o)
+             (run-hook-with-args 'semantic-edits-new-change-functions o)
            (error nil)))
       (let ((tmp changes-in-change))
        ;; Find greatest bounds of all changes
@@ -189,7 +197,7 @@ Argument START, END, and LENGTH specify the bounds of the change."
        ;; Delete other changes.  They are now all bound here.
        (while changes-in-change
          (condition-case nil
-             (run-hook-with-args 'semantic-edits-delete-change-hooks
+             (run-hook-with-args 'semantic-edits-delete-change-functions
                                  (car changes-in-change))
            (error nil))
          (semantic-overlay-delete (car changes-in-change))
@@ -199,7 +207,7 @@ Argument START, END, and LENGTH specify the bounds of the change."
 (defsubst semantic-edits-flush-change (change)
   "Flush the CHANGE overlay."
   (condition-case nil
-      (run-hook-with-args 'semantic-edits-delete-change-hooks
+      (run-hook-with-args 'semantic-edits-delete-change-functions
                          change)
     (error nil))
   (semantic-overlay-delete change))
@@ -317,7 +325,7 @@ See `semantic-edits-change-leaf-tag' for details on parents."
                  (setq list-to-search nil)))
        ;; Search list is nil.
        ))
-    ;; If we have a search list, lets go.  Otherwise nothing.
+    ;; If we have a search list, let's go.  Otherwise nothing.
     (while (and list-to-search (not found))
       (if (cdr list-to-search)
           ;; We end when the start of the CDR is after the end of our
@@ -393,7 +401,7 @@ See `semantic-edits-change-leaf-tag' for details on parents."
              ;; There are no tags left, and all tags originally
              ;; found are encompassed by the change.  Setup our list
              ;; from the cache
-             (setq list-to-search semantic--buffer-cache);; We have a tag ouside the list.  Check for
+             (setq list-to-search semantic--buffer-cache);; We have a tag outside the list.  Check for
            ;; We know we have a parent because it would
            ;; completely cover the change.  A tag can only
            ;; do that if it is a parent after we get here.
@@ -427,8 +435,8 @@ See `semantic-edits-change-leaf-tag' for details on parents."
            ;; confirmed as the lineage of `overlapped-tags'
            ;; which must have a value by now.
 
-           ;; Loop over the search list to find the preceeding CDR.
-           ;; Fortunatly, (car overlapped-tags) happens to be
+           ;; Loop over the search list to find the preceding CDR.
+           ;; Fortunately, (car overlapped-tags) happens to be
            ;; the first tag positionally.
            (let ((tokstart (semantic-tag-start (car overlapped-tags))))
              (while (and list-to-search
@@ -471,6 +479,7 @@ a 'semantic-parse-changes-failed exception with value t."
             (buffer-name (current-buffer))))
   (run-hooks 'semantic-edits-incremental-reparse-failed-hook))
 
+;;;###autoload
 (defun semantic-edits-incremental-parser ()
   "Incrementally reparse the current buffer.
 Incremental parser allows semantic to only reparse those sections of
@@ -538,7 +547,7 @@ This function is for internal use by `semantic-edits-incremental-parser'."
       ;; We want to take some set of changes, and group them
       ;; together into a small change group. One change forces
       ;; a reparse of a larger region (the size of some set of
-      ;; tags it encompases.)  It may contain several tags.
+      ;; tags it encompasses.)  It may contain several tags.
       ;; That region may have other changes in it (several small
       ;; changes in one function, for example.)
       ;; Optimize for the simple cases here, but try to handle
@@ -550,7 +559,7 @@ This function is for internal use by `semantic-edits-incremental-parser'."
                       ;; is not the first change for this
                       ;; iteration, and it starts before the end
                       ;; of current parse region, then it is
-                      ;; encompased within the bounds of tags
+                      ;; encompassed within the bounds of tags
                       ;; modified by the previous iteration's
                       ;; change.
                       (< (semantic-overlay-start (car changes))
@@ -596,7 +605,7 @@ This function is for internal use by `semantic-edits-incremental-parser'."
               ;; Feb 06 -
               ;; IDed when the first cache-list tag is after
               ;; our change, meaning there is nothing before
-              ;; the chnge.
+              ;; the change.
                ((> (semantic-tag-start (car cache-list))
                    (semantic-overlay-end (car changes)))
                (setq last-cond "Beginning of buffer")
@@ -650,7 +659,7 @@ This function is for internal use by `semantic-edits-incremental-parser'."
                     parent-tag (aref tmp 2))
               ;; We can calculate parse begin/end by checking
               ;; out what is in TAGS.  The one near start is
-              ;; always first.  Make sure the reprase includes
+              ;; always first.  Make sure the reparse includes
               ;; the `whitespace' around the snarfed tags.
               ;; Since cache-list is positioned properly, use it
               ;; to find that boundary.
@@ -708,7 +717,7 @@ This function is for internal use by `semantic-edits-incremental-parser'."
       ;; since that is how the multi-tag parser works.  Grab
       ;; the reparse symbol from the first of the returned tags.
       ;;
-      ;; Feb '06 - If repase-symbol is nil, then they are top level
+      ;; Feb '06 - If reparse-symbol is nil, then they are top level
       ;;     tags.  (I'm guessing.)  Is this right?
       (setq reparse-symbol
             (semantic--tag-get-property (car (or tags cache-list))
@@ -860,7 +869,7 @@ pre-positioned to a convenient location."
          (setq cacheend chil)
          (while (and cacheend (not (eq last (car cacheend))))
            (setq cacheend (cdr cacheend)))
-         ;; The splicable part is after cacheend.. so move cacheend
+         ;; The spliceable part is after cacheend.. so move cacheend
          ;; one more tag.
          (setq cacheend (cdr cacheend))
          ;; Splice the found end tag into the cons cell
@@ -873,9 +882,10 @@ pre-positioned to a convenient location."
            ;; reparse
            (semantic-parse-changes-failed "Splice-remove failed.  Empty buffer?")
            ))
-      (message "To Remove Middle Tag: (%s)"
-              (semantic-format-tag-name first)))
-    ;; Find in the cache the preceeding tag
+      (when semantic-edits-verbose-flag
+       (message "To Remove Middle Tag: (%s)"
+                (semantic-format-tag-name first))))
+    ;; Find in the cache the preceding tag
     (while (and cachestart (not (eq first (car (cdr cachestart)))))
       (setq cachestart (cdr cachestart)))
     ;; Find the last tag
@@ -897,11 +907,11 @@ pre-positioned to a convenient location."
 
 (defun semantic-edits-splice-insert (newtags parent cachelist)
   "Insert NEWTAGS into PARENT using CACHELIST.
-PARENT could be nil, in which case CACHLIST is the buffer cache
+PARENT could be nil, in which case CACHELIST is the buffer cache
 which must be updated.
 CACHELIST must be searched to find where NEWTAGS are to be inserted.
 The positions of NEWTAGS must be synchronized with those in
-CACHELIST for this to work.  Some routines pre-position CACHLIST at a
+CACHELIST for this to work.  Some routines pre-position CACHELIST at a
 convenient location, so use that."
   (let* ((start (semantic-tag-start (car newtags)))
         (newtagendcell (nthcdr (1- (length newtags)) newtags))