[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Is there a "selective setq locator/highlighter" anywhere?
From: |
Davis Herring |
Subject: |
Re: Is there a "selective setq locator/highlighter" anywhere? |
Date: |
Thu, 22 Jan 2009 10:06:28 -0800 (PST) |
User-agent: |
SquirrelMail/1.4.8-5.2.lanl1 |
> I would like a tool which would highlight these:
>
> (setq foo bar
> c-state-cache (cdr c-state-cache))
> (setcar c-state-cache (caar c-state-cache))
>
> , but not this:
>
> (setq old-cache c-state-cache)
Not a polished tool, by any means, but can't you just do
;; Handles set, setq, setcar, setcdr
(save-excursion
(save-restriction
(widen)
(goto-char (point-min))
(while (re-search-forward "(set\\(q?\\|c[ad]r\\)\\>" nil t)
(skip-syntax-forward "^ >")
(while
(progn
(skip-syntax-forward " >'p")
(when (looking-at "c-state-cache")
(let ((o (make-overlay (point) (match-end 0) nil t)))
(overlay-put o 'face 'highlight)
(overlay-put o 'c-state-cache t)
(overlay-put o 'evaporate t)))
(ignore-errors (forward-sexp 2) t))))))
;; Putting the (meaningless) "c-state-cache" property
;; on the overlay means we can remove them easily:
(remove-overlays nil nil 'c-state-cache t)
Wrap in defuns/commands as desired.
Davis
--
This product is sold by volume, not by mass. If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.