diff options
| author | Lars Ingebrigtsen | 2022-06-09 14:42:31 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2022-06-09 14:43:40 +0200 |
| commit | 39d2efbfae1dc081258a764f3c47f5f492f38fec (patch) | |
| tree | 91d8c5ccbe4fa28a45626b1866fb7c1ed3bb4e7c /src | |
| parent | 64b5fd2e435312346189852013c7504780f7c1d2 (diff) | |
| download | emacs-39d2efbfae1dc081258a764f3c47f5f492f38fec.tar.gz emacs-39d2efbfae1dc081258a764f3c47f5f492f38fec.zip | |
Make `line-number-at-pos' work more like in earlier Emacs versions
* src/fns.c (Fline_number_at_pos): Allow calling with position
outside the region if called with ABSOLUTE non-nil (bug#55847).
This isn't announced in the doc string, but makes function
compatible with the version in earlier Emacs versions.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fns.c | 7 |
1 files changed, 5 insertions, 2 deletions
| @@ -5869,9 +5869,12 @@ from the absolute start of the buffer, disregarding the narrowing. */) | |||
| 5869 | if (!NILP (absolute)) | 5869 | if (!NILP (absolute)) |
| 5870 | start = BEG_BYTE; | 5870 | start = BEG_BYTE; |
| 5871 | 5871 | ||
| 5872 | /* Check that POSITION is in the accessible range of the buffer. */ | 5872 | /* Check that POSITION is in the accessible range of the buffer, or, |
| 5873 | if (pos < BEGV || pos > ZV) | 5873 | if we're reporting absolute positions, in the buffer. */ |
| 5874 | if (NILP (absolute) && (pos < BEGV || pos > ZV)) | ||
| 5874 | args_out_of_range_3 (make_int (pos), make_int (BEGV), make_int (ZV)); | 5875 | args_out_of_range_3 (make_int (pos), make_int (BEGV), make_int (ZV)); |
| 5876 | else if (!NILP (absolute) && (pos < 1 || pos > Z)) | ||
| 5877 | args_out_of_range_3 (make_int (pos), make_int (1), make_int (Z)); | ||
| 5875 | 5878 | ||
| 5876 | return make_int (count_lines (start, CHAR_TO_BYTE (pos)) + 1); | 5879 | return make_int (count_lines (start, CHAR_TO_BYTE (pos)) + 1); |
| 5877 | } | 5880 | } |