-
Notifications
You must be signed in to change notification settings - Fork 37
/
evil-mc-cursor-state.el
157 lines (119 loc) · 6.01 KB
/
evil-mc-cursor-state.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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
;;; evil-mc-cursor-state.el --- State saved for each fake cursor -*- lexical-binding: t; -*-
;;; Commentary:
;; This file contains functions to interact with the state of a fake cursor
(require 'evil-mc-common)
;;; Code:
;; This module is loaded after `evil-mc-vars'
(defvar evil-mc-cursor-variables)
(defun evil-mc-get-cursor-variables (&optional categories)
"Gets the cursor variable names associated with CATEGORIES.
If CATEGORIES is nil return all cursor variables."
(cond ((null categories)
(apply 'append (mapcar 'cdr evil-mc-cursor-variables)))
((atom categories)
(evil-mc-get-object-property evil-mc-cursor-variables categories))
(t (apply 'append (mapcar (lambda (category)
(evil-mc-get-object-property
evil-mc-cursor-variables
category))
categories)))))
(defun evil-mc-get-cursor-property (cursor name)
"Return the value of the CURSOR property with NAME."
(when cursor (evil-mc-get-object-property cursor name)))
(defun evil-mc-put-cursor-property (cursor &rest properties)
"Return a new CURSOR that has one or more PROPERTIES set to the specified values."
(apply 'evil-mc-put-object-property (cons cursor properties)))
(defun evil-mc-get-cursor-properties (cursor properties)
"Return the values of all CURSOR PROPERTIES as a list."
(when cursor
(mapcar (lambda (prop) (evil-mc-get-object-property cursor prop))
properties)))
(defun evil-mc-get-cursor-overlay (cursor)
"Get the overlay for CURSOR."
(evil-mc-get-cursor-property cursor 'overlay))
(defun evil-mc-put-cursor-overlay (cursor overlay)
"Set the overlay for CURSOR to OVERLAY."
(evil-mc-put-cursor-property cursor 'overlay overlay))
(defun evil-mc-get-cursor-last-position (cursor)
"Get the last-position for CURSOR."
(evil-mc-get-cursor-property cursor 'last-position))
(defun evil-mc-put-cursor-last-position (cursor last-position)
"Set the last-position for CURSOR to LAST-POSITION."
(evil-mc-put-cursor-property cursor 'last-position last-position))
(defun evil-mc-get-cursor-undo-stack (cursor)
"Get the undo-stack for CURSOR."
(evil-mc-get-cursor-property cursor 'undo-stack))
(defun evil-mc-put-cursor-undo-stack (cursor undo-stack)
"Set the undo-stack for CURSOR to UNDO-STACK."
(evil-mc-put-cursor-property cursor 'undo-stack undo-stack))
(defun evil-mc-get-cursor-undo-stack-pointer (cursor)
"Get the undo-stack-pointer for CURSOR."
(evil-mc-get-cursor-property cursor 'undo-stack-pointer))
(defun evil-mc-put-cursor-undo-stack-pointer (cursor undo-stack-pointer)
"Set the undo-stack-pointer for CURSOR to UNDO-STACK-POINTER."
(evil-mc-put-cursor-property cursor 'undo-stack-pointer undo-stack-pointer))
(defun evil-mc-get-cursor-region (cursor)
"Get the region for CURSOR."
(evil-mc-get-cursor-property cursor 'region))
(defun evil-mc-put-cursor-region (cursor region)
"Set the region for CURSOR to REGION."
(evil-mc-put-cursor-property cursor 'region region))
(defun evil-mc-get-cursor-kill-ring (cursor)
"Get the `kill-ring' for CURSOR."
(evil-mc-get-cursor-property cursor 'kill-ring))
(defun evil-mc-put-cursor-kill-ring (cursor kill-ring)
"Set the `kill-ring' for CURSOR to KILL-RING."
(evil-mc-put-cursor-property cursor 'kill-ring kill-ring))
(defun evil-mc-get-cursor-kill-ring-yank-pointer (cursor)
"Get the `kill-ring-yank-pointer' for CURSOR."
(evil-mc-get-cursor-property
cursor 'kill-ring-yank-pointer))
(defun evil-mc-put-cursor-kill-ring-yank-pointer (cursor kill-ring-yank-pointer)
"Set the `kill-ring-yank-pointer' for CURSOR to KILL-RING-YANK-POINTER."
(evil-mc-put-cursor-property
cursor 'kill-ring-yank-pointer kill-ring-yank-pointer))
(defun evil-mc-get-cursor-temporary-goal-column (cursor)
"Get the `temporary-goal-column' for CURSOR."
(evil-mc-get-cursor-property cursor 'temporary-goal-column))
(defun evil-mc-put-cursor-temporary-goal-column (cursor temporary-goal-column)
"Set the `temporary-goal-column' for CURSOR to TEMPORARY-GOAL-COLUMN."
(evil-mc-put-cursor-property cursor 'temporary-goal-column temporary-goal-column))
(defun evil-mc-get-cursor-evil-markers-alist (cursor)
"Get the evil-markers-alist for CURSOR."
(evil-mc-get-cursor-property cursor 'evil-markers-alist))
(defun evil-mc-put-cursor-evil-markers-alist (cursor evil-markers-alist)
"Set the evil-markers-alist for CURSOR to EVIL-MARKERS-ALIST."
(evil-mc-put-cursor-property cursor 'evil-markers-alist evil-markers-alist))
(defun evil-mc-get-cursor-evil-jump-list (cursor)
"Get the evil-jump-list for CURSOR."
(evil-mc-get-cursor-property cursor 'evil-jump-list))
(defun evil-mc-put-cursor-evil-jump-list (cursor evil-jump-list)
"Set the evil-jump-list for CURSOR to EVIL-JUMP-LIST."
(evil-mc-put-cursor-property cursor 'evil-jump-list evil-jump-list))
(defun evil-mc-get-cursor-mark-ring (cursor)
"Get the `mark-ring' for CURSOR."
(evil-mc-get-cursor-property cursor 'mark-ring))
(defun evil-mc-put-cursor-mark-ring (cursor mark-ring)
"Set the `mark-ring' for CURSOR to MARK-RING."
(evil-mc-put-cursor-property cursor 'mark-ring mark-ring))
(defun evil-mc-get-cursor-mark-active (cursor)
"Get the `mark-active' for CURSOR."
(evil-mc-get-cursor-property cursor 'mark-active))
(defun evil-mc-put-cursor-mark-active (cursor mark-active)
"Set the `mark-active' for CURSOR to MARK-ACTIVE."
(evil-mc-put-cursor-property cursor 'mark-active mark-active))
(defun evil-mc-get-cursor-start (cursor)
"Get the CURSOR overlay start."
(when cursor
(overlay-start (evil-mc-get-cursor-overlay cursor))))
(defun evil-mc-get-cursor-end (cursor)
"Get the CURSOR overlay end."
(when cursor
(overlay-end (evil-mc-get-cursor-overlay cursor))))
(defun evil-mc-delete-cursor-overlay (cursor)
"Deletes the overlay associated with CURSOR."
(when cursor
(let ((overlay (evil-mc-get-cursor-overlay cursor)))
(when overlay (delete-overlay overlay)))))
(provide 'evil-mc-cursor-state)
;;; evil-mc-cursor-state.el ends here