comparison lisp/simple.el @ 11479:266653a85b65

(line-move): Fix previous change: if we get an error, move to where the error happened, don't go back to starting point.
author Richard M. Stallman <rms@gnu.org>
date Tue, 18 Apr 1995 07:01:34 +0000
parents b51e4c4cb0de
children 09d49f6e0af9
comparison
equal deleted inserted replaced
11478:8a5fc4539429 11479:266653a85b65
1604 Outline mode sets this.") 1604 Outline mode sets this.")
1605 1605
1606 ;; This is the guts of next-line and previous-line. 1606 ;; This is the guts of next-line and previous-line.
1607 ;; Arg says how many lines to move. 1607 ;; Arg says how many lines to move.
1608 (defun line-move (arg) 1608 (defun line-move (arg)
1609 (let (new) 1609 ;; Don't run any point-motion hooks, and disregard intangibility,
1610 ;; Don't run any point-motion hooks, and disregard intangibility, 1610 ;; for intermediate positions.
1611 ;; for intermediate positions. 1611 (let ((inhibit-point-motion-hooks t)
1612 (let ((inhibit-point-motion-hooks t)) 1612 (opoint (point))
1613 (save-excursion 1613 new)
1614 (if (not (or (eq last-command 'next-line) 1614 (unwind-protect
1615 (eq last-command 'previous-line))) 1615 (progn
1616 (setq temporary-goal-column 1616 (if (not (or (eq last-command 'next-line)
1617 (if (and track-eol (eolp) 1617 (eq last-command 'previous-line)))
1618 ;; Don't count beg of empty line as end of line 1618 (setq temporary-goal-column
1619 ;; unless we just did explicit end-of-line. 1619 (if (and track-eol (eolp)
1620 (or (not (bolp)) (eq last-command 'end-of-line))) 1620 ;; Don't count beg of empty line as end of line
1621 9999 1621 ;; unless we just did explicit end-of-line.
1622 (current-column)))) 1622 (or (not (bolp)) (eq last-command 'end-of-line)))
1623 (if (and (not (integerp selective-display)) 1623 9999
1624 (not line-move-ignore-invisible)) 1624 (current-column))))
1625 ;; Use just newline characters. 1625 (if (and (not (integerp selective-display))
1626 (or (if (> arg 0) 1626 (not line-move-ignore-invisible))
1627 (progn (if (> arg 1) (forward-line (1- arg))) 1627 ;; Use just newline characters.
1628 ;; This way of moving forward ARG lines 1628 (or (if (> arg 0)
1629 ;; verifies that we have a newline after the last one. 1629 (progn (if (> arg 1) (forward-line (1- arg)))
1630 ;; It doesn't get confused by intangible text. 1630 ;; This way of moving forward ARG lines
1631 (end-of-line) 1631 ;; verifies that we have a newline after the last one.
1632 (zerop (forward-line 1))) 1632 ;; It doesn't get confused by intangible text.
1633 (and (zerop (forward-line arg)) 1633 (end-of-line)
1634 (bolp))) 1634 (zerop (forward-line 1)))
1635 (signal (if (< arg 0) 1635 (and (zerop (forward-line arg))
1636 'beginning-of-buffer 1636 (bolp)))
1637 'end-of-buffer) 1637 (signal (if (< arg 0)
1638 nil)) 1638 'beginning-of-buffer
1639 ;; Move by arg lines, but ignore invisible ones. 1639 'end-of-buffer)
1640 (while (> arg 0) 1640 nil))
1641 (end-of-line) 1641 ;; Move by arg lines, but ignore invisible ones.
1642 (and (zerop (vertical-motion 1)) 1642 (while (> arg 0)
1643 (signal 'end-of-buffer nil)) 1643 (end-of-line)
1644 ;; If the following character is currently invisible, 1644 (and (zerop (vertical-motion 1))
1645 ;; skip all characters with that same `invisible' property value. 1645 (signal 'end-of-buffer nil))
1646 (while (and (not (eobp)) 1646 ;; If the following character is currently invisible,
1647 (let ((prop 1647 ;; skip all characters with that same `invisible' property value.
1648 (get-char-property (point) 'invisible))) 1648 (while (and (not (eobp))
1649 (if (eq buffer-invisibility-spec t) 1649 (let ((prop
1650 prop 1650 (get-char-property (point) 'invisible)))
1651 (or (memq prop buffer-invisibility-spec) 1651 (if (eq buffer-invisibility-spec t)
1652 (assq prop buffer-invisibility-spec))))) 1652 prop
1653 (if (get-text-property (point) 'invisible) 1653 (or (memq prop buffer-invisibility-spec)
1654 (goto-char (next-single-property-change (point) 'invisible)) 1654 (assq prop buffer-invisibility-spec)))))
1655 (goto-char (next-overlay-change (point))))) 1655 (if (get-text-property (point) 'invisible)
1656 (setq arg (1- arg))) 1656 (goto-char (next-single-property-change (point) 'invisible))
1657 (while (< arg 0) 1657 (goto-char (next-overlay-change (point)))))
1658 (beginning-of-line) 1658 (setq arg (1- arg)))
1659 (and (zerop (vertical-motion -1)) 1659 (while (< arg 0)
1660 (signal 'beginning-of-buffer nil)) 1660 (beginning-of-line)
1661 (while (and (not (bobp)) 1661 (and (zerop (vertical-motion -1))
1662 (let ((prop 1662 (signal 'beginning-of-buffer nil))
1663 (get-char-property (1- (point)) 'invisible))) 1663 (while (and (not (bobp))
1664 (if (eq buffer-invisibility-spec t) 1664 (let ((prop
1665 prop 1665 (get-char-property (1- (point)) 'invisible)))
1666 (or (memq prop buffer-invisibility-spec) 1666 (if (eq buffer-invisibility-spec t)
1667 (assq prop buffer-invisibility-spec))))) 1667 prop
1668 (if (get-text-property (1- (point)) 'invisible) 1668 (or (memq prop buffer-invisibility-spec)
1669 (goto-char (previous-single-property-change (point) 'invisible)) 1669 (assq prop buffer-invisibility-spec)))))
1670 (goto-char (previous-overlay-change (point))))) 1670 (if (get-text-property (1- (point)) 'invisible)
1671 (setq arg (1+ arg)))) 1671 (goto-char (previous-single-property-change (point) 'invisible))
1672 (move-to-column (or goal-column temporary-goal-column)) 1672 (goto-char (previous-overlay-change (point)))))
1673 (setq new (point)))) 1673 (setq arg (1+ arg))))
1674 ;; Run any point-motion hooks, deal with intangible text, etc., 1674 (move-to-column (or goal-column temporary-goal-column)))
1675 ;; once and for all, for the entire motion we did. 1675 ;; Remember where we moved to, go back home,
1676 (goto-char new) 1676 ;; then do the motion over again
1677 nil)) 1677 ;; in just one step, with intangibility and point-motion hooks
1678 ;; enabled this time.
1679 (setq new (point))
1680 (goto-char opoint)
1681 (setq inhibit-point-motion-hooks nil)
1682 (goto-char new)))
1683 nil)
1678 1684
1679 ;;; Many people have said they rarely use this feature, and often type 1685 ;;; Many people have said they rarely use this feature, and often type
1680 ;;; it by accident. Maybe it shouldn't even be on a key. 1686 ;;; it by accident. Maybe it shouldn't even be on a key.
1681 (put 'set-goal-column 'disabled t) 1687 (put 'set-goal-column 'disabled t)
1682 1688