+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.
(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"))
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.
(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)
;; ... 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
(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)
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)
;; 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.
))))
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)
(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))