|
46 | 46 | (define-key evil-normal-state-map (kbd "k") 'evil-previous-visual-line)
|
47 | 47 | (define-key evil-motion-state-map (kbd "<C-escape>") 'evil-execute-in-emacs-state)
|
48 | 48 |
|
49 |
| -;; evilem on SPACE m |
| 49 | +;; evilem on \ |
50 | 50 | (evilem-default-keybindings "\\" )
|
51 | 51 |
|
| 52 | +;; {{{ |
| 53 | +;; keep these around untill https://github.com/PythonNut/evil-easymotion/pull/71 is merged |
| 54 | + |
| 55 | +(defun evilem--collect (func &optional |
| 56 | + scope |
| 57 | + all-windows |
| 58 | + initial-point |
| 59 | + sort-key |
| 60 | + collect-postprocess |
| 61 | + include-invisible) |
| 62 | + "Repeatedly execute func, and collect the cursor positions into a list" |
| 63 | + (cl-letf ((points nil) |
| 64 | + (point nil) |
| 65 | + (avy-all-windows all-windows) |
| 66 | + ;; make sure the motion doesn't move the window |
| 67 | + (scroll-conservatively 101) |
| 68 | + (smooth-scrolling-mode nil) |
| 69 | + (scroll-margin 0) |
| 70 | + (evil-state 'normal)) |
| 71 | + |
| 72 | + (if (functionp func) |
| 73 | + (avy-dowindows current-prefix-arg |
| 74 | + (save-excursion |
| 75 | + (save-restriction |
| 76 | + (when initial-point |
| 77 | + (goto-char (funcall initial-point))) |
| 78 | + (cl-destructuring-bind (beg . end) |
| 79 | + (if scope |
| 80 | + (bounds-of-thing-at-point scope) |
| 81 | + (cons (point-min) |
| 82 | + (point-max))) |
| 83 | + |
| 84 | + ;; trim trailing newline |
| 85 | + (when (= (char-before end) 10) |
| 86 | + (cl-decf end)) |
| 87 | + |
| 88 | + (narrow-to-region (max beg (window-start)) |
| 89 | + (min end (window-end)))) |
| 90 | + (while (and (ignore-errors |
| 91 | + (setq this-command func |
| 92 | + last-command func) |
| 93 | + (call-interactively func) |
| 94 | + ;; (let ((res (call-interactively func))) |
| 95 | + ;; (message "calling func %S resulted in %S" func rec) |
| 96 | + ;; res) |
| 97 | + (message "movement at %S" (point)) |
| 98 | + |
| 99 | + (message "inclue visible %S" include-invisible) |
| 100 | + |
| 101 | + (unless include-invisible |
| 102 | + (let ((ov (car (overlays-at (point))))) |
| 103 | + (while (and ov (member |
| 104 | + 'invisible |
| 105 | + (overlay-properties ov))) |
| 106 | + (goto-char (overlay-end ov)) |
| 107 | + ;; This is a bit of a hack, since we |
| 108 | + ;; can't guarantee that we will end |
| 109 | + ;; up at the same point if we start |
| 110 | + ;; at the end of the invisible |
| 111 | + ;; region vs. looping through it. |
| 112 | + (call-interactively func) |
| 113 | + (setq ov (car (overlays-at (point))))))) |
| 114 | + t) |
| 115 | + (setq point (cons (point) (get-buffer-window))) |
| 116 | + (not (member point points)) |
| 117 | + (push point points)))))) |
| 118 | + (setq points (cl-remove-duplicates |
| 119 | + (cl-mapcan (lambda (f) |
| 120 | + (evilem--collect f scope all-windows)) |
| 121 | + func)))) |
| 122 | + (funcall (or collect-postprocess |
| 123 | + #'evilem--default-collect-postprocess) |
| 124 | + points))) |
| 125 | + |
| 126 | +(eval-and-compile |
| 127 | + (defun evilem--compute-inclusivity (funcs) |
| 128 | + (cond ((symbolp funcs) `(setq evil-this-type |
| 129 | + ',(evil-get-command-property funcs :type))) |
| 130 | + |
| 131 | + ((and (listp funcs) (= (length funcs) 1)) (evilem--compute-inclusivity (car funcs))) |
| 132 | + |
| 133 | + ((and (listp funcs) (= (length funcs) 2) (eq (car funcs) 'function)) (evilem--compute-inclusivity (cdr funcs)))))) |
| 134 | + |
| 135 | +(evilem-make-motion |
| 136 | + evilem-motion-forward-word-begin #'evil-forward-word-begin |
| 137 | + :scope 'line) |
| 138 | + |
| 139 | +(evilem-make-motion |
| 140 | + evilem-motion-forward-WORD-begin #'evil-forward-WORD-begin |
| 141 | + :scope 'line) |
| 142 | + |
| 143 | +(evilem-make-motion |
| 144 | + evilem-motion-forward-word-end #'evil-forward-word-end |
| 145 | + :scope 'line) |
| 146 | + |
| 147 | +(evilem-make-motion |
| 148 | + evilem-motion-forward-WORD-end #'evil-forward-WORD-end |
| 149 | + :scope 'line) |
| 150 | + |
| 151 | +(evilem-make-motion |
| 152 | + evilem-motion-backward-word-begin #'evil-backward-word-begin |
| 153 | + :scope 'line) |
| 154 | + |
| 155 | +(evilem-make-motion |
| 156 | + evilem-motion-backward-WORD-begin #'evil-backward-WORD-begin |
| 157 | + :scope 'line) |
| 158 | + |
| 159 | +(evilem-make-motion |
| 160 | + evilem-motion-backward-word-end #'evil-backward-word-end |
| 161 | + :scope 'line) |
| 162 | + |
| 163 | +(evilem-make-motion |
| 164 | + evilem-motion-backward-WORD-end #'evil-backward-WORD-end |
| 165 | + :scope 'line) |
| 166 | + |
| 167 | +(evilem-make-motion |
| 168 | + evilem-motion-next-line #'next-line |
| 169 | + :pre-hook (setq evil-this-type 'line) |
| 170 | + :bind ((temporary-goal-column (current-column)) |
| 171 | + (line-move-visual nil))) |
| 172 | + |
| 173 | +(evilem-make-motion |
| 174 | + evilem-motion-previous-line #'previous-line |
| 175 | + :pre-hook (setq evil-this-type 'line) |
| 176 | + :bind ((temporary-goal-column (current-column)) |
| 177 | + (line-move-visual nil))) |
| 178 | + |
| 179 | +(evilem-make-motion |
| 180 | + evilem-motion-next-visual-line #'next-line |
| 181 | + :pre-hook (setq evil-this-type 'line) |
| 182 | + :bind ((temporary-goal-column (current-column)) |
| 183 | + (line-move-visual t))) |
| 184 | + |
| 185 | +(evilem-make-motion |
| 186 | + evilem-motion-previous-visual-line #'previous-line |
| 187 | + :pre-hook (setq evil-this-type 'line) |
| 188 | + :bind ((temporary-goal-column (current-column)) |
| 189 | + (line-move-visual t))) |
| 190 | + |
| 191 | +(evilem-make-motion |
| 192 | + evilem-motion-find-char-to #'evil-repeat-find-char |
| 193 | + :pre-hook (save-excursion |
| 194 | + (setq evil-this-type 'inclusive) |
| 195 | + (call-interactively #'evil-find-char-to)) |
| 196 | + :bind ((evil-cross-lines t))) |
| 197 | + |
| 198 | +(evilem-make-motion |
| 199 | + evilem-motion-find-char-to-backward #'evil-repeat-find-char |
| 200 | + :pre-hook (save-excursion |
| 201 | + (setq evil-this-type 'exclusive) |
| 202 | + (call-interactively #'evil-find-char-to-backward)) |
| 203 | + :bind ((evil-cross-lines t))) |
| 204 | + |
| 205 | +(evilem-make-motion |
| 206 | + evilem-motion-find-char #'evil-repeat-find-char |
| 207 | + :pre-hook (save-excursion |
| 208 | + (setq evil-this-type 'inclusive) |
| 209 | + (call-interactively #'evil-find-char)) |
| 210 | + :bind ((evil-cross-lines t))) |
| 211 | + |
| 212 | +(evilem-make-motion |
| 213 | + evilem-motion-find-char-backward #'evil-repeat-find-char |
| 214 | + :pre-hook (save-excursion |
| 215 | + (setq evil-this-type 'exclusive) |
| 216 | + (call-interactively #'evil-find-char-backward)) |
| 217 | + :bind ((evil-cross-lines t))) |
| 218 | + |
| 219 | +(evilem-make-motion |
| 220 | + evilem-motion-backward-section-begin #'evil-backward-section-begin |
| 221 | + :pre-hook (setq evil-this-type 'line)) |
| 222 | + |
| 223 | +(evilem-make-motion |
| 224 | + evilem-motion-backward-section-end #'evil-backward-section-end |
| 225 | + :pre-hook (setq evil-this-type 'line)) |
| 226 | + |
| 227 | +(evilem-make-motion |
| 228 | + evilem-motion-forward-section-begin #'evil-forward-section-begin |
| 229 | + :pre-hook (setq evil-this-type 'line)) |
| 230 | + |
| 231 | +(evilem-make-motion |
| 232 | + evilem-motion-forward-section-end #'evil-forward-section-end |
| 233 | + :pre-hook (setq evil-this-type 'line)) |
| 234 | + |
| 235 | +(evilem-make-motion |
| 236 | + evilem-motion-backward-sentence-begin #'evil-backward-sentence-begin) |
| 237 | + |
| 238 | +(evilem-make-motion |
| 239 | + evilem-motion-forward-sentence-begin #'evil-forward-sentence-begin) |
| 240 | + |
| 241 | +(evilem-make-motion |
| 242 | + evilem-motion-search-next #'evil-search-next |
| 243 | + :bind (((symbol-function #'isearch-lazy-highlight-update) |
| 244 | + #'ignore) |
| 245 | + (search-highlight nil))) |
| 246 | + |
| 247 | +(evilem-make-motion |
| 248 | + evilem-motion-search-previous #'evil-search-previous |
| 249 | + :bind (((symbol-function #'isearch-lazy-highlight-update) |
| 250 | + #'ignore) |
| 251 | + (search-highlight nil))) |
| 252 | + |
| 253 | +(evilem-make-motion |
| 254 | + evilem-motion-search-word-forward #'evil-search-word-forward |
| 255 | + :bind (((symbol-function #'isearch-lazy-highlight-update) |
| 256 | + #'ignore) |
| 257 | + (search-highlight nil))) |
| 258 | + |
| 259 | +(evilem-make-motion |
| 260 | + evilem-motion-search-word-backward #'evil-search-word-backward |
| 261 | + :bind (((symbol-function #'isearch-lazy-highlight-update) |
| 262 | + #'ignore) |
| 263 | + (search-highlight nil))) |
| 264 | + |
| 265 | +(evilem-make-motion |
| 266 | + evilem-motion-previous-line-first-non-blank #'evil-previous-line-first-non-blank) |
| 267 | + |
| 268 | +(evilem-make-motion |
| 269 | + evilem-motion-next-line-first-non-blank #'evil-next-line-first-non-blank) |
| 270 | + |
| 271 | +;; ;; fix some evilem motions not being inclusive |
| 272 | +;; (evilem-make-motion |
| 273 | +;; evilem-motion-forward-word-end #'evil-forward-word-end |
| 274 | +;; :scope 'line |
| 275 | +;; :pre-hook (setq evil-this-type 'inclusive)) |
| 276 | + |
| 277 | +;; (evilem-make-motion |
| 278 | +;; evilem-motion-forward-WORD-end #'evil-forward-WORD-end |
| 279 | +;; :scope 'line |
| 280 | +;; :pre-hook (setq evil-this-type 'inclusive)) |
| 281 | + |
| 282 | +;; (evilem-make-motion |
| 283 | +;; evilem-motion-backward-word-begin #'evil-backward-word-begin |
| 284 | +;; :scope 'line |
| 285 | +;; :pre-hook (setq evil-this-type 'inclusive)) |
| 286 | + |
| 287 | +;; (evilem-make-motion |
| 288 | +;; evilem-motion-backward-WORD-begin #'evil-backward-WORD-begin |
| 289 | +;; :scope 'line |
| 290 | +;; :pre-hook (setq evil-this-type 'inclusive)) |
| 291 | + |
| 292 | + |
| 293 | +;; (evilem-make-motion |
| 294 | +;; evilem-motion-backward-word-end #'evil-backward-word-end |
| 295 | +;; :scope 'line |
| 296 | +;; :pre-hook (setq evil-this-type 'inclusive)) |
| 297 | + |
| 298 | +;; (evilem-make-motion |
| 299 | +;; evilem-motion-backward-WORD-end #'evil-backward-WORD-end |
| 300 | +;; :scope 'line |
| 301 | +;; :pre-hook (setq evil-this-type 'inclusive)) |
| 302 | + |
| 303 | +;; ;; increase scope of word jumps |
| 304 | +;; (evilem-make-motion |
| 305 | +;; evilem-motion-forward-word-begin #'evil-forward-word-begin) |
| 306 | + |
| 307 | +;; (evilem-make-motion |
| 308 | +;; evilem-motion-forward-WORD-begin #'evil-forward-WORD-begin) |
| 309 | + |
| 310 | +;; }}} |
| 311 | + |
52 | 312 | ;; MAP C-v
|
53 | 313 | ;; evil-args
|
54 | 314 | (general-define-key "L" '(evil-forward-arg :which-key "Arg Forward")
|
|
0 commit comments