diff options
Diffstat (limited to 'lisp/simple.el')
| -rw-r--r-- | lisp/simple.el | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index 67cd341bf1f..f07006b5cc8 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -887,7 +887,9 @@ and the greater of them is not at the start of a line." | |||
| 887 | 887 | ||
| 888 | (defun line-number-at-pos (&optional pos) | 888 | (defun line-number-at-pos (&optional pos) |
| 889 | "Return (narrowed) buffer line number at position POS. | 889 | "Return (narrowed) buffer line number at position POS. |
| 890 | If POS is nil, use current buffer location." | 890 | If POS is nil, use current buffer location. |
| 891 | Counting starts at (point-min), so the value refers | ||
| 892 | to the contents of the accessible portion of the buffer." | ||
| 891 | (let ((opoint (or pos (point))) start) | 893 | (let ((opoint (or pos (point))) start) |
| 892 | (save-excursion | 894 | (save-excursion |
| 893 | (goto-char (point-min)) | 895 | (goto-char (point-min)) |
| @@ -3689,7 +3691,10 @@ because what we really need is for `move-to-column' | |||
| 3689 | and `current-column' to be able to ignore invisible text." | 3691 | and `current-column' to be able to ignore invisible text." |
| 3690 | (if (zerop col) | 3692 | (if (zerop col) |
| 3691 | (beginning-of-line) | 3693 | (beginning-of-line) |
| 3692 | (move-to-column col)) | 3694 | (let ((opoint (point))) |
| 3695 | (move-to-column col) | ||
| 3696 | ;; move-to-column doesn't respect field boundaries. | ||
| 3697 | (goto-char (constrain-to-field (point) opoint)))) | ||
| 3693 | 3698 | ||
| 3694 | (when (and line-move-ignore-invisible | 3699 | (when (and line-move-ignore-invisible |
| 3695 | (not (bolp)) (line-move-invisible-p (1- (point)))) | 3700 | (not (bolp)) (line-move-invisible-p (1- (point)))) |
| @@ -3759,7 +3764,8 @@ To ignore intangibility, bind `inhibit-point-motion-hooks' to t." | |||
| 3759 | (interactive "p") | 3764 | (interactive "p") |
| 3760 | (or arg (setq arg 1)) | 3765 | (or arg (setq arg 1)) |
| 3761 | 3766 | ||
| 3762 | (let ((orig (point))) | 3767 | (let ((orig (point)) |
| 3768 | start first-vis first-vis-field-value) | ||
| 3763 | 3769 | ||
| 3764 | ;; Move by lines, if ARG is not 1 (the default). | 3770 | ;; Move by lines, if ARG is not 1 (the default). |
| 3765 | (if (/= arg 1) | 3771 | (if (/= arg 1) |
| @@ -3770,10 +3776,24 @@ To ignore intangibility, bind `inhibit-point-motion-hooks' to t." | |||
| 3770 | (while (and (not (bobp)) (line-move-invisible-p (1- (point)))) | 3776 | (while (and (not (bobp)) (line-move-invisible-p (1- (point)))) |
| 3771 | (goto-char (previous-char-property-change (point))) | 3777 | (goto-char (previous-char-property-change (point))) |
| 3772 | (skip-chars-backward "^\n")) | 3778 | (skip-chars-backward "^\n")) |
| 3773 | 3779 | (setq start (point)) | |
| 3774 | ;; Take care of fields. | 3780 | |
| 3775 | (goto-char (constrain-to-field (point) orig | 3781 | ;; Now find first visible char in the line |
| 3776 | (/= arg 1) t nil)))) | 3782 | (while (and (not (eobp)) (line-move-invisible-p (point))) |
| 3783 | (goto-char (next-char-property-change (point)))) | ||
| 3784 | (setq first-vis (point)) | ||
| 3785 | |||
| 3786 | ;; See if fields would stop us from reaching FIRST-VIS. | ||
| 3787 | (setq first-vis-field-value | ||
| 3788 | (constrain-to-field first-vis orig (/= arg 1) t nil)) | ||
| 3789 | |||
| 3790 | (goto-char (if (/= first-vis-field-value first-vis) | ||
| 3791 | ;; If yes, obey them. | ||
| 3792 | first-vis-field-value | ||
| 3793 | ;; Otherwise, move to START with attention to fields. | ||
| 3794 | ;; (It is possible that fields never matter in this case.) | ||
| 3795 | (constrain-to-field (point) orig | ||
| 3796 | (/= arg 1) t nil))))) | ||
| 3777 | 3797 | ||
| 3778 | 3798 | ||
| 3779 | ;;; Many people have said they rarely use this feature, and often type | 3799 | ;;; Many people have said they rarely use this feature, and often type |