From unknown Sat Jun 21 05:14:26 2025 X-Loop: help-debbugs@gnu.org Subject: bug#66614: 29.1.50; Support not capitalizing words inside symbols Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 18 Oct 2023 16:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 66614 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 66614@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16976467673066 (code B ref -1); Wed, 18 Oct 2023 16:33:02 +0000 Received: (at submit) by debbugs.gnu.org; 18 Oct 2023 16:32:47 +0000 Received: from localhost ([127.0.0.1]:34561 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qt9TS-0000nO-IL for submit@debbugs.gnu.org; Wed, 18 Oct 2023 12:32:47 -0400 Received: from lists.gnu.org ([2001:470:142::17]:56010) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qt9TO-0000n6-1e for submit@debbugs.gnu.org; Wed, 18 Oct 2023 12:32:45 -0400 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 1qt9Ss-0007H7-B4 for bug-gnu-emacs@gnu.org; Wed, 18 Oct 2023 12:32:10 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qt9Sq-0006Xo-Mh for bug-gnu-emacs@gnu.org; Wed, 18 Oct 2023 12:32:10 -0400 From: Spencer Baugh Date: Wed, 18 Oct 2023 12:32:04 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=64.215.233.18; envelope-from=sbaugh@janestreet.com; helo=mxout5.mail.janestreet.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) Quick definitions: - word: a sequence of characters whose syntax is word constituent - symbol: a sequence of characters whose syntax is either word constituent or symbol constituent In some programming languages and styles, a symbol (or every symbol in a sequence of symbols) might be capitalized, but the individual words making up the symbol should never be capitalized. For example, in OCaml, type names Look_like_this and variable names look_like_this, but it is basically never correct for something to Look_Like_This. And one might have "aa_bb cc_dd ee_ff" or "Aa_bb Cc_dd Ee_ff", but never "Aa_Bb Cc_Dd Ee_Ff". Currently, case handling in casefiddle.c and Freplace_match always capitalizes individual words, which has undesirable effects when programming in these styles. Three examples: - If I have a variable "hash_set" and a type name "Hash_set", and I type "Ha" and dabbrev-expand, then depending on the context Ha may expand to Hash_Set instead of hash_set. But it is never correct to caplitalize internal words in this style, so we could avoid this. - If I have a variable foo and Foo, and I query-replace foo with bar_baz, the replacements will be bar_baz and Bar_Baz. But again it is never correct to capitalize internal words in this style. - More concretely, (progn (string-match "az" "Az") (replace-match "az_bz" nil nil "Az")) yields Az_Bz, but in this programming style it should always yield Az_bz. A naive solution is to change the syntax class of symbol constituents so that they are treated as part of words. Or, equivalently, to use superword-mode. This solution is incorrect, though: the distinction between symbols and words is still useful for word and symbol navigation commands, and other purposes besides. Changing the syntax class will break those other use cases. The only thing that needs to be changed is the case behavior. This is straightforwardly solvable by supporting a behavior where symbol constituents are treated as part of words only for case operations. A patch follows which adds a variable which allows that. In GNU Emacs 29.1.50 (build 11, x86_64-pc-linux-gnu, X toolkit, cairo version 1.15.12, Xaw scroll bars) of 2023-10-18 built on Repository revision: 9163e634e296435aa7a78bc6b77b4ee90666d2ac Repository branch: emacs-29 Windowing system distributor 'The X.Org Foundation', version 11.0.12011000 From unknown Sat Jun 21 05:14:26 2025 X-Loop: help-debbugs@gnu.org Subject: bug#66614: 29.1.50; Support not capitalizing words inside symbols Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 18 Oct 2023 17:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66614 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 66614@debbugs.gnu.org Received: via spool by 66614-submit@debbugs.gnu.org id=B66614.16976485386973 (code B ref 66614); Wed, 18 Oct 2023 17:03:01 +0000 Received: (at 66614) by debbugs.gnu.org; 18 Oct 2023 17:02:18 +0000 Received: from localhost ([127.0.0.1]:34580 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qt9w2-0001oP-5U for submit@debbugs.gnu.org; Wed, 18 Oct 2023 13:02:18 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:36385) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qt9vz-0001o6-DP for 66614@debbugs.gnu.org; Wed, 18 Oct 2023 13:02:16 -0400 From: Spencer Baugh In-Reply-To: (Spencer Baugh's message of "Wed, 18 Oct 2023 12:32:04 -0400") References: Date: Wed, 18 Oct 2023 13:01:43 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Patch follows. --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline; filename=0001-Add-case-symbols-as-words-to-configure-symbol-case-b.patch Content-Transfer-Encoding: quoted-printable >From e11c5096b2e0a3eddec8fac692142ff31c889109 Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Wed, 18 Oct 2023 12:51:37 -0400 Subject: [PATCH] Add case-symbols-as-words to configure symbol case behavior In some programming languages and styles, a symbol (or every symbol in a sequence of symbols) might be capitalized, but the individual words making up the symbol should never be capitalized. For example, in OCaml, type names Look_like_this and variable names look_like_this, but it is basically never correct for something to Look_Like_This. And one might have "aa_bb cc_dd ee_ff" or "Aa_bb Cc_dd Ee_ff", but never "Aa_Bb Cc_Dd Ee_Ff". To support this, the new variable case-symbols-as-words causes symbol constituents to be treated as part of words only for case operations. * src/casefiddle.c (case_ch_is_word): Add. (case_character_impl): Use case_ch_is_word. (case_character): Use case_ch_is_word. (syms_of_casefiddle): Define case-symbols-as-words. (bug#66614) * src/search.c (Freplace_match): Use case-symbols-as-words when calculating case pattern. * test/src/casefiddle-tests.el (casefiddle-tests--check-syms) (casefiddle-case-symbols-as-words): Test case-symbols-as-words. * etc/NEWS: Announce case-symbols-as-words. * doc/lispref/strings.texi (Case Conversion): Document case-symbols-as-words. --- doc/lispref/strings.texi | 8 ++++++-- etc/NEWS | 8 ++++++++ src/casefiddle.c | 23 +++++++++++++++++++++-- src/search.c | 11 +++++++---- test/src/casefiddle-tests.el | 12 ++++++++++++ 5 files changed, 54 insertions(+), 8 deletions(-) diff --git a/doc/lispref/strings.texi b/doc/lispref/strings.texi index 7d11db49def..417614c9320 100644 --- a/doc/lispref/strings.texi +++ b/doc/lispref/strings.texi @@ -1510,7 +1510,9 @@ Case Conversion =20 The definition of a word is any sequence of consecutive characters that are assigned to the word constituent syntax class in the current syntax -table (@pxref{Syntax Class Table}). +table (@pxref{Syntax Class Table}), or if @var{case-symbols-as-words} is +non-nil, also characters assigned to the symbol constituent syntax +class. =20 When @var{string-or-char} is a character, this function does the same thing as @code{upcase}. @@ -1542,7 +1544,9 @@ Case Conversion =20 The definition of a word is any sequence of consecutive characters that are assigned to the word constituent syntax class in the current syntax -table (@pxref{Syntax Class Table}). +table (@pxref{Syntax Class Table}), or if @var{case-symbols-as-words} is +non-nil, also characters assigned to the symbol constituent syntax +class. =20 When the argument to @code{upcase-initials} is a character, @code{upcase-initials} has the same result as @code{upcase}. diff --git a/etc/NEWS b/etc/NEWS index 129017f7dbe..23078f18273 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1100,6 +1100,14 @@ instead of "ctags", "ebrowse", "etags", "hexl", "ema= csclient", and "rcs2log", when starting one of these built in programs in a subprocess. =20 ++++ +** New variable 'case-symbols-as-words' to change case behavior for symbol= s. +If this is set to non-nil, then case operations such as +'upcase-initials' or 'replace-match' (with nil FIXEDCASE) will treat +symbol constituents as if they were part of words. This is useful for +programming languages and style where words in the middle of symbols +are never capitalized. + +++ ** 'x-popup-menu' now understands touch screen events. When a 'touchscreen-begin' or 'touchscreen-end' event is passed as the diff --git a/src/casefiddle.c b/src/casefiddle.c index d567a5e353a..3f1f5680dd5 100644 --- a/src/casefiddle.c +++ b/src/casefiddle.c @@ -92,6 +92,12 @@ prepare_casing_context (struct casing_context *ctx, SETUP_BUFFER_SYNTAX_TABLE (); /* For syntax_prefix_flag_p. */ } =20 +static bool +case_ch_is_word (enum syntaxcode syntax) +{ + return syntax =3D=3D Sword || (case_symbols_as_words && syntax =3D=3D Ss= ymbol); +} + struct casing_str_buf { unsigned char data[max (6, MAX_MULTIBYTE_LENGTH)]; @@ -115,7 +121,7 @@ case_character_impl (struct casing_str_buf *buf, =20 /* Update inword state */ bool was_inword =3D ctx->inword; - ctx->inword =3D SYNTAX (ch) =3D=3D Sword && + ctx->inword =3D case_ch_is_word (SYNTAX (ch)) && (!ctx->inbuffer || was_inword || !syntax_prefix_flag_p (ch)); =20 /* Normalize flag so its one of CASE_UP, CASE_DOWN or CASE_CAPITALIZE. = */ @@ -222,7 +228,7 @@ case_character (struct casing_str_buf *buf, struct casi= ng_context *ctx, has a word syntax (i.e. current character is end of word), use final sigma. */ if (was_inword && ch =3D=3D GREEK_CAPITAL_LETTER_SIGMA && changed - && (!next || SYNTAX (STRING_CHAR (next)) !=3D Sword)) + && (!next || !case_ch_is_word (SYNTAX (STRING_CHAR (next))))) { buf->len_bytes =3D CHAR_STRING (GREEK_SMALL_LETTER_FINAL_SIGMA, buf-= >data); buf->len_chars =3D 1; @@ -720,6 +726,19 @@ syms_of_casefiddle (void) 3rd argument. */); Vregion_extract_function =3D Qnil; /* simple.el sets this. */ =20 + DEFVAR_BOOL ("case-symbols-as-words", case_symbols_as_words, + doc: /* If non-nil, case functions treat symbol syntax as part of = words. + +Functions such as `upcase-initials' and `replace-match' check or modify +the case pattern of sequences of characters. Normally, these operate on +sequences of characters whose syntax is word constituent. If this +variable is non-nil, then they operate on sequences of characters who +syntax is either word constituent or symbol constituent. + +This is useful for programming styles which wish to capitalize the +beginning of symbols, but not capitalize individual words in a symbol.*/); + case_symbols_as_words =3D 0; + defsubr (&Supcase); defsubr (&Sdowncase); defsubr (&Scapitalize); diff --git a/src/search.c b/src/search.c index e9b29bb7179..b15ec52fa46 100644 --- a/src/search.c +++ b/src/search.c @@ -2365,7 +2365,7 @@ DEFUN ("replace-match", Freplace_match, Sreplace_matc= h, 1, 5, 0, convert NEWTEXT to all caps. Otherwise if all words are capitalized in the replaced text, capitalize each word in NEWTEXT. Note that what exactly is a word is determined by the syntax tables in effect -in the current buffer. +in the current buffer, and the variable `case-symbols-as-words'. =20 If optional third arg LITERAL is non-nil, insert NEWTEXT literally. Otherwise treat `\\' as special: @@ -2479,7 +2479,8 @@ DEFUN ("replace-match", Freplace_match, Sreplace_matc= h, 1, 5, 0, /* Cannot be all caps if any original char is lower case */ =20 some_lowercase =3D 1; - if (SYNTAX (prevc) !=3D Sword) + if (SYNTAX (prevc) !=3D Sword + && (!case_symbols_as_words || SYNTAX (prevc) !=3D Ssymbol)) some_nonuppercase_initial =3D 1; else some_multiletter_word =3D 1; @@ -2487,7 +2488,8 @@ DEFUN ("replace-match", Freplace_match, Sreplace_matc= h, 1, 5, 0, else if (uppercasep (c)) { some_uppercase =3D 1; - if (SYNTAX (prevc) !=3D Sword) + if (SYNTAX (prevc) !=3D Sword + && (!case_symbols_as_words || SYNTAX (prevc) !=3D Ssymbol)) ; else some_multiletter_word =3D 1; @@ -2496,7 +2498,8 @@ DEFUN ("replace-match", Freplace_match, Sreplace_matc= h, 1, 5, 0, { /* If the initial is a caseless word constituent, treat that like a lowercase initial. */ - if (SYNTAX (prevc) !=3D Sword) + if (SYNTAX (prevc) !=3D Sword + && (!case_symbols_as_words || SYNTAX (prevc) !=3D Ssymbol)) some_nonuppercase_initial =3D 1; } =20 diff --git a/test/src/casefiddle-tests.el b/test/src/casefiddle-tests.el index e7f4348b0c6..12984d898b9 100644 --- a/test/src/casefiddle-tests.el +++ b/test/src/casefiddle-tests.el @@ -294,4 +294,16 @@ casefiddle-turkish ;;(should (string-equal (capitalize "indI=C3=A1") "=C4=B0nd=C4=B1a")) )) =20 +(defun casefiddle-tests--check-syms (init with-words with-symbols) + (let ((case-symbols-as-words nil)) + (should (string-equal (upcase-initials init) with-words))) + (let ((case-symbols-as-words t)) + (should (string-equal (upcase-initials init) with-symbols)))) + +(ert-deftest casefiddle-case-symbols-as-words () + (casefiddle-tests--check-syms "Aa_bb Cc_dd" "Aa_Bb Cc_Dd" "Aa_bb Cc_dd") + (casefiddle-tests--check-syms "Aa_bb cc_DD" "Aa_Bb Cc_DD" "Aa_bb Cc_DD") + (casefiddle-tests--check-syms "aa_bb cc_dd" "Aa_Bb Cc_Dd" "Aa_bb Cc_dd") + (casefiddle-tests--check-syms "Aa_Bb Cc_Dd" "Aa_Bb Cc_Dd" "Aa_Bb Cc_Dd")) + ;;; casefiddle-tests.el ends here --=20 2.39.3 --=-=-=-- From unknown Sat Jun 21 05:14:26 2025 X-Loop: help-debbugs@gnu.org Subject: bug#66614: 29.1.50; Support not capitalizing words inside symbols Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 18 Oct 2023 18:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66614 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Spencer Baugh , Stefan Monnier Cc: 66614@debbugs.gnu.org Received: via spool by 66614-submit@debbugs.gnu.org id=B66614.169765353527526 (code B ref 66614); Wed, 18 Oct 2023 18:26:01 +0000 Received: (at 66614) by debbugs.gnu.org; 18 Oct 2023 18:25:35 +0000 Received: from localhost ([127.0.0.1]:34654 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qtBEc-00079o-PZ for submit@debbugs.gnu.org; Wed, 18 Oct 2023 14:25:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38600) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qtBEa-00079O-82 for 66614@debbugs.gnu.org; Wed, 18 Oct 2023 14:25:33 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtBE3-0002jY-M2; Wed, 18 Oct 2023 14:24:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=ftZwHAM5b4MVzVHVospipudqcfTh2gCqtuzW/v1qEb0=; b=OJ1qTOii4oxL uVFm1fA6L5v3ujqkZ5lCYsEbJHLitE1xZWFUQ/0fNrc2Y+ckoC+Etf6HHJEih5wPcSKg8OIPyX0ZH g4vak26lBR3NPLru5I5lAbMq9aetuNBD3xAq1G2SjJy63PBowQhqGpoVZFHLH94ilFpLUHawXcXdH ZHZb7pvOx2638A4FBw68STXtK+KfQGs9JfzDqiMWvJK98jFQJiQktclE3PBwCE/sx4fk5tO/aq2ND Zamx/hF+hKUBvtwY13efUSsYLv0qouXv5OoVhxCrAPPdxzF/uFV5AbugiM1Sd4Bnu9rULR1Aw2kam 9U89OrmHb/chhqy3VKqigA==; Date: Wed, 18 Oct 2023 21:24:49 +0300 Message-Id: <8334y7okjy.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (message from Spencer Baugh on Wed, 18 Oct 2023 13:01:43 -0400) References: X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Spencer Baugh > Date: Wed, 18 Oct 2023 13:01:43 -0400 > > >From e11c5096b2e0a3eddec8fac692142ff31c889109 Mon Sep 17 00:00:00 2001 > From: Spencer Baugh > Date: Wed, 18 Oct 2023 12:51:37 -0400 > Subject: [PATCH] Add case-symbols-as-words to configure symbol case behavior > > In some programming languages and styles, a symbol (or every symbol in > a sequence of symbols) might be capitalized, but the individual words > making up the symbol should never be capitalized. > > For example, in OCaml, type names Look_like_this and variable names > look_like_this, but it is basically never correct for something to > Look_Like_This. And one might have "aa_bb cc_dd ee_ff" or "Aa_bb > Cc_dd Ee_ff", but never "Aa_Bb Cc_Dd Ee_Ff". > > To support this, the new variable case-symbols-as-words causes symbol > constituents to be treated as part of words only for case operations. > > * src/casefiddle.c (case_ch_is_word): Add. > (case_character_impl): Use case_ch_is_word. > (case_character): Use case_ch_is_word. > (syms_of_casefiddle): Define case-symbols-as-words. (bug#66614) > * src/search.c (Freplace_match): Use case-symbols-as-words when > calculating case pattern. > * test/src/casefiddle-tests.el (casefiddle-tests--check-syms) > (casefiddle-case-symbols-as-words): Test case-symbols-as-words. > * etc/NEWS: Announce case-symbols-as-words. > * doc/lispref/strings.texi (Case Conversion): Document > case-symbols-as-words. Stefan, any comments? From unknown Sat Jun 21 05:14:26 2025 X-Loop: help-debbugs@gnu.org Subject: bug#66614: 29.1.50; Support not capitalizing words inside symbols Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 18 Oct 2023 18:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66614 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Spencer Baugh Cc: 66614@debbugs.gnu.org Received: via spool by 66614-submit@debbugs.gnu.org id=B66614.169765414028602 (code B ref 66614); Wed, 18 Oct 2023 18:36:02 +0000 Received: (at 66614) by debbugs.gnu.org; 18 Oct 2023 18:35:40 +0000 Received: from localhost ([127.0.0.1]:34668 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qtBOO-0007RG-C8 for submit@debbugs.gnu.org; Wed, 18 Oct 2023 14:35:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43186) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qtBOM-0007R1-W6 for 66614@debbugs.gnu.org; Wed, 18 Oct 2023 14:35:39 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtBNq-0004bS-PO; Wed, 18 Oct 2023 14:35:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=W8dXduKOnail0vtxkP2ypz6HKLIv8cQ+N0HlJjE5dig=; b=MJjR96OWANAj lO2Lb6iT4VZQ9zfWXxDsvV922izM+Vq7nxZj3pCRacNXq0BTD2b8+0KTFkb4meX0usHNe6/1PQdKY ImuNOpMjf/ETGmT39O9+kSt6KaUjnJmBVrBme+dJ7AWKqiiMBkoso5F4sCeZvhbJZgwGnh0nnxUdn G3YYREtXI7opgXef/nu1g9ngwombvBy2wgnHDcKWwdpOKQ06I19nlMveq2Vv1Xx8sA5iINAnHm2kv YJmA8cqQZs7GSt7hlCzu2d8f9gd3Px68Mb1tLqjcY/0qG70uNwgTDEslpPQNk2R4lVdm97t51P3mA aa2BqylEmoo0mf++ZivLFQ==; Date: Wed, 18 Oct 2023 21:34:55 +0300 Message-Id: <831qdrok34.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (message from Spencer Baugh on Wed, 18 Oct 2023 13:01:43 -0400) References: X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Spencer Baugh > Date: Wed, 18 Oct 2023 13:01:43 -0400 > > --- a/doc/lispref/strings.texi > +++ b/doc/lispref/strings.texi > @@ -1510,7 +1510,9 @@ Case Conversion > > The definition of a word is any sequence of consecutive characters that > are assigned to the word constituent syntax class in the current syntax > -table (@pxref{Syntax Class Table}). > +table (@pxref{Syntax Class Table}), or if @var{case-symbols-as-words} is > +non-nil, also characters assigned to the symbol constituent syntax > +class. > > When @var{string-or-char} is a character, this function does the same > thing as @code{upcase}. > @@ -1542,7 +1544,9 @@ Case Conversion > > The definition of a word is any sequence of consecutive characters that > are assigned to the word constituent syntax class in the current syntax > -table (@pxref{Syntax Class Table}). > +table (@pxref{Syntax Class Table}), or if @var{case-symbols-as-words} is > +non-nil, also characters assigned to the symbol constituent syntax > +class. These two hunks use @var incorrectly: case-symbols-as-words is a literal symbol, so it should have the @code markup. > ++++ > +** New variable 'case-symbols-as-words' to change case behavior for symbols. "Case behavior" is confusing. I think you mean New variable 'case-symbols-as-words' affects case operations for symbols. > +If this is set to non-nil, then case operations such as > +'upcase-initials' or 'replace-match' (with nil FIXEDCASE) will treat > +symbol constituents as if they were part of words. Don't you mean will treat the entire symbol name as a single word ? I find the text you used confusing, FWIW. > This is useful for > +programming languages and style where words in the middle of symbols > +are never capitalized. Likewise here: instead of talking about "words in the middle of symbols", wouldn't it be better to say something like ...style where only the first letter of a symbol's name is ever capitalized. ? Also, please say here that the default of this new variable is nil. > + DEFVAR_BOOL ("case-symbols-as-words", case_symbols_as_words, > + doc: /* If non-nil, case functions treat symbol syntax as part of words. > + > +Functions such as `upcase-initials' and `replace-match' check or modify > +the case pattern of sequences of characters. Normally, these operate on > +sequences of characters whose syntax is word constituent. If this > +variable is non-nil, then they operate on sequences of characters who > +syntax is either word constituent or symbol constituent. > + > +This is useful for programming styles which wish to capitalize the > +beginning of symbols, but not capitalize individual words in a symbol.*/); Similar comments about this doc string. Also, shouldn't this variable be buffer-local? You want certain major modes to set it, right? > - if (SYNTAX (prevc) != Sword) > + if (SYNTAX (prevc) != Sword > + && (!case_symbols_as_words || SYNTAX (prevc) != Ssymbol)) I think the code will be more clear if you use && !(case_symbols_as_words && SYNTAX (prevc) == Ssymbol)) > else if (uppercasep (c)) > { > some_uppercase = 1; > - if (SYNTAX (prevc) != Sword) > + if (SYNTAX (prevc) != Sword > + && (!case_symbols_as_words || SYNTAX (prevc) != Ssymbol)) Same here. > /* If the initial is a caseless word constituent, > treat that like a lowercase initial. */ > - if (SYNTAX (prevc) != Sword) > + if (SYNTAX (prevc) != Sword > + && (!case_symbols_as_words || SYNTAX (prevc) != Ssymbol)) > some_nonuppercase_initial = 1; And here. Thanks. From unknown Sat Jun 21 05:14:26 2025 X-Loop: help-debbugs@gnu.org Subject: bug#66614: 29.1.50; Support not capitalizing words inside symbols Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 18 Oct 2023 18:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66614 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: Spencer Baugh , 66614@debbugs.gnu.org Received: via spool by 66614-submit@debbugs.gnu.org id=B66614.169765550731703 (code B ref 66614); Wed, 18 Oct 2023 18:59:02 +0000 Received: (at 66614) by debbugs.gnu.org; 18 Oct 2023 18:58:27 +0000 Received: from localhost ([127.0.0.1]:34701 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qtBkR-0008FG-9q for submit@debbugs.gnu.org; Wed, 18 Oct 2023 14:58:27 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:59399) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qtBkP-0008F3-66 for 66614@debbugs.gnu.org; Wed, 18 Oct 2023 14:58:25 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 5D197442860; Wed, 18 Oct 2023 14:57:53 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1697655472; bh=oVMSju5Hkj4HhG9B62cgyf4mkhnf2IiTPG4/k8E/SP0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=UvhvuhrKl+Eqy31N++Encgzv7we9SP6X8VA1rKqmcIiJD0Lmh0+dwpf6OPQ3ol1kg gy+Hh2U+s/oRC8QREIIE/7B8JAFUJ1aHIu55TlIzf9+TX99uJKm4NOQjhZZyA4EQ/O rrR4GE4DlMxSWZwUW5cmi1Hltjc/ALZAskNuQutHUlJuZFUnwSB2lZZpSWiTnqGVeB zQw6LERZsb0kyLhcteOn8KmZ/os3J7Wr8M7IleVNAKmwsvNsmhMa4TRb3NQTyZqU8R jagMJbNGGHz81vCtIRXcVDlfwbtFrCRzV7qHEw3bs1CcO/hTUF5QH7GfSwMJ21nMZr 6ic1BJGttQTIg== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 0461F44285A; Wed, 18 Oct 2023 14:57:52 -0400 (EDT) Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id EC1181202E5; Wed, 18 Oct 2023 14:57:51 -0400 (EDT) From: Stefan Monnier In-Reply-To: <8334y7okjy.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 18 Oct 2023 21:24:49 +0300") Message-ID: References: <8334y7okjy.fsf@gnu.org> Date: Wed, 18 Oct 2023 14:55:53 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.103 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Stefan, any comments? Not really, no. Ideally, we could introduce some kind of `case-word-forward-function` hook so that we can accommodate even more conventions, but this boolean var doesn't cost much. Stefan From unknown Sat Jun 21 05:14:26 2025 X-Loop: help-debbugs@gnu.org Subject: bug#66614: 29.1.50; Support not capitalizing words inside symbols Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 18 Oct 2023 19:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66614 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 66614@debbugs.gnu.org Received: via spool by 66614-submit@debbugs.gnu.org id=B66614.169765795014083 (code B ref 66614); Wed, 18 Oct 2023 19:40:02 +0000 Received: (at 66614) by debbugs.gnu.org; 18 Oct 2023 19:39:10 +0000 Received: from localhost ([127.0.0.1]:34710 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qtCNp-0003f3-Rq for submit@debbugs.gnu.org; Wed, 18 Oct 2023 15:39:10 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:37989) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qtCNl-0003eU-Pv for 66614@debbugs.gnu.org; Wed, 18 Oct 2023 15:39:07 -0400 From: Spencer Baugh In-Reply-To: <831qdrok34.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 18 Oct 2023 21:34:55 +0300") References: <831qdrok34.fsf@gnu.org> Date: Wed, 18 Oct 2023 15:38:34 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: Spencer Baugh >> Date: Wed, 18 Oct 2023 13:01:43 -0400 >> >> --- a/doc/lispref/strings.texi >> +++ b/doc/lispref/strings.texi >> @@ -1510,7 +1510,9 @@ Case Conversion >> >> The definition of a word is any sequence of consecutive characters that >> are assigned to the word constituent syntax class in the current syntax >> -table (@pxref{Syntax Class Table}). >> +table (@pxref{Syntax Class Table}), or if @var{case-symbols-as-words} is >> +non-nil, also characters assigned to the symbol constituent syntax >> +class. >> >> When @var{string-or-char} is a character, this function does the same >> thing as @code{upcase}. >> @@ -1542,7 +1544,9 @@ Case Conversion >> >> The definition of a word is any sequence of consecutive characters that >> are assigned to the word constituent syntax class in the current syntax >> -table (@pxref{Syntax Class Table}). >> +table (@pxref{Syntax Class Table}), or if @var{case-symbols-as-words} is >> +non-nil, also characters assigned to the symbol constituent syntax >> +class. > > These two hunks use @var incorrectly: case-symbols-as-words is a > literal symbol, so it should have the @code markup. Fixed. >> ++++ >> +** New variable 'case-symbols-as-words' to change case behavior for symbols. > > "Case behavior" is confusing. I think you mean > > New variable 'case-symbols-as-words' affects case operations for symbols. Fixed. >> +If this is set to non-nil, then case operations such as >> +'upcase-initials' or 'replace-match' (with nil FIXEDCASE) will treat >> +symbol constituents as if they were part of words. > > Don't you mean > > will treat the entire symbol name as a single word > > ? I find the text you used confusing, FWIW. Fixed. >> This is useful for >> +programming languages and style where words in the middle of symbols >> +are never capitalized. > > Likewise here: instead of talking about "words in the middle of > symbols", wouldn't it be better to say something like > > ...style where only the first letter of a symbol's name is ever > capitalized. > > ? > > Also, please say here that the default of this new variable is nil. Fixed. >> + DEFVAR_BOOL ("case-symbols-as-words", case_symbols_as_words, >> + doc: /* If non-nil, case functions treat symbol syntax as part of words. >> + >> +Functions such as `upcase-initials' and `replace-match' check or modify >> +the case pattern of sequences of characters. Normally, these operate on >> +sequences of characters whose syntax is word constituent. If this >> +variable is non-nil, then they operate on sequences of characters who >> +syntax is either word constituent or symbol constituent. >> + >> +This is useful for programming styles which wish to capitalize the >> +beginning of symbols, but not capitalize individual words in a symbol.*/); > > Similar comments about this doc string. Fixed. > Also, shouldn't this variable be buffer-local? You want certain major > modes to set it, right? Yes, I want certain major modes to set it, although it's also possible that some users will want to set it globally. Are you suggesting it should be a DEFVAR_PER_BUFFER? I can do that, but I didn't think it was worth putting another slot into struct buffer. Plus DEFVAR_PER_BUFFER has bad performance (O(#buffers)) when you let-bind it, which I expect users might want to do sometimes. >> - if (SYNTAX (prevc) != Sword) >> + if (SYNTAX (prevc) != Sword >> + && (!case_symbols_as_words || SYNTAX (prevc) != Ssymbol)) > > I think the code will be more clear if you use > > && !(case_symbols_as_words && SYNTAX (prevc) == Ssymbol)) Fixed. >> else if (uppercasep (c)) >> { >> some_uppercase = 1; >> - if (SYNTAX (prevc) != Sword) >> + if (SYNTAX (prevc) != Sword >> + && (!case_symbols_as_words || SYNTAX (prevc) != Ssymbol)) > > Same here. > Fixed. >> /* If the initial is a caseless word constituent, >> treat that like a lowercase initial. */ >> - if (SYNTAX (prevc) != Sword) >> + if (SYNTAX (prevc) != Sword >> + && (!case_symbols_as_words || SYNTAX (prevc) != Ssymbol)) >> some_nonuppercase_initial = 1; > > And here. > Fixed. --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline; filename=0001-Add-case-symbols-as-words-to-configure-symbol-case-b.patch Content-Transfer-Encoding: quoted-printable >From 8286118c70288217badbbb2afd7863ae2ba6848c Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Wed, 18 Oct 2023 12:51:37 -0400 Subject: [PATCH] Add case-symbols-as-words to configure symbol case behavior In some programming languages and styles, a symbol (or every symbol in a sequence of symbols) might be capitalized, but the individual words making up the symbol should never be capitalized. For example, in OCaml, type names Look_like_this and variable names look_like_this, but it is basically never correct for something to Look_Like_This. And one might have "aa_bb cc_dd ee_ff" or "Aa_bb Cc_dd Ee_ff", but never "Aa_Bb Cc_Dd Ee_Ff". To support this, the new variable case-symbols-as-words causes symbol constituents to be treated as part of words only for case operations. * src/casefiddle.c (case_ch_is_word): Add. (case_character_impl): Use case_ch_is_word. (case_character): Use case_ch_is_word. (syms_of_casefiddle): Define case-symbols-as-words. (bug#66614) * src/search.c (Freplace_match): Use case-symbols-as-words when calculating case pattern. * test/src/casefiddle-tests.el (casefiddle-tests--check-syms) (casefiddle-case-symbols-as-words): Test case-symbols-as-words. * etc/NEWS: Announce case-symbols-as-words. * doc/lispref/strings.texi (Case Conversion): Document case-symbols-as-words. --- doc/lispref/strings.texi | 8 ++++++-- etc/NEWS | 8 ++++++++ src/casefiddle.c | 23 +++++++++++++++++++++-- src/search.c | 11 +++++++---- test/src/casefiddle-tests.el | 12 ++++++++++++ 5 files changed, 54 insertions(+), 8 deletions(-) diff --git a/doc/lispref/strings.texi b/doc/lispref/strings.texi index 7d11db49def..665d4f9a8dc 100644 --- a/doc/lispref/strings.texi +++ b/doc/lispref/strings.texi @@ -1510,7 +1510,9 @@ Case Conversion =20 The definition of a word is any sequence of consecutive characters that are assigned to the word constituent syntax class in the current syntax -table (@pxref{Syntax Class Table}). +table (@pxref{Syntax Class Table}), or if @code{case-symbols-as-words} +is non-nil, also characters assigned to the symbol constituent syntax +class. =20 When @var{string-or-char} is a character, this function does the same thing as @code{upcase}. @@ -1542,7 +1544,9 @@ Case Conversion =20 The definition of a word is any sequence of consecutive characters that are assigned to the word constituent syntax class in the current syntax -table (@pxref{Syntax Class Table}). +table (@pxref{Syntax Class Table}), or if @code{case-symbols-as-words} +is non-nil, also characters assigned to the symbol constituent syntax +class. =20 When the argument to @code{upcase-initials} is a character, @code{upcase-initials} has the same result as @code{upcase}. diff --git a/etc/NEWS b/etc/NEWS index 129017f7dbe..23867aafe6f 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1100,6 +1100,14 @@ instead of "ctags", "ebrowse", "etags", "hexl", "ema= csclient", and "rcs2log", when starting one of these built in programs in a subprocess. =20 ++++ +** New variable 'case-symbols-as-words' affects case operations for symbol= s. +If non-nil, then case operations such as 'upcase-initials' or +'replace-match' (with nil FIXEDCASE) will treat the entire symbol name +as a single word. This is useful for programming languages and styles +where only the first letter of a symbol's name is ever capitalized. +It defaults to nil. + +++ ** 'x-popup-menu' now understands touch screen events. When a 'touchscreen-begin' or 'touchscreen-end' event is passed as the diff --git a/src/casefiddle.c b/src/casefiddle.c index d567a5e353a..47e8950cda6 100644 --- a/src/casefiddle.c +++ b/src/casefiddle.c @@ -92,6 +92,12 @@ prepare_casing_context (struct casing_context *ctx, SETUP_BUFFER_SYNTAX_TABLE (); /* For syntax_prefix_flag_p. */ } =20 +static bool +case_ch_is_word (enum syntaxcode syntax) +{ + return syntax =3D=3D Sword || (case_symbols_as_words && syntax =3D=3D Ss= ymbol); +} + struct casing_str_buf { unsigned char data[max (6, MAX_MULTIBYTE_LENGTH)]; @@ -115,7 +121,7 @@ case_character_impl (struct casing_str_buf *buf, =20 /* Update inword state */ bool was_inword =3D ctx->inword; - ctx->inword =3D SYNTAX (ch) =3D=3D Sword && + ctx->inword =3D case_ch_is_word (SYNTAX (ch)) && (!ctx->inbuffer || was_inword || !syntax_prefix_flag_p (ch)); =20 /* Normalize flag so its one of CASE_UP, CASE_DOWN or CASE_CAPITALIZE. = */ @@ -222,7 +228,7 @@ case_character (struct casing_str_buf *buf, struct casi= ng_context *ctx, has a word syntax (i.e. current character is end of word), use final sigma. */ if (was_inword && ch =3D=3D GREEK_CAPITAL_LETTER_SIGMA && changed - && (!next || SYNTAX (STRING_CHAR (next)) !=3D Sword)) + && (!next || !case_ch_is_word (SYNTAX (STRING_CHAR (next))))) { buf->len_bytes =3D CHAR_STRING (GREEK_SMALL_LETTER_FINAL_SIGMA, buf-= >data); buf->len_chars =3D 1; @@ -720,6 +726,19 @@ syms_of_casefiddle (void) 3rd argument. */); Vregion_extract_function =3D Qnil; /* simple.el sets this. */ =20 + DEFVAR_BOOL ("case-symbols-as-words", case_symbols_as_words, + doc: /* If non-nil, case functions treat symbol syntax as part of = words. + +Functions such as `upcase-initials' and `replace-match' check or modify +the case pattern of sequences of characters. Normally, these operate on +sequences of characters whose syntax is word constituent. If this +variable is non-nil, then they operate on sequences of characters whose +syntax is either word constituent or symbol constituent. + +This is useful for programming languages and styles where only the first +letter of a symbol's name is ever capitalized.*/); + case_symbols_as_words =3D 0; + defsubr (&Supcase); defsubr (&Sdowncase); defsubr (&Scapitalize); diff --git a/src/search.c b/src/search.c index e9b29bb7179..692d8488049 100644 --- a/src/search.c +++ b/src/search.c @@ -2365,7 +2365,7 @@ DEFUN ("replace-match", Freplace_match, Sreplace_matc= h, 1, 5, 0, convert NEWTEXT to all caps. Otherwise if all words are capitalized in the replaced text, capitalize each word in NEWTEXT. Note that what exactly is a word is determined by the syntax tables in effect -in the current buffer. +in the current buffer, and the variable `case-symbols-as-words'. =20 If optional third arg LITERAL is non-nil, insert NEWTEXT literally. Otherwise treat `\\' as special: @@ -2479,7 +2479,8 @@ DEFUN ("replace-match", Freplace_match, Sreplace_matc= h, 1, 5, 0, /* Cannot be all caps if any original char is lower case */ =20 some_lowercase =3D 1; - if (SYNTAX (prevc) !=3D Sword) + if (SYNTAX (prevc) !=3D Sword + && !(case_symbols_as_words && SYNTAX (prevc) =3D=3D Ssymbol)) some_nonuppercase_initial =3D 1; else some_multiletter_word =3D 1; @@ -2487,7 +2488,8 @@ DEFUN ("replace-match", Freplace_match, Sreplace_matc= h, 1, 5, 0, else if (uppercasep (c)) { some_uppercase =3D 1; - if (SYNTAX (prevc) !=3D Sword) + if (SYNTAX (prevc) !=3D Sword + && !(case_symbols_as_words && SYNTAX (prevc) =3D=3D Ssymbol)) ; else some_multiletter_word =3D 1; @@ -2496,7 +2498,8 @@ DEFUN ("replace-match", Freplace_match, Sreplace_matc= h, 1, 5, 0, { /* If the initial is a caseless word constituent, treat that like a lowercase initial. */ - if (SYNTAX (prevc) !=3D Sword) + if (SYNTAX (prevc) !=3D Sword + && !(case_symbols_as_words && SYNTAX (prevc) =3D=3D Ssymbol)) some_nonuppercase_initial =3D 1; } =20 diff --git a/test/src/casefiddle-tests.el b/test/src/casefiddle-tests.el index e7f4348b0c6..12984d898b9 100644 --- a/test/src/casefiddle-tests.el +++ b/test/src/casefiddle-tests.el @@ -294,4 +294,16 @@ casefiddle-turkish ;;(should (string-equal (capitalize "indI=C3=A1") "=C4=B0nd=C4=B1a")) )) =20 +(defun casefiddle-tests--check-syms (init with-words with-symbols) + (let ((case-symbols-as-words nil)) + (should (string-equal (upcase-initials init) with-words))) + (let ((case-symbols-as-words t)) + (should (string-equal (upcase-initials init) with-symbols)))) + +(ert-deftest casefiddle-case-symbols-as-words () + (casefiddle-tests--check-syms "Aa_bb Cc_dd" "Aa_Bb Cc_Dd" "Aa_bb Cc_dd") + (casefiddle-tests--check-syms "Aa_bb cc_DD" "Aa_Bb Cc_DD" "Aa_bb Cc_DD") + (casefiddle-tests--check-syms "aa_bb cc_dd" "Aa_Bb Cc_Dd" "Aa_bb Cc_dd") + (casefiddle-tests--check-syms "Aa_Bb Cc_Dd" "Aa_Bb Cc_Dd" "Aa_Bb Cc_Dd")) + ;;; casefiddle-tests.el ends here --=20 2.39.3 --=-=-=-- From unknown Sat Jun 21 05:14:26 2025 X-Loop: help-debbugs@gnu.org Subject: bug#66614: 29.1.50; Support not capitalizing words inside symbols Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 19 Oct 2023 04:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66614 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Spencer Baugh Cc: 66614@debbugs.gnu.org Received: via spool by 66614-submit@debbugs.gnu.org id=B66614.169769017823420 (code B ref 66614); Thu, 19 Oct 2023 04:37:02 +0000 Received: (at 66614) by debbugs.gnu.org; 19 Oct 2023 04:36:18 +0000 Received: from localhost ([127.0.0.1]:35397 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qtKle-00065I-8v for submit@debbugs.gnu.org; Thu, 19 Oct 2023 00:36:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46868) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qtKlb-00064e-ME for 66614@debbugs.gnu.org; Thu, 19 Oct 2023 00:36:16 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtKl3-0005U9-Vw; Thu, 19 Oct 2023 00:35:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=BVhg5RbL/BufK6XNfL3LFLA8StdkXPwE4/Xq4htB6rc=; b=f+cxYR+9EgNz VtWZk74xFam8UYP9jt8P5EnIoWvm84a9e6TcEagynQsLNN/0NQ7s+wIG5bURo8kU2hXKHdazxYo6C bG3RZgJ+/03TophIHPAg5J4zvneo5i8zThw14u1AHyAKKfwYklZRPxkURauyic9+dKAYgyreqtvKB VwVsv11oatSpc/o1pdPg8zbqVPFTgtAwySw20ZclP7GzCy1gDQtxa0wNhZTy3x4HVtryfJzIXWGi9 OxUHl0FRuwkHUtY7fbmI5+ytKtZt39/a++AkE1vPemnv/ZZYX4zW7A/VXJ1ZKqMxwtp2ip3aTCVB1 /KJn9pNbhOnYQl7ey8Jbug==; Date: Thu, 19 Oct 2023 07:35:33 +0300 Message-Id: <83zg0fmdpm.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (message from Spencer Baugh on Wed, 18 Oct 2023 15:38:34 -0400) References: <831qdrok34.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Spencer Baugh > Cc: 66614@debbugs.gnu.org > Date: Wed, 18 Oct 2023 15:38:34 -0400 > > >> + DEFVAR_BOOL ("case-symbols-as-words", case_symbols_as_words, > >> + doc: /* If non-nil, case functions treat symbol syntax as part of words. > >> + > >> +Functions such as `upcase-initials' and `replace-match' check or modify > >> +the case pattern of sequences of characters. Normally, these operate on > >> +sequences of characters whose syntax is word constituent. If this > >> +variable is non-nil, then they operate on sequences of characters who > >> +syntax is either word constituent or symbol constituent. > >> + > >> +This is useful for programming styles which wish to capitalize the > >> +beginning of symbols, but not capitalize individual words in a symbol.*/); > > > > Similar comments about this doc string. > > Fixed. > > > Also, shouldn't this variable be buffer-local? You want certain major > > modes to set it, right? > > Yes, I want certain major modes to set it, although it's also possible > that some users will want to set it globally. > > Are you suggesting it should be a DEFVAR_PER_BUFFER? I can do that, but > I didn't think it was worth putting another slot into struct buffer. You don't have to add it to the buffer structure, you could call Fmake_variable_buffer_local instead. We already do that for some variables. > Plus DEFVAR_PER_BUFFER has bad performance (O(#buffers)) when you > let-bind it, which I expect users might want to do sometimes. That is a separate problem, and adding one more buffer-local variable will hardly change the fact that let-binding and/or temporarily switching buffers is expensive. We should think about correctness before we think about performance. And correctness requires that this variable be buffer-local, as making it global makes no sense IMO. From unknown Sat Jun 21 05:14:26 2025 X-Loop: help-debbugs@gnu.org Subject: bug#66614: 29.1.50; Support not capitalizing words inside symbols Resent-From: Po Lu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 19 Oct 2023 10:56:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66614 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Spencer Baugh Cc: Eli Zaretskii , 66614@debbugs.gnu.org Received: via spool by 66614-submit@debbugs.gnu.org id=B66614.169771293932597 (code B ref 66614); Thu, 19 Oct 2023 10:56:01 +0000 Received: (at 66614) by debbugs.gnu.org; 19 Oct 2023 10:55:39 +0000 Received: from localhost ([127.0.0.1]:35918 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qtQgl-0008Th-6V for submit@debbugs.gnu.org; Thu, 19 Oct 2023 06:55:39 -0400 Received: from sonic316-22.consmr.mail.ne1.yahoo.com ([66.163.187.148]:43046) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qtQgi-0008TO-7s for 66614@debbugs.gnu.org; Thu, 19 Oct 2023 06:55:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1697712904; bh=Okmnacuajs3qXf83S4FYSFlzNPpEVBYlGN/uzfZmyTg=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=TFSKu8sYVZHLEdPvHIVN88ozUd29ueIiNrwwn+gFjKwk7rsVwNZ3Yfytmf8kyUcgghN7w6thVdaiE5N24cvgGfUkpU5IGlwhn1T8ryLNjuM+kYdvNSqwj7B+epQuexxHwbKD+Z1HclZuxHn9ZmniYd8jAg5yWqDBFDslgsngM1B/VdlC0s4fxQ903xRDO63AYOIq7bNmoRJQYRrVk1JZXThDrf8YGmM9AIuAV9gK4TQKYIQhHMkrAi5COLyLEgc9W9uvgKz1ylt6Yu8JUWK7vQ5PWU6CGi2dCQDcIB4ZC/ykgdzz4AOX5cNKDP29U2JTGBIYvPFfjm38oSVkaksaOQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1697712904; bh=MQbA2XEt0wFXpwphlR3uc3efZkknckt8GsEzOWbMh1E=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=rUN5KeAnHsQLhGGHYamHo6JJ6bg1IAiUBNpTFAR9ntRgPUgFAK8/zbmHqA5TGNjXWXy0ZTNHalcSo1Xmulh+VC2z0Un0zpX337+8dp3MM7Kv9X9wSfoHUMYSwtf9d1j/ZHccT4e//kiJEcU8cdRt8cmgNfKPGa2cy1mkrK6PVREhgdVqDHGhyqlBHZ4zI0+v9ljGw1fMNbQEfN+/rWg2OUnXWxVd4MdZIpniAeYznSb0763WmTtIklySSwcatG8Y+r1UiV8jBMOVu55qZAO3NquYS0x3JM4ilvPoYOOFxaJVsk4fboDKoY3XcH4s6Ei2HnUioh+Zermtj40vKquZEg== X-YMail-OSG: 06.KCCAVM1mTHMpdev3PpHWP5N1SUjQOaCqMdrOoU0l9k4zjXd48Q5MOu6ZCLUq r4FtsAGnE8R3bZX1pA0tlneiEG52Fo72H7OGfrYq5AMV437yCOAbd3cpv1ifsWYKdBaoV8aJBelx X8F2ktmm1iaosYEE4BsSCHwAHvgIiDSFJgBO0xfL4DToJj3dyZk5.fcGzW4B7.N5axfFhVHKv0AE lrGVTY_YFNOa2_37bEfV9rGsQMhs1pS46bkiAExUkX1yMvjJVNzVhfAC8VG.qJWTwYkv7rzv.cTe zy8Lpx7TN8k_kd0532h9wDLgMr1yD4ez44sYENFhTfb4b8PBQR3NCxSb4D5fKiSKq9ZNJyJBKYNw HxgeJsrF_5Trb6ty76dQm7mbB5R6VuhB4SX0xUmKNJ3ZgWI4QpuT6igo15_WnnQEBdL5Ve.yAL2j 5jwj6yv1qhMZHXt6McbwT3TnXLnCzqb0gkWdCMHQLV9VLaj60AHX38U1n8fnoeZqpYkXz515PNFv FZ2tEoNwUmIUO3KfXrJSklKLAoQ8u3aKhfSYJe.fl3x_WxnjAABqUix.F8jrImYFUaVmMRdo1Aq0 mXY93vd4tkhffoYA2W18LgqAR_EiPPQWHohEGDid76fPgCd.oDUZUhV5qb8NbCvZVn_d0rFiJgyi 10dz2xcQMtegb8RA_y1xtUMPhonbrAMu8T7KyNDNv_dHQFmEQ_NdOk2PRHkJSEghCqty8plXbdf1 PqR4Z0WjglvhBI9YRuIN9Zk8L43J8vGZNrDYJQ5HivKvRVggzZrNOhl1Yz8Yl7UqTU9WtSIeZbZ6 G2xEF_H.Q.kogM_0Cyd9x0PGJP_S9n_6eDSwUiWaIE9UncEyzYcm7rttUCbrqr_Mrf8bogOBOfii BoXiWZ1VV.eKGaOGM8e06vmOFrBpz9AXCYFJGxogeuoQDL68Dmz_zFJSOlyp4hcUahKfdIoT8h1d iaDS5Pt9DY77UvQMBWPUvncP4jIRr7Q6OX4XdA1qa2yTT48RXZQjca6NBe7_TBe_aGeKCKosVwqX JJ6eg5P8ZHFpdszgXLGKlzF02G2k7kruJz_55BsURrbVX0QBucomwN2LNO_KTP3sU0DrlqrTMbKN pSTbQHw7rUATMJo6ZvAysUWVNGeHINuVS1gyXltQcpImdMUGfN81to1M3LDG7pisk_PXizatTa83 b30vRYvYc53JH4lltvKKokWhA7NQGhXMU3xibdqdPlHv7FnnYNu4QQD9G6ib0SaWkxdogh9ZBJP4 04R9zsbLN7ki0xBs77rRdlA5IhEHHG1nbafFSVVmjeRzwadWME_L6vTpacEoHocTmKtiM8qSGDmu siI4rdJbLjbakF9CtBH_67ERO0bebj7fhJtWSjwv4JEvnEQigWFalcTuGbtI5QblOykXaPsB4svN 9n_XXDOpq6o5OU9WSctXz25ax1I.9RhlWkf_vtGoiGGHfiJ.BA9RrCOZniDjtCUoeIdVBlO4.xEW BbjquBsbd7aYxcWjZ9TJDvMyhodWHpDCLCDJUe1mcL9BXBCdrcoC4DjuKZMVlEnnVMHVxaRI6dHT 9LxRQgKtO0d33m9IcFZStJ746vUVVrUZTHRz1qUY57yPqVHTlw4UQXTSzBdB8.UybMWiXZCbr9Ri 2qEBO3xUMg_6BJ9z3D6KuCaMJjJvLZ0t43Tpym5Sl5O7mpv8ApmclPolvU_AbS6xXGmbC5bizdi4 N.SIAaX9V1ypbnoa2BPtaTZxe1fHkJEV_cjvIpXSXWDCO.8GaqGongIGky18jUeJoHOQM9CHYGP_ Cw.8fqqYBRgcz2tpZCGu8bu_wsMyKFfE.KteTGQhxf39kexk5qIwj75o.aMfDYNM6L424TEfPnbX zIhsf77NMKxBXnhOJpy0kVJMoe9WcRHGVVRTfM9NR.qgYH1qi.TXFv499aSeCZqzkYDWIMpjBm5S TOPjEO9ZxwTbV3319xfVAlL7t8zQMAlqOOY62t6uK0kZrwhy_X9KOzyTLSztJUt87C72PzoApjlr b7lYR.GOeDAX0TkvbTRFUDmH0kUg3D3YSDGECf0EBPSiy65pWUPxcj8mhcVyE_MsEOV0UeuvBNuj VV1emQ_X1x2raedoyK1wFFZmcQwsIt1igsiU0GymAUJGAwB5n7gzwchZQn.xUePZ7ce.oaZNKslD DvBKlKDhOmQVJ.y0DN2rC7Y2NoIVd0j6QoFJXRLjYxMoNespvpPWkhjZU_m1ibyuRb5AYuKZjZot qVVkIkA1KvT.VuyeQ1NP7fFFOnHnuBMlQtSAGQk1hV7CGjIzwZTETsB9m097hxMuTD9zyLA-- X-Sonic-MF: X-Sonic-ID: 9ac74149-dc0b-4689-8f07-bfe302ef79dc Received: from sonic.gate.mail.ne1.yahoo.com by sonic316.consmr.mail.ne1.yahoo.com with HTTP; Thu, 19 Oct 2023 10:55:04 +0000 Received: by hermes--production-sg3-57f7997989-fcsf4 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 0a7e22cba3611f0bd4bbbd996152a300; Thu, 19 Oct 2023 10:55:01 +0000 (UTC) From: Po Lu In-Reply-To: (Spencer Baugh's message of "Wed, 18 Oct 2023 15:38:34 -0400") References: <831qdrok34.fsf@gnu.org> Date: Thu, 19 Oct 2023 18:54:55 +0800 Message-ID: <87cyxa6fwg.fsf@yahoo.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Mailer: WebService/1.1.21863 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Content-Length: 1175 X-Spam-Score: -0.5 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.5 (-) Spencer Baugh writes: > + DEFVAR_BOOL ("case-symbols-as-words", case_symbols_as_words, > + doc: /* If non-nil, case functions treat symbol syntax as part of words. > + > +Functions such as `upcase-initials' and `replace-match' check or modify > +the case pattern of sequences of characters. Normally, these operate on > +sequences of characters whose syntax is word constituent. If this > +variable is non-nil, then they operate on sequences of characters whose > +syntax is either word constituent or symbol constituent. > + > +This is useful for programming languages and styles where only the first > +letter of a symbol's name is ever capitalized.*/); > + case_symbols_as_words = 0; Incidentally: Let's not introduce further instances of the anti-pattern where the ``doc:'' marker in DEFVAR constructs is aligned with its opening paren, rather than two columns into the word DEFVAR itself. Generally, this deprives you of latitude for the first line of the doc string, for you are either compelled to contravene the 80 column limit or to render that line exceptionally laconic, both of which are ultimately counterproductive. TIA. From unknown Sat Jun 21 05:14:26 2025 X-Loop: help-debbugs@gnu.org Subject: bug#66614: 29.1.50; Support not capitalizing words inside symbols Resent-From: sbaugh@catern.com Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 21 Oct 2023 15:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66614 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: Spencer Baugh , 66614@debbugs.gnu.org Received: via spool by 66614-submit@debbugs.gnu.org id=B66614.16979011114336 (code B ref 66614); Sat, 21 Oct 2023 15:12:02 +0000 Received: (at 66614) by debbugs.gnu.org; 21 Oct 2023 15:11:51 +0000 Received: from localhost ([127.0.0.1]:44877 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1quDdj-00017o-8o for submit@debbugs.gnu.org; Sat, 21 Oct 2023 11:11:51 -0400 Received: from s.wrqvtzvf.outbound-mail.sendgrid.net ([149.72.126.143]:27438) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1quDdd-00017Q-CL for 66614@debbugs.gnu.org; Sat, 21 Oct 2023 11:11:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com; h=from:subject:in-reply-to:references:mime-version:to:cc:content-type: cc:content-type:from:subject:to; s=s1; bh=LwLTPTSExTmmP1Gk6ohnIfrcSQoxUjzgLPFkGA/xqss=; b=ylPCGAbDMGceg5x7otP9Y2b+9PW/fGAlSOgPSatwfthC1CkTvr5O9siiStkRk8F1FGxL 3iWlj7aUa7tP8exiol12bG3nOuLNBL1qL6nbJofKeR6rmBSBskj8sRQS2gw/+xKmHLIAO7 +h/yZ7Mwv0dHbSwPd7/5uHTSeI3DTEmHd2jH21fnrW7+zxyfoL/t/hPPo0dDY+kGgR8pdk X2+KuTng74rUOzeuaXp248ulCvWBbktVXgiLq/pC0QW7ebWA5+CRyaWw5Axd2j8ackrK5j Z9RjJq7eRWHvO9OeQX14ts3RxVAjffWopXCB0TvXzxFVUma5uudL3tKVOjMThmHg== Received: by filterdrecv-5bbdbb56cd-h9hcp with SMTP id filterdrecv-5bbdbb56cd-h9hcp-1-6533EA0C-2 2023-10-21 15:11:08.073493827 +0000 UTC m=+333079.648129779 Received: from earth.catern.com (unknown) by geopod-ismtpd-36 (SG) with ESMTP id hi6sN3WoSTiDLodmZI7dXA Sat, 21 Oct 2023 15:11:07.989 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=::1; helo=localhost; envelope-from=sbaugh@catern.com; receiver=gnu.org Received: from localhost (localhost [IPv6:::1]) by earth.catern.com (Postfix) with ESMTPSA id 881046360E; Sat, 21 Oct 2023 11:11:07 -0400 (EDT) From: sbaugh@catern.com In-Reply-To: <83zg0fmdpm.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 19 Oct 2023 07:35:33 +0300") References: <831qdrok34.fsf@gnu.org> <83zg0fmdpm.fsf@gnu.org> Date: Sat, 21 Oct 2023 15:11:08 +0000 (UTC) Message-ID: <87wmvgroxg.fsf@catern.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-SG-EID: ZgbRq7gjGrt0q/Pjvxk7wM0yQFRdOkTJAtEbkjCkHbKkzMtZIoMQrhduyXzOA5gy8VWGai6eIkslCr0jm6M2cbvkA3cKsk9VehQMoP1dhsl+MeTwqEhsbVUvVU5tkrF3oODkDFtFTWon8MdXzjgabrBK06MmgHqfHZwMjN37fLZm4Pr4/5szAgNsp7kuxb/v3NCBevYDZ34xAqjnx/6twA== X-Entity-ID: d/0VcHixlS0t7iB1YKCv4Q== Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 1.2 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Eli Zaretskii writes: >> From: Spencer Baugh >> Cc: 66614@debbugs.gnu.org >> Date: Wed, 18 Oct 2023 15:38:34 -0400 >> >> >> + DEFVAR_BOOL ("case-symbols-as-words", case_symbols_as_words, >> >> + doc [...] Content analysis details: (1.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 1.2 RCVD_IN_BL_SPAMCOP_NET RBL: Received via a relay in bl.spamcop.net [Blocked - see ] 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.2 (/) --=-=-= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Eli Zaretskii writes: >> From: Spencer Baugh >> Cc: 66614@debbugs.gnu.org >> Date: Wed, 18 Oct 2023 15:38:34 -0400 >> >> >> + DEFVAR_BOOL ("case-symbols-as-words", case_symbols_as_words, >> >> + doc: /* If non-nil, case functions treat symbol syntax as part of words. >> >> + >> >> +Functions such as `upcase-initials' and `replace-match' check or modify >> >> +the case pattern of sequences of characters. Normally, these operate on >> >> +sequences of characters whose syntax is word constituent. If this >> >> +variable is non-nil, then they operate on sequences of characters who >> >> +syntax is either word constituent or symbol constituent. >> >> + >> >> +This is useful for programming styles which wish to capitalize the >> >> +beginning of symbols, but not capitalize individual words in a symbol.*/); >> > >> > Similar comments about this doc string. >> >> Fixed. >> >> > Also, shouldn't this variable be buffer-local? You want certain major >> > modes to set it, right? >> >> Yes, I want certain major modes to set it, although it's also possible >> that some users will want to set it globally. >> >> Are you suggesting it should be a DEFVAR_PER_BUFFER? I can do that, but >> I didn't think it was worth putting another slot into struct buffer. > > You don't have to add it to the buffer structure, you could call > Fmake_variable_buffer_local instead. We already do that for some > variables. Oh, of course. Done. --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline; filename=0001-Add-case-symbols-as-words-to-configure-symbol-case-b.patch Content-Transfer-Encoding: quoted-printable >From 22540be262399f3ec232da713b3ba454299e18d2 Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Sat, 21 Oct 2023 11:09:39 -0400 Subject: [PATCH] Add case-symbols-as-words to configure symbol case behavior In some programming languages and styles, a symbol (or every symbol in a sequence of symbols) might be capitalized, but the individual words making up the symbol should never be capitalized. For example, in OCaml, type names Look_like_this and variable names look_like_this, but it is basically never correct for something to Look_Like_This. And one might have "aa_bb cc_dd ee_ff" or "Aa_bb Cc_dd Ee_ff", but never "Aa_Bb Cc_Dd Ee_Ff". To support this, the new variable case-symbols-as-words causes symbol constituents to be treated as part of words only for case operations. * src/casefiddle.c (case_ch_is_word): Add. (case_character_impl): Use case_ch_is_word. (case_character): Use case_ch_is_word. (syms_of_casefiddle): Define case-symbols-as-words. (bug#66614) * src/search.c (Freplace_match): Use case-symbols-as-words when calculating case pattern. * test/src/casefiddle-tests.el (casefiddle-tests--check-syms) (casefiddle-case-symbols-as-words): Test case-symbols-as-words. * etc/NEWS: Announce case-symbols-as-words. * doc/lispref/strings.texi (Case Conversion): Document case-symbols-as-words. --- doc/lispref/strings.texi | 8 ++++++-- etc/NEWS | 8 ++++++++ src/casefiddle.c | 25 +++++++++++++++++++++++-- src/search.c | 11 +++++++---- test/src/casefiddle-tests.el | 12 ++++++++++++ 5 files changed, 56 insertions(+), 8 deletions(-) diff --git a/doc/lispref/strings.texi b/doc/lispref/strings.texi index 7d11db49def..665d4f9a8dc 100644 --- a/doc/lispref/strings.texi +++ b/doc/lispref/strings.texi @@ -1510,7 +1510,9 @@ Case Conversion =20 The definition of a word is any sequence of consecutive characters that are assigned to the word constituent syntax class in the current syntax -table (@pxref{Syntax Class Table}). +table (@pxref{Syntax Class Table}), or if @code{case-symbols-as-words} +is non-nil, also characters assigned to the symbol constituent syntax +class. =20 When @var{string-or-char} is a character, this function does the same thing as @code{upcase}. @@ -1542,7 +1544,9 @@ Case Conversion =20 The definition of a word is any sequence of consecutive characters that are assigned to the word constituent syntax class in the current syntax -table (@pxref{Syntax Class Table}). +table (@pxref{Syntax Class Table}), or if @code{case-symbols-as-words} +is non-nil, also characters assigned to the symbol constituent syntax +class. =20 When the argument to @code{upcase-initials} is a character, @code{upcase-initials} has the same result as @code{upcase}. diff --git a/etc/NEWS b/etc/NEWS index 4a44782f972..9d1a81789c6 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1131,6 +1131,14 @@ instead of "ctags", "ebrowse", "etags", "hexl", "ema= csclient", and "rcs2log", when starting one of these built in programs in a subprocess. =20 ++++ +** New variable 'case-symbols-as-words' affects case operations for symbol= s. +If non-nil, then case operations such as 'upcase-initials' or +'replace-match' (with nil FIXEDCASE) will treat the entire symbol name +as a single word. This is useful for programming languages and styles +where only the first letter of a symbol's name is ever capitalized. +It defaults to nil. + +++ ** 'x-popup-menu' now understands touch screen events. When a 'touchscreen-begin' or 'touchscreen-end' event is passed as the diff --git a/src/casefiddle.c b/src/casefiddle.c index d567a5e353a..3afb131c50e 100644 --- a/src/casefiddle.c +++ b/src/casefiddle.c @@ -92,6 +92,12 @@ prepare_casing_context (struct casing_context *ctx, SETUP_BUFFER_SYNTAX_TABLE (); /* For syntax_prefix_flag_p. */ } =20 +static bool +case_ch_is_word (enum syntaxcode syntax) +{ + return syntax =3D=3D Sword || (case_symbols_as_words && syntax =3D=3D Ss= ymbol); +} + struct casing_str_buf { unsigned char data[max (6, MAX_MULTIBYTE_LENGTH)]; @@ -115,7 +121,7 @@ case_character_impl (struct casing_str_buf *buf, =20 /* Update inword state */ bool was_inword =3D ctx->inword; - ctx->inword =3D SYNTAX (ch) =3D=3D Sword && + ctx->inword =3D case_ch_is_word (SYNTAX (ch)) && (!ctx->inbuffer || was_inword || !syntax_prefix_flag_p (ch)); =20 /* Normalize flag so its one of CASE_UP, CASE_DOWN or CASE_CAPITALIZE. = */ @@ -222,7 +228,7 @@ case_character (struct casing_str_buf *buf, struct casi= ng_context *ctx, has a word syntax (i.e. current character is end of word), use final sigma. */ if (was_inword && ch =3D=3D GREEK_CAPITAL_LETTER_SIGMA && changed - && (!next || SYNTAX (STRING_CHAR (next)) !=3D Sword)) + && (!next || !case_ch_is_word (SYNTAX (STRING_CHAR (next))))) { buf->len_bytes =3D CHAR_STRING (GREEK_SMALL_LETTER_FINAL_SIGMA, buf-= >data); buf->len_chars =3D 1; @@ -720,6 +726,21 @@ syms_of_casefiddle (void) 3rd argument. */); Vregion_extract_function =3D Qnil; /* simple.el sets this. */ =20 + DEFVAR_BOOL ("case-symbols-as-words", case_symbols_as_words, + doc: /* If non-nil, case functions treat symbol syntax as part of word= s. + +Functions such as `upcase-initials' and `replace-match' check or modify +the case pattern of sequences of characters. Normally, these operate on +sequences of characters whose syntax is word constituent. If this +variable is non-nil, then they operate on sequences of characters whose +syntax is either word constituent or symbol constituent. + +This is useful for programming languages and styles where only the first +letter of a symbol's name is ever capitalized.*/); + case_symbols_as_words =3D 0; + DEFSYM (Qcase_symbols_as_words, "case-symbols-as-words"); + Fmake_variable_buffer_local (Qcase_symbols_as_words); + defsubr (&Supcase); defsubr (&Sdowncase); defsubr (&Scapitalize); diff --git a/src/search.c b/src/search.c index e9b29bb7179..692d8488049 100644 --- a/src/search.c +++ b/src/search.c @@ -2365,7 +2365,7 @@ DEFUN ("replace-match", Freplace_match, Sreplace_matc= h, 1, 5, 0, convert NEWTEXT to all caps. Otherwise if all words are capitalized in the replaced text, capitalize each word in NEWTEXT. Note that what exactly is a word is determined by the syntax tables in effect -in the current buffer. +in the current buffer, and the variable `case-symbols-as-words'. =20 If optional third arg LITERAL is non-nil, insert NEWTEXT literally. Otherwise treat `\\' as special: @@ -2479,7 +2479,8 @@ DEFUN ("replace-match", Freplace_match, Sreplace_matc= h, 1, 5, 0, /* Cannot be all caps if any original char is lower case */ =20 some_lowercase =3D 1; - if (SYNTAX (prevc) !=3D Sword) + if (SYNTAX (prevc) !=3D Sword + && !(case_symbols_as_words && SYNTAX (prevc) =3D=3D Ssymbol)) some_nonuppercase_initial =3D 1; else some_multiletter_word =3D 1; @@ -2487,7 +2488,8 @@ DEFUN ("replace-match", Freplace_match, Sreplace_matc= h, 1, 5, 0, else if (uppercasep (c)) { some_uppercase =3D 1; - if (SYNTAX (prevc) !=3D Sword) + if (SYNTAX (prevc) !=3D Sword + && !(case_symbols_as_words && SYNTAX (prevc) =3D=3D Ssymbol)) ; else some_multiletter_word =3D 1; @@ -2496,7 +2498,8 @@ DEFUN ("replace-match", Freplace_match, Sreplace_matc= h, 1, 5, 0, { /* If the initial is a caseless word constituent, treat that like a lowercase initial. */ - if (SYNTAX (prevc) !=3D Sword) + if (SYNTAX (prevc) !=3D Sword + && !(case_symbols_as_words && SYNTAX (prevc) =3D=3D Ssymbol)) some_nonuppercase_initial =3D 1; } =20 diff --git a/test/src/casefiddle-tests.el b/test/src/casefiddle-tests.el index e7f4348b0c6..12984d898b9 100644 --- a/test/src/casefiddle-tests.el +++ b/test/src/casefiddle-tests.el @@ -294,4 +294,16 @@ casefiddle-turkish ;;(should (string-equal (capitalize "indI=C3=A1") "=C4=B0nd=C4=B1a")) )) =20 +(defun casefiddle-tests--check-syms (init with-words with-symbols) + (let ((case-symbols-as-words nil)) + (should (string-equal (upcase-initials init) with-words))) + (let ((case-symbols-as-words t)) + (should (string-equal (upcase-initials init) with-symbols)))) + +(ert-deftest casefiddle-case-symbols-as-words () + (casefiddle-tests--check-syms "Aa_bb Cc_dd" "Aa_Bb Cc_Dd" "Aa_bb Cc_dd") + (casefiddle-tests--check-syms "Aa_bb cc_DD" "Aa_Bb Cc_DD" "Aa_bb Cc_DD") + (casefiddle-tests--check-syms "aa_bb cc_dd" "Aa_Bb Cc_Dd" "Aa_bb Cc_dd") + (casefiddle-tests--check-syms "Aa_Bb Cc_Dd" "Aa_Bb Cc_Dd" "Aa_Bb Cc_Dd")) + ;;; casefiddle-tests.el ends here --=20 2.41.0 --=-=-=-- From unknown Sat Jun 21 05:14:26 2025 X-Loop: help-debbugs@gnu.org Subject: bug#66614: 29.1.50; Support not capitalizing words inside symbols Resent-From: sbaugh@catern.com Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 21 Oct 2023 15:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66614 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Po Lu Cc: Spencer Baugh , Eli Zaretskii , 66614@debbugs.gnu.org Received: via spool by 66614-submit@debbugs.gnu.org id=B66614.16979012334540 (code B ref 66614); Sat, 21 Oct 2023 15:14:01 +0000 Received: (at 66614) by debbugs.gnu.org; 21 Oct 2023 15:13:53 +0000 Received: from localhost ([127.0.0.1]:44882 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1quDfg-0001B5-Tv for submit@debbugs.gnu.org; Sat, 21 Oct 2023 11:13:53 -0400 Received: from s.wfbtzhsw.outbound-mail.sendgrid.net ([159.183.224.105]:48568) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1quDfb-0001Am-Gg for 66614@debbugs.gnu.org; Sat, 21 Oct 2023 11:13:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com; h=from:subject:in-reply-to:references:mime-version:to:cc:content-type: content-transfer-encoding:cc:content-type:from:subject:to; s=s1; bh=b2lXnuvmEmNc/VkCqI/4l4TDN1hLy18Qfj2aM9T4+Rw=; b=0lAVxWnxzIKM6/XUbrv0CtNa4SsfGwEKyKlYmqAuz3TIScFFHbB5Q879AKlOX0rHVTnn tKhHeH3nmiOkfa5w68xMJEYsVZGaAg2V89GmCc6Pyv40wsQI9WHrVoVqlrxi5Db26PxgKu 3KMFbLQ1+34MASvul6vR8I0NJBC1Czvh9CB9dEDWzAyZoiHRYnuIMQYwSElsPA467S1fp/ cXgMQxqRgE14kK3r2jGn7jbt5By1ebfBDEuGZZN7jdg+Vei8s0bnhu9cL1zGmPezFFSMwO uS/oErRTjgNafJQAPHHBPJV0LIV3KNkEysbkeqcl5J7qHiKHF/j2043h8ZSzu+7A== Received: by filterdrecv-6b68c9f446-wb9xt with SMTP id filterdrecv-6b68c9f446-wb9xt-1-6533EA84-35 2023-10-21 15:13:08.91451324 +0000 UTC m=+333133.267291372 Received: from earth.catern.com (unknown) by geopod-ismtpd-6 (SG) with ESMTP id F6P-YvGASMCJTcQmHEl9WQ Sat, 21 Oct 2023 15:13:08.827 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=::1; helo=localhost; envelope-from=sbaugh@catern.com; receiver=yahoo.com Received: from localhost (localhost [IPv6:::1]) by earth.catern.com (Postfix) with ESMTPSA id 701BE601BB; Sat, 21 Oct 2023 11:13:08 -0400 (EDT) From: sbaugh@catern.com In-Reply-To: <87cyxa6fwg.fsf@yahoo.com> (Po Lu's message of "Thu, 19 Oct 2023 18:54:55 +0800") References: <831qdrok34.fsf@gnu.org> <87cyxa6fwg.fsf@yahoo.com> Date: Sat, 21 Oct 2023 15:13:08 +0000 (UTC) Message-ID: <87sf64rou3.fsf@catern.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-SG-EID: ZgbRq7gjGrt0q/Pjvxk7wM0yQFRdOkTJAtEbkjCkHbIlGE8GshshM4Uifg7A6yF+pbB0H8HpCssK/GseYZPJIEMlS2uWPGZdXXmyDZFwHgD/+mav0JBfxyr+eSqoaIpHhjVfSoqQQQCzLPBQw7akiR7GVGlwAFgeFWexRa7zB8Gw3TrGPueHpdfTr0T5XpHug3aAyp2cbQqKGzqd5+bvHw== X-Entity-ID: d/0VcHixlS0t7iB1YKCv4Q== Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Score: -0.5 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.5 (-) Po Lu writes: > Spencer Baugh writes: > >> + DEFVAR_BOOL ("case-symbols-as-words", case_symbols_as_words, >> + doc: /* If non-nil, case functions treat symbol syntax as part of words. >> + >> +Functions such as `upcase-initials' and `replace-match' check or modify >> +the case pattern of sequences of characters. Normally, these operate on >> +sequences of characters whose syntax is word constituent. If this >> +variable is non-nil, then they operate on sequences of characters whose >> +syntax is either word constituent or symbol constituent. >> + >> +This is useful for programming languages and styles where only the first >> +letter of a symbol's name is ever capitalized.*/); >> + case_symbols_as_words = 0; > > Incidentally: > > Let's not introduce further instances of the anti-pattern where the > ``doc:'' marker in DEFVAR constructs is aligned with its opening paren, > rather than two columns into the word DEFVAR itself. Generally, this > deprives you of latitude for the first line of the doc string, for you > are either compelled to contravene the 80 column limit or to render that > line exceptionally laconic, both of which are ultimately > counterproductive. > > TIA. I agree and I made this change, but if you want this style of indentation for doc: markers to be more common, then you should probably make c-indent-line-or-region do this. Right now if I indent a region it will re-indent the doc: marker to align with the opening paren. From unknown Sat Jun 21 05:14:26 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Spencer Baugh Subject: bug#66614: closed (Re: bug#66614: 29.1.50; Support not capitalizing words inside symbols) Message-ID: References: <83msw1bqpg.fsf@gnu.org> X-Gnu-PR-Message: they-closed 66614 X-Gnu-PR-Package: emacs Reply-To: 66614@debbugs.gnu.org Date: Sun, 29 Oct 2023 11:44:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1698579842-31152-1" This is a multi-part message in MIME format... ------------=_1698579842-31152-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #66614: 29.1.50; Support not capitalizing words inside symbols which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 66614@debbugs.gnu.org. --=20 66614: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D66614 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1698579842-31152-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 66614-done) by debbugs.gnu.org; 29 Oct 2023 11:43:02 +0000 Received: from localhost ([127.0.0.1]:40581 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qx4C6-00084o-Go for submit@debbugs.gnu.org; Sun, 29 Oct 2023 07:43:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36502) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qx4C3-00084J-IX for 66614-done@debbugs.gnu.org; Sun, 29 Oct 2023 07:43:00 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qx4BQ-00008G-B9; Sun, 29 Oct 2023 07:42:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=ldfCRKizq7zbUMlAp/6UNc8t6Lt9WyKsv+qx2Lt/r1g=; b=qRLRhvTAr51n eNTtNZ0PgW7dWnA+h7DArOse2jQuoY8BaC156gyDqmWLrNnyshzprNbpGdp2PBFVUEOuf/x3jWPFZ Z64K0bux/g9l4ZhX0otjzH/seHs4OClj/t7X8cN3oCtdFmHOi8nwiT4OGf1F4Vj6vaYQ6s1os1neP LpOo1dY9fM790jkzRl7NtDIVjTSEkyneT+xBRgRAAT0W/bVIpEt/qMb49zKrCq64WMx9igvUEAZyO tzIpjV3c27ScATTi1dh/vgrdxsdIVKA5+yxsIJyAcv2FglxjQ+VWEI3jKL3wFz1tub957WneC6xBN nsjURKILN5xZjgp/zXCvBA==; Date: Sun, 29 Oct 2023 13:42:03 +0200 Message-Id: <83msw1bqpg.fsf@gnu.org> From: Eli Zaretskii To: sbaugh@catern.com In-Reply-To: <87wmvgroxg.fsf@catern.com> (sbaugh@catern.com) Subject: Re: bug#66614: 29.1.50; Support not capitalizing words inside symbols References: <831qdrok34.fsf@gnu.org> <83zg0fmdpm.fsf@gnu.org> <87wmvgroxg.fsf@catern.com> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 66614-done Cc: sbaugh@janestreet.com, 66614-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: sbaugh@catern.com > Date: Sat, 21 Oct 2023 15:11:08 +0000 (UTC) > Cc: Spencer Baugh , 66614@debbugs.gnu.org > > > You don't have to add it to the buffer structure, you could call > > Fmake_variable_buffer_local instead. We already do that for some > > variables. > > Oh, of course. Done. Thanks, installed on master, and closing the bug. Btw, I consistently need to make minor fixups in your commit log messages. Please try to follow our style better, as indicated by my changes. ------------=_1698579842-31152-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 18 Oct 2023 16:32:47 +0000 Received: from localhost ([127.0.0.1]:34561 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qt9TS-0000nO-IL for submit@debbugs.gnu.org; Wed, 18 Oct 2023 12:32:47 -0400 Received: from lists.gnu.org ([2001:470:142::17]:56010) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qt9TO-0000n6-1e for submit@debbugs.gnu.org; Wed, 18 Oct 2023 12:32:45 -0400 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 1qt9Ss-0007H7-B4 for bug-gnu-emacs@gnu.org; Wed, 18 Oct 2023 12:32:10 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qt9Sq-0006Xo-Mh for bug-gnu-emacs@gnu.org; Wed, 18 Oct 2023 12:32:10 -0400 From: Spencer Baugh To: bug-gnu-emacs@gnu.org Subject: 29.1.50; Support not capitalizing words inside symbols Date: Wed, 18 Oct 2023 12:32:04 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=64.215.233.18; envelope-from=sbaugh@janestreet.com; helo=mxout5.mail.janestreet.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) Quick definitions: - word: a sequence of characters whose syntax is word constituent - symbol: a sequence of characters whose syntax is either word constituent or symbol constituent In some programming languages and styles, a symbol (or every symbol in a sequence of symbols) might be capitalized, but the individual words making up the symbol should never be capitalized. For example, in OCaml, type names Look_like_this and variable names look_like_this, but it is basically never correct for something to Look_Like_This. And one might have "aa_bb cc_dd ee_ff" or "Aa_bb Cc_dd Ee_ff", but never "Aa_Bb Cc_Dd Ee_Ff". Currently, case handling in casefiddle.c and Freplace_match always capitalizes individual words, which has undesirable effects when programming in these styles. Three examples: - If I have a variable "hash_set" and a type name "Hash_set", and I type "Ha" and dabbrev-expand, then depending on the context Ha may expand to Hash_Set instead of hash_set. But it is never correct to caplitalize internal words in this style, so we could avoid this. - If I have a variable foo and Foo, and I query-replace foo with bar_baz, the replacements will be bar_baz and Bar_Baz. But again it is never correct to capitalize internal words in this style. - More concretely, (progn (string-match "az" "Az") (replace-match "az_bz" nil nil "Az")) yields Az_Bz, but in this programming style it should always yield Az_bz. A naive solution is to change the syntax class of symbol constituents so that they are treated as part of words. Or, equivalently, to use superword-mode. This solution is incorrect, though: the distinction between symbols and words is still useful for word and symbol navigation commands, and other purposes besides. Changing the syntax class will break those other use cases. The only thing that needs to be changed is the case behavior. This is straightforwardly solvable by supporting a behavior where symbol constituents are treated as part of words only for case operations. A patch follows which adds a variable which allows that. In GNU Emacs 29.1.50 (build 11, x86_64-pc-linux-gnu, X toolkit, cairo version 1.15.12, Xaw scroll bars) of 2023-10-18 built on Repository revision: 9163e634e296435aa7a78bc6b77b4ee90666d2ac Repository branch: emacs-29 Windowing system distributor 'The X.Org Foundation', version 11.0.12011000 ------------=_1698579842-31152-1--