aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMarco Wahl2019-07-04 22:32:44 +0200
committerEli Zaretskii2019-07-14 09:23:20 +0300
commit352530ee0a52153a7936864275dce7f89e070a15 (patch)
treead132f6c5f219c2fbddeae0b148efc9f487822ca /test
parent474bd9d4a0f57c55d8c7ab435885804062992d0f (diff)
downloademacs-352530ee0a52153a7936864275dce7f89e070a15.tar.gz
emacs-352530ee0a52153a7936864275dce7f89e070a15.zip
New function for scroll-lock-mode to almost always scroll
* lisp/scroll-lock.el (scroll-lock-next-line-always-scroll): New function. Opposed to scroll-lock-next-line it does not switch to forward-line at eob. S-down is the default key binding for this function. (Bug#36494) * test/lisp/scroll-lock-tests.el: A few tests for scroll-lock-next-line-always-scroll. * etc/NEWS: Announce the new command.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/scroll-lock-tests.el68
1 files changed, 68 insertions, 0 deletions
diff --git a/test/lisp/scroll-lock-tests.el b/test/lisp/scroll-lock-tests.el
new file mode 100644
index 00000000000..f1ffeed2654
--- /dev/null
+++ b/test/lisp/scroll-lock-tests.el
@@ -0,0 +1,68 @@
1;;; scroll-lock-tests.el --- Test suite for scroll-lock -*- lexical-binding: t -*-
2
3;; Copyright (C) 2019 Free Software Foundation, Inc.
4
5;; This file is part of GNU Emacs.
6
7;; GNU Emacs is free software: you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation, either version 3 of the License, or
10;; (at your option) any later version.
11
12;; GNU Emacs is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16
17;; You should have received a copy of the GNU General Public License
18;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
19
20;;; Code:
21
22(require 'ert)
23(require 'scroll-lock)
24
25
26(defun point-in-window-line-p (n)
27 "Return if point is in window line N.
28Meaning of N as in `move-to-window-line'.
29Precondition: the line N must be available in the window."
30 (save-excursion
31 (let ((point (progn (beginning-of-line) (point))))
32 (let ((moved-to-line (move-to-window-line n)))
33 (cl-assert (= n moved-to-line) t "precondition violation"))
34 (= point (progn (beginning-of-line) (point))))))
35
36
37(ert-deftest scroll-lock-next-line-always-scroll-1 ()
38 "Point stays in top line."
39 (with-temp-buffer
40 (insert "\n\n\n")
41 (goto-char (point-min))
42 (switch-to-buffer (current-buffer))
43 (scroll-lock-next-line-always-scroll)
44 (should (point-in-window-line-p 0))))
45
46(ert-deftest scroll-lock-next-line-always-scroll-2 ()
47 "Point stays in second line."
48 (with-temp-buffer
49 (scroll-lock-mode)
50 (insert "\n\n\n")
51 (goto-char (1+ (point-min)))
52 (switch-to-buffer (current-buffer))
53 (scroll-lock-next-line-always-scroll)
54 (should (point-in-window-line-p 1))))
55
56(ert-deftest scroll-lock-next-line-always-scroll-3 ()
57 "Point stays in second line when scrolling beyond the number of buffer lines."
58 (with-temp-buffer
59 (scroll-lock-mode)
60 (insert (make-string 1000 ?\n))
61 (goto-char (1+ (point-min)))
62 (switch-to-buffer (current-buffer))
63 (scroll-lock-next-line-always-scroll 1234)
64 (should (point-in-window-line-p 1))))
65
66(provide 'scroll-lock-tests)
67
68;;; scroll-lock-tests.el ends here