Skip to content

Instantly share code, notes, and snippets.

@dvzubarev
Last active January 27, 2023 23:12
Show Gist options
  • Save dvzubarev/2cf2cb43ac9d67f70d3c2b441e4c24c2 to your computer and use it in GitHub Desktop.
Save dvzubarev/2cf2cb43ac9d67f70d3c2b441e4c24c2 to your computer and use it in GitHub Desktop.
targets.el setup
;; 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)
(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)))
(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