Function: srecode-add-code-generator
srecode-add-code-generator is a byte-compiled function defined in
mode.el.gz.
Signature
(srecode-add-code-generator FUNCTION NAME &optional BINDING)
Documentation
Add the srecoder code generator FUNCTION with NAME to the menu.
Optional BINDING specifies the keybinding to use in the srecoder map. BINDING should be a capital letter. Lower case letters are reserved for individual templates. Optional MODE specifies a major mode this function applies to. Do not specify a mode if this function could be applied to most programming modes.
Source Code
;; Defined in /usr/src/emacs/lisp/cedet/srecode/mode.el.gz
(defun srecode-add-code-generator (function name &optional binding)
"Add the srecoder code generator FUNCTION with NAME to the menu.
Optional BINDING specifies the keybinding to use in the srecoder map.
BINDING should be a capital letter. Lower case letters are reserved
for individual templates.
Optional MODE specifies a major mode this function applies to.
Do not specify a mode if this function could be applied to most
programming modes."
;; Update the menu generating part.
(let ((remloop nil))
(while (setq remloop (assoc function srecode-minor-mode-generators))
(setq srecode-minor-mode-generators
(remove remloop srecode-minor-mode-generators))))
(add-to-list 'srecode-minor-mode-generators
(cons function name))
;; Remove this function from any old bindings.
(when binding
(let ((oldkey (where-is-internal function
(list srecode-prefix-map)
t t t)))
(if (or (not oldkey)
(and (= (length oldkey) 1)
(= (length binding) 1)
(= (aref oldkey 0) (aref binding 0))))
;; Its the same.
nil
;; Remove the old binding
(define-key srecode-prefix-map oldkey nil)
)))
;; Update Keybindings
(let ((oldbinding (lookup-key srecode-prefix-map binding)))
;; During development, allow overrides.
(when (and oldbinding
(not (eq oldbinding function))
(or (eq this-command 'eval-defun) (eq this-command 'checkdoc-eval-defun))
(y-or-n-p (format "Override old binding %s? " oldbinding)))
(setq oldbinding nil))
(if (not oldbinding)
(define-key srecode-prefix-map binding function)
(if (eq function oldbinding)
nil
;; Not the same.
(message "Conflict binding %S binding to srecode map."
binding))))
)