unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Idea: Allow faces to have text-like properties
@ 2002-02-28 10:25 Kim F. Storm
  2002-02-28 12:05 ` Per Abrahamsen
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Kim F. Storm @ 2002-02-28 10:25 UTC (permalink / raw)
  Cc: tzz


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?

++kfs

------------- comp.emacs article follows ----------------
From: Ted Zlatanov <tzz@beld.net>

eugene kim <eugene1977@hotmail.com> 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.

Ted


_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel


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

* Re: Idea: Allow faces to have text-like properties
  2002-02-28 10:25 Idea: Allow faces to have text-like properties Kim F. Storm
@ 2002-02-28 12:05 ` Per Abrahamsen
  2002-02-28 13:15   ` Kim F. Storm
  2002-03-01  1:05 ` Stefan Monnier
  2002-03-01  1:11 ` Richard Stallman
  2 siblings, 1 reply; 7+ messages in thread
From: Per Abrahamsen @ 2002-02-28 12:05 UTC (permalink / raw)
  Cc: emacs-devel, tzz

Couldn't the same effect be achieved if font lock used categories
instead of faces?  

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel


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

* Re: Idea: Allow faces to have text-like properties
  2002-02-28 12:05 ` Per Abrahamsen
@ 2002-02-28 13:15   ` Kim F. Storm
  0 siblings, 0 replies; 7+ messages in thread
From: Kim F. Storm @ 2002-02-28 13:15 UTC (permalink / raw)
  Cc: emacs-devel, tzz

Per Abrahamsen <abraham@dina.kvl.dk> writes:

> Couldn't the same effect be achieved if font lock used categories
> instead of faces?  
> 

You are right.  That is the generic (i.e. proper) approach to doing
this.


Actually, the changes needed to change font-lock to use categories
instead of faces seem to be fairly trivial, if we do it like this
(illustrated by font-lock-comment-face):

(defface font-lock-comment-face ...)  ;; as now

(defvar font-lock-comment-face 'font-lock-comment-face)   ;; as now

(put 'font-lock-comment-face 'face font-lock-comment-face) ;; new

and then replace all

( .... 'face font-lock-comment-face)

with

( .... 'category 'font-lock-comment-face)

[this is an oversimplification as the properties are not
set in that way ... but I hope you get the idea].


However, the problem with this approach is that setting the
font-lock-comment-face variable to another face is not reflected in
the `face' property of font-lock-comment-face, so it will not longer
have any effect.   Any ideas how to overcome that problem?

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk


_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel


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

* Re: Idea: Allow faces to have text-like properties
  2002-02-28 10:25 Idea: Allow faces to have text-like properties Kim F. Storm
  2002-02-28 12:05 ` Per Abrahamsen
@ 2002-03-01  1:05 ` Stefan Monnier
  2002-03-01  1:11 ` Richard Stallman
  2 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2002-03-01  1:05 UTC (permalink / raw)
  Cc: emacs-devel, tzz

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

It would be convenient for X-Symbol since XEmacs has this feature
and X-Symbol uses it (the Emacs port of X-Symbol uses a hack to get
the "same" behavior: set the `font' property to a special font (distributed
with X-Symbol) that's of size 0x0).

Actually, I can't remember if XEmacs really has an `invisible' property
for its faces.  Maybe X-Symbol uses the `display-table' property instead
(which is available as a face-property under XEmacs) to make every char
into an empty glyph .


	Stefan


_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel


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

* Re: Idea: Allow faces to have text-like properties
  2002-02-28 10:25 Idea: Allow faces to have text-like properties Kim F. Storm
  2002-02-28 12:05 ` Per Abrahamsen
  2002-03-01  1:05 ` Stefan Monnier
@ 2002-03-01  1:11 ` Richard Stallman
  2002-03-01  1:24   ` Stefan Monnier
  2 siblings, 1 reply; 7+ messages in thread
From: Richard Stallman @ 2002-03-01  1:11 UTC (permalink / raw)
  Cc: emacs-devel, tzz

I don't think that faces should specify general text properties.
But it seems reasonable for font lock to be able to attach
other properties (including `category').

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel


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

* Re: Idea: Allow faces to have text-like properties
  2002-03-01  1:11 ` Richard Stallman
@ 2002-03-01  1:24   ` Stefan Monnier
  2002-03-05 19:02     ` Teodor Zlatanov
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2002-03-01  1:24 UTC (permalink / raw)
  Cc: no-spam, emacs-devel, tzz

> I don't think that faces should specify general text properties.
> But it seems reasonable for font lock to be able to attach
> other properties (including `category').

This feature is already implemented (recently, by yours truly):

** font-lock can manage arbitrary text-properties beside `face'.
*** the FACENAME returned in font-lock-keywords can be a list
of the form (face FACE PROP1 VAL1 PROP2 VAL2 ...) so you can set
other properties than `face'.
*** font-lock-extra-managed-props can be set to make sure those extra
properties are automatically cleaned up by font-lock.


	Stefan


_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel


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

* Re: Idea: Allow faces to have text-like properties
  2002-03-01  1:24   ` Stefan Monnier
@ 2002-03-05 19:02     ` Teodor Zlatanov
  0 siblings, 0 replies; 7+ messages in thread
From: Teodor Zlatanov @ 2002-03-05 19:02 UTC (permalink / raw)
  Cc: Richard Stallman, no-spam, emacs-devel

On Thu, Feb 28, 2002 at 08:24:25PM -0500, Stefan Monnier wrote:
> > I don't think that faces should specify general text properties.
> > But it seems reasonable for font lock to be able to attach
> > other properties (including `category').
> 
> This feature is already implemented (recently, by yours truly):
> 
> ** font-lock can manage arbitrary text-properties beside `face'.
> *** the FACENAME returned in font-lock-keywords can be a list
> of the form (face FACE PROP1 VAL1 PROP2 VAL2 ...) so you can set
> other properties than `face'.
> *** font-lock-extra-managed-props can be set to make sure those extra
> properties are automatically cleaned up by font-lock.

Has anyone taken interest in developing a package to utilize these text
properties to provide "invisible" (from the user's viewpoint) faces?  I
think it's a great idea.

Thanks
Ted

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel


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

end of thread, other threads:[~2002-03-05 19:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-02-28 10:25 Idea: Allow faces to have text-like properties Kim F. Storm
2002-02-28 12:05 ` Per Abrahamsen
2002-02-28 13:15   ` Kim F. Storm
2002-03-01  1:05 ` Stefan Monnier
2002-03-01  1:11 ` Richard Stallman
2002-03-01  1:24   ` Stefan Monnier
2002-03-05 19:02     ` Teodor Zlatanov

Code repositories for project(s) associated with this public inbox

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

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