[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-goggles d759e22ba3 062/225: Re-add support for yank,
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-goggles d759e22ba3 062/225: Re-add support for yank, join, commentary, surround, replace with register |
Date: |
Wed, 12 Jan 2022 08:58:43 -0500 (EST) |
branch: elpa/evil-goggles
commit d759e22ba397484456cad9a91221bc3d62e55727
Author: Evgeni Kolev <evgenysw@gmail.com>
Commit: Evgeni Kolev <evgenysw@gmail.com>
Re-add support for yank, join, commentary, surround, replace with register
---
evil-goggles-faces.el | 32 ++++++++++++++-
evil-goggles.el | 106 +++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 136 insertions(+), 2 deletions(-)
diff --git a/evil-goggles-faces.el b/evil-goggles-faces.el
index 3d0449c241..0f4ae64d81 100644
--- a/evil-goggles-faces.el
+++ b/evil-goggles-faces.el
@@ -2,6 +2,8 @@
;; load diff-mode faces
(require 'diff-mode)
+;; evil core
+
(defface evil-goggles-delete-face
'((t (:inherit diff-removed)))
"Face for delete action"
@@ -9,7 +11,35 @@
(defface evil-goggles-indent-face
'((t (:inherit region)))
- "Face for delete action"
+ "Face for indent action"
+ :group 'evil-goggles-faces)
+
+(defface evil-goggles-yank-face
+ '((t (:inherit region)))
+ "Face for yank action"
:group 'evil-goggles-faces)
+(defface evil-goggles-join-face
+ '((t (:inherit region)))
+ "Face for join action"
+ :group 'evil-goggles-faces)
+
+;; non-core
+
+(defface evil-goggles-surround-face
+ '((t (:inherit region)))
+ "Face for surround action"
+ :group 'evil-goggles-faces)
+
+
+(defface evil-goggles-commentary-face
+ '((t (:inherit region)))
+ "Face for commentary action"
+ :group 'evil-goggles-sur)
+
+(defface evil-goggles-replace-with-register-face
+ '((t (:inherit region)))
+ "Face for replace with register action"
+ :group 'evil-goggles-sur)
+
(provide 'evil-goggles-faces)
diff --git a/evil-goggles.el b/evil-goggles.el
index 2a24dd220d..477fd616a0 100644
--- a/evil-goggles.el
+++ b/evil-goggles.el
@@ -127,6 +127,8 @@ displayed while its running."
;;; core ends here ;;;
+;; delete
+
(defcustom evil-goggles-enable-delete t
"If non-nil, enable delete support"
:type 'boolean
@@ -140,6 +142,8 @@ BEG END &OPTIONAL TYPE REGISTER YANK-HANDLER are the
arguments of the original f
(evil-goggles--with-goggles beg end 'evil-goggles-delete-face
(evil-goggles--funcall-preserve-interactive orig-fun beg end type register
yank-handler)))
+;; indent
+
(defcustom evil-goggles-enable-indent t
"If non-nil, enable indent support"
:type 'boolean
@@ -153,6 +157,86 @@ BEG END are the arguments of the original function."
(evil-goggles--with-goggles beg end 'evil-goggles-indent-face
(evil-goggles--funcall-preserve-interactive orig-fun beg end)))
+;; yank
+
+(defcustom evil-goggles-enable-yank t
+ "If non-nil, enable yank support"
+ :type 'boolean
+ :group 'evil-goggles)
+
+(defun evil-goggles--evil-yank-advice (orig-fun beg end &optional type
register yank-handler)
+ "Around-advice for function `evil-yank'.
+
+ORIG-FUN is the original function.
+BEG END &OPTIONAL TYPE REGISTER YANK-HANDLER are the arguments of the original
function."
+ (evil-goggles--with-goggles beg end 'evil-goggles-yank-face
+ (evil-goggles--funcall-preserve-interactive orig-fun beg end type register
yank-handler)))
+
+;; join
+
+(defcustom evil-goggles-enable-join t
+ "If non-nil, enable join support"
+ :type 'boolean
+ :group 'evil-goggles)
+
+(defun evil-goggles--evil-join-advice (orig-fun beg end)
+ "Around-advice for function `evil-join'.
+
+ORIG-FUN is the original function.
+BEG END are the arguments of the original function."
+ (let* ((beg-line (line-number-at-pos beg))
+ (end-line (line-number-at-pos end))
+ (line-count (- end-line beg-line)))
+ (if (> line-count 1) ;; don't show goggles for single lines ("J"/"gJ"
without count)
+ (evil-goggles--with-goggles beg end 'evil-goggles-join-face
+ (evil-goggles--funcall-preserve-interactive orig-fun beg end))
+ (evil-goggles--funcall-preserve-interactive orig-fun beg end))))
+
+;; surround
+
+(defcustom evil-goggles-enable-surround t
+ "If non-nil, enable surround support"
+ :type 'boolean
+ :group 'evil-goggles)
+
+(defun evil-goggles--evil-surround-region-advice (orig-fun beg end &optional
type char force-new-line)
+ "Around-advice for function `evil-surround-region'.
+
+ORIG-FUN is the original function.
+BEG END &OPTIONAL TYPE CHAR FORCE-NEW-LINE are the arguments of the original
function."
+ (evil-goggles--with-goggles beg end 'evil-goggles-surround-face
+ (evil-goggles--funcall-preserve-interactive orig-fun beg end type char
force-new-line)))
+
+;; commentary
+
+(defcustom evil-goggles-enable-commentary t
+ "If non-nil, enable commentary support"
+ :type 'boolean
+ :group 'evil-goggles)
+
+(defun evil-goggles--evil-commentary-advice (orig-fun beg end &optional type)
+ "Around-advice for function `evil-commentary'.
+
+ORIG-FUN is the original function.
+BEG END &OPTIONAL TYPE are the arguments of the original function."
+ (evil-goggles--with-goggles beg end 'evil-goggles-commentary-face
+ (evil-goggles--funcall-preserve-interactive orig-fun beg end type)))
+
+;; replace with register
+
+(defcustom evil-goggles-enable-replace-with-register t
+ "If non-nil, enable replace with register support"
+ :type 'boolean
+ :group 'evil-goggles)
+
+(defun evil-goggles--evil-replace-with-register-advice (orig-fun count beg
&optional end type register)
+ "Around-advice for function `evil-replace-with-register'.
+
+ORIG-FUN is the original function.
+COUNT BEG &OPTIONAL END TYPE REGISTER are the arguments of the original
function."
+ (evil-goggles--with-goggles beg end 'evil-goggles-replace-with-register-face
+ (evil-goggles--funcall-preserve-interactive orig-fun count beg end type
register)))
+
;;; mode defined below ;;;
(defcustom evil-goggles-lighter
@@ -170,10 +254,30 @@ BEG END are the arguments of the original function."
(evil-goggles-mode
;; evil core functions
+
(when evil-goggles-enable-delete
(advice-add 'evil-delete :around 'evil-goggles--evil-delete-advice))
+
(when evil-goggles-enable-indent
- (advice-add 'evil-indent :around 'evil-goggles--evil-indent-advice)))
+ (advice-add 'evil-indent :around 'evil-goggles--evil-indent-advice))
+
+ (when evil-goggles-enable-yank
+ (advice-add 'evil-yank :around 'evil-goggles--evil-yank-advice))
+
+ (when evil-goggles-enable-join
+ (advice-add 'evil-join :around 'evil-goggles--evil-join-advice)
+ (advice-add 'evil-join-whitespace :around
'evil-goggles--evil-join-advice))
+
+ ;; evil non-core functions
+
+ (when evil-goggles-enable-surround
+ (advice-add 'evil-surround-region :around
'evil-goggles--evil-surround-region-advice))
+
+ (when evil-goggles-enable-commentary
+ (advice-add 'evil-commentary :around
'evil-goggles--evil-commentary-advice))
+
+ (when evil-goggles-enable-replace-with-register
+ (advice-add 'evil-replace-with-register :around
'evil-goggles--evil-replace-with-register-advice)))
(t
(advice-remove 'evil-delete 'evil-goggles--evil-delete-advice))))
- [nongnu] elpa/evil-goggles a4958cf377 012/225: Add evil-commentary and evil-replace-with-register, (continued)
- [nongnu] elpa/evil-goggles a4958cf377 012/225: Add evil-commentary and evil-replace-with-register, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles dc4ce17b65 013/225: Add license header, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 8d6fc41234 023/225: Doc strings, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 743fd1d96d 027/225: Indent tweak, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 805e20dcde 022/225: Don't show overlay when :global or :vglobal is executed, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles ac3b272cdb 031/225: Reduce byte compiler errors, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles dd9a888516 032/225: Test infrastructure, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 412ed4ce79 035/225: Initial README, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles fd417360a2 038/225: Update README.md, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 6e4d0fab3c 047/225: Add missing :group to custom variable, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles d759e22ba3 062/225: Re-add support for yank, join, commentary, surround, replace with register,
ELPA Syncer <=
- [nongnu] elpa/evil-goggles 336f6038a3 066/225: Don't inherit diff-mode's faces by default, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 214fb33c8f 063/225: Re-add :g/:v. Fix disabling the mode, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 6645070a0c 068/225: Add helper `evil-goggles-use-diff-faces`, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 7f09345024 069/225: Update README, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles c405e0e58f 074/225: Update README, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 10285be578 073/225: Improve doc for on/off custom vars, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 126b9f77aa 076/225: Update README.md, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles d2dfe823d5 077/225: Remove deprecated variable evil-goggles-faces-alist, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles bb49e3a001 078/225: Make travis catch compilation warnings, ELPA Syncer, 2022/01/12
- [nongnu] elpa/evil-goggles 5b9a3af1af 080/225: Make pasting from a register show the goggles overlay, ELPA Syncer, 2022/01/12