Function: gud-find-c-expr
gud-find-c-expr is an interactive and byte-compiled function defined
in gud.el.gz.
Signature
(gud-find-c-expr)
Documentation
Return the expr that surrounds point.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/gud.el.gz
;; The next eight functions are hacked from gdbsrc.el by
;; Debby Ayers <ayers@asc.slb.com>,
;; Rich Schaefer <schaefer@asc.slb.com> Schlumberger, Austin, Tx.
(defun gud-find-c-expr ()
"Return the expr that surrounds point."
(interactive)
(save-excursion
(let ((p (point))
(expr (gud-innermost-expr))
(test-expr (gud-prev-expr)))
(while (and test-expr (gud-expr-compound test-expr expr))
(let ((prev-expr expr))
(setq expr (cons (car test-expr) (cdr expr)))
(goto-char (car expr))
(setq test-expr (gud-prev-expr))
;; If we just pasted on the condition of an if or while,
;; throw it away again.
(if (member (buffer-substring (car test-expr) (cdr test-expr))
'("if" "while" "for"))
(setq test-expr nil
expr prev-expr))))
(goto-char p)
(setq test-expr (gud-next-expr))
(while (gud-expr-compound expr test-expr)
(setq expr (cons (car expr) (cdr test-expr)))
(setq test-expr (gud-next-expr)))
(buffer-substring (car expr) (cdr expr)))))