|
103 | 103 | "avy-jump to the set of points generated by collector"
|
104 | 104 | (require 'avy)
|
105 | 105 | (let* ((avy-style (or evilem-style avy-style))
|
106 |
| - (avy-keys (or evilem-keys avy-keys)) |
107 |
| - (avy-all-windows nil)) |
108 |
| - (avy--process (mapcar |
109 |
| - (lambda (pt) |
110 |
| - (cons pt (get-buffer-window))) |
111 |
| - points) |
| 106 | + (avy-keys (or evilem-keys avy-keys))) |
| 107 | + (avy--process points |
112 | 108 | (avy--style-fn avy-style))))
|
113 | 109 |
|
114 |
| -(defun evilem--collect (func &optional scope) |
| 110 | +(defun evilem--collect (func &optional scope all-windows) |
115 | 111 | "Repeatedly execute func, and collect the cursor positions into a list"
|
116 | 112 | (if (functionp func)
|
117 | 113 | (let ((points)
|
| 114 | + (point) |
| 115 | + (avy-all-windows all-windows) |
118 | 116 | ;; make sure the motion doesn't move the window
|
119 | 117 | (scroll-conservatively 101)
|
120 | 118 | (smooth-scroll-margin 0)
|
121 | 119 | (scroll-margin 0))
|
122 |
| - (save-excursion |
123 |
| - (save-restriction |
124 |
| - (cl-destructuring-bind (beg . end) |
125 |
| - (if scope |
126 |
| - (bounds-of-thing-at-point scope) |
127 |
| - (cons (point-min) |
128 |
| - (point-max))) |
129 |
| - |
130 |
| - ;; trim trailing newline |
131 |
| - (when (= (char-before end) 10) |
132 |
| - (cl-decf end)) |
133 |
| - |
134 |
| - (narrow-to-region (max beg (window-start)) |
135 |
| - (min end (window-end)))) |
136 |
| - (while (and (ignore-errors |
137 |
| - (setq this-command func |
138 |
| - last-command func) |
139 |
| - (call-interactively func) |
140 |
| - t) |
141 |
| - (not (memq (point) points)) |
142 |
| - (push (point) points)))) |
143 |
| - (nreverse points))) |
| 120 | + (avy-dowindows current-prefix-arg |
| 121 | + (save-excursion |
| 122 | + (save-restriction |
| 123 | + (cl-destructuring-bind (beg . end) |
| 124 | + (if scope |
| 125 | + (bounds-of-thing-at-point scope) |
| 126 | + (cons (point-min) |
| 127 | + (point-max))) |
| 128 | + |
| 129 | + ;; trim trailing newline |
| 130 | + (when (= (char-before end) 10) |
| 131 | + (cl-decf end)) |
| 132 | + |
| 133 | + (narrow-to-region (max beg (window-start)) |
| 134 | + (min end (window-end)))) |
| 135 | + (while (and (ignore-errors |
| 136 | + (setq this-command func |
| 137 | + last-command func) |
| 138 | + (call-interactively func) |
| 139 | + t) |
| 140 | + (setq point (cons (point) (get-buffer-window))) |
| 141 | + (not (member point points)) |
| 142 | + (push point points)))))) |
| 143 | + (nreverse points)) |
144 | 144 | (cl-remove-duplicates
|
145 | 145 | (cl-mapcan (lambda (f)
|
146 |
| - (evilem--collect f scope)) |
| 146 | + (evilem--collect f scope all-windows)) |
147 | 147 | func))))
|
148 | 148 |
|
149 |
| -(cl-defmacro evilem-make-motion (name func &key pre-hook post-hook bind scope) |
| 149 | +(cl-defmacro evilem-make-motion (name func &key pre-hook post-hook bind scope |
| 150 | + all-windows) |
150 | 151 | "Automatically define an evil easymotion for `func', naming it `name'"
|
151 | 152 | `(evil-define-motion ,name (_count)
|
152 | 153 | (evil-without-repeat
|
|
155 | 156 | ,(when pre-hook `(funcall ,(if (functionp pre-hook)
|
156 | 157 | pre-hook
|
157 | 158 | `(lambda () ,pre-hook))))
|
158 |
| - (evilem--jump (evilem--collect ,func ,scope)) |
| 159 | + (evilem--jump (evilem--collect ,func ,scope ,all-windows)) |
159 | 160 | ,(when post-hook `(funcall ,(if (functionp post-hook)
|
160 | 161 | post-hook
|
161 | 162 | `(lambda () ,post-hook))))))))
|
162 | 163 |
|
163 |
| -(cl-defmacro evilem-make-motion-plain (name func &key pre-hook post-hook bind scope) |
| 164 | +(cl-defmacro evilem-make-motion-plain (name func &key pre-hook post-hook bind scope |
| 165 | + all-windows) |
164 | 166 | "Automatically define a plain easymotion for `func', naming it `name'"
|
165 | 167 | `(defun ,name ()
|
166 | 168 | (interactive)
|
167 | 169 | (cl-letf ,bind
|
168 | 170 | ,(when pre-hook `(funcall ,(if (functionp pre-hook)
|
169 | 171 | pre-hook
|
170 | 172 | `(lambda () ,pre-hook))))
|
171 |
| - (evilem--jump (evilem--collect ,func ,scope)) |
| 173 | + (evilem--jump (evilem--collect ,func ,scope ,all-windows)) |
172 | 174 | ,(when post-hook `(funcall ,(if (functionp post-hook)
|
173 | 175 | post-hook
|
174 | 176 | `(lambda () ,post-hook)))))))
|
175 | 177 |
|
176 |
| -(cl-defmacro evilem-create (motion &key pre-hook post-hook bind scope) |
| 178 | +(cl-defmacro evilem-create (motion &key pre-hook post-hook bind scope |
| 179 | + all-windows) |
177 | 180 | `(evilem-make-motion
|
178 | 181 | ,(intern (evilem--make-name motion))
|
179 | 182 | ,motion
|
180 | 183 | :pre-hook ,pre-hook
|
181 | 184 | :post-hook ,post-hook
|
182 | 185 | :bind ,bind
|
183 |
| - :scope ,scope)) |
| 186 | + :scope ,scope |
| 187 | + :all-windows ,all-windows)) |
184 | 188 |
|
185 |
| -(cl-defmacro evilem-create-plain (motion &key pre-hook post-hook bind scope) |
| 189 | +(cl-defmacro evilem-create-plain (motion &key pre-hook post-hook bind scope |
| 190 | + all-windows) |
186 | 191 | `(evilem-make-motion-plain
|
187 | 192 | ,(intern (evilem--make-name motion))
|
188 | 193 | ,motion
|
189 | 194 | :pre-hook ,pre-hook
|
190 | 195 | :post-hook ,post-hook
|
191 | 196 | :bind ,bind
|
192 |
| - :scope ,scope)) |
| 197 | + :scope ,scope |
| 198 | + :all-windows ,all-windows)) |
193 | 199 |
|
194 |
| -(cl-defmacro evilem-define (key motion &key pre-hook post-hook bind scope) |
| 200 | +(cl-defmacro evilem-define (key motion &key pre-hook post-hook bind scope |
| 201 | + all-windows) |
195 | 202 | "Automatically create and bind an evil motion"
|
196 | 203 | `(define-key evil-motion-state-map ,key
|
197 | 204 | (evilem-create ,motion
|
198 | 205 | :pre-hook ,pre-hook
|
199 | 206 | :post-hook ,post-hook
|
200 | 207 | :bind ,bind
|
201 |
| - :scope ,scope))) |
| 208 | + :scope ,scope |
| 209 | + :all-windows ,all-windows))) |
202 | 210 |
|
203 | 211 | ;;;###autoload
|
204 | 212 | (defun evilem-default-keybindings (prefix)
|
|
0 commit comments