changeset 104492:8db96f200ac8

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
author Chong Yidong <cyd@stupidchicken.com>
date Sat, 19 Sep 2009 17:25:30 +0000
parents ee206d5b836f
children a4e1a12c8b97
files 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
diffstat 9 files changed, 98 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sun Sep 13 16:18:01 2009 +0000
+++ b/lisp/ChangeLog	Sat Sep 19 17:25:30 2009 +0000
@@ -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.
--- a/lisp/cedet/semantic/db-global.el	Sun Sep 13 16:18:01 2009 +0000
+++ b/lisp/cedet/semantic/db-global.el	Sat Sep 19 17:25:30 2009 +0000
@@ -231,13 +231,15 @@
   (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"))
--- a/lisp/cedet/semantic/db.el	Sun Sep 13 16:18:01 2009 +0000
+++ b/lisp/cedet/semantic/db.el	Sat Sep 19 17:25:30 2009 +0000
@@ -273,7 +273,9 @@
 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.
--- a/lisp/cedet/semantic/format.el	Sun Sep 13 16:18:01 2009 +0000
+++ b/lisp/cedet/semantic/format.el	Sat Sep 19 17:25:30 2009 +0000
@@ -450,7 +450,8 @@
     (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)
--- a/lisp/cedet/semantic/fw.el	Sun Sep 13 16:18:01 2009 +0000
+++ b/lisp/cedet/semantic/fw.el	Sat Sep 19 17:25:30 2009 +0000
@@ -447,9 +447,10 @@
 	 ;; ... 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)))
     ))
 
 
--- a/lisp/cedet/semantic/lex-spp.el	Sun Sep 13 16:18:01 2009 +0000
+++ b/lisp/cedet/semantic/lex-spp.el	Sat Sep 19 17:25:30 2009 +0000
@@ -862,20 +862,21 @@
       (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)
--- a/lisp/cedet/semantic/tag-file.el	Sun Sep 13 16:18:01 2009 +0000
+++ b/lisp/cedet/semantic/tag-file.el	Sat Sep 19 17:25:30 2009 +0000
@@ -45,29 +45,30 @@
 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)
--- a/lisp/cedet/semantic/tag.el	Sun Sep 13 16:18:01 2009 +0000
+++ b/lisp/cedet/semantic/tag.el	Sat Sep 19 17:25:30 2009 +0000
@@ -198,7 +198,8 @@
       ;; 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.
        ))))
 
--- a/lisp/cedet/semantic/util.el	Sun Sep 13 16:18:01 2009 +0000
+++ b/lisp/cedet/semantic/util.el	Sat Sep 19 17:25:30 2009 +0000
@@ -68,19 +68,20 @@
    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 @@
 	(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))