-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscroll.el
49 lines (39 loc) · 1.58 KB
/
scroll.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
(autoload 'View-scroll-half-page-forward "view")
(autoload 'View-scroll-half-page-backward "view")
(global-set-key (kbd "C-v") 'View-scroll-half-page-forward)
(global-set-key (kbd "M-v") 'View-scroll-half-page-backward)
(global-set-key (kbd "C-M-v")
'my-View-scroll-half-page-forward-other-window)
(global-set-key (kbd "C-M-S-v")
'my-View-scroll-half-page-backward-other-window)
(defun my-View-scroll-half-page-forward-other-window ()
(interactive)
(with-selected-window (next-window)
(call-interactively 'View-scroll-half-page-forward)))
(defun my-View-scroll-half-page-backward-other-window ()
(interactive)
(with-selected-window (next-window)
(call-interactively 'View-scroll-half-page-backward)))
(setq scroll-preserve-screen-position 'always)
(advice-add #'View-scroll-half-page-forward :around
#'my-indicate-scroll-forward)
(advice-add #'View-scroll-half-page-backward :around
#'my-indicate-scroll-backward)
(defun my-indicate-scroll-get-line (pos)
(save-excursion
(goto-char pos)
(string-to-number (format-mode-line "%l"))))
(defun my-indicate-scroll (linep f args)
(let ((linen (my-indicate-scroll-get-line linep))
(pulse-delay 0.1))
(set-transient-map
`(keymap (?v . ,real-this-command)))
(save-excursion
(goto-line linen)
(pulse-momentary-highlight-one-line (point) 'highlight))
(sit-for 0.1)
(apply f args)))
(defun my-indicate-scroll-forward (f &rest args)
(my-indicate-scroll (1- (window-end)) f args))
(defun my-indicate-scroll-backward (f &rest args)
(my-indicate-scroll (window-start) f args))