hchbaw/eval-sexp-fu.el

Remove dependency on highlight.el?

yuhan0 opened this issue · 2 comments

eval-sexp-fu currently requires the large and fully-featured (3000+ LOC) highlight.el library, for the use of only two basic functions:

  • hlt-highlight-region
  • hlt-unhighlight-region.

These deal with many conditions required of the other hlt functions, but in the context of eval-sexp-fu can be simplified to the following for exactly the same functionality:

- (hlt-highlight-region (car bounds) (cdr bounds) face)
+ (let ((ov (make-overlay (car bounds) (cdr bounds))))
+   (overlay-put ov 'face face)
+   (overlay-put ov 'esf-highlight t)

- (hlt-unhighlight-region (car bounds) (cdr-bounds))
+ (dolist (ov (overlays-in (car bounds) (cdr bounds)))
+   (when (overlay-get ov 'esf-highlight)
+     (delete-overlay ov)))

If this is alright I can open a PR with the above changes :)

I've merged.
Thank you very much your contribution!