[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Idea: Allow faces to have text-like properties

From: Kim F. Storm
Subject: Idea: Allow faces to have text-like properties
Date: 28 Feb 2002 11:25:45 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.50

I saw the article below in comp.emacs, and it got me wondering whether
it would make sense for a `face' to have an `invisible' property.

That would - among other things, make it very easy to toggle
visibility of comments in a buffer by simply changing the `invisible'
property of the comment face (or setting font-lock-comment-face to a
face derived from the original comment face with the invisible
property set).

In general, maybe a `face' could have all the normal `text properties'
like keymap, invisible, intangible, etc.  (except face of course).

I don't know whether it is worth any efforts to pursue this, but
it might open up some interesting possibilities -- e.g. clicking
mouse-3 on a comment will open a pop-up menu with the options to
spell check it, refill it, uncomment it, ...   That could be
achieved simply by adding the keymap property to the comment face.

What do you think?


------------- comp.emacs article follows ----------------
From: Ted Zlatanov <address@hidden>

eugene kim <address@hidden> writes:

> i think i found a lisp package which does what i wanted...
> hideshow..
> but i can't figure out how i can hide/show all comments in buffer..
> could u help a newbie?

Hideshow is overkill, I think.

You could temporarily set the comment face (a face is like a
combination of font size and text color properties as far as the user
is concerned) color to be invisible.  This may not be the way to
achieve the results you were looking for, but the effect will be the
same, and likely much easier to do.

Put this in your .emacs:

(make-face 'fl1-comment-face) ;; comment
(set-face-foreground 'fl1-comment-face "white")
(set-face-background 'fl1-comment-face "black")
(setq font-lock-comment-face 'fl1-comment-face)

Bind a key to a lambda function that executes

(set-face-foreground 'fl1-comment-face "black")
(set-face-background 'fl1-comment-face "black")

And another one to a lambda that executes

(set-face-foreground 'fl1-comment-face "white")
(set-face-background 'fl1-comment-face "black")

You can use colors other than black and white, if you wish.  The idea
is just to make the foreground temporarily invisible by making it the
same as the background.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]