all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* describe-face should show an example of text in the face.
@ 2006-10-15 18:15 Yoni Rabkin Katzenell
  2006-10-15 21:44 ` Drew Adams
  0 siblings, 1 reply; 5+ messages in thread
From: Yoni Rabkin Katzenell @ 2006-10-15 18:15 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 444 bytes --]


Hello, I'm using GNU Emacs 22.0.50.1 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2006-10-15 on ardbeg

emacs/etc/TODO says: "describe-face should show an example of text in
the face."

The attached patch against `faces.el' adds the word "sample", rendered
in the appropriate face, to the top row of the `describe-face' pop-up
buffer.

An example result can be seen in this screenshot:
http://yrk.nfshost.com/images/faces-sample.png


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: describe_face.patch --]
[-- Type: text/x-patch, Size: 1292 bytes --]

Index: faces.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/faces.el,v
retrieving revision 1.354
diff -u -r1.354 faces.el
--- faces.el	14 Sep 2006 23:54:44 -0000	1.354
+++ faces.el	15 Oct 2006 18:01:00 -0000
@@ -32,6 +32,8 @@
   ;; Warning suppression -- can't require x-win in batch:
   (autoload 'xw-defined-colors "x-win"))
 
+(defvar faces-example-overlay nil)
+
 (defvar help-xref-stack-item)
 \f
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1253,6 +1255,14 @@
 	    (setq faces (cdr faces)))))))
 
 
+(defun faces-sample-overlay (face)
+  (let ((f (if (facep face) face 'default))
+	(start (point)))
+    (insert " sample")
+    (setq faces-example-overlay (make-overlay start (point)))
+    (overlay-put faces-example-overlay 'face f)))
+
+
 (defun describe-face (face &optional frame)
   "Display the properties of face FACE on FRAME.
 Interactively, FACE defaults to the faces of the character after point
@@ -1293,6 +1303,7 @@
 	      (insert "   undefined face.\n")
 	    (let ((customize-label "customize this face")
 		  file-name)
+	      (faces-sample-overlay f)
 	      (princ (concat " (" customize-label ")\n"))
 	      (insert "Documentation: "
 		      (or (face-documentation f)

[-- Attachment #3: Type: text/plain, Size: 56 bytes --]



-- 
   "Cut your own wood and it will warm you twice"

[-- Attachment #4: Type: text/plain, Size: 142 bytes --]

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

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

* RE: describe-face should show an example of text in the face.
  2006-10-15 18:15 describe-face should show an example of text in the face Yoni Rabkin Katzenell
@ 2006-10-15 21:44 ` Drew Adams
  2006-10-16  8:32   ` Yoni Rabkin Katzenell
  0 siblings, 1 reply; 5+ messages in thread
From: Drew Adams @ 2006-10-15 21:44 UTC (permalink / raw)


    emacs/etc/TODO says: "describe-face should show an example of text in
    the face."
    
    The attached patch against `faces.el' adds the word "sample", rendered
    in the appropriate face, to the top row of the `describe-face' pop-up
    buffer.
    
    An example result can be seen in this screenshot:
    http://yrk.nfshost.com/images/faces-sample.png

Good idea. How about showing two samples: foreground and background?

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

* Re: describe-face should show an example of text in the face.
  2006-10-15 21:44 ` Drew Adams
@ 2006-10-16  8:32   ` Yoni Rabkin Katzenell
  2006-10-16 16:28     ` Drew Adams
  0 siblings, 1 reply; 5+ messages in thread
From: Yoni Rabkin Katzenell @ 2006-10-16  8:32 UTC (permalink / raw)


"Drew Adams" <drew.adams@oracle.com> writes:

>     emacs/etc/TODO says: "describe-face should show an example of text in
>     the face."
>     
>     The attached patch against `faces.el' adds the word "sample", rendered
>     in the appropriate face, to the top row of the `describe-face' pop-up
>     buffer.
>     
>     An example result can be seen in this screenshot:
>     http://yrk.nfshost.com/images/faces-sample.png
>
> Good idea. How about showing two samples: foreground and background?

Like in `list-colors-display'? If that is not what you mean then I am
misunderstanding you.

-- 
   "Cut your own wood and it will warm you twice"

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

* RE: describe-face should show an example of text in the face.
  2006-10-16  8:32   ` Yoni Rabkin Katzenell
@ 2006-10-16 16:28     ` Drew Adams
  2006-10-16 20:01       ` Yoni Rabkin Katzenell
  0 siblings, 1 reply; 5+ messages in thread
From: Drew Adams @ 2006-10-16 16:28 UTC (permalink / raw)


    > Good idea. How about showing two samples: foreground and background?

    Like in `list-colors-display'? If that is not what you mean then I am
    misunderstanding you.

Yes, that's what I was thinking.

But I was mistakenly thinking of colors, not faces. Please ignore my
suggestion.

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

* Re: describe-face should show an example of text in the face.
  2006-10-16 16:28     ` Drew Adams
@ 2006-10-16 20:01       ` Yoni Rabkin Katzenell
  0 siblings, 0 replies; 5+ messages in thread
From: Yoni Rabkin Katzenell @ 2006-10-16 20:01 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 751 bytes --]

"Drew Adams" <drew.adams@oracle.com> writes:

>     > Good idea. How about showing two samples: foreground and background?
>
>     Like in `list-colors-display'? If that is not what you mean then I am
>     misunderstanding you.
>
> Yes, that's what I was thinking.
>
> But I was mistakenly thinking of colors, not faces. Please ignore my
> suggestion.

Your reply got me thinking. 

The following patch does exactly the same, except that it renders the
"sample" text to look just like the "sample" text in the `customize'
buffer. So that both are visually consistent examples.

The following screenshot shows how `describe-face' looks with the
attached patch, as compared with the `customize' buffer:

http://yrk.nfshost.com/images/faces-sample.png


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: describe_face.patch --]
[-- Type: text/x-patch, Size: 1467 bytes --]

Index: faces.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/faces.el,v
retrieving revision 1.354
diff -u -r1.354 faces.el
--- faces.el	14 Sep 2006 23:54:44 -0000	1.354
+++ faces.el	16 Oct 2006 19:52:28 -0000
@@ -32,6 +32,9 @@
   ;; Warning suppression -- can't require x-win in batch:
   (autoload 'xw-defined-colors "x-win"))
 
+(defvar faces-sample-overlay nil
+  "Overlay for showing an example of a face.")
+
 (defvar help-xref-stack-item)
 \f
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1253,6 +1256,17 @@
 	    (setq faces (cdr faces)))))))
 
 
+(defun faces-sample-overlay (face)
+  "Insert sample text with FACE.
+
+If FACE is not a face or nil, use the default face."
+  (let ((f (if (facep face) face 'default))
+	(start (+ (point) 2))) ;; +1 to skip leading space
+    (insert " (sample)")
+    (setq faces-sample-overlay (make-overlay start (1- (point))))
+    (overlay-put faces-sample-overlay 'face f)))
+
+
 (defun describe-face (face &optional frame)
   "Display the properties of face FACE on FRAME.
 Interactively, FACE defaults to the faces of the character after point
@@ -1293,6 +1307,7 @@
 	      (insert "   undefined face.\n")
 	    (let ((customize-label "customize this face")
 		  file-name)
+	      (faces-sample-overlay f)
 	      (princ (concat " (" customize-label ")\n"))
 	      (insert "Documentation: "
 		      (or (face-documentation f)

[-- Attachment #3: Type: text/plain, Size: 56 bytes --]



-- 
   "Cut your own wood and it will warm you twice"

[-- Attachment #4: Type: text/plain, Size: 142 bytes --]

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

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

end of thread, other threads:[~2006-10-16 20:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-15 18:15 describe-face should show an example of text in the face Yoni Rabkin Katzenell
2006-10-15 21:44 ` Drew Adams
2006-10-16  8:32   ` Yoni Rabkin Katzenell
2006-10-16 16:28     ` Drew Adams
2006-10-16 20:01       ` Yoni Rabkin Katzenell

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.