]> git.eshelyaron.com Git - emacs.git/commitdiff
* facemenu.el (list-colors-print): New function created from code
authorJuri Linkov <juri@jurta.org>
Wed, 12 Jan 2005 00:33:00 +0000 (00:33 +0000)
committerJuri Linkov <juri@jurta.org>
Wed, 12 Jan 2005 00:33:00 +0000 (00:33 +0000)
in list-colors-display.  Print #RRGGBB at the window right edge.
(list-colors-display): When temp-buffer-show-function is not
defined, call list-colors-print from temp-buffer-show-hook
to get the right value of window-width in list-colors-print
after the buffer is displayed.

lisp/ChangeLog
lisp/facemenu.el

index a4c4c0d030efa61d1a4092ef5736f80bac7944d7..bfd88a6e9f70982a7241c76921d86dd9b7073d4c 100644 (file)
        (list-colors-duplicates): New function.
        (facemenu-color-name-equal): Delete function.
 
+       * facemenu.el (list-colors-print): New function created from code
+       in list-colors-display.  Print #RRGGBB at the window right edge.
+       (list-colors-display): When temp-buffer-show-function is not
+       defined, call list-colors-print from temp-buffer-show-hook
+       to get the right value of window-width in list-colors-print
+       after the buffer is displayed.
+
 2005-01-12  Juri Linkov  <juri@jurta.org>
 
        * isearch.el (search-highlight, isearch, isearch-lazy-highlight):
index 7179523eec8489eabcf9247614debd42441d4ca0..127b8fe608b1a74aba38d1a351eca2711eb78700 100644 (file)
@@ -489,27 +489,42 @@ argument BUFFER-NAME is nil, it defaults to *Colors*."
     (save-excursion
       (set-buffer standard-output)
       (setq truncate-lines t)
-      (dolist (color list)
-       (if (consp color)
-           (if (cdr color)
-               (setq color (sort color (lambda (a b)
-                                         (string< (downcase a)
-                                                  (downcase b))))))
-         (setq color (list color)))
-       (put-text-property
-        (prog1 (point)
-          (insert (car color))
-          (indent-to 22))
-        (point)
-        'face (cons 'background-color (car color)))
-       (put-text-property
-        (prog1 (point)
-          (insert "  " (if (cdr color)
-                           (mapconcat 'identity (cdr color) ", ")
-                         (car color))
-                  "\n"))
-        (point)
-        'face (cons 'foreground-color (car color)))))))
+      (if temp-buffer-show-function
+         (list-colors-print list)
+       ;; Call list-colors-print from temp-buffer-show-hook
+       ;; to get the right value of window-width in list-colors-print
+       ;; after the buffer is displayed.
+       (add-hook 'temp-buffer-show-hook
+                 (lambda () (list-colors-print list)) nil t)))))
+
+(defun list-colors-print (list)
+  (dolist (color list)
+    (if (consp color)
+       (if (cdr color)
+           (setq color (sort color (lambda (a b)
+                                     (string< (downcase a)
+                                              (downcase b))))))
+      (setq color (list color)))
+    (put-text-property
+     (prog1 (point)
+       (insert (car color))
+       (indent-to 22))
+     (point)
+     'face (cons 'background-color (car color)))
+    (put-text-property
+     (prog1 (point)
+       (insert "  " (if (cdr color)
+                       (mapconcat 'identity (cdr color) ", ")
+                     (car color)))
+       (indent-to (max (- (window-width) 8) 44))
+       (insert (apply 'format " #%02x%02x%02x"
+                     (mapcar (lambda (c) (lsh c -8))
+                             (color-values (car color)))))
+
+       (insert "\n"))
+     (point)
+     'face (cons 'foreground-color (car color))))
+  (goto-char (point-min)))
 
 (defun list-colors-duplicates (&optional list)
   "Return a list of colors with grouped duplicate colors.