]> code.delx.au - gnu-emacs/blobdiff - lisp/facemenu.el
* lisp/descr-text.el (describe-char-unicode-data): Fix copy/paste errors.
[gnu-emacs] / lisp / facemenu.el
index 88b9ddc7f54f036a8f866304be8af37fc38b0c0f..8b01c4e47bfe8af5d1251770dad63181d7afdb69 100644 (file)
@@ -1,6 +1,6 @@
 ;;; facemenu.el --- create a face menu for interactively adding fonts to text
 
-;; Copyright (C) 1994-1996, 2001-2012 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1996, 2001-2016 Free Software Foundation, Inc.
 
 ;; Author: Boris Goldowsky <boris@gnu.org>
 ;; Keywords: faces
@@ -329,7 +329,7 @@ This command can also add FACE to the menu of faces,
 if `facemenu-listed-faces' says to do that."
   (interactive (list (progn
                       (barf-if-buffer-read-only)
-                      (read-face-name "Use face"))
+                      (read-face-name "Use face" (face-at-point t)))
                     (if (and mark-active (not current-prefix-arg))
                         (region-beginning))
                     (if (and mark-active (not current-prefix-arg))
@@ -458,7 +458,7 @@ These special properties include `invisible', `intangible' and `read-only'."
 
 (defcustom list-colors-sort nil
   "Color sort order for `list-colors-display'.
-`nil' means default implementation-dependent order (defined in `x-colors').
+nil means default implementation-dependent order (defined in `x-colors').
 `name' sorts by color name.
 `rgb' sorts by red, green, blue components.
 `(rgb-dist . COLOR)' sorts by the RGB distance to the specified color.
@@ -513,12 +513,23 @@ filter out the color from the output."
         (* (nth 1 c-rgb) 0.7151522)
         (* (nth 2 c-rgb) 0.0721750))))))
 
+(defvar list-colors-callback nil
+  "Value of CALLBACK arg passed to `list-colors-display'; internal use.")
+
+(defun list-colors-redisplay (_ignore-auto _noconfirm)
+  "Redisplay the colors using `list-colors-sort'.
+
+This is installed as a `revert-buffer-function' in the *Colors* buffer."
+  (list-colors-display nil (buffer-name) list-colors-callback))
+
 (defun list-colors-display (&optional list buffer-name callback)
   "Display names of defined colors, and show what they look like.
 If the optional argument LIST is non-nil, it should be a list of
 colors to display.  Otherwise, this command computes a list of
 colors that the current display can handle.  Customize
 `list-colors-sort' to change the order in which colors are shown.
+Type `g' or \\[revert-buffer] after customizing `list-colors-sort'
+to redisplay colors in the new order.
 
 If the optional argument BUFFER-NAME is nil, it defaults to *Colors*.
 
@@ -566,7 +577,9 @@ color.  The function should accept a single argument, the color name."
       (erase-buffer)
       (list-colors-print list callback)
       (set-buffer-modified-p nil)
-      (setq truncate-lines t)))
+      (setq truncate-lines t)
+      (setq-local list-colors-callback callback)
+      (setq revert-buffer-function 'list-colors-redisplay)))
   (when callback
     (pop-to-buffer buffer-name)
     (message "Click on a color to select it.")))
@@ -607,7 +620,7 @@ color.  The function should accept a single argument, the color name."
                 'help-echo
                 (let ((hsv (apply 'color-rgb-to-hsv
                                   (color-name-to-rgb (car color)))))
-                  (format "H:%d S:%d V:%d"
+                  (format "H:%.2f S:%.2f V:%.2f"
                           (nth 0 hsv) (nth 1 hsv) (nth 2 hsv)))))
        (when callback
          (make-text-button
@@ -624,8 +637,8 @@ color.  The function should accept a single argument, the color name."
 (defun list-colors-duplicates (&optional list)
   "Return a list of colors with grouped duplicate colors.
 If a color has no duplicates, then the element of the returned list
-has the form '(COLOR-NAME).  The element of the returned list with
-duplicate colors has the form '(COLOR-NAME DUPLICATE-COLOR-NAME ...).
+has the form (COLOR-NAME).  The element of the returned list with
+duplicate colors has the form (COLOR-NAME DUPLICATE-COLOR-NAME ...).
 This function uses the predicate `facemenu-color-equal' to compare
 color names.  If the optional argument LIST is non-nil, it should
 be a list of colors to display.  Otherwise, this function uses
@@ -719,7 +732,7 @@ effect.  See `facemenu-remove-face-function'."
                                  face
                                (facemenu-active-faces
                                 (cons face
-                                      (if (listp prev)
+                                      (if (face-list-p prev)
                                           prev
                                         (list prev)))
                                 ;; Specify the selected frame