summaryrefslogtreecommitdiff
path: root/lisp/facemenu.el
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2013-03-27 18:03:15 +0200
committerEli Zaretskii <eliz@gnu.org>2013-03-27 18:03:15 +0200
commitb59f639d99a4bb3f29d8700c084b2b4082eba877 (patch)
tree657ddce741d5cba5e4ab768a79fcb8357af22fe2 /lisp/facemenu.el
parentb1da29572e811d18ee5f200a28192ea2f58ff9bf (diff)
downloademacs-b59f639d99a4bb3f29d8700c084b2b4082eba877.tar.gz
Fix bug #14063 with reverting the *Colors* buffer.
lisp/facemenu.el (list-colors-callback): New defvar. (list-colors-redisplay): New function. (list-colors-display): Install list-colors-redisplay as the revert-buffer-function.
Diffstat (limited to 'lisp/facemenu.el')
-rw-r--r--lisp/facemenu.el15
1 files changed, 14 insertions, 1 deletions
diff --git a/lisp/facemenu.el b/lisp/facemenu.el
index e86c1c23d66..9a66edd28fc 100644
--- a/lisp/facemenu.el
+++ b/lisp/facemenu.el
@@ -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.")))