Synch to Eric M. Ludlam's upstream CEDET repository.
authorChong Yidong <cyd@stupidchicken.com>
Sat, 19 Sep 2009 17:25:30 +0000 (17:25 +0000)
committerChong Yidong <cyd@stupidchicken.com>
Sat, 19 Sep 2009 17:25:30 +0000 (17:25 +0000)
* cedet/semantic/db.el (semanticdb-get-buffer): Wrap find-file in
save-match-data.

* cedet/semantic/db-global.el (semanticdb-test-gnu-global): Wrap
find-file in save-match-data.

* cedet/semantic/util.el (semantic-file-tag-table)
(semantic-recursive-find-nonterminal-by-name): Wrap find-file in
save-match-data.

* cedet/semantic/tag.el (semantic-tag-buffer): Wrap find-file in
save-match-data.

* cedet/semantic/tag-file.el (semantic-go-to-tag): Wrap the "goto"
part with save-match-data.

* cedet/semantic/lex-spp.el (semantic-lex-spp-lex-text-string):
Save match data around calling the major mode to enable.

* cedet/semantic/format.el (semantic-format-tag-short-doc-default):
Wrap find-file in save-match-data.

* cedet/semantic/fw.el (semantic-find-file-noselect): Wrap
find-file in save-match-data

lisp/ChangeLog
lisp/cedet/semantic/db-global.el
lisp/cedet/semantic/db.el
lisp/cedet/semantic/format.el
lisp/cedet/semantic/fw.el
lisp/cedet/semantic/lex-spp.el
lisp/cedet/semantic/tag-file.el
lisp/cedet/semantic/tag.el
lisp/cedet/semantic/util.el

index a86f1b7..d50154a 100644 (file)
@@ -1,3 +1,32 @@
+2009-09-19  Chong Yidong  <cyd@stupidchicken.com>
+
+       Synch to Eric Ludlam's upstream CEDET repository.
+
+       * cedet/semantic/db.el (semanticdb-get-buffer): Wrap find-file in
+       save-match-data.
+
+       * cedet/semantic/db-global.el (semanticdb-test-gnu-global): Wrap
+       find-file in save-match-data.
+
+       * cedet/semantic/util.el (semantic-file-tag-table)
+       (semantic-recursive-find-nonterminal-by-name): Wrap find-file in
+       save-match-data.
+
+       * cedet/semantic/tag.el (semantic-tag-buffer): Wrap find-file in
+       save-match-data.
+
+       * cedet/semantic/tag-file.el (semantic-go-to-tag): Wrap the "goto"
+       part with save-match-data.
+
+       * cedet/semantic/lex-spp.el (semantic-lex-spp-lex-text-string):
+       Save match data around calling the major mode to enable.
+
+       * cedet/semantic/format.el (semantic-format-tag-short-doc-default):
+       Wrap find-file in save-match-data.
+
+       * cedet/semantic/fw.el (semantic-find-file-noselect): Wrap
+       find-file in save-match-data
+
 2009-09-13  Chong Yidong  <cyd@stupidchicken.com>
 
        Synch to Eric Ludlam's upstream CEDET repository.
index cf91a04..1b3be12 100644 (file)
@@ -231,13 +231,15 @@ If optional arg STANDARDFILE is non nil, use a standard file w/ global enabled."
   (require 'data-debug)
   (save-excursion
     (when standardfile
-      (set-buffer (find-file-noselect semanticdb-test-gnu-global-startfile)))
+      (save-match-data
+       (set-buffer (find-file-noselect semanticdb-test-gnu-global-startfile))))
 
     (condition-case err
        (semanticdb-enable-gnu-global-in-buffer)
       (error (if standardfile
                 (error err)
-              (set-buffer (find-file-noselect semanticdb-test-gnu-global-startfile))
+              (save-match-data
+                (set-buffer (find-file-noselect semanticdb-test-gnu-global-startfile)))
               (semanticdb-enable-gnu-global-in-buffer))))
 
     (let* ((db (semanticdb-project-database-global "global"))
index 22c474c..813786f 100644 (file)
@@ -273,7 +273,9 @@ If the buffer is in memory, return that buffer."
 If the buffer is in memory, return that buffer.
 If the buffer is not in memory, load it with `find-file-noselect'."
   (or (semanticdb-in-buffer-p obj)
-      (find-file-noselect (semanticdb-full-filename obj) t)))
+      ;; Save match data to protect against odd stuff in mode hooks.
+      (save-match-data
+       (find-file-noselect (semanticdb-full-filename obj) t))))
 
 (defmethod semanticdb-set-buffer ((obj semanticdb-table))
   "Set the current buffer to be a buffer owned by OBJ.
index b136733..05bebb0 100644 (file)
@@ -450,7 +450,8 @@ Optional argument COLOR means highlight the prototype with font-lock colors."
     (when (and (not doc) (not buf) fname)
       ;; If there is no doc, and no buffer, but we have a filename,
       ;; lets try again.
-      (setq buf (find-file-noselect fname))
+      (save-match-data
+       (setq buf (find-file-noselect fname)))
       (setq doc (semantic-tag-docstring tag buf)))
     (when (not doc)
       (require 'semantic/doc)
index b960a42..0e8f64a 100644 (file)
@@ -447,9 +447,10 @@ FILE, NOWARN, RAWFILE, and WILDCARDS are passed into `find-file-noselect'"
         ;; ... or eval variables
         (enable-local-eval nil)
         )
-    (if (featurep 'xemacs)
-       (find-file-noselect file nowarn rawfile)
-      (find-file-noselect file nowarn rawfile wildcards))
+    (save-match-data
+      (if (featurep 'xemacs)
+         (find-file-noselect file nowarn rawfile)
+       (find-file-noselect file nowarn rawfile wildcards)))
     ))
 
 \f
index de0f6fa..5ab7466 100644 (file)
@@ -862,20 +862,21 @@ and variable state from the current buffer."
       (erase-buffer)
       ;; Below is a painful hack to make sure everything is setup correctly.
       (when (not (eq major-mode mode))
-       (funcall mode)
-       ;; Hack in mode-local
-       (activate-mode-local-bindings)
-       ;; CHEATER!  The following 3 lines are from
-       ;; `semantic-new-buffer-fcn', but we don't want to turn
-       ;; on all the other annoying modes for this little task.
-       (setq semantic-new-buffer-fcn-was-run t)
-       (semantic-lex-init)
-       (semantic-clear-toplevel-cache)
-       (remove-hook 'semantic-lex-reset-hooks 'semantic-lex-spp-reset-hook
-                    t)
-       )
+       (save-match-data
+         (funcall mode)
+         ;; Hack in mode-local
+         (activate-mode-local-bindings)
+         ;; CHEATER!  The following 3 lines are from
+         ;; `semantic-new-buffer-fcn', but we don't want to turn
+         ;; on all the other annoying modes for this little task.
+         (setq semantic-new-buffer-fcn-was-run t)
+         (semantic-lex-init)
+         (semantic-clear-toplevel-cache)
+         (remove-hook 'semantic-lex-reset-hooks 'semantic-lex-spp-reset-hook
+                      t)
+         ))
 
-      ;; Second Cheat: copy key variables reguarding macro state from the
+      ;; Second Cheat: copy key variables regarding macro state from the
       ;; the originating buffer we are parsing.  We need to do this every time
       ;; since the state changes.
       (dolist (V important-vars)
index a013035..d7fe7d5 100644 (file)
@@ -45,29 +45,30 @@ TAG may be a stripped element, in which case PARENT specifies a
 parent tag that has position information.
 PARENT can also be a `semanticdb-table' object."
   (:override
-   (cond ((semantic-tag-in-buffer-p tag)
-         ;; We have a linked tag, go to that buffer.
-         (set-buffer (semantic-tag-buffer tag)))
-        ((semantic-tag-file-name tag)
-         ;; If it didn't have a buffer, but does have a file
-         ;; name, then we need to get to that file so the tag
-         ;; location is made accurate.
-         (set-buffer (find-file-noselect (semantic-tag-file-name tag))))
-        ((and parent (semantic-tag-p parent) (semantic-tag-in-buffer-p parent))
-         ;; The tag had nothing useful, but we have a parent with
-         ;; a buffer, then go there.
-         (set-buffer (semantic-tag-buffer parent)))
-        ((and parent (semantic-tag-p parent) (semantic-tag-file-name parent))
-         ;; Tag had nothing, and the parent only has a file-name, then
-         ;; find that file, and switch to that buffer.
-         (set-buffer (find-file-noselect (semantic-tag-file-name parent))))
-        ((and parent (featurep 'semantic/db)
-              (semanticdb-table-child-p parent))
-         (set-buffer (semanticdb-get-buffer parent)))
-        (t
-         ;; Well, just assume things are in the current buffer.
-         nil
-         ))
+   (save-match-data
+     (cond ((semantic-tag-in-buffer-p tag)
+           ;; We have a linked tag, go to that buffer.
+           (set-buffer (semantic-tag-buffer tag)))
+          ((semantic-tag-file-name tag)
+           ;; If it didn't have a buffer, but does have a file
+           ;; name, then we need to get to that file so the tag
+           ;; location is made accurate.
+           (set-buffer (find-file-noselect (semantic-tag-file-name tag))))
+          ((and parent (semantic-tag-p parent) (semantic-tag-in-buffer-p parent))
+           ;; The tag had nothing useful, but we have a parent with
+           ;; a buffer, then go there.
+           (set-buffer (semantic-tag-buffer parent)))
+          ((and parent (semantic-tag-p parent) (semantic-tag-file-name parent))
+           ;; Tag had nothing, and the parent only has a file-name, then
+           ;; find that file, and switch to that buffer.
+           (set-buffer (find-file-noselect (semantic-tag-file-name parent))))
+          ((and parent (featurep 'semantic/db)
+                (semanticdb-table-child-p parent))
+           (set-buffer (semanticdb-get-buffer parent)))
+          (t
+           ;; Well, just assume things are in the current buffer.
+           nil
+           )))
    ;; We should be in the correct buffer now, try and figure out
    ;; where the tag is.
    (cond ((semantic-tag-with-position-p tag)
index 015efb2..a16e558 100644 (file)
@@ -198,7 +198,8 @@ Return nil if there is no buffer for this tag."
       ;; TAG has an originating file, read that file into a buffer, and
       ;; return it.
      (if (semantic--tag-get-property tag :filename)
-        (find-file-noselect (semantic--tag-get-property tag :filename))
+        (save-match-data
+          (find-file-noselect (semantic--tag-get-property tag :filename)))
        ;; TAG is not in Emacs right now, no buffer is available.
        ))))
 
index a70b086..7981f75 100644 (file)
@@ -68,19 +68,20 @@ If FILE is not loaded, check to see if `semanticdb' feature exists,
    and use it to get tags from files not in memory.
 If FILE is not loaded, and semanticdb is not available, find the file
    and parse it."
-  (if (find-buffer-visiting file)
-      (save-excursion
-       (set-buffer (find-buffer-visiting file))
-       (semantic-fetch-tags))
-    ;; File not loaded
-    (if (and (require 'semantic/db-mode)
-            (semanticdb-minor-mode-p))
-       ;; semanticdb is around, use it.
-       (semanticdb-file-stream file)
-      ;; Get the stream ourselves.
-      (save-excursion
-       (set-buffer (find-file-noselect file))
-       (semantic-fetch-tags)))))
+  (save-match-data
+    (if (find-buffer-visiting file)
+       (save-excursion
+         (set-buffer (find-buffer-visiting file))
+         (semantic-fetch-tags))
+      ;; File not loaded
+      (if (and (require 'semantic/db-mode)
+              (semanticdb-minor-mode-p))
+         ;; semanticdb is around, use it.
+         (semanticdb-file-stream file)
+       ;; Get the stream ourselves.
+       (save-excursion
+         (set-buffer (find-file-noselect file))
+         (semantic-fetch-tags))))))
 
 (semantic-alias-obsolete 'semantic-file-token-stream
                         'semantic-file-tag-table)
@@ -161,7 +162,8 @@ THIS ISN'T USED IN SEMANTIC.  DELETE ME SOON."
        (let ((fn (semantic-dependency-tag-file (car includelist))))
          (if (and fn (not (member fn unfound)))
              (save-excursion
-               (set-buffer (find-file-noselect fn))
+               (save-match-data
+                 (set-buffer (find-file-noselect fn)))
                (message "Scanning %s" (buffer-file-name))
                (setq stream (semantic-fetch-tags))
                (setq found (semantic-find-first-tag-by-name name stream))