branch: elpa/evil-goggles
commit 3d71c2c24ca0ce6243e1295e57def54e86f08b00
Author: Evgeni Kolev <[email protected]>
Commit: Evgeni Kolev <[email protected]>

    Add support for evil-set-marker
---
 README.md       |  2 ++
 evil-goggles.el | 30 ++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/README.md b/README.md
index 4a6cde9d53..e8b3418c61 100644
--- a/README.md
+++ b/README.md
@@ -99,6 +99,7 @@ evil-goggles-shift-face
 evil-goggles-surround-face
 evil-goggles-commentary-face
 evil-goggles-replace-with-register-face
+evil-goggles-set-marker-face
 ```
 
 #### Other Customizations
@@ -125,6 +126,7 @@ evil-goggles-replace-with-register-face
 ;; evil-goggles-enable-surround
 ;; evil-goggles-enable-commentary
 ;; evil-goggles-enable-replace-with-register
+;; evil-goggles-enable-set-marker
 ```
 
 ## Recent Significant Changes
diff --git a/evil-goggles.el b/evil-goggles.el
index 6c3d9b27d7..fa241b96a1 100644
--- a/evil-goggles.el
+++ b/evil-goggles.el
@@ -283,6 +283,32 @@ BEG END &OPTIONAL COUNT PRESERVE-EMPTY are the arguments 
of the original functio
   (evil-goggles--with-goggles beg end 'evil-goggles-shift-face
     (evil-goggles--funcall-preserve-interactive orig-fun beg end count 
preserve-empty)))
 
+;; set mark
+
+(evil-goggles--define-switch-and-face
+    evil-goggles-enable-set-marker "If non-nil, enable set mark support"
+    evil-goggles-set-marker-face "Face for set mark action")
+
+(defun evil-goggles--evil-set-marker-advice (orig-fun char &optional pos 
advance)
+  "Around-advice for function `evil-set-marker`.
+
+ORIG-FUN is the original function.
+CHAR POS ADVANCE are the arguments of the original function."
+  ;; call orig-fun
+  (evil-goggles--funcall-preserve-interactive orig-fun char pos advance)
+  ;; maybe show the goggles overlay
+  (when (<= ?a char ?z)
+    (save-excursion
+      (when pos
+        (goto-char pos))
+      (let ((beg (save-excursion
+                   (move-beginning-of-line nil)
+                   (point)))
+            (end (1+ (save-excursion
+                       (move-end-of-line nil)
+                       (point)))))
+        (evil-goggles--show beg end 'evil-goggles-set-marker-face)))))
+
 ;; ex global
 
 (defun evil-goggles--evil-ex-global-advice (orig-fun beg end pattern command 
&optional invert)
@@ -377,6 +403,9 @@ COUNT BEG &OPTIONAL END TYPE REGISTER are the arguments of 
the original function
       (advice-add 'evil-shift-left :around 'evil-goggles--evil-shift-advice)
       (advice-add 'evil-shift-right :around 'evil-goggles--evil-shift-advice))
 
+    (when evil-goggles-enable-set-marker
+      (advice-add 'evil-set-marker :around 
'evil-goggles--evil-set-marker-advice))
+
     ;; make sure :global and :v don't show the goggles overlay
     (advice-add 'evil-ex-global :around 'evil-goggles--evil-ex-global-advice)
 
@@ -401,6 +430,7 @@ COUNT BEG &OPTIONAL END TYPE REGISTER are the arguments of 
the original function
     (advice-remove 'evil-paste-before 'evil-goggles--evil-paste-before-advice)
     (advice-remove 'evil-shift-left 'evil-goggles--evil-shift-advice)
     (advice-remove 'evil-shift-right 'evil-goggles--evil-shift-advice)
+    (advice-remove 'evil-set-marker 'evil-goggles--evil-set-marker-advice)
 
     (advice-remove 'evil-ex-global 'evil-goggles--evil-ex-global-advice)
 

Reply via email to