Cleanup uses of "-hooks".
[bpt/emacs.git] / lisp / cedet / semantic / edit.el
index ab9b887..5b39dec 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 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2012 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <zappo@gnu.org>
 
@@ -54,7 +53,7 @@
 ;;    syntax instead.
 ;;
 ;; 2. Incremental parsing while a new function is being typed in
-;;    somtimes gets a chance only when lists are incomplete,
+;;    sometimes gets a chance only when lists are incomplete,
 ;;    preventing correct context identification.
 
 ;;
@@ -73,29 +72,34 @@ updated in the current buffer.
 
 For language specific hooks, make sure you define this as a local hook.")
 
-(defvar semantic-change-hooks nil
+(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
 common hook `after-change-functions'.")
 
 (defvar semantic-reparse-needed-change-hook nil
   "Hooks run when a user edit is detected as needing a reparse.
-For language specific hooks, make sure you define this as a local
-hook.
-Not used yet; part of the next generation reparse mechanism")
+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-no-reparse-needed-change-hook nil
   "Hooks run when a user edit is detected as not needing a reparse.
 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.
+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.")
@@ -106,20 +110,22 @@ 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.")
 
 (defvar semantic-edits-incremental-reparse-failed-hook nil
   "Hook run after the incremental parser fails.
-When this happens, the buffer is marked as needing a full reprase.")
+When this happens, the buffer is marked as needing a full reparse.")
 
 (semantic-varalias-obsolete 'semantic-edits-incremental-reparse-failed-hooks
-                           'semantic-edits-incremental-reparse-failed-hook)
+                           'semantic-edits-incremental-reparse-failed-hook "23.2")
 
 (defcustom semantic-edits-verbose-flag nil
-  "Non-nil means the incremental perser is verbose.
+  "Non-nil means the incremental parser is verbose.
 If nil, errors are still displayed, but informative messages are not."
   :group 'semantic
   :type 'boolean)
@@ -135,7 +141,7 @@ 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)
+     (run-hook-with-args 'semantic-change-functions start end length)
      ))
 
 (defun semantic-changes-in-region (start end &optional buffer)
@@ -170,7 +176,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
@@ -190,7 +196,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))
@@ -200,7 +206,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))
@@ -306,7 +312,7 @@ See `semantic-edits-change-leaf-tag' for details on parents."
                    (semantic-tag-components (car tags)))
              ;; Ok, we are completely encompassed within the first tag
              ;; entry, AND that tag has children.  This means that change
-             ;; occured outside of all children, but inside some tag
+             ;; occurred outside of all children, but inside some tag
              ;; with children.
              (if (or (not (semantic-tag-with-position-p (car list-to-search)))
                      (> start (semantic-tag-end
@@ -318,7 +324,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
@@ -394,7 +400,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.
@@ -428,8 +434,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
@@ -472,6 +478,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
@@ -498,7 +505,7 @@ the semantic cache to see what needs to be changed."
     changed-tags))
 
 (defmacro semantic-edits-assert-valid-region ()
-  "Asert that parse-start and parse-end are sorted correctly."
+  "Assert that parse-start and parse-end are sorted correctly."
 ;;;  (if (> parse-start parse-end)
 ;;;      (error "Bug is %s !> %d!  Buff min/max = [ %d %d ]"
 ;;;         parse-start parse-end
@@ -539,7 +546,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
@@ -551,7 +558,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))
@@ -597,7 +604,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")
@@ -651,7 +658,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.
@@ -709,7 +716,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))
@@ -750,7 +757,7 @@ This function is for internal use by `semantic-edits-incremental-parser'."
 
 ;;;; Whitespace change
        ((and (not tags) (not newf-tags))
-        ;; A change that occured outside of any existing tags
+        ;; A change that occurred outside of any existing tags
         ;; and there are no new tags to replace it.
        (when semantic-edits-verbose-flag
          (message "White space changes"))
@@ -759,7 +766,7 @@ This function is for internal use by `semantic-edits-incremental-parser'."
 
 ;;;; New tags in old whitespace area.
        ((and (not tags) newf-tags)
-        ;; A change occured outside existing tags which added
+        ;; A change occurred outside existing tags which added
         ;; a new tag.  We need to splice these tags back
         ;; into the cache at the right place.
         (semantic-edits-splice-insert newf-tags parent-tag cache-list)
@@ -774,7 +781,7 @@ This function is for internal use by `semantic-edits-incremental-parser'."
 
 ;;;; Old tags removed
        ((and tags (not newf-tags))
-        ;; A change occured where pre-existing tags were
+        ;; A change occurred where pre-existing tags were
         ;; deleted!  Remove the tag from the cache.
         (semantic-edits-splice-remove tags parent-tag cache-list)
 
@@ -837,7 +844,7 @@ This function is for internal use by `semantic-edits-incremental-parser'."
 ;; list can be fiddled.
 (defun semantic-edits-splice-remove (oldtags parent cachelist)
   "Remove OLDTAGS from PARENT's CACHELIST.
-OLDTAGS are tags in the currenet buffer, preferably linked
+OLDTAGS are tags in the current buffer, preferably linked
 together also in CACHELIST.
 PARENT is the parent tag containing OLDTAGS.
 CACHELIST should be the children from PARENT, but may be
@@ -861,7 +868,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
@@ -876,7 +883,7 @@ pre-positioned to a convenient location."
            ))
       (message "To Remove Middle Tag: (%s)"
               (semantic-format-tag-name first)))
-    ;; Find in the cache the preceeding tag
+    ;; Find in the cache the preceding tag
     (while (and cachestart (not (eq first (car (cdr cachestart)))))
       (setq cachestart (cdr cachestart)))
     ;; Find the last tag
@@ -930,7 +937,7 @@ convenient location, so use that."
 
 (defun semantic-edits-splice-replace (oldtag newtag)
   "Replace OLDTAG with NEWTAG in the current cache.
-Do this by recycling OLDTAG's first CONS cell.  This effectivly
+Do this by recycling OLDTAG's first CONS cell.  This effectively
 causes the new tag to completely replace the old one.
 Make sure that all information in the overlay is transferred.
 It is presumed that OLDTAG and NEWTAG are both cooked.
@@ -956,11 +963,7 @@ lost if not transferred into NEWTAG."
     ;; to point at the updated state of the world.
     (semantic-overlay-put o 'semantic oldtag)
     ))
-\f
-;;; Setup incremental parser
-;;
-(add-hook 'semantic-change-hooks
-          #'semantic-edits-change-function-handle-changes)
+
 (add-hook 'semantic-before-toplevel-cache-flush-hook
           #'semantic-edits-flush-changes)
 
@@ -968,7 +971,6 @@ lost if not transferred into NEWTAG."
 
 ;; Local variables:
 ;; generated-autoload-file: "loaddefs.el"
-;; generated-autoload-feature: semantic/loaddefs
 ;; generated-autoload-load-name: "semantic/edit"
 ;; End: