+ (recenter arg)
+ (gud-display-frame))
+
+;;; Code for parsing expressions out of C code. The single entry point is
+;;; find-c-expr, which tries to return an lvalue expression from around point.
+;;;
+;;; The rest of this file is a hacked version of gdbsrc.el by
+;;; Debby Ayers <ayers@asc.slb.com>,
+;;; Rich Schaefer <schaefer@asc.slb.com> Schlumberger, Austin, Tx.
+;;; ??? We're waiting on papers from these people
+
+(defun find-c-expr ()
+ "Returns the C expr that surrounds point."
+ (interactive)
+ (save-excursion
+ (let ((p) (expr) (test-expr))
+ (setq p (point))
+ (setq expr (expr-cur))
+ (setq test-expr (expr-prev))
+ (while (expr-compound test-expr expr)
+ (setq expr (cons (car test-expr) (cdr expr)))
+ (goto-char (car expr))
+ (setq test-expr (expr-prev))
+ )
+ (goto-char p)
+ (setq test-expr (expr-next))
+ (while (expr-compound expr test-expr)
+ (setq expr (cons (car expr) (cdr test-expr)))
+ (setq test-expr (expr-next))
+ )
+ (buffer-substring (car expr) (cdr expr))
+ )
+ )
+ )
+
+(defun expr-cur ()
+ "Returns the expr that point is in; point is set to beginning of expr.
+The expr is represented as a cons cell, where the car specifies the point in
+the current buffer that marks the beginning of the expr and the cdr specifies
+the character after the end of the expr"
+ (let ((p (point)) (begin) (end))
+ (back-expr)
+ (setq begin (point))
+ (forw-expr)
+ (setq end (point))
+ (if (>= p end)
+ (progn
+ (setq begin p)
+ (goto-char p)
+ (forw-expr)
+ (setq end (point))
+ )
+ )
+ (goto-char begin)
+ (cons begin end)
+ )
+ )
+
+(defun back-expr ()
+ "Version of backward-sexp that catches errors"
+ (condition-case nil
+ (backward-sexp)
+ (error t)))
+
+(defun forw-expr ()
+ "Version of forward-sexp that catches errors"
+ (condition-case nil
+ (forward-sexp)
+ (error t)))
+
+(defun expr-prev ()
+ "Returns the previous expr, point is set to beginning of that expr.
+The expr is represented as a cons cell, where the car specifies the point in
+the current buffer that marks the beginning of the expr and the cdr specifies
+the character after the end of the expr"
+ (let ((begin) (end))
+ (back-expr)
+ (setq begin (point))
+ (forw-expr)
+ (setq end (point))
+ (goto-char begin)
+ (cons begin end)))
+
+(defun expr-next ()
+ "Returns the following expr, point is set to beginning of that expr.
+The expr is represented as a cons cell, where the car specifies the point in
+the current buffer that marks the beginning of the expr and the cdr specifies
+the character after the end of the expr"
+ (let ((begin) (end))
+ (forw-expr)
+ (forw-expr)
+ (setq end (point))
+ (back-expr)
+ (setq begin (point))
+ (cons begin end)
+ )
+ )
+
+(defun expr-compound-sep (span-start span-end)
+ "Returns '.' for '->' & '.', returns ' ' for white space,
+returns '?' for other puctuation."
+ (let ((result ? )
+ (syntax))
+ (while (< span-start span-end)
+ (setq syntax (char-syntax (char-after span-start)))
+ (cond
+ ((= syntax ? ) t)
+ ((= syntax ?.) (setq syntax (char-after span-start))
+ (cond
+ ((= syntax ?.) (setq result ?.))
+ ((and (= syntax ?-) (= (char-after (+ span-start 1)) ?>))
+ (setq result ?.)
+ (setq span-start (+ span-start 1)))
+ (t (setq span-start span-end)
+ (setq result ??)))))
+ (setq span-start (+ span-start 1)))
+ result
+ )
+ )
+
+(defun expr-compound (first second)
+ "Returns non-nil if the concatenation of two exprs results in a single C
+token. The two exprs are represented as a cons cells, where the car
+specifies the point in the current buffer that marks the beginning of the
+expr and the cdr specifies the character after the end of the expr
+Link exprs of the form:
+ Expr -> Expr
+ Expr . Expr
+ Expr (Expr)
+ Expr [Expr]
+ (Expr) Expr
+ [Expr] Expr"
+ (let ((span-start (cdr first))
+ (span-end (car second))
+ (syntax))
+ (setq syntax (expr-compound-sep span-start span-end))
+ (cond
+ ((= (car first) (car second)) nil)
+ ((= (cdr first) (cdr second)) nil)
+ ((= syntax ?.) t)
+ ((= syntax ? )
+ (setq span-start (char-after (- span-start 1)))
+ (setq span-end (char-after span-end))
+ (cond
+ ((= span-start ?) ) t )
+ ((= span-start ?] ) t )
+ ((= span-end ?( ) t )
+ ((= span-end ?[ ) t )
+ (t nil))
+ )
+ (t nil))
+ )
+ )
+
+;;; There appears to be a bug in the byte compiler somewhere near macro
+;;; handling that (a) generates a spurious message about gud-key-prefix
+;;; when the global-set-key clause in gud-def is compiled, (b) generates
+;;; incorrect bytecode for gud-def. The symptom of this incorrectness
+;;; is that loading gud.elc brings in a compiled gud-def that doesn't
+;;; properly perform both global (C-x C-a) and local (C-c) bindings.
+;;; The workaround is to always load from source. Consequently, we try
+;;; to disable byte-compilation here.
+;;;
+;;; Local Variables:
+;;; no-byte-compile: t
+;;; End: