Last active
January 27, 2023 23:12
-
-
Save dvzubarev/2cf2cb43ac9d67f70d3c2b441e4c24c2 to your computer and use it in GitHub Desktop.
targets.el setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; this is needed for targets remote objects. Without this advice remote objects | |
;; do not work in other windows | |
;; TODO see evil-surround-interactive-setup - they change evil-inhibit-operator there | |
;; maybe it possible to do the same in targets.el to get rid of this advice | |
;;;###autoload | |
(defun my-evil-motion-advice (orig-fun motion &optional count type) | |
(let* ((regex (rx "targets-" | |
(or "a" "inner" "inside" "around") | |
"-remote-" | |
(one-or-more (any ascii)))) | |
(match-index (string-match-p regex (symbol-name motion)))) | |
(if (eq match-index 0) | |
(let ((evil-inhibit-operator t)) | |
(funcall orig-fun motion count type)) | |
(funcall orig-fun motion count type)))) | |
;;;###autoload | |
(advice-add 'evil-motion-range :around #'my-evil-motion-advice) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-package! targets | |
:config | |
(setq targets-text-objects nil) | |
(targets-setup nil) | |
(targets-define-composite-to any-block | |
(("(" ")" pair) | |
("[" "]" pair) | |
("{" "}" pair) | |
;; ("<" ">" pair) | |
) | |
:bind t | |
:next-key "N" | |
:last-key "L" | |
:around-key nil | |
:inside-key nil | |
:keys "f") | |
(targets-define-composite-to any-quote | |
(("\"" "\"" quote) | |
("'" "'" quote)) | |
:bind t | |
:next-key "N" | |
:last-key "L" | |
:around-key nil | |
:inside-key nil | |
:keys "q") | |
(targets-define-to double-quote | |
"\"" nil quote | |
:bind t | |
:next-key "N" | |
:last-key "L" | |
:around-key nil | |
:inside-key nil | |
:keys "q" | |
:hooks (emacs-lisp-mode-hook))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(package! targets :recipe (:host github | |
:repo "dvzubarev/targets.el" | |
:branch "fix-remote")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment