From 1eac105a705a5d055f38e2734c16101d0f550112 Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Sat, 19 Sep 2009 17:25:30 +0000 Subject: [PATCH] Synch to Eric M. 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 --- lisp/ChangeLog | 29 ++++++++++++++++++++ lisp/cedet/semantic/db-global.el | 6 ++-- lisp/cedet/semantic/db.el | 4 ++- lisp/cedet/semantic/format.el | 3 +- lisp/cedet/semantic/fw.el | 7 +++-- lisp/cedet/semantic/lex-spp.el | 27 +++++++++--------- lisp/cedet/semantic/tag-file.el | 47 ++++++++++++++++---------------- lisp/cedet/semantic/tag.el | 3 +- lisp/cedet/semantic/util.el | 30 ++++++++++---------- 9 files changed, 98 insertions(+), 58 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a86f1b7e77..d50154ad51 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,32 @@ +2009-09-19 Chong Yidong + + 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 Synch to Eric Ludlam's upstream CEDET repository. diff --git a/lisp/cedet/semantic/db-global.el b/lisp/cedet/semantic/db-global.el index cf91a0498f..1b3be12a5f 100644 --- a/lisp/cedet/semantic/db-global.el +++ b/lisp/cedet/semantic/db-global.el @@ -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")) diff --git a/lisp/cedet/semantic/db.el b/lisp/cedet/semantic/db.el index 22c474cc0b..813786fb18 100644 --- a/lisp/cedet/semantic/db.el +++ b/lisp/cedet/semantic/db.el @@ -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. diff --git a/lisp/cedet/semantic/format.el b/lisp/cedet/semantic/format.el index b13673318d..05bebb04ff 100644 --- a/lisp/cedet/semantic/format.el +++ b/lisp/cedet/semantic/format.el @@ -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) diff --git a/lisp/cedet/semantic/fw.el b/lisp/cedet/semantic/fw.el index b960a4274e..0e8f64a21c 100644 --- a/lisp/cedet/semantic/fw.el +++ b/lisp/cedet/semantic/fw.el @@ -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))) )) diff --git a/lisp/cedet/semantic/lex-spp.el b/lisp/cedet/semantic/lex-spp.el index de0f6fa61d..5ab74668a4 100644 --- a/lisp/cedet/semantic/lex-spp.el +++ b/lisp/cedet/semantic/lex-spp.el @@ -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) diff --git a/lisp/cedet/semantic/tag-file.el b/lisp/cedet/semantic/tag-file.el index a013035a84..d7fe7d5017 100644 --- a/lisp/cedet/semantic/tag-file.el +++ b/lisp/cedet/semantic/tag-file.el @@ -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) diff --git a/lisp/cedet/semantic/tag.el b/lisp/cedet/semantic/tag.el index 015efb24fd..a16e558c58 100644 --- a/lisp/cedet/semantic/tag.el +++ b/lisp/cedet/semantic/tag.el @@ -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. )))) diff --git a/lisp/cedet/semantic/util.el b/lisp/cedet/semantic/util.el index a70b086f78..7981f75c30 100644 --- a/lisp/cedet/semantic/util.el +++ b/lisp/cedet/semantic/util.el @@ -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)) -- 2.39.2