diff options
| author | Richard M. Stallman | 1996-09-13 21:58:23 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1996-09-13 21:58:23 +0000 |
| commit | ab4b0d2f59ae74877a8cdc7d564383fbd0786667 (patch) | |
| tree | 36c25cb464b9ee4c02d5b2071c96139a29b43f76 | |
| parent | 8adfc1ec004362696a990b823f269e6ccc7cc622 (diff) | |
| download | emacs-ab4b0d2f59ae74877a8cdc7d564383fbd0786667.tar.gz emacs-ab4b0d2f59ae74877a8cdc7d564383fbd0786667.zip | |
(gud-find-c-expr): Renamed from find-c-expr.
Don't get fooled by if and while statements.
(gud-expr-compound): Renamed from expr-compound.
(gud-expr-compound-sep): Renamed from expr-compound-sep.
(gud-next-expr): Renamed from expr-next.
(gud-prev-expr): Renamed from expr-prev.
(gud-forward-sexp): Renamed from expr-forward-sexp.
(gud-backward-sexp): Renamed from expr-backward-sexp.
(gud-innermost-expr): Renamed from expr-cur.
| -rw-r--r-- | lisp/gud.el | 95 |
1 files changed, 51 insertions, 44 deletions
diff --git a/lisp/gud.el b/lisp/gud.el index 281ceb50573..8d7fc1f95a5 100644 --- a/lisp/gud.el +++ b/lisp/gud.el | |||
| @@ -1403,7 +1403,7 @@ Obeying it means displaying in another window the specified file and line." | |||
| 1403 | (1+ (count-lines 1 (point))))) | 1403 | (1+ (count-lines 1 (point))))) |
| 1404 | (cdr frame)))) | 1404 | (cdr frame)))) |
| 1405 | ((eq key ?e) | 1405 | ((eq key ?e) |
| 1406 | (setq subst (find-c-expr))) | 1406 | (setq subst (gud-find-c-expr))) |
| 1407 | ((eq key ?a) | 1407 | ((eq key ?a) |
| 1408 | (setq subst (gud-read-address))) | 1408 | (setq subst (gud-read-address))) |
| 1409 | ((eq key ?p) | 1409 | ((eq key ?p) |
| @@ -1470,94 +1470,102 @@ Obeying it means displaying in another window the specified file and line." | |||
| 1470 | ;;; Debby Ayers <ayers@asc.slb.com>, | 1470 | ;;; Debby Ayers <ayers@asc.slb.com>, |
| 1471 | ;;; Rich Schaefer <schaefer@asc.slb.com> Schlumberger, Austin, Tx. | 1471 | ;;; Rich Schaefer <schaefer@asc.slb.com> Schlumberger, Austin, Tx. |
| 1472 | 1472 | ||
| 1473 | (defun find-c-expr () | 1473 | (defun gud-find-c-expr () |
| 1474 | "Returns the C expr that surrounds point." | 1474 | "Returns the C expr that surrounds point." |
| 1475 | (interactive) | 1475 | (interactive) |
| 1476 | (save-excursion | 1476 | (save-excursion |
| 1477 | (let ((p) (expr) (test-expr)) | 1477 | (let (p expr test-expr) |
| 1478 | (setq p (point)) | 1478 | (setq p (point)) |
| 1479 | (setq expr (expr-cur)) | 1479 | (setq expr (gud-innermost-expr)) |
| 1480 | (setq test-expr (expr-prev)) | 1480 | (setq test-expr (gud-prev-expr)) |
| 1481 | (while (expr-compound test-expr expr) | 1481 | (while (and test-expr (gud-expr-compound test-expr expr)) |
| 1482 | (setq expr (cons (car test-expr) (cdr expr))) | 1482 | (let ((prev-expr expr)) |
| 1483 | (goto-char (car expr)) | 1483 | (setq expr (cons (car test-expr) (cdr expr))) |
| 1484 | (setq test-expr (expr-prev))) | 1484 | (goto-char (car expr)) |
| 1485 | (setq test-expr (gud-prev-expr)) | ||
| 1486 | ;; If we just pasted on the condition of an if or while, | ||
| 1487 | ;; throw it away again. | ||
| 1488 | (if (member (buffer-substring (car test-expr) (cdr test-expr)) | ||
| 1489 | '("if" "while" "for")) | ||
| 1490 | (setq test-expr nil | ||
| 1491 | expr prev-expr)))) | ||
| 1485 | (goto-char p) | 1492 | (goto-char p) |
| 1486 | (setq test-expr (expr-next)) | 1493 | (setq test-expr (gud-next-expr)) |
| 1487 | (while (expr-compound expr test-expr) | 1494 | (while (gud-expr-compound expr test-expr) |
| 1488 | (setq expr (cons (car expr) (cdr test-expr))) | 1495 | (setq expr (cons (car expr) (cdr test-expr))) |
| 1489 | (setq test-expr (expr-next)) | 1496 | (setq test-expr (gud-next-expr)) |
| 1490 | ) | 1497 | ) |
| 1491 | (buffer-substring (car expr) (cdr expr))))) | 1498 | (buffer-substring (car expr) (cdr expr))))) |
| 1492 | 1499 | ||
| 1493 | (defun expr-cur () | 1500 | (defun gud-innermost-expr () |
| 1494 | "Returns the expr that point is in; point is set to beginning of expr. | 1501 | "Returns the smallest expr that point is in; move point to beginning of it. |
| 1495 | The expr is represented as a cons cell, where the car specifies the point in | 1502 | The expr is represented as a cons cell, where the car specifies the point in |
| 1496 | the current buffer that marks the beginning of the expr and the cdr specifies | 1503 | the current buffer that marks the beginning of the expr and the cdr specifies |
| 1497 | the character after the end of the expr." | 1504 | the character after the end of the expr." |
| 1498 | (let ((p (point)) (begin) (end)) | 1505 | (let ((p (point)) begin end) |
| 1499 | (expr-backward-sexp) | 1506 | (gud-backward-sexp) |
| 1500 | (setq begin (point)) | 1507 | (setq begin (point)) |
| 1501 | (expr-forward-sexp) | 1508 | (gud-forward-sexp) |
| 1502 | (setq end (point)) | 1509 | (setq end (point)) |
| 1503 | (if (>= p end) | 1510 | (if (>= p end) |
| 1504 | (progn | 1511 | (progn |
| 1505 | (setq begin p) | 1512 | (setq begin p) |
| 1506 | (goto-char p) | 1513 | (goto-char p) |
| 1507 | (expr-forward-sexp) | 1514 | (gud-forward-sexp) |
| 1508 | (setq end (point)) | 1515 | (setq end (point))) |
| 1509 | ) | ||
| 1510 | ) | 1516 | ) |
| 1511 | (goto-char begin) | 1517 | (goto-char begin) |
| 1512 | (cons begin end))) | 1518 | (cons begin end))) |
| 1513 | 1519 | ||
| 1514 | (defun expr-backward-sexp () | 1520 | (defun gud-backward-sexp () |
| 1515 | "Version of `backward-sexp' that catches errors." | 1521 | "Version of `backward-sexp' that catches errors." |
| 1516 | (condition-case nil | 1522 | (condition-case nil |
| 1517 | (backward-sexp) | 1523 | (backward-sexp) |
| 1518 | (error t))) | 1524 | (error t))) |
| 1519 | 1525 | ||
| 1520 | (defun expr-forward-sexp () | 1526 | (defun gud-forward-sexp () |
| 1521 | "Version of `forward-sexp' that catches errors." | 1527 | "Version of `forward-sexp' that catches errors." |
| 1522 | (condition-case nil | 1528 | (condition-case nil |
| 1523 | (forward-sexp) | 1529 | (forward-sexp) |
| 1524 | (error t))) | 1530 | (error t))) |
| 1525 | 1531 | ||
| 1526 | (defun expr-prev () | 1532 | (defun gud-prev-expr () |
| 1527 | "Returns the previous expr, point is set to beginning of that expr. | 1533 | "Returns the previous expr, point is set to beginning of that expr. |
| 1528 | The expr is represented as a cons cell, where the car specifies the point in | 1534 | The expr is represented as a cons cell, where the car specifies the point in |
| 1529 | the current buffer that marks the beginning of the expr and the cdr specifies | 1535 | the current buffer that marks the beginning of the expr and the cdr specifies |
| 1530 | the character after the end of the expr" | 1536 | the character after the end of the expr" |
| 1531 | (let ((begin) (end)) | 1537 | (let ((begin) (end)) |
| 1532 | (expr-backward-sexp) | 1538 | (gud-backward-sexp) |
| 1533 | (setq begin (point)) | 1539 | (setq begin (point)) |
| 1534 | (expr-forward-sexp) | 1540 | (gud-forward-sexp) |
| 1535 | (setq end (point)) | 1541 | (setq end (point)) |
| 1536 | (goto-char begin) | 1542 | (goto-char begin) |
| 1537 | (cons begin end))) | 1543 | (cons begin end))) |
| 1538 | 1544 | ||
| 1539 | (defun expr-next () | 1545 | (defun gud-next-expr () |
| 1540 | "Returns the following expr, point is set to beginning of that expr. | 1546 | "Returns the following expr, point is set to beginning of that expr. |
| 1541 | The expr is represented as a cons cell, where the car specifies the point in | 1547 | The expr is represented as a cons cell, where the car specifies the point in |
| 1542 | the current buffer that marks the beginning of the expr and the cdr specifies | 1548 | the current buffer that marks the beginning of the expr and the cdr specifies |
| 1543 | the character after the end of the expr." | 1549 | the character after the end of the expr." |
| 1544 | (let ((begin) (end)) | 1550 | (let ((begin) (end)) |
| 1545 | (expr-forward-sexp) | 1551 | (gud-forward-sexp) |
| 1546 | (expr-forward-sexp) | 1552 | (gud-forward-sexp) |
| 1547 | (setq end (point)) | 1553 | (setq end (point)) |
| 1548 | (expr-backward-sexp) | 1554 | (gud-backward-sexp) |
| 1549 | (setq begin (point)) | 1555 | (setq begin (point)) |
| 1550 | (cons begin end))) | 1556 | (cons begin end))) |
| 1551 | 1557 | ||
| 1552 | (defun expr-compound-sep (span-start span-end) | 1558 | (defun gud-expr-compound-sep (span-start span-end) |
| 1553 | "Returns '.' for '->' & '.', returns ' ' for white space, | 1559 | "Scan from SPAN-START to SPAN-END for punctuation characters. |
| 1554 | returns '?' for other punctuation." | 1560 | If `->' is found, return `?.'. If `.' is found, return `?.'. |
| 1555 | (let ((result ? ) | 1561 | If any other punctuation is found, return `??'. |
| 1562 | If no punctuation is found, return `? '." | ||
| 1563 | (let ((result ?\ ) | ||
| 1556 | (syntax)) | 1564 | (syntax)) |
| 1557 | (while (< span-start span-end) | 1565 | (while (< span-start span-end) |
| 1558 | (setq syntax (char-syntax (char-after span-start))) | 1566 | (setq syntax (char-syntax (char-after span-start))) |
| 1559 | (cond | 1567 | (cond |
| 1560 | ((= syntax ? ) t) | 1568 | ((= syntax ?\ ) t) |
| 1561 | ((= syntax ?.) (setq syntax (char-after span-start)) | 1569 | ((= syntax ?.) (setq syntax (char-after span-start)) |
| 1562 | (cond | 1570 | (cond |
| 1563 | ((= syntax ?.) (setq result ?.)) | 1571 | ((= syntax ?.) (setq result ?.)) |
| @@ -1569,8 +1577,8 @@ returns '?' for other punctuation." | |||
| 1569 | (setq span-start (+ span-start 1))) | 1577 | (setq span-start (+ span-start 1))) |
| 1570 | result)) | 1578 | result)) |
| 1571 | 1579 | ||
| 1572 | (defun expr-compound (first second) | 1580 | (defun gud-expr-compound (first second) |
| 1573 | "Non-nil if concatenating FIRST and SECOND makes a single C token. | 1581 | "Non-nil if concatenating FIRST and SECOND makes a single C expression. |
| 1574 | The two exprs are represented as a cons cells, where the car | 1582 | The two exprs are represented as a cons cells, where the car |
| 1575 | specifies the point in the current buffer that marks the beginning of the | 1583 | specifies the point in the current buffer that marks the beginning of the |
| 1576 | expr and the cdr specifies the character after the end of the expr. | 1584 | expr and the cdr specifies the character after the end of the expr. |
| @@ -1584,21 +1592,20 @@ Link exprs of the form: | |||
| 1584 | (let ((span-start (cdr first)) | 1592 | (let ((span-start (cdr first)) |
| 1585 | (span-end (car second)) | 1593 | (span-end (car second)) |
| 1586 | (syntax)) | 1594 | (syntax)) |
| 1587 | (setq syntax (expr-compound-sep span-start span-end)) | 1595 | (setq syntax (gud-expr-compound-sep span-start span-end)) |
| 1588 | (cond | 1596 | (cond |
| 1589 | ((= (car first) (car second)) nil) | 1597 | ((= (car first) (car second)) nil) |
| 1590 | ((= (cdr first) (cdr second)) nil) | 1598 | ((= (cdr first) (cdr second)) nil) |
| 1591 | ((= syntax ?.) t) | 1599 | ((= syntax ?.) t) |
| 1592 | ((= syntax ? ) | 1600 | ((= syntax ?\ ) |
| 1593 | (setq span-start (char-after (- span-start 1))) | 1601 | (setq span-start (char-after (- span-start 1))) |
| 1594 | (setq span-end (char-after span-end)) | 1602 | (setq span-end (char-after span-end)) |
| 1595 | (cond | 1603 | (cond |
| 1596 | ((= span-start ?) ) t ) | 1604 | ((= span-start ?)) t) |
| 1597 | ((= span-start ?] ) t ) | 1605 | ((= span-start ?]) t) |
| 1598 | ((= span-end ?( ) t ) | 1606 | ((= span-end ?() t) |
| 1599 | ((= span-end ?[ ) t ) | 1607 | ((= span-end ?[) t) |
| 1600 | (t nil)) | 1608 | (t nil))) |
| 1601 | ) | ||
| 1602 | (t nil)))) | 1609 | (t nil)))) |
| 1603 | 1610 | ||
| 1604 | (provide 'gud) | 1611 | (provide 'gud) |