unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* list-faces-display
@ 2005-05-30 13:39 Juanma Barranquero
  2005-05-31 11:15 ` list-faces-display Juanma Barranquero
  2005-06-01  9:39 ` list-faces-display Richard Stallman
  0 siblings, 2 replies; 6+ messages in thread
From: Juanma Barranquero @ 2005-05-30 13:39 UTC (permalink / raw)


The new regexp argument for list-faces-display is not documented on
NEWS. Should it? And if yes, in what section? "Changes in Specialized
Modes and Packages in Emacs 22.1" and "Lisp Changes in Emacs 22.1"
both seem in order.

Somewhat related: on 1999-07-21 Gerd committed lots and lots of
changes (possibly he was synchronizing from a branch). faces.el got an
almost complete rewrite, and in particular list-faces-display lost the
following ability:

1999-01-11  Richard Stallman  <rms@psilocin.ai.mit.edu>

        * faces.el (list-faces-display): Improve the formatting
        by computing the maximum length required for any face-name.

(I'm attaching a patch that shows the changes done to
list-faces-display; line numbers are wrong because I've cut out just
the code for the function)

Question is, should this change be reverted? And, it is that a bugfix
or a new feature?

                    /L/e/k/t/u


--- faces-1.138	Mon May 30 13:35:15 2005
+++ faces-1.139	Mon May 30 13:35:29 2005
@@ -1,2 +1 @@
-\f
  (defvar list-faces-sample-text
@@ -5,4 +4,6 @@
 
-;; The name list-faces would be more consistent, but let's avoid a conflict
-;; with Lucid, which uses that name differently.
+
+;; The name list-faces would be more consistent, but let's avoid a
+;; conflict with Lucid, which uses that name differently.
+
  (defun list-faces-display ()
@@ -10,16 +11,8 @@
 The sample text is a string that comes from the variable
-`list-faces-sample-text'.
-
-It is possible to give a particular face name different appearances in
-different frames.  This command shows the appearance in the
-selected frame."
+`list-faces-sample-text'."
   (interactive)
-  (let ((faces (sort (face-list) (function string-lessp)))
+  (let ((faces (sort (face-list) #'string-lessp))
 	(face nil)
 	(frame (selected-frame))
-	disp-frame window
-        (face-name-max-length
-         (car (sort (mapcar (function string-width)
-			    (mapcar (function symbol-name) (face-list)))
-                    (function >)))))
+	disp-frame window)
     (with-output-to-temp-buffer "*Faces*"
@@ -31,6 +24,3 @@
  	  (setq faces (cdr faces))
-	  (insert (format 
-                   (format "%%-%ds "
-                           face-name-max-length)
-                   (symbol-name face)))
+	  (insert (format "%25s " (face-name face)))
 	  (let ((beg (point)))
@@ -43,3 +33,3 @@
  	    (while (not (eobp))
-	      (insert-char ?  (1+ face-name-max-length))
+	      (insert "                          ")
 	      (forward-line 1))))

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

* Re: list-faces-display
  2005-05-30 13:39 list-faces-display Juanma Barranquero
@ 2005-05-31 11:15 ` Juanma Barranquero
  2005-05-31 11:17   ` list-faces-display Juanma Barranquero
  2005-06-01  9:39 ` list-faces-display Richard Stallman
  1 sibling, 1 reply; 6+ messages in thread
From: Juanma Barranquero @ 2005-05-31 11:15 UTC (permalink / raw)


Anyway, this is the patch I propose, if deemed a fix and not a feature.

-- 
                    /L/e/k/t/u


Index: faces.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/faces.el,v
retrieving revision 1.310
diff -u -2 -r1.310 faces.el
--- faces.el	31 May 2005 11:10:43 -0000	1.310
+++ faces.el	31 May 2005 11:07:42 -0000
@@ -1155,16 +1155,21 @@
   (interactive (list (and current-prefix-arg
                           (read-string "List faces matching regexp: "))))
-  (let ((faces (sort (face-list) #'string-lessp))
+  (let ((all-faces (zerop (length regexp)))
 	(frame (selected-frame))
+	(max-length 0)
+	face line-format
  	disp-frame window face-name)
-    (when (> (length regexp) 0)
-      (setq faces
-            (delq nil
-                  (mapcar (lambda (f)
-                            (when (string-match regexp (symbol-name f))
-                              f))
-                          faces)))
-      (unless faces
-        (error "No faces matching \"%s\"" regexp)))
+    (setq faces
+	  (delq nil
+		(mapcar (lambda (f)
+			  (let ((s (symbol-name f)))
+			    (when (or all-faces (string-match regexp s))
+			      (setq max-length (max (length s) max-length))
+			      f)))
+			(sort (face-list) #'string-lessp))))
+    (unless faces
+      (error "No faces matching \"%s\"" regexp))
+    (setq max-length (1+ max-length)
+	  line-format (format "%%-%ds" max-length))
     (with-output-to-temp-buffer "*Faces*"
       (save-excursion
@@ -1181,5 +1186,5 @@
  	(dolist (face faces)
  	  (setq face-name (symbol-name face))
-	  (insert (format "%25s " face-name))
+	  (insert (format line-format face-name))
 	  ;; Hyperlink to a customization buffer for the face.  Using
 	  ;; the help xref mechanism may not be the best way.
@@ -1206,5 +1211,5 @@
 	    (forward-line 1)
  	    (while (not (eobp))
-	      (insert "                          ")
+	      (insert-char ?\s max-length)
 	      (forward-line 1))))
  	(goto-char (point-min)))

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

* Re: list-faces-display
  2005-05-31 11:15 ` list-faces-display Juanma Barranquero
@ 2005-05-31 11:17   ` Juanma Barranquero
  0 siblings, 0 replies; 6+ messages in thread
From: Juanma Barranquero @ 2005-05-31 11:17 UTC (permalink / raw)


> +       face line-format

That would be

> +       faces line-format

of course.

                    /L/e/k/t/u

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

* Re: list-faces-display
  2005-05-30 13:39 list-faces-display Juanma Barranquero
  2005-05-31 11:15 ` list-faces-display Juanma Barranquero
@ 2005-06-01  9:39 ` Richard Stallman
  2005-06-01 10:04   ` list-faces-display Juanma Barranquero
  1 sibling, 1 reply; 6+ messages in thread
From: Richard Stallman @ 2005-06-01  9:39 UTC (permalink / raw)
  Cc: emacs-devel

Please do reinstall the 1999 code that got lost.

    The new regexp argument for list-faces-display is not documented on
    NEWS. Should it? And if yes, in what section? "Changes in Specialized
    Modes and Packages in Emacs 22.1" and "Lisp Changes in Emacs 22.1"
    both seem in order.

The latter is better--this isn't big enough to be called a
"specialized mode or package".

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

* Re: list-faces-display
  2005-06-01  9:39 ` list-faces-display Richard Stallman
@ 2005-06-01 10:04   ` Juanma Barranquero
  2005-06-02  6:40     ` list-faces-display Richard Stallman
  0 siblings, 1 reply; 6+ messages in thread
From: Juanma Barranquero @ 2005-06-01 10:04 UTC (permalink / raw)


> Please do reinstall the 1999 code that got lost.

OK (I'll install the patch I sent, which is a reworking of it).

> The latter is better--this isn't big enough to be called a
> "specialized mode or package".

No, but it is a "change in a specialized mode or package". The problem
with describing the new feature only on Lisp Changes (though it also
is that) is that it misses the fact that the user-level command can
now be called with C-u to force it to ask for a regexp.

-- 
                    /L/e/k/t/u

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

* Re: list-faces-display
  2005-06-01 10:04   ` list-faces-display Juanma Barranquero
@ 2005-06-02  6:40     ` Richard Stallman
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Stallman @ 2005-06-02  6:40 UTC (permalink / raw)
  Cc: emacs-devel

    > The latter is better--this isn't big enough to be called a
    > "specialized mode or package".

    No, but it is a "change in a specialized mode or package".

list-faces-display is not big enough to be called a "specialized mode
or package".

     The problem
    with describing the new feature only on Lisp Changes (though it also
    is that) is that it misses the fact that the user-level command can
    now be called with C-u to force it to ask for a regexp.

Then put it in the user-level command changes page.

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

end of thread, other threads:[~2005-06-02  6:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-30 13:39 list-faces-display Juanma Barranquero
2005-05-31 11:15 ` list-faces-display Juanma Barranquero
2005-05-31 11:17   ` list-faces-display Juanma Barranquero
2005-06-01  9:39 ` list-faces-display Richard Stallman
2005-06-01 10:04   ` list-faces-display Juanma Barranquero
2005-06-02  6:40     ` list-faces-display Richard Stallman

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