[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key
From: |
Lars Ingebrigtsen |
Subject: |
bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key |
Date: |
Tue, 19 Oct 2021 19:12:20 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
Eli Zaretskii <eliz@gnu.org> writes:
> I think we can leave the behavior with raw bytes as it is, and still
> document this use case as being meant for ASCII conversions, leaving
> the subtle case of raw bytes ... subtle.
Yup.
The following patch seems to do the trick, and should be conservative
enough for emacs-28, I think.
diff --git a/src/casefiddle.c b/src/casefiddle.c
index a7a2541490..edc9dec2d7 100644
--- a/src/casefiddle.c
+++ b/src/casefiddle.c
@@ -297,6 +297,16 @@ do_casify_multibyte_string (struct casing_context *ctx,
Lisp_Object obj)
return obj;
}
+static int
+ascii_casify_character (bool downcase, int c)
+{
+ Lisp_Object cased = CHAR_TABLE_REF (downcase?
+ uniprop_table (Qlowercase) :
+ uniprop_table (Quppercase),
+ c);
+ return FIXNATP (cased) ? XFIXNAT (cased) : c;
+}
+
static Lisp_Object
do_casify_unibyte_string (struct casing_context *ctx, Lisp_Object obj)
{
@@ -310,11 +320,12 @@ do_casify_unibyte_string (struct casing_context *ctx,
Lisp_Object obj)
cased = case_single_character (ctx, ch);
if (ch == cased)
continue;
- cased = make_char_unibyte (cased);
- /* If the char can't be converted to a valid byte, just don't
- change it. */
- if (SINGLE_BYTE_CHAR_P (cased))
- SSET (obj, i, cased);
+ /* If down/upcasing changed an ASCII character into a non-ASCII
+ character (this can happen in some locales, like the Turkish
+ "I"), downcase using the ASCII char table. */
+ if (SINGLE_BYTE_CHAR_P (ch) && !SINGLE_BYTE_CHAR_P (cased))
+ cased = ascii_casify_character (ctx->flag == CASE_DOWN, ch);
+ SSET (obj, i, make_char_unibyte (cased));
}
return obj;
}
@@ -651,6 +662,8 @@ syms_of_casefiddle (void)
DEFSYM (Qbounds, "bounds");
DEFSYM (Qidentity, "identity");
DEFSYM (Qtitlecase, "titlecase");
+ DEFSYM (Qlowercase, "lowercase");
+ DEFSYM (Quppercase, "uppercase");
DEFSYM (Qspecial_uppercase, "special-uppercase");
DEFSYM (Qspecial_lowercase, "special-lowercase");
DEFSYM (Qspecial_titlecase, "special-titlecase");
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, (continued)
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Eli Zaretskii, 2021/10/19
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Lars Ingebrigtsen, 2021/10/19
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Eli Zaretskii, 2021/10/19
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Lars Ingebrigtsen, 2021/10/19
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Lars Ingebrigtsen, 2021/10/19
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Eli Zaretskii, 2021/10/19
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key,
Lars Ingebrigtsen <=
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Eli Zaretskii, 2021/10/19
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Lars Ingebrigtsen, 2021/10/19
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Eli Zaretskii, 2021/10/20
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Glenn Morris, 2021/10/20
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Stefan Kangas, 2021/10/24
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Lars Ingebrigtsen, 2021/10/25
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Eli Zaretskii, 2021/10/25
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Lars Ingebrigtsen, 2021/10/25
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Eli Zaretskii, 2021/10/25
- bug#50752: 28.0.50; easy-menu-define lowers the menu-bar key, Lars Ingebrigtsen, 2021/10/25