unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Context sensitive code highlighting.
@ 2008-04-08  9:51 Robin.Fairey
  2008-04-08 13:24 ` Tassilo Horn
  2008-04-09 22:53 ` Eric M. Ludlam
  0 siblings, 2 replies; 4+ messages in thread
From: Robin.Fairey @ 2008-04-08  9:51 UTC (permalink / raw)
  To: help-gnu-emacs

How hard would it be to implement context sensitive font lock
behaviour? I'm thinking of something that scans the code for an
argument list and then highlights subsequent occurences of the
argument names in a new colour. This requires adding new keywords to
the highlighter on the fly, determined by content in the file itself
instead of in a keyword list at the beginning of the process. I've
tweaked some other syntax highlighting modes, but I've no idea where
to start with this one. I'm not looking for a full solution, just a
pointer to where to start looking, or something I can read and modify
to my needs?


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Context sensitive code highlighting.
  2008-04-08  9:51 Context sensitive code highlighting Robin.Fairey
@ 2008-04-08 13:24 ` Tassilo Horn
  2008-04-08 14:17   ` Lennart Borgman (gmail)
  2008-04-09 22:53 ` Eric M. Ludlam
  1 sibling, 1 reply; 4+ messages in thread
From: Tassilo Horn @ 2008-04-08 13:24 UTC (permalink / raw)
  To: help-gnu-emacs

Robin.Fairey@gmail.com writes:

> How hard would it be to implement context sensitive font lock
> behaviour? I'm thinking of something that scans the code for an
> argument list and then highlights subsequent occurences of the
> argument names in a new colour.

Have a look at highlight-symbol.el [1], especially `highlight-symbol-mode'.

Bye,
Tassilo
__________
[1] http://www.emacswiki.org/cgi-bin/emacs-en/HighlightSymbol
    http://nschum.de/src/emacs/highlight-symbol/





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Context sensitive code highlighting.
  2008-04-08 13:24 ` Tassilo Horn
@ 2008-04-08 14:17   ` Lennart Borgman (gmail)
  0 siblings, 0 replies; 4+ messages in thread
From: Lennart Borgman (gmail) @ 2008-04-08 14:17 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: help-gnu-emacs

Tassilo Horn wrote:
> Robin.Fairey@gmail.com writes:
> 
>> How hard would it be to implement context sensitive font lock
>> behaviour? I'm thinking of something that scans the code for an
>> argument list and then highlights subsequent occurences of the
>> argument names in a new colour.

See

   (info "(elisp) Search-based Fontification")

You can use a function instead of a regexp for searching for things to 
highlight. So it is possible to do what you want. You just need to do 
some book-keeping.

> Have a look at highlight-symbol.el [1], especially `highlight-symbol-mode'.
> 
> Bye,
> Tassilo
> __________
> [1] http://www.emacswiki.org/cgi-bin/emacs-en/HighlightSymbol
>     http://nschum.de/src/emacs/highlight-symbol/


It is very good, but would look much better if a background overlay 
could be used instead in hi-lock.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Context sensitive code highlighting.
  2008-04-08  9:51 Context sensitive code highlighting Robin.Fairey
  2008-04-08 13:24 ` Tassilo Horn
@ 2008-04-09 22:53 ` Eric M. Ludlam
  1 sibling, 0 replies; 4+ messages in thread
From: Eric M. Ludlam @ 2008-04-09 22:53 UTC (permalink / raw)
  To: help-gnu-emacs

>>> Robin.Fairey@gmail.com seems to think that:
>How hard would it be to implement context sensitive font lock
>behaviour? I'm thinking of something that scans the code for an
>argument list and then highlights subsequent occurences of the
>argument names in a new colour. This requires adding new keywords to
>the highlighter on the fly, determined by content in the file itself
>instead of in a keyword list at the beginning of the process. I've
>tweaked some other syntax highlighting modes, but I've no idea where
>to start with this one. I'm not looking for a full solution, just a
>pointer to where to start looking, or something I can read and modify
>to my needs?

If you have particularly complex context/highlighting needs, in
CEDET/Semantic there is a decoration mode which calls your function
whenever a semantic tag (function, variable, argument, struct field,
etc) is found, and you can then highlight it using any mechanism you
like, though creating the overlays w/ the decoration API makes sure they
are kept up to date.

One sample mode in CEDET puts an overline on top of any function or data
type that is a certain length.

http://cedet.sourceforge.net/

Of course, then your highlighter is dependent on a particularly complex
secondary installation.

Eric


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-04-09 22:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-08  9:51 Context sensitive code highlighting Robin.Fairey
2008-04-08 13:24 ` Tassilo Horn
2008-04-08 14:17   ` Lennart Borgman (gmail)
2008-04-09 22:53 ` Eric M. Ludlam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).