emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master b2fcba4: Revert "Add current-line in simple.el"


From: Nicolas Petton
Subject: [Emacs-diffs] master b2fcba4: Revert "Add current-line in simple.el"
Date: Mon, 19 Jun 2017 08:47:31 -0400 (EDT)

branch: master
commit b2fcba448486ced5c75e666a0ce964aebccf4aa5
Author: Nicolas Petton <address@hidden>
Commit: Nicolas Petton <address@hidden>

    Revert "Add current-line in simple.el"
    
    This reverts commit ae98cdf9431604d0f722f1db217ca06debfbb7b6.
---
 lisp/simple.el            | 29 +++++++++++-----------------
 test/lisp/simple-tests.el | 49 -----------------------------------------------
 2 files changed, 11 insertions(+), 67 deletions(-)

diff --git a/lisp/simple.el b/lisp/simple.el
index e3b7665..a5565ab 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1270,25 +1270,18 @@ and the greater of them is not at the start of a line."
                done)))
        (- (buffer-size) (forward-line (buffer-size)))))))
 
-(defun line-number-at-pos (&optional pos absolute-p)
-  "Return buffer line number at position POS.
+(defun line-number-at-pos (&optional pos)
+  "Return (narrowed) buffer line number at position POS.
 If POS is nil, use current buffer location.
-
-If ABSOLUTE-P is nil, the default, counting starts
-at (point-min), so the value refers to the contents of the
-accessible portion of the (potentially narrowed) buffer.  If
-ABSOLUTE-P is non-nil, ignore any narrowing and return the
-absolute line number."
-  (save-restriction
-    (when absolute-p
-      (widen))
-    (let ((opoint (or pos (point))) start)
-      (save-excursion
-        (goto-char (point-min))
-        (setq start (point))
-        (goto-char opoint)
-        (forward-line 0)
-        (1+ (count-lines start (point)))))))
+Counting starts at (point-min), so the value refers
+to the contents of the accessible portion of the buffer."
+  (let ((opoint (or pos (point))) start)
+    (save-excursion
+      (goto-char (point-min))
+      (setq start (point))
+      (goto-char opoint)
+      (forward-line 0)
+      (1+ (count-lines start (point))))))
 
 (defun what-cursor-position (&optional detail)
   "Print info on cursor position (on screen and within buffer).
diff --git a/test/lisp/simple-tests.el b/test/lisp/simple-tests.el
index ad7aee1..180dcc0 100644
--- a/test/lisp/simple-tests.el
+++ b/test/lisp/simple-tests.el
@@ -448,54 +448,5 @@ See Bug#21722."
         (call-interactively #'eval-expression)
         (should (equal (current-message) "66 (#o102, #x42, ?B)"))))))
 
-(ert-deftest line-number-at-pos-in-widen-buffer ()
-  (let ((target-line 3))
-    (with-temp-buffer
-      (insert "a\nb\nc\nd\n")
-      (goto-char (point-min))
-      (forward-line (1- target-line))
-      (should (equal (line-number-at-pos) target-line))
-      (should (equal (line-number-at-pos nil t) target-line)))))
-
-(ert-deftest line-number-at-pos-in-narrow-buffer ()
-  (let ((target-line 3))
-    (with-temp-buffer
-      (insert "a\nb\nc\nd\n")
-      (goto-char (point-min))
-      (forward-line (1- target-line))
-      (narrow-to-region (line-beginning-position) (line-end-position))
-      (should (equal (line-number-at-pos) 1))
-      (should (equal (line-number-at-pos nil t) target-line)))))
-
-(ert-deftest line-number-at-pos-keeps-restriction ()
-  (with-temp-buffer
-    (insert "a\nb\nc\nd\n")
-    (goto-char (point-min))
-    (forward-line 2)
-    (narrow-to-region (line-beginning-position) (line-end-position))
-    (should (equal (line-number-at-pos) 1))
-    (line-number-at-pos nil t)
-    (should (equal (line-number-at-pos) 1))))
-
-(ert-deftest line-number-at-pos-keeps-point ()
-  (let (pos)
-    (with-temp-buffer
-      (insert "a\nb\nc\nd\n")
-      (goto-char (point-min))
-      (forward-line 2)
-      (setq pos (point))
-      (line-number-at-pos)
-      (line-number-at-pos nil t)
-      (should (equal pos (point))))))
-
-(ert-deftest line-number-at-pos-when-passing-point ()
-  (let (pos)
-    (with-temp-buffer
-      (insert "a\nb\nc\nd\n")
-      (should (equal (line-number-at-pos 1) 1))
-      (should (equal (line-number-at-pos 3) 2))
-      (should (equal (line-number-at-pos 5) 3))
-      (should (equal (line-number-at-pos 7) 4)))))
-
 (provide 'simple-test)
 ;;; simple-test.el ends here



reply via email to

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