all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Davis Herring" <herring@lanl.gov>
To: "Alan Mackenzie" <acm@muc.de>
Cc: emacs-devel@gnu.org
Subject: Re: Is there a "selective setq locator/highlighter" anywhere?
Date: Thu, 22 Jan 2009 10:06:28 -0800 (PST)	[thread overview]
Message-ID: <42394.128.165.123.18.1232647588.squirrel@webmail.lanl.gov> (raw)
In-Reply-To: <20090122135425.GA3719@muc.de>

> 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.




  parent reply	other threads:[~2009-01-22 18:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-22 13:54 Is there a "selective setq locator/highlighter" anywhere? Alan Mackenzie
2009-01-22 13:44 ` Lennart Borgman
2009-01-22 16:23   ` Stefan Monnier
2009-01-23 15:41   ` Alan Mackenzie
2009-01-23 15:36     ` Lennart Borgman
2009-01-23 16:12       ` Lennart Borgman
2009-01-22 14:49 ` Stefan Monnier
2009-01-22 18:06 ` Davis Herring [this message]
2009-01-23 15:58   ` Is there a "selective setq locator/highlighter" anywhere? There is now! Alan Mackenzie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42394.128.165.123.18.1232647588.squirrel@webmail.lanl.gov \
    --to=herring@lanl.gov \
    --cc=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.