branch: master commit 5fd312b3f7b89eef5d6ec4280f42cc9c5e435894 Author: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com> Commit: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com>
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)))))