Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
goggles for custom evil-operators #10
Comments
|
What do you mean by custom evil operators? Operators you define yourself? Are you requesting something like (evil-define-command my-custom-command (count)
:visual-hint t
...
) |
|
Yes something like: (evil-define-operator my/evil-operator-org-capture (beg end)
"Evil operator for org-capture."
:visual-hint t |
|
I don't think this could be achieved because evil-goggles could provide other means of registering custom operators. Maybe some API which can register custom operators. |
|
That's bad news. |
|
Could you paste the whole custom operator code? |
|
I got lots of custom evil-operators in my config file, one of it is this: (evil-define-operator my/evil-operator-org-capture (beg end)
"Evil operator for org-capture."
(interactive "<r>")
(require 'org)
(unless (region-active-p)
(goto-char beg)
(set-mark-command nil)
(goto-char end))
(org-capture))
|
|
just thinking out loud: it seems evil uses an (evil-goggles-add #'my-custom-evil-operator 'partial-face-name 'before)the before/after choice would be nice to have; see #7. |
VanLaser
commented
Jun 2, 2017
|
Wouldn't it be possible to make it truly generic, by monitoring what is "a single change" (that can be undone in one step) and highlight that? I.e. without the need to maintain an operation list, add custom operators to that list etc. |
|
Probably it can be done with emacs' |
VanLaser
commented
Aug 20, 2017
•
Ok, here's a small proof-of-concept: :) ;; ------------------------------------------------------------------
;; * note, this doesn't work with copying
;; (one could follow the kill-ring perhaps?)
;; * visual state change also doesn't quite work
;; (but there you *can* see what you're doing anyway
;; ------------------------------------------------------------------
(defun evil-gg--highlight-changes (beg end &optional len)
"Local hook run before and after the buffer is changed."
(when (and (not (minibufferp))
(evil-normal-state-p)
(< (1+ beg) end)) ; that (1+ beg) *is* needed (just try with `beg' instead)
(let ((cmd (symbol-name this-command)))
(when (or (string-prefix-p "evil-" cmd)
(string-prefix-p "undo-" cmd))
(let ((ov (make-overlay beg end)))
(if len ;or, use command name to build a face name and use that, if it exists
(overlay-put ov 'face '(:background "green"))
(overlay-put ov 'face '(:background "red")))
(redisplay t)
(message "%s" this-command) ;debug
(sleep-for 0.150)
(delete-overlay ov))))))
(add-hook 'before-change-functions #'evil-gg--highlight-changes nil t)
(add-hook 'after-change-functions #'evil-gg--highlight-changes nil t)
;; ------------------------------------------------------------------
;; to disable
(remove-hook 'after-change-functions #'evil-gg--highlight--changes t)
(remove-hook 'before-change-functions #'evil-gg--highlight--changes t)
;; ------------------------------------------------------------------ |
Dickby commentedMay 26, 2017
Hi,
it would be a nice to be able to turn on goggles for custom evil-operators.
This could be possible by adding an evil-command-property.