emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 19096a6 10/34: Initial (failed) impl for beacon at end of


From: Artur Malabarba
Subject: [elpa] master 19096a6 10/34: Initial (failed) impl for beacon at end of line
Date: Fri, 16 Oct 2015 09:56:51 +0000

branch: master
commit 19096a62529a75ea8999c3ee31babe097e3219b1
Author: Artur Malabarba <address@hidden>
Commit: Artur Malabarba <address@hidden>

    Initial (failed) impl for beacon at end of line
---
 beacon.el |   28 ++++++++++++++++++++++++++--
 1 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/beacon.el b/beacon.el
index 18d4819..dd1976d 100644
--- a/beacon.el
+++ b/beacon.el
@@ -94,6 +94,25 @@ e.g. \"#666600\"."
     (overlay-put ov 'beacon t)
     (push ov beacon--ovs)))
 
+(defun beacon--ov-put-after-string (overlay colors)
+  "Add an after-string property to OVERLAY.
+The property's value is a string of spaces with background
+COLORS applied to each one."
+  (overlay-put overlay 'beacon-colors colors)
+  (overlay-put overlay 'after-string
+               (mapconcat (lambda (c) (propertize " " 'face (list :background 
c)))
+                          colors
+                          "")))
+
+(defun beacon--after-string-overlay (colors)
+  "Put an overlay at point with an after-string property.
+The property's value is a string of spaces with background
+COLORS applied to each one."
+  (let ((ov (make-overlay (point) (point))))
+    (beacon--ov-put-after-string ov colors)
+    (overlay-put ov 'beacon t)
+    (push ov beacon--ovs)))
+
 (defun beacon--ov-at-point ()
   (car (cl-member-if (lambda (o) (overlay-get o 'beacon))
                      (overlays-at (point)))))
@@ -138,7 +157,7 @@ Only returns `beacon-size' elements."
       (while colors
         (if (looking-at "$")
             (progn
-              ;; (beacon--after-string)
+              (beacon--after-string-overlay colors)
               (setq colors nil))
           (beacon--colored-overlay (pop colors))
           (forward-char 1))))))
@@ -152,7 +171,12 @@ Only returns `beacon-size' elements."
       (save-excursion
         (while (progn (forward-char 1)
                       (setq o (beacon--ov-at-point)))
-          (move-overlay o (1- (point)) (point)))))))
+          (let ((colors (overlay-get o 'beacon-colors)))
+            (if (not colors)
+                (move-overlay o (1- (point)) (point))
+              (forward-char -1)
+              (beacon--colored-overlay (pop colors))
+              (beacon--ov-put-after-string o colors))))))))
 
 (defun beacon-blink ()
   "Blink the beacon at the position of the cursor."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]