emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 39d2efbfae: Make `line-number-at-pos' work more like in earlier E


From: Lars Ingebrigtsen
Subject: master 39d2efbfae: Make `line-number-at-pos' work more like in earlier Emacs versions
Date: Thu, 9 Jun 2022 08:43:46 -0400 (EDT)

branch: master
commit 39d2efbfae1dc081258a764f3c47f5f492f38fec
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    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.
---
 src/fns.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/fns.c b/src/fns.c
index 2c206c62b2..fceab9ba0c 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -5869,9 +5869,12 @@ from the absolute start of the buffer, disregarding the 
narrowing.  */)
   if (!NILP (absolute))
     start = BEG_BYTE;
 
-  /* Check that POSITION is in the accessible range of the buffer. */
-  if (pos < BEGV || pos > ZV)
+  /* Check that POSITION is in the accessible range of the buffer, or,
+     if we're reporting absolute positions, in the buffer. */
+  if (NILP (absolute) && (pos < BEGV || pos > ZV))
     args_out_of_range_3 (make_int (pos), make_int (BEGV), make_int (ZV));
+  else if (!NILP (absolute) && (pos < 1 || pos > Z))
+    args_out_of_range_3 (make_int (pos), make_int (1), make_int (Z));
 
   return make_int (count_lines (start, CHAR_TO_BYTE (pos)) + 1);
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]