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

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

[elpa] master 5fd312b 002/271: More planning and research.


From: Jackson Ray Hamilton
Subject: [elpa] master 5fd312b 002/271: More planning and research.
Date: Thu, 05 Feb 2015 18:29:20 +0000

branch: master
commit 5fd312b3f7b89eef5d6ec4280f42cc9c5e435894
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>

    More planning and research.
---
 context-coloring.el |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/context-coloring.el b/context-coloring.el
index e892a6c..16e5157 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -41,3 +41,28 @@
 ;;   according to `function.level`
 ;; - ...
 ;; - Profit.
+
+;; elisp functions that may come in handy:
+
+;; save-excursion: Wrap the whole body in this.
+;; goto-line, move-to-column: Finding ranges to apply colors to.
+;; with-silent-modifications: The colorization itself.
+
+;; Probably useful, here's the rainbow-blocks colorizer.
+(defsubst rainbow-blocks-propertize-delimiter (loc depth)
+  "Highlight a single delimiter at LOC according to DEPTH.
+LOC is the location of the character to add text properties to.
+DEPTH is the nested depth at LOC, which determines the face to use.
+Sets text properties:
+`font-lock-face' to the appropriate delimiter face.
+`rear-nonsticky' to prevent color from bleeding into subsequent characters 
typed by the user."
+  (with-silent-modifications
+    (let* ((delim-face (if (<= depth 0)
+                           'rainbow-blocks-unmatched-face
+                         (rainbow-blocks-depth-face depth)))
+           (end-pos    (save-excursion (goto-char loc)
+                                       (forward-sexp)
+                                       (point))))
+      (add-text-properties loc end-pos
+                           `(font-lock-face ,delim-face
+                                            rear-nonsticky t)))))



reply via email to

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