[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-goggles ef1cad8f3a 064/225: Re-add paste and fill-and
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-goggles ef1cad8f3a 064/225: Re-add paste and fill-and-move |
Date: |
Wed, 12 Jan 2022 08:58:44 -0500 (EST) |
branch: elpa/evil-goggles
commit ef1cad8f3a63680e406ad8e84295dc01458ed7e7
Author: Evgeni Kolev <evgenysw@gmail.com>
Commit: Evgeni Kolev <evgenysw@gmail.com>
Re-add paste and fill-and-move
---
evil-goggles-faces.el | 11 +++++++++-
evil-goggles.el | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 71 insertions(+), 1 deletion(-)
diff --git a/evil-goggles-faces.el b/evil-goggles-faces.el
index 0f4ae64d81..8c1eb8ad87 100644
--- a/evil-goggles-faces.el
+++ b/evil-goggles-faces.el
@@ -24,6 +24,16 @@
"Face for join action"
:group 'evil-goggles-faces)
+(defface evil-goggles-fill-and-move-face
+ '((t (:inherit region)))
+ "Face for fill and move (reformat) action"
+ :group 'evil-goggles-faces)
+
+(defface evil-goggles-paste-face
+ '((t (:inherit diff-added)))
+ "Face for paste action"
+ :group 'evil-goggles-faces)
+
;; non-core
(defface evil-goggles-surround-face
@@ -31,7 +41,6 @@
"Face for surround action"
:group 'evil-goggles-faces)
-
(defface evil-goggles-commentary-face
'((t (:inherit region)))
"Face for commentary action"
diff --git a/evil-goggles.el b/evil-goggles.el
index 65993d293d..f14bf1a316 100644
--- a/evil-goggles.el
+++ b/evil-goggles.el
@@ -192,6 +192,57 @@ BEG END are the arguments of the original function."
(evil-goggles--funcall-preserve-interactive orig-fun beg end))
(evil-goggles--funcall-preserve-interactive orig-fun beg end))))
+(defcustom evil-goggles-enable-fill-and-move t
+ "If non-nil, enable fill and move (reformat) support"
+ :type 'boolean
+ :group 'evil-goggles)
+
+(defun evil-goggles--evil-fill-and-move-advice (orig-fun beg end)
+ "Around-advice for function `evil-fill-and-move'.
+
+ORIG-FUN is the original function.
+BEG END are arguments of the original function."
+ (evil-goggles--with-goggles beg end 'evil-goggles-fill-and-move-face
+ (evil-goggles--funcall-preserve-interactive orig-fun beg end)))
+
+(defcustom evil-goggles-enable-paste t
+ "If non-nil, enable paste support"
+ :type 'boolean
+ :group 'evil-goggles)
+
+(defun evil-goggles--evil-paste-after-advice (orig-fun count &optional
register yank-handler)
+ "Around-advice for function `evil-paste-after'.
+
+ORIG-FUN is the original function.
+COUNT REGISTER YANK-HANDLER are the arguments of the original function."
+ (let ((was-in-normal-state (evil-normal-state-p))
+ (orig-fun-result (evil-goggles--funcall-preserve-interactive orig-fun
count register yank-handler)))
+ (when was-in-normal-state
+ (evil-goggles--evil-paste-show))
+ orig-fun-result))
+
+(defun evil-goggles--evil-paste-before-advice (orig-fun count &optional
register yank-handler)
+ "Around-advice for function `evil-paste-before'.
+
+ORIG-FUN is the original function.
+COUNT REGISTER YANK-HANDLER are the arguments of the original function."
+ (let ((was-in-normal-state (evil-normal-state-p))
+ (orig-fun-result (evil-goggles--funcall-preserve-interactive orig-fun
count register yank-handler)))
+ (when was-in-normal-state
+ (evil-goggles--evil-paste-show))
+ orig-fun-result))
+
+(defun evil-goggles--evil-paste-show ()
+ "Helper fun to show the goggles overlay on the last pasted text.
+
+The overlay region is derermined by evil's variable `evil-last-paste'"
+ (unless (or evil-goggles--on (null evil-last-paste))
+ (let* ((beg (nth 3 evil-last-paste))
+ (end (nth 4 evil-last-paste))
+ (is-beg-at-eol (save-excursion (goto-char beg) (eolp)))
+ (beg-corrected (if is-beg-at-eol (1+ beg) beg) ))
+ (evil-goggles--show beg-corrected end 'evil-goggles-paste-face))))
+
;; ex global
(defun evil-goggles--evil-ex-global-advice (orig-fun beg end pattern command
&optional invert)
@@ -278,6 +329,13 @@ COUNT BEG &OPTIONAL END TYPE REGISTER are the arguments of
the original function
(advice-add 'evil-join :around 'evil-goggles--evil-join-advice)
(advice-add 'evil-join-whitespace :around
'evil-goggles--evil-join-advice))
+ (when evil-goggles-enable-fill-and-move
+ (advice-add 'evil-fill-and-move :around
'evil-goggles--evil-fill-and-move-advice))
+
+ (when evil-goggles-enable-paste
+ (advice-add 'evil-paste-after :around
'evil-goggles--evil-paste-after-advice)
+ (advice-add 'evil-paste-before :around
'evil-goggles--evil-paste-before-advice))
+
;; make sure :global and :v don't show the goggles overlay
(advice-add 'evil-ex-global :around 'evil-goggles--evil-ex-global-advice)
@@ -297,6 +355,9 @@ COUNT BEG &OPTIONAL END TYPE REGISTER are the arguments of
the original function
(advice-remove 'evil-yank 'evil-goggles--evil-yank-advice)
(advice-remove 'evil-join 'evil-goggles--evil-join-advice)
(advice-remove 'evil-join-whitespace 'evil-goggles--evil-join-advice)
+ (advice-remove 'evil-fill-and-move
'evil-goggles--evil-fill-and-move-advice)
+ (advice-remove 'evil-paste-after 'evil-goggles--evil-paste-after-advice)
+ (advice-remove 'evil-paste-before 'evil-goggles--evil-paste-before-advice)
(advice-remove 'evil-ex-global 'evil-goggles--evil-ex-global-advice)
- [nongnu] elpa/evil-goggles 2e5452b6a5 216/225: Revert "evil-goggles--show-p: no need to check evil-inhibit-operator-value", (continued)
- [nongnu] elpa/evil-goggles 2e5452b6a5 216/225: Revert "evil-goggles--show-p: no need to check evil-inhibit-operator-value", ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 78454a7e8b 220/225: Merge pull request #24 from unhammer/count-lines-speedup, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 1f8ca71acd 221/225: Fix custom variable's label, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles fa7dca4f82 016/225: Cleanup delete advice, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 0afe8cf165 020/225: Fix no-whitespace check, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 55ecf5c2c4 045/225: Update README.md, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 450e153a2d 046/225: Depend on emacs 25 for `funcall-interactively', ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 99d3416598 049/225: Update README.md, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 9927490983 042/225: Update README.md, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 08da44cf83 057/225: Add the evil-goggles face, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles ef1cad8f3a 064/225: Re-add paste and fill-and-move,
ELPA Syncer <=
- [nongnu] elpa/evil-goggles 179c3002f2 071/225: Update README.md, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 904fc39728 072/225: Add doc for evil-goggles-use-diff-faces, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles e65aa39749 083/225: Add support for block paste, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 685e3714a5 090/225: Handle a specific u/redo case when the list has 2 connecting items, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 1e9ebe5e4c 095/225: Extend support for u/redo after some text is changed., ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 221a5ed8ea 098/225: Add support for Emacs 24 by not relying on funcall-interactively, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles aaa93841f9 103/225: Update evil-goggles.el, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles f79c03ba62 108/225: Experimental: add support for pulsing, new option`evil-goggles-pulse', ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 9fa3d448ca 112/225: Update "Recent Significant Changes" section in README, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 219d93e125 118/225: Add support for displaying the hint after the operation, ELPA Syncer, 2022/01/12