Function: define-semantic-idle-service
define-semantic-idle-service is a macro defined in idle.el.gz.
Signature
(define-semantic-idle-service NAME DOC &rest FORMS)
Documentation
Create a new idle services with NAME.
DOC will be a documentation string describing FORMS. FORMS will be called during idle time after the current buffer's semantic tag information has been updated. This routine creates the following functions and variables:
Source Code
;; Defined in /usr/src/emacs/lisp/cedet/semantic/idle.el.gz
;;; IDLE SERVICES
;;
;; Idle Services are minor modes which enable or disable a services in
;; the idle scheduler. Creating a new services only requires calling
;; `semantic-create-idle-services' which does all the setup
;; needed to create the minor mode that will enable or disable
;; a services. The services must provide a single function.
;; FIXME doc is incomplete.
(defmacro define-semantic-idle-service (name doc &rest forms)
"Create a new idle services with NAME.
DOC will be a documentation string describing FORMS.
FORMS will be called during idle time after the current buffer's
semantic tag information has been updated.
This routine creates the following functions and variables:"
(declare (indent 1) (debug (&define name stringp def-body)))
(let ((global (intern (concat "global-" (symbol-name name) "-mode")))
(mode (intern (concat (symbol-name name) "-mode")))
(hook (intern (concat (symbol-name name) "-mode-hook")))
(map (intern (concat (symbol-name name) "-mode-map")))
;; (setup (intern (concat (symbol-name name) "-mode-setup")))
(func (intern (concat (symbol-name name) "-idle-function"))))
`(progn
(define-minor-mode ,global
,(concat "Toggle " (symbol-name global) ".
With ARG, turn the minor mode on if ARG is positive, off otherwise.\n\n"
(internal--format-docstring-line
"When this minor mode is enabled, `%s' is \
turned on in every Semantic-supported buffer."
(symbol-name mode)))
:global t
:group 'semantic
:group 'semantic-modes
:require 'semantic/idle
(semantic-toggle-minor-mode-globally
',mode (if ,global 1 -1)))
;; FIXME: Get rid of this when define-minor-mode does it for us.
(defcustom ,hook nil
,(concat "Hook run at the end of function `" (symbol-name mode) "'.")
:group 'semantic
:type 'hook)
(defvar ,map
(let ((km (make-sparse-keymap)))
km)
,(concat "Keymap for `" (symbol-name mode) "'."))
(define-minor-mode ,mode
,doc
:keymap ,map
(if ,mode
(if (not (and (featurep 'semantic) (semantic-active-p)))
(progn
;; Disable minor mode if semantic stuff not available
(setq ,mode nil)
(error "Buffer %s was not set up for parsing"
(buffer-name)))
;; Enable the mode mode
(semantic-idle-scheduler-add #',func))
;; Disable the mode mode
(semantic-idle-scheduler-remove #',func)))
(semantic-add-minor-mode ',mode
"") ; idle schedulers are quiet?
(defun ,func ()
,(internal--format-docstring-line
"Perform idle activity for the minor mode `%s'."
(symbol-name mode))
,@forms))))