|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
;; -*- lexical-binding: t; -*-
;; From <http://www.kollektiv-hamburg.de/~forcer/hisex.el>:
;;; Code thrown together by Jorgen Schaefer
;;; Placed into the public domain. All rites reversed. Use at your own risk.
(defface hisex-face '((t :background "blue"))
"The face used to highlight sexps.")
(defvar hisex-overlay nil
"The overlay used for `hisex-mode'.")
(define-minor-mode hisex-mode
"Highlight the current expression."
:group 'paredit
(if hisex-mode
(progn
(add-hook 'post-command-hook 'hisex-highlight nil t)
(hisex-highlight))
(remove-hook 'post-command-hook 'hisex-highlight)
(when hisex-overlay
(delete-overlay hisex-overlay)
(setq hisex-overlay nil))))
(defun hisex-highlight ()
"Set `hisex-overlay'."
(let ((beg nil)
(end nil))
(condition-case nil
(progn
(save-excursion
(up-list)
(setq end (point))
(backward-sexp)
(setq beg (point)))
(if hisex-overlay
(move-overlay hisex-overlay beg end)
(setq hisex-overlay (make-overlay beg end))
(overlay-put hisex-overlay 'face 'hisex-face)))
(scan-error
(when hisex-overlay
(delete-overlay hisex-overlay)
(setq hisex-overlay nil))))))