diff options
| author | Lars Ingebrigtsen | 2021-02-07 16:02:56 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2021-02-07 16:03:02 +0100 |
| commit | 094a109b8eefbabbc99dba925ebec9887c101a91 (patch) | |
| tree | de1959ee43a6a1b8bda4de6b4ec781a8eccdd0a3 /test/src | |
| parent | 4e8d36fdaadade020f0bcadc70d617d8b07b739c (diff) | |
| download | emacs-094a109b8eefbabbc99dba925ebec9887c101a91.tar.gz emacs-094a109b8eefbabbc99dba925ebec9887c101a91.zip | |
Add a new function 'line-number-at-position'
* doc/lispref/positions.texi (Text Lines): Document it.
* lisp/simple.el (count-lines): Use it.
(line-number-at-pos): Ditto.
* src/fns.c (Fline_number_at_position): New function (bug#22763).
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/fns-tests.el | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el index e0aed2a71b6..3a43142106b 100644 --- a/test/src/fns-tests.el +++ b/test/src/fns-tests.el | |||
| @@ -1098,3 +1098,11 @@ | |||
| 1098 | (goto-char (point-max)) | 1098 | (goto-char (point-max)) |
| 1099 | (insert "fóo") | 1099 | (insert "fóo") |
| 1100 | (should (approx-equal (buffer-line-statistics) '(1002 50 49.9))))) | 1100 | (should (approx-equal (buffer-line-statistics) '(1002 50 49.9))))) |
| 1101 | |||
| 1102 | (ert-deftest test-line-number-at-position () | ||
| 1103 | (with-temp-buffer | ||
| 1104 | (insert (make-string 10 ?\n)) | ||
| 1105 | (should (= (line-number-at-position (point)) 11)) | ||
| 1106 | (should-error (line-number-at-position nil)) | ||
| 1107 | (should-error (line-number-at-position -1)) | ||
| 1108 | (should-error (line-number-at-position 100)))) | ||