Function: gud-def
gud-def is a macro defined in gud.el.gz.
Signature
(gud-def FUNC CMD KEY &optional DOC ASYNC-OK)
Documentation
Define FUNC to be a command sending CMD and bound to KEY, with optional doc string DOC. Certain %-escapes in the string arguments are interpreted specially if present. These are:
%f -- Name (without directory) of current source file.
%F -- Name (without directory or extension) of current source file.
%d -- Directory of current source file.
%l -- Number of current source line.
%e -- Text of the C lvalue or function-call expression surrounding point.
%a -- Text of the hexadecimal address surrounding point.
%p -- Prefix argument to the command (if any) as a number.
%c -- Fully qualified class name derived from the expression
surrounding point (jdb only).
The current source file is the file of the current buffer (if
we're in a C file) or the source file current at the last break or
step (if we're in the GUD buffer).
The current line is that of the current buffer (if we're in a
source file) or the source line number at the last break or step (if
we're in the GUD buffer).
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/gud.el.gz
;; ======================================================================
;; command definition
;; This macro is used below to define some basic debugger interface commands.
;; Of course you may use `gud-def' with any other debugger command, including
;; user defined ones.
;; A macro call like (gud-def FUNC CMD KEY DOC ASYNC-OK) expands to a form
;; which defines FUNC to send the command CMD to the debugger, gives
;; it the docstring DOC, and binds that function to KEY in the GUD
;; major mode. The FUNC still sends CMD when both ASYNC-OK and
;; `gud-async-running' are t even `gud-running' is t.
;; The function is also bound in the global keymap with the
;; GUD prefix.
(defmacro gud-def (func cmd key &optional doc async-ok)
"Define FUNC to be a command sending CMD and bound to KEY, with
optional doc string DOC. Certain %-escapes in the string arguments
are interpreted specially if present. These are:
%f -- Name (without directory) of current source file.
%F -- Name (without directory or extension) of current source file.
%d -- Directory of current source file.
%l -- Number of current source line.
%e -- Text of the C lvalue or function-call expression surrounding point.
%a -- Text of the hexadecimal address surrounding point.
%p -- Prefix argument to the command (if any) as a number.
%c -- Fully qualified class name derived from the expression
surrounding point (jdb only).
The `current' source file is the file of the current buffer (if
we're in a C file) or the source file current at the last break or
step (if we're in the GUD buffer).
The `current' line is that of the current buffer (if we're in a
source file) or the source line number at the last break or step (if
we're in the GUD buffer)."
`(progn
(defalias ',func (lambda (arg)
,@(if doc (list doc))
(interactive "p")
(if (or (not gud-running) (and ,async-ok gud-async-running))
,(if (stringp cmd)
`(gud-call ,cmd arg)
;; Unused lexical warning if cmd does not use "arg".
cmd))))
,(if key `(local-set-key ,(concat "\C-c" key) #',func))
,(if key `(define-key gud-global-map ,key #',func))))