1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-17 17:58:46 +00:00

* cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.

* cedet/semantic/idle.el
(semantic-before-idle-scheduler-reparse-hook)
(semantic-after-idle-scheduler-reparse-hook): Rename from *-hooks.
Make old name an obsolete alias.

* cedet/semantic/edit.el (semantic-after-partial-cache-change-hook)
(semantic-change-hooks, semantic-edits-new-change-hooks)
(semantic-edits-delete-change-hooks)
(semantic-edits-move-change-hook)
(semantic-edits-reparse-change-hooks)
(semantic-edits-incremental-reparse-failed-hooks): Doc fixes.

* cedet/semantic/debug.el (semantic-debug-mode): Rename hook
symbols.

* cedet/semantic/db-mode.el (semanticdb-mode-hook): Rename from
semanticdb-mode-hooks.
(global-semanticdb-minor-mode): Use the new name.
(semanticdb-hooks): Use semantic-init-db-hook instead of obsolete
alias semantic-init-db-hooks.

* cedet/semantic/db-global.el (semanticdb-enable-gnu-global-databases):
Use semantic-init-hook instead of obsolete alias
semantic-init-hooks.

* cedet/semantic/db-file.el (semanticdb-save-database-hook):
Rename from semanticdb-save-database-hooks.  Make old name an
obsolete alias.

* cedet/semantic/decorate/mode.el
(semantic-decorate-pending-decoration-hook): Rename from
semantic-decorate-pending-decoration-hooks.  Make old name an
obsolete alias.

* cedet/srecode/map.el (srecode-map-validate-file-for-mode): Use
semantic-init-hook instead of obsolete alias semantic-init-hooks.

* cedet/semantic/fw.el (semantic-find-file-noselect): Use
semantic-init-hook instead of obsolete alias semantic-init-hooks.

* cedet/ede/project-am.el (project-am-with-makefile-current): Use
semantic-init-hook instead of obsolete alias semantic-init-hooks.

* cedet/semantic/util.el (semantic-describe-buffer): Use
semantic-init-hook and semantic-init-db-hook instead of obsolete
aliases.

* cedet/semantic/util-modes.el (semantic-mode-line-update)
(semantic-toggle-minor-mode-globally): Use semantic-init-hook
instead of obsolete alias semantic-init-hooks.


Synch to Eric M. Ludlam's upstream CEDET repository:

* cedet/semantic/bovine/c.el (semantic-c-parse-token-hack-depth):
New var.
(semantic-c-parse-lexical-token): Save match data when setting up
the secondary parse buffer.  Allow recursion.  Protect against
initializing the major mode from throwing errors, ie user hooks.

* cedet/semantic/lex-spp.el (semantic-lex-spp-lex-text-string):
Protect installing a major mode from throwing errors.
This commit is contained in:
Chong Yidong 2009-09-26 17:47:11 +00:00
parent 17e1f4bc65
commit 29e1a603c0
16 changed files with 177 additions and 66 deletions

View File

@ -1,3 +1,71 @@
2009-09-26 Chong Yidong <cyd@stupidchicken.com>
* cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
* cedet/semantic/idle.el
(semantic-before-idle-scheduler-reparse-hook)
(semantic-after-idle-scheduler-reparse-hook): Rename from *-hooks.
Make old name an obsolete alias.
* cedet/semantic/edit.el (semantic-after-partial-cache-change-hook)
(semantic-change-hooks, semantic-edits-new-change-hooks)
(semantic-edits-delete-change-hooks)
(semantic-edits-move-change-hook)
(semantic-edits-reparse-change-hooks)
(semantic-edits-incremental-reparse-failed-hooks): Doc fixes.
* cedet/semantic/debug.el (semantic-debug-mode): Rename hook
symbols.
* cedet/semantic/db-mode.el (semanticdb-mode-hook): Rename from
semanticdb-mode-hooks.
(global-semanticdb-minor-mode): Use the new name.
(semanticdb-hooks): Use semantic-init-db-hook instead of obsolete
alias semantic-init-db-hooks.
* cedet/semantic/db-global.el (semanticdb-enable-gnu-global-databases):
Use semantic-init-hook instead of obsolete alias
semantic-init-hooks.
* cedet/semantic/db-file.el (semanticdb-save-database-hook):
Rename from semanticdb-save-database-hooks. Make old name an
obsolete alias.
* cedet/semantic/decorate/mode.el
(semantic-decorate-pending-decoration-hook): Rename from
semantic-decorate-pending-decoration-hooks. Make old name an
obsolete alias.
* cedet/srecode/map.el (srecode-map-validate-file-for-mode): Use
semantic-init-hook instead of obsolete alias semantic-init-hooks.
* cedet/semantic/fw.el (semantic-find-file-noselect): Use
semantic-init-hook instead of obsolete alias semantic-init-hooks.
* cedet/ede/project-am.el (project-am-with-makefile-current): Use
semantic-init-hook instead of obsolete alias semantic-init-hooks.
* cedet/semantic/util.el (semantic-describe-buffer): Use
semantic-init-hook and semantic-init-db-hook instead of obsolete
aliases.
* cedet/semantic/util-modes.el (semantic-mode-line-update)
(semantic-toggle-minor-mode-globally): Use semantic-init-hook
instead of obsolete alias semantic-init-hooks.
2009-09-26 Chong Yidong <cyd@stupidchicken.com>
Synch to Eric Ludlam's upstream CEDET repository.
* cedet/semantic/bovine/c.el (semantic-c-parse-token-hack-depth):
New var.
(semantic-c-parse-lexical-token): Save match data when setting up
the secondary parse buffer. Allow recursion. Protect against
initializing the major mode from throwing errors, ie user hooks.
* cedet/semantic/lex-spp.el (semantic-lex-spp-lex-text-string):
Protect installing a major mode from throwing errors.
2009-09-21 Chong Yidong <cyd@stupidchicken.com>
* cedet/semantic.el (semantic-parser-working-message): Use a less

View File

@ -475,7 +475,7 @@ Kill the makefile if it was not loaded before the load."
(if kb (setq fb kb)
;; We need to find-file this thing, but don't use
;; any semantic features.
(let ((semantic-init-hooks nil))
(let ((semantic-init-hook nil))
(setq fb (find-file-noselect fn)))
)
(set-buffer fb)

View File

@ -283,7 +283,7 @@ values of the conditions in the #if blocks."
(defun semantic-c-skip-conditional-section ()
"Skip one section of a conditional.
Moves forward to a matching #elif, #else, or #endif.
Movers completely over balanced #if blocks."
Moves completely over balanced #if blocks."
(require 'cc-cmds)
(let ((done nil))
;; (if (looking-at "^\\s-*#if")
@ -684,6 +684,9 @@ as for the parent."
depth returnonerror)
))
(defvar semantic-c-parse-token-hack-depth 0
"Current depth of recursive calls to `semantic-c-parse-lexical-token'")
(defun semantic-c-parse-lexical-token (lexicaltoken nonterminal depth
returnonerror)
"Do a region parse on the contents of LEXICALTOKEN.
@ -692,7 +695,9 @@ The text of the token is inserted into a different buffer, and
parsed there.
Argument NONTERMINAL, DEPTH, and RETURNONERROR are passed into
the regular parser."
(let* ((buf (get-buffer-create " *C parse hack*"))
(let* ((semantic-c-parse-token-hack-depth (1+ semantic-c-parse-token-hack-depth))
(buf (get-buffer-create (format " *C parse hack %d*"
semantic-c-parse-token-hack-depth)))
(mode major-mode)
(spp-syms semantic-lex-spp-dynamic-macro-symbol-obarray)
(stream nil)
@ -705,18 +710,24 @@ the regular parser."
(set-buffer buf)
(erase-buffer)
(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
;; Protect against user hooks throwing errors.
(condition-case nil
(funcall mode)
(error nil))
;; 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)
))
;; Get the macro symbol table right.
(setq semantic-lex-spp-dynamic-macro-symbol-obarray spp-syms)
;; (message "%S" macros)

View File

@ -68,13 +68,17 @@ passes a list of predicates in `semanticdb-project-predicate-functions'."
:group 'semanticdb
:type nil)
(defcustom semanticdb-save-database-hooks nil
"Hooks run after a database is saved.
(defcustom semanticdb-save-database-hook nil
"Normal hook run after a database is saved.
Each function is called with one argument, the object representing
the database recently written."
:group 'semanticdb
:type 'hook)
(define-obsolete-variable-alias
'semanticdb-save-database-hooks
'semanticdb-save-database-hook "23.2")
(defvar semanticdb-dir-sep-char (if (boundp 'directory-sep-char)
(symbol-value 'directory-sep-char)
?/)
@ -210,9 +214,10 @@ If SUPRESS-QUESTIONS, then do not ask to create the directory."
((y-or-n-p (format "Create directory %s for SemanticDB? " dest))
(make-directory dest t)
t)
(t (if (boundp 'semanticdb--inhibit-make-directory)
(setq semanticdb--inhibit-make-directory t))
nil))))
(t
(if (boundp 'semanticdb--inhibit-make-directory)
(setq semanticdb--inhibit-make-directory t))
nil))))
(defmethod semanticdb-save-db ((DB semanticdb-project-database-file)
&optional

View File

@ -61,9 +61,9 @@ in a GNU Global supported hierarchy."
(when (stringp mode)
(setq mode (intern mode)))
(let ((ih (mode-local-value mode 'semantic-init-mode-hooks)))
(let ((ih (mode-local-value mode 'semantic-init-mode-hook)))
(eval `(setq-mode-local
,mode semantic-init-mode-hooks
,mode semantic-init-mode-hook
(cons 'semanticdb-enable-gnu-global-hook ih))))
)

View File

@ -47,17 +47,21 @@
(global-semanticdb-minor-mode (if val 1 -1))
(custom-set-default sym val)))
(defcustom semanticdb-mode-hooks nil
"*Hooks run whenever `global-semanticdb-minor-mode' is run.
(defcustom semanticdb-mode-hook nil
"Normal hook run whenever `global-semanticdb-minor-mode' is run.
Use `semanticdb-minor-mode-p' to determine if the mode has been turned
on or off."
:group 'semanticdb
:type 'hook)
(define-obsolete-variable-alias
'semanticdb-mode-hooks
'semanticdb-mode-hook "23.2")
;;; Start/Stop database use
;;
(defvar semanticdb-hooks
'((semanticdb-semantic-init-hook-fcn semantic-init-db-hooks)
'((semanticdb-semantic-init-hook-fcn semantic-init-db-hook)
(semanticdb-synchronize-table semantic-after-toplevel-cache-change-hook)
(semanticdb-partial-synchronize-table semantic-after-partial-cache-change-hook)
(semanticdb-revert-hook before-revert-hook)
@ -101,7 +105,7 @@ If ARG is nil, then toggle."
(funcall fn (car (cdr (car h))) (car (car h)))
(setq h (cdr h)))
;; Call a hook
(run-hooks 'semanticdb-mode-hooks))
(run-hooks 'semanticdb-mode-hook))
))
(defun semanticdb-toggle-global-mode ()
@ -119,7 +123,7 @@ Update the environment of Semantic enabled buffers accordingly."
;; Functions used in hooks to keep SemanticDB operating.
;;
(defun semanticdb-semantic-init-hook-fcn ()
"Function saved in `semantic-init-db-hooks'.
"Function saved in `semantic-init-db-hook'.
Sets up the semanticdb environment."
;; Only initialize semanticdb if we have a file name.
;; There is no reason to cache a tag table if there is no

View File

@ -319,7 +319,7 @@ Argument ONOFF is non-nil when we are entering debug mode.
;; Make the buffer read only
(toggle-read-only 1)
;; Hooks
(run-hooks 'semantic-debug-mode-hooks)
(run-hooks 'semantic-debug-mode-hook)
)
;; Restore old mode information
(save-excursion
@ -334,7 +334,7 @@ Argument ONOFF is non-nil when we are entering debug mode.
(use-local-map
(oref semantic-debug-current-interface source-local-map))
)
(run-hooks 'semantic-debug-exit-hooks)
(run-hooks 'semantic-debug-exit-hook)
)))
(defun semantic-debug ()

View File

@ -194,9 +194,13 @@ Also make sure old decorations in the area are completely flushed."
;; such identified change ought to be setup as PENDING. This means
;; that the next idle step will do the decoration change, but at the
;; time of the state change, minimal work would be done.
(defvar semantic-decorate-pending-decoration-hooks nil
(defvar semantic-decorate-pending-decoration-hook nil
"Functions to call with pending decoration changes.")
(define-obsolete-variable-alias
'semantic-decorate-pending-decoration-hooks
'semantic-decorate-pending-decoration-hook "23.2")
(defun semantic-decorate-add-pending-decoration (fcn &optional buffer)
"Add a pending decoration change represented by FCN.
Applies only to the current BUFFER.
@ -204,17 +208,17 @@ The setting of FCN will be removed after it is run."
(save-excursion
(when buffer (set-buffer buffer))
(semantic-make-local-hook 'semantic-decorate-flush-pending-decorations)
(add-hook 'semantic-decorate-pending-decoration-hooks fcn nil t)))
(add-hook 'semantic-decorate-pending-decoration-hook fcn nil t)))
;;;;###autoload
(defun semantic-decorate-flush-pending-decorations (&optional buffer)
"Flush any pending decorations for BUFFER.
Flush functions from `semantic-decorate-pending-decoration-hooks'."
Flush functions from `semantic-decorate-pending-decoration-hook'."
(save-excursion
(when buffer (set-buffer buffer))
(run-hooks 'semantic-decorate-pending-decoration-hooks)
(run-hooks 'semantic-decorate-pending-decoration-hook)
;; Always reset the hooks
(setq semantic-decorate-pending-decoration-hooks nil)))
(setq semantic-decorate-pending-decoration-hook nil)))
;;; DECORATION MODE

View File

@ -62,7 +62,7 @@
;;; Code:
(defvar semantic-after-partial-cache-change-hook nil
"Hooks run after the buffer cache has been updated.
"Normal hook run after the buffer cache has been updated.
This hook will run when the cache has been partially reparsed.
Partial reparses are incurred when a user edits a buffer, and only the
@ -74,7 +74,7 @@ updated in the current buffer.
For language specific hooks, make sure you define this as a local hook.")
(defvar semantic-change-hooks nil
"Hooks run when semantic detects a change in a buffer.
"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'.")
@ -92,27 +92,27 @@ hook.
Not used yet; part of the next generation reparse mechanism.")
(defvar semantic-edits-new-change-hooks nil
"Hooks run when a new change is found.
"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
"Hooks run before a change overlay is deleted.
"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.")
(defvar semantic-edits-move-change-hooks nil
"Hooks run after a change overlay is moved.
(defvar semantic-edits-move-change-hook nil
"Abnormal hook run after a change overlay is moved.
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
"Hooks run after a change results in a reparse.
"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-hooks nil
"Hooks run after the incremental parser fails.
"Abnormal hook run after the incremental parser fails.
When this happens, the buffer is marked as needing a full reprase.")
(defcustom semantic-edits-verbose-flag nil

View File

@ -391,7 +391,7 @@ FILE, NOWARN, RAWFILE, and WILDCARDS are passed into `find-file-noselect'"
;; This is a brave statement. Don't waste time loading in
;; lots of modes. Especially decoration mode can waste a lot
;; of time for a buffer we intend to kill.
(semantic-init-hooks nil)
(semantic-init-hook nil)
;; This disables the part of EDE that asks questions
(ede-auto-add-method 'never)
;; Ask font-lock to not colorize these buffers, nor to

View File

@ -500,16 +500,26 @@ datasets."
;; :group 'semantic
;; :type 'boolean)
(defvar semantic-before-idle-scheduler-reparse-hooks nil
"Hooks run before option `semantic-idle-scheduler' begins parsing.
If any hook throws an error, this variable is reset to nil.
(defvar semantic-before-idle-scheduler-reparse-hook nil
"Normal hook run before option `semantic-idle-scheduler' begins parsing.
If any hook function throws an error, this variable is reset to nil.
This hook is not protected from lexical errors.")
(defvar semantic-after-idle-scheduler-reparse-hooks nil
"Hooks run after option `semantic-idle-scheduler' has parsed.
If any hook throws an error, this variable is reset to nil.
(define-obsolete-variable-alias
'semantic-before-idle-scheduler-reparse-hooks
'semantic-before-idle-scheduler-reparse-hook
"23.2")
(defvar semantic-after-idle-scheduler-reparse-hook nil
"Normal hook run after option `semantic-idle-scheduler' has parsed.
If any hook function throws an error, this variable is reset to nil.
This hook is not protected from lexical errors.")
(define-obsolete-variable-alias
'semantic-after-idle-scheduler-reparse-hooks
'semantic-after-idle-scheduler-reparse-hook
"23.2")
(defun semantic-idle-scheduler-refresh-tags ()
"Refreshes the current buffer's tags.
This is called by `semantic-idle-scheduler-function' to update the
@ -553,8 +563,8 @@ Does nothing if the current buffer doesn't need reparsing."
;; Let people hook into this, but don't let them hose
;; us over!
(condition-case nil
(run-hooks 'semantic-before-idle-scheduler-reparse-hooks)
(error (setq semantic-before-idle-scheduler-reparse-hooks nil)))
(run-hooks 'semantic-before-idle-scheduler-reparse-hook)
(error (setq semantic-before-idle-scheduler-reparse-hook nil)))
(unwind-protect
;; Perform the parsing.
@ -576,8 +586,8 @@ Does nothing if the current buffer doesn't need reparsing."
;; Let people hook into this, but don't let them hose
;; us over!
(condition-case nil
(run-hooks 'semantic-after-idle-scheduler-reparse-hooks)
(error (setq semantic-after-idle-scheduler-reparse-hooks nil))))
(run-hooks 'semantic-after-idle-scheduler-reparse-hook)
(error (setq semantic-after-idle-scheduler-reparse-hook nil))))
;; Return if we are lexically safe (from prog1)
lexically-safe)))

View File

@ -863,7 +863,12 @@ and variable state from the current buffer."
;; Below is a painful hack to make sure everything is setup correctly.
(when (not (eq major-mode mode))
(save-match-data
(funcall mode)
;; Protect against user-hooks that throw errors.
(condition-case nil
(funcall mode)
(error nil))
;; Hack in mode-local
(activate-mode-local-bindings)
;; CHEATER! The following 3 lines are from

View File

@ -769,9 +769,10 @@ start position of the block, and STREAM is the list of tokens in that
block.")
(defvar semantic-lex-reset-hooks nil
"List of hooks major-modes use to reset lexical analyzers.
Hooks are called with START and END values for the current lexical pass.
Should be set with `add-hook'specifying a LOCAL option.")
"Abnormal hook used by major-modes to reset lexical analyzers.
Hook functions are called with START and END values for the
current lexical pass. Should be set with `add-hook', specifying
a LOCAL option.")
;; Stack of nested blocks.
(defvar semantic-lex-block-stack nil)

View File

@ -97,7 +97,7 @@ Only minor modes that are locally enabled are shown in the mode line."
ml (cdr ml))
(when (and (symbol-value mm)
;; Only show local minor mode status
(not (memq mm semantic-init-hooks)))
(not (memq mm semantic-init-hook)))
(and ms
(symbolp ms)
(setq ms (symbol-value ms)))
@ -178,26 +178,26 @@ function used to toggle the mode."
(or (and (fboundp mode) (assq mode minor-mode-alist))
(error "Semantic minor mode %s not found" mode))
(if (not arg)
(if (memq mode semantic-init-hooks)
(if (memq mode semantic-init-hook)
(setq arg -1)
(setq arg 1)))
;; Add or remove the MODE toggle function from
;; `semantic-init-hooks'. Then turn MODE on or off in every
;; `semantic-init-hook'. Then turn MODE on or off in every
;; Semantic enabled buffer.
(cond
;; Turn off if ARG < 0
((< arg 0)
(remove-hook 'semantic-init-hooks mode)
(remove-hook 'semantic-init-hook mode)
(semantic-map-buffers #'(lambda () (funcall mode -1)))
nil)
;; Turn on if ARG > 0
((> arg 0)
(add-hook 'semantic-init-hooks mode)
(add-hook 'semantic-init-hook mode)
(semantic-map-buffers #'(lambda () (funcall mode 1)))
t)
;; Otherwise just check MODE state
(t
(memq mode semantic-init-hooks))
(memq mode semantic-init-hook))
))
;;;;

View File

@ -335,8 +335,8 @@ If TAG is not specified, use the tag at point."
(princ "\nGeneral configuration items:\n")
(let ((vars '(semantic-inhibit-functions
semantic-init-hooks
semantic-init-db-hooks
semantic-init-hook
semantic-init-db-hook
semantic-unmatched-syntax-hook
semantic--before-fetch-tags-hook
semantic-after-toplevel-bovinate-hook
@ -445,6 +445,8 @@ NOTFIRST indicates that this was not the first call in the recursive use."
;; "transparently". Here are some interactive commands based on
;; Senator.
;; Symbol completion
(defvar semantic--completion-cache nil
"Internal variable used by `senator-complete-symbol'.")
@ -456,6 +458,7 @@ NOTFIRST indicates that this was not the first call in the recursive use."
"Find all tags with name starting with PREFIX.
This uses `semanticdb' when available."
(let (result ctxt)
;; Try the Semantic analyzer
(condition-case nil
(and (featurep 'semantic/analyze)
(setq ctxt (semantic-analyze-current-context))

View File

@ -355,7 +355,7 @@ Return non-nil if the map changed."
(insert-file-contents file nil nil nil t)
;; Force it to be ready to parse.
(srecode-template-mode)
(let ((semantic-init-hooks nil))
(let ((semantic-init-hook nil))
(semantic-new-buffer-fcn))
)