From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Glenn Morris Newsgroups: gmane.emacs.bugs Subject: bug#33799: 27.0.50; set-foreground-color completion shows background colors Date: Wed, 19 Dec 2018 13:51:59 -0500 Message-ID: <5aftutcptc.fsf@fencepost.gnu.org> References: <875zvqz8om.fsf@mail.linkov.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1545245477 7444 195.159.176.226 (19 Dec 2018 18:51:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 19 Dec 2018 18:51:17 +0000 (UTC) User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) Cc: 33799@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Dec 19 19:51:13 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gZgvz-0001eD-8r for geb-bug-gnu-emacs@m.gmane.org; Wed, 19 Dec 2018 19:51:07 +0100 Original-Received: from localhost ([::1]:33634 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZgy6-0002It-0T for geb-bug-gnu-emacs@m.gmane.org; Wed, 19 Dec 2018 13:53:18 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40190) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZgxv-0002HY-Aa for bug-gnu-emacs@gnu.org; Wed, 19 Dec 2018 13:53:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZgxq-0007fV-7s for bug-gnu-emacs@gnu.org; Wed, 19 Dec 2018 13:53:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:50832) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gZgxq-0007fO-3h for bug-gnu-emacs@gnu.org; Wed, 19 Dec 2018 13:53:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gZgxq-0000Go-0O for bug-gnu-emacs@gnu.org; Wed, 19 Dec 2018 13:53:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Glenn Morris Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 19 Dec 2018 18:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33799 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 33799-submit@debbugs.gnu.org id=B33799.1545245533968 (code B ref 33799); Wed, 19 Dec 2018 18:53:01 +0000 Original-Received: (at 33799) by debbugs.gnu.org; 19 Dec 2018 18:52:13 +0000 Original-Received: from localhost ([127.0.0.1]:55090 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gZgx2-0000FY-Kw for submit@debbugs.gnu.org; Wed, 19 Dec 2018 13:52:12 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:58562) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gZgx1-0000FK-RL for 33799@debbugs.gnu.org; Wed, 19 Dec 2018 13:52:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZgwv-0006n6-3Q for 33799@debbugs.gnu.org; Wed, 19 Dec 2018 13:52:06 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:43997) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZgwp-0006l0-Ti; Wed, 19 Dec 2018 13:52:01 -0500 Original-Received: from rgm by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1gZgwp-0007Sd-PX; Wed, 19 Dec 2018 13:51:59 -0500 X-Spook: Tehrik-i-Taliban Pakistan Arnett Influenza DES Power X-Ran: /<[{md^PTPS)]`4\'OII|llu&.N:jT#(A)*vxJYz$HNz%]z0"&b^y~H)=c$'=^;x-?h*uN X-Hue: white X-Attribution: GM In-Reply-To: <875zvqz8om.fsf@mail.linkov.net> (Juri Linkov's message of "Wed, 19 Dec 2018 02:01:13 +0200") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:153608 Archived-At: Juri Linkov wrote: > 0. emacs -Q > > 1. M-x set-foreground-color RET TAB > > shows a completion list of colors with different backgrounds, not > foregrounds as it would be natural to expect Very lightly tested: --- i/lisp/faces.el +++ w/lisp/faces.el @@ -1838,18 +1838,21 @@ defined-colors (mapcar 'car (tty-color-alist frame)))) (defalias 'x-defined-colors 'defined-colors) -(defun defined-colors-with-face-attributes (&optional frame) +(defun defined-colors-with-face-attributes (&optional frame foreground) "Return a list of colors supported for a particular frame. See `defined-colors' for arguments and return value. In contrast to `define-colors' the elements of the returned list are color strings with text properties, that make the color names render -with the color they represent as background color." +with the color they represent as background (or foreground if +optional argument FOREGROUND is no-nil) color. " (mapcar (lambda (color-name) - (let ((foreground (readable-foreground-color color-name)) - (color (copy-sequence color-name))) - (propertize color 'face (list :foreground foreground - :background color)))) + (let ((readable (readable-foreground-color color-name)) + (color (copy-sequence color-name))) + (propertize color 'face + (if foreground + (list :foreground color) + (list :foreground readable :background color))))) (defined-colors frame))) (defun readable-foreground-color (color) @@ -1935,7 +1938,8 @@ display-grayscale-p (t (> (tty-color-gray-shades display) 2))))) -(defun read-color (&optional prompt convert-to-RGB allow-empty-name msg) +(defun read-color (&optional prompt convert-to-RGB allow-empty-name msg + foreground) "Read a color name or RGB triplet. Completion is available for color names, but not for RGB triplets. @@ -1962,14 +1966,19 @@ read-color to enter an empty color name (the empty string). Interactively, or with optional arg MSG non-nil, print the -resulting color name in the echo area." +resulting color name in the echo area. + +Interactively, displays a list of colored completions. If optional +argument FOREGROUND is non-nil, shows them as foregrounds, otherwise +as backgrounds." (interactive "i\np\ni\np") ; Always convert to RGB interactively. (let* ((completion-ignore-case t) (colors (or facemenu-color-alist (append '("foreground at point" "background at point") (if allow-empty-name '("")) (if (display-color-p) - (defined-colors-with-face-attributes) + (defined-colors-with-face-attributes + nil foreground) (defined-colors))))) (color (completing-read (or prompt "Color (name or #RGB triplet): ") diff --git i/lisp/frame.el w/lisp/frame.el index 56b8c54..f056b6d 100644 --- i/lisp/frame.el +++ w/lisp/frame.el @@ -1335,7 +1335,7 @@ set-foreground-color "Set the foreground color of the selected frame to COLOR-NAME. When called interactively, prompt for the name of the color to use. To get the frame's current foreground color, use `frame-parameters'." - (interactive (list (read-color "Foreground color: "))) + (interactive (list (read-color "Foreground color: " nil nil nil t))) (modify-frame-parameters (selected-frame) (list (cons 'foreground-color color-name))) (or window-system