Function: gud-format-command
gud-format-command is a byte-compiled function defined in gud.el.gz.
Signature
(gud-format-command STR ARG)
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/gud.el.gz
;; The gud-call function must do the right thing whether its invoking
;; keystroke is from the GUD buffer itself (via major-mode binding)
;; or a C buffer. In the former case, we want to supply data from
;; gud-last-frame. Here's how we do it:
(defun gud-format-command (str arg)
(let ((insource (not (eq (current-buffer) gud-comint-buffer)))
(frame (or gud-last-frame gud-last-last-frame))
(buffer-file-name-localized
(and (buffer-file-name)
(file-local-name (buffer-file-name))))
result)
(while (and str
(let ((case-fold-search nil))
(string-match "\\([^%]*\\)%\\([adefFlpc]\\)" str)))
(let ((key (string-to-char (match-string 2 str)))
subst)
(cond
((eq key ?f)
(setq subst (file-name-nondirectory (if insource
buffer-file-name-localized
(car frame)))))
((eq key ?F)
(setq subst (file-name-base (if insource
buffer-file-name-localized
(car frame)))))
((eq key ?d)
(setq subst (file-name-directory (if insource
buffer-file-name-localized
(car frame)))))
((eq key ?l)
(setq subst (int-to-string
(if insource
(save-restriction
(widen)
(+ (count-lines (point-min) (point))
(if (bolp) 1 0)))
(cdr frame)))))
((eq key ?e)
(setq subst (gud-find-expr)))
((eq key ?a)
(setq subst (gud-read-address)))
((eq key ?c)
(setq subst
(gud-find-class
(if insource
(buffer-file-name)
(car frame))
(if insource
(save-restriction
(widen)
(+ (count-lines (point-min) (point))
(if (bolp) 1 0)))
(cdr frame)))))
((eq key ?p)
(setq subst (if arg (int-to-string arg)))))
(setq result (concat result (match-string 1 str) subst)))
(setq str (substring str (match-end 2))))
;; There might be text left in STR when the loop ends.
(concat result str)))