blob: 6325d81b7863149a2aa132f53eeec3dd8743cd10 (
plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
;;; hide-cursor-mode.el --- Hide the cursor and scroll-lock -*- lexical-binding: t; -*-
;;; Commentary:
;; From Karthik: https://karthinks.com/software/more-less-emacs/
;;; Code:
(defvar-local hide-cursor--original nil)
(progn
(progn :autoload-end
(defvar-local hide-cursor-mode nil "Non-nil if Hide-Cursor mode is enabled.
Use the command `hide-cursor-mode' to change this variable."))
(defun hide-cursor-mode
(&optional arg)
"Hide or show the cursor.
This is a minor mode. If called interactively, toggle the
`Hide-Cursor mode' mode. If the prefix argument is positive,
enable the mode, and if it is zero or negative, disable the mode.
If called from Lisp, toggle the mode if ARG is `toggle'. Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.
To check whether the minor mode is enabled in the current buffer,
evaluate `hide-cursor-mode'.
The mode's hook is called both when the mode is enabled and when
it is disabled.
When the cursor is hidden `scroll-lock-mode' is enabled, so that
the buffer works like a pager."
(interactive
(list
(if current-prefix-arg
(prefix-numeric-value current-prefix-arg)
'toggle)))
(let
((last-message
(current-message)))
(setq hide-cursor-mode
(cond
((eq arg 'toggle)
(not hide-cursor-mode))
((and
(numberp arg)
(< arg 1))
nil)
(t t)))
(when
(boundp 'local-minor-modes)
(setq local-minor-modes
(delq 'hide-cursor-mode local-minor-modes))
(when hide-cursor-mode
(push 'hide-cursor-mode local-minor-modes)))
(if hide-cursor-mode
(progn
(scroll-lock-mode 1)
(setq-local hide-cursor--original cursor-type)
(setq-local cursor-type nil))
(scroll-lock-mode -1)
(setq-local cursor-type
(or hide-cursor--original t)))
(run-hooks 'hide-cursor-mode-hook
(if hide-cursor-mode 'hide-cursor-mode-on-hook 'hide-cursor-mode-off-hook))
(if
(called-interactively-p 'any)
(progn nil
(unless
(and
(current-message)
(not
(equal last-message
(current-message))))
(let
((local " in current buffer"))
(message "Hide-Cursor mode %sabled%s"
(if hide-cursor-mode "en" "dis")
local))))))
(force-mode-line-update)
hide-cursor-mode)
:autoload-end
(defvar hide-cursor-mode-hook nil)
(unless
(get 'hide-cursor-mode-hook 'variable-documentation)
(put 'hide-cursor-mode-hook 'variable-documentation "Hook run after entering or leaving `hide-cursor-mode'.
No problems result if this variable is not bound.
`add-hook' automatically binds it. (This is true for all hook variables.)"))
(put 'hide-cursor-mode-hook 'custom-type 'hook)
(put 'hide-cursor-mode-hook 'standard-value
(list nil))
(defvar hide-cursor-mode-map
(let
((m
(let
((map
(make-sparse-keymap)))
(define-key map
[f7]
(function hide-cursor-mode))
map)))
(cond
((keymapp m)
m)
((listp m)
(easy-mmode-define-keymap m))
(t
(error "Invalid keymap %S" m))))
"Keymap for `hide-cursor-mode'.")
(with-no-warnings
(add-minor-mode 'hide-cursor-mode '"H" hide-cursor-mode-map nil nil)))
(provide 'hide-cursor-mode)
;;; hide-cursor-mode.el ends here
|