From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key Date: Tue, 19 Oct 2021 14:43:28 +0300 Message-ID: <83sfwxck9r.fsf@gnu.org> References: <87bl4jvudm.fsf@gnus.org> <837dehp248.fsf@gnu.org> <87czo96shw.fsf@gnus.org> <87wnmh5bes.fsf@gnus.org> <87wnmh3p9k.fsf@gnus.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28285"; mail-complaints-to="usenet@ciao.gmane.io" Cc: shuguang79@qq.com, larsi@gnus.org, 50752@debbugs.gnu.org To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Oct 19 13:56:00 2021 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 1mcnip-0007Dd-KX for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 19 Oct 2021 13:55:59 +0200 Original-Received: from localhost ([::1]:56788 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mcnio-0008Ka-Iq for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 19 Oct 2021 07:55:58 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mcnXH-0000EV-2O for bug-gnu-emacs@gnu.org; Tue, 19 Oct 2021 07:44:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38150) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mcnXG-0004wo-JT for bug-gnu-emacs@gnu.org; Tue, 19 Oct 2021 07:44:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mcnXG-0004PJ-Hq for bug-gnu-emacs@gnu.org; Tue, 19 Oct 2021 07:44:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 19 Oct 2021 11:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50752 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 50752-submit@debbugs.gnu.org id=B50752.163464381216879 (code B ref 50752); Tue, 19 Oct 2021 11:44:02 +0000 Original-Received: (at 50752) by debbugs.gnu.org; 19 Oct 2021 11:43:32 +0000 Original-Received: from localhost ([127.0.0.1]:49689 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mcnWl-0004OB-MC for submit@debbugs.gnu.org; Tue, 19 Oct 2021 07:43:31 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:52474) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mcnWj-0004Nv-Al for 50752@debbugs.gnu.org; Tue, 19 Oct 2021 07:43:30 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:49800) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mcnWb-0004Wn-8k; Tue, 19 Oct 2021 07:43:21 -0400 Original-Received: from [87.69.77.57] (port=2543 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mcnWa-0001uf-Bk; Tue, 19 Oct 2021 07:43:21 -0400 In-Reply-To: (message from Stefan Kangas on Mon, 18 Oct 2021 20:22:18 -0700) 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" Xref: news.gmane.io gmane.emacs.bugs:217561 Archived-At: > From: Stefan Kangas > Date: Mon, 18 Oct 2021 20:22:18 -0700 > Cc: Eli Zaretskii , Shuguang Sun , 50752@debbugs.gnu.org > > If anyone has any preferences or further ideas here, that would be much > appreciated, otherwise I'll keep investigating. > > The attached patch is what I have so far. It's obviously not yet > finished, but all tests pass except for the one for "I->i" conversion in > the Turkish language environment. Don't give up, you are close. > + memcpy (dst, SSDATA (lc_key), SBYTES (lc_key)); > + for (int i = 0; i < SBYTES (lc_key); ++i) > + { > + if (*(dst + i) == ' ') > + *(dst + i) = '-'; > + } If you want to use an index to walk the string data, as you did above, please use dst[i] instead of *(dst + i); the latter is correct, but ugly and un-C-ish. Or you could use a pointer to walk, like this: unsigned char *p = dst, *dst_end = dst + SBYTES (lc_key); for ( ; p < dst_end; p++) { if (*p == ' ') *p = '-'; } > > We could use the equivalent of > > > > (get-char-code-property ?I 'lowercase) > > > > If the above returns nil, it means the lower-case variant is the > > character itself. > > > > In C, this means to use uniprop_table, like bidi.c and casefiddle.c > > do. This accesses the database generated from UnicodeData.txt. > > I didn't try this approach, mostly because it sounds more difficult to > implement than what Lars said. I think? Wouldn't it amount to > basically re-implementing Fdowncase? Sorry, I didn't look too closely > at this. Perhaps this would be the better approach. It shouldn't be hard. You need to call uniprop_table to get a char-table: Lisp_Object unicode_case_table = uniprop_table (intern ("lowercase")); which you then reference with int low_ch = XFIXNUM (CHAR_TABLE_REF (unicode_case_table, ch)); to get the codepoint of the lower-case character that corresponds to the (possibly upper-case) character whose codepoint is CH. Then downcasing a string boils down to a loop that fetches characters one by one with fetch_string_char_advance and then stores the lower-case characters, obtained as above, with CHAR_STRING. (It's a bit more complicated than that, because CHAR_TABLE_REF can return nil for the characters that are either already lower-case or don't have case variants. And the uniprop_table call should be done once, at startup time, or upon first usage, and stored in a staticpro'd variable, see bidi_initialize for an example.)