From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Brennan Vincent Newsgroups: gmane.emacs.bugs Subject: bug#61521: "default" is now the first item returned from (font-faces), breaking various code. Date: Wed, 15 Feb 2023 11:19:54 -0500 Message-ID: <05d313ea-7355-189f-62b0-1ba439ff0acf@umanwizard.com> References: <831qmrcch3.fsf@gnu.org> <2485DA7C-3614-4182-BC29-7EFCF5C86A45@umanwizard.com> <83cz6batw1.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12728"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Cc: 61521@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Feb 15 17:21:24 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pSKX6-00036Y-Ib for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 15 Feb 2023 17:21:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSKWm-0003FS-Aw; Wed, 15 Feb 2023 11:21:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSKWk-0003EF-S6 for bug-gnu-emacs@gnu.org; Wed, 15 Feb 2023 11:21:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSKWk-0001fC-JP for bug-gnu-emacs@gnu.org; Wed, 15 Feb 2023 11:21:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pSKWk-0000nh-Cb for bug-gnu-emacs@gnu.org; Wed, 15 Feb 2023 11:21:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Brennan Vincent Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 15 Feb 2023 16:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61521 X-GNU-PR-Package: emacs Original-Received: via spool by 61521-submit@debbugs.gnu.org id=B61521.16764780112956 (code B ref 61521); Wed, 15 Feb 2023 16:21:02 +0000 Original-Received: (at 61521) by debbugs.gnu.org; 15 Feb 2023 16:20:11 +0000 Original-Received: from localhost ([127.0.0.1]:33735 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pSKVv-0000lc-2V for submit@debbugs.gnu.org; Wed, 15 Feb 2023 11:20:11 -0500 Original-Received: from smtp.umanwizard.com ([54.203.248.109]:51387) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pSKVr-0000kz-Aq for 61521@debbugs.gnu.org; Wed, 15 Feb 2023 11:20:10 -0500 Original-Received: from [10.10.1.60] ([173.205.212.102]) by umanwizard.com ; 15 Feb 2023 16:19:57 +0000 X-Fes-Received-For: 61521@debbugs.gnu.org X-Fes-Received-From: Content-Language: en-US In-Reply-To: <83cz6batw1.fsf@gnu.org> X-Fes-Encrypted: true X-Fes-Ehlo-Domain: [10.10.1.60] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:255741 Archived-At: On 2023-02-15 09:24, Eli Zaretskii wrote: >> From: Brennan Vincent >> Date: Wed, 15 Feb 2023 09:01:31 -0500 >> Cc: 61521@debbugs.gnu.org >> >>> On Feb 15, 2023, at 07:58, Eli Zaretskii wrote: >>> >>>  >>>> >>>> Date: Tue, 14 Feb 2023 19:31:30 -0500 >>>> From: Brennan Vincent >>>> >>>> Various code seems to expect "default" to be the /last/ item in the list >>>> returned by that function, not the first. For example, this comment in faces.el: >>>> >>>> ;; The `reverse' is so that `default' goes first. >>>> (dolist (face (nreverse (face-list))) >>> >>> That comment is obsolete and needs to be changed (and the call to >>> nreverse should perhaps be removed). >> >> If the order returned by face-list is not guaranteed, then why does it do sorting at all? > > Good question. AFAICT, the sorting was added when we switched from > storing faces in alists to storing them in hash tables. It probably > sorted faces to be more compatible with what face-list returned before > the switch to hash table. So I suspect the order we have now is > simply a bug, and we do need to change the order of sorting to get > back the original order. I tend to agree. Sorry for not explaining this reasoning more fully in my original message. Here's what I suspect happened (not 100% sure, it's just a theory): (1) Initially set of faces was stored as a list, so it was naturally maintained in the inverse order that things were added to it (thus default would be at the end). (2) Now faces are stored in a hash table whose key is the face and whose value contains various pieces of data, including the face ID. (3) This face ID is allocated in increasing order (see e.g. this code in xfaces.c: Lisp_Object face_id = make_fixnum (next_lface_id); lface_id_to_name[next_lface_id] = face; Fput (face, Qface, face_id); ++next_lface_id; (4) Thus, `face-list` and `frame-face-alist` sorted the faces by face ID in order to maintain the old ordering behavior. However, the author accidentally inverted the comparison when doing so. > Gregory, any counter-arguments?