diff options
| author | Spencer Baugh | 2023-10-21 11:09:39 -0400 |
|---|---|---|
| committer | Eli Zaretskii | 2023-10-29 13:32:43 +0200 |
| commit | 5c8fc0b0594b1e3af43d86c0bc96e10d03bc75a2 (patch) | |
| tree | 37e56deacbaaa4492eff5c0211ec362dbfc1a409 /test/src | |
| parent | 3dca52dd422c50ebf24a304e7c3d36cf5f1c55cf (diff) | |
| download | emacs-5c8fc0b0594b1e3af43d86c0bc96e10d03bc75a2.tar.gz emacs-5c8fc0b0594b1e3af43d86c0bc96e10d03bc75a2.zip | |
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): New function.
(case_character_impl, case_character): Use 'case_ch_is_word'.
(syms_of_casefiddle): Define 'case-symbols-as-words'.
* 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'.
(Bug#66614)
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/casefiddle-tests.el | 12 |
1 files changed, 12 insertions, 0 deletions
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 @@ | |||
| 294 | ;;(should (string-equal (capitalize "indIá") "İndıa")) | 294 | ;;(should (string-equal (capitalize "indIá") "İndıa")) |
| 295 | )) | 295 | )) |
| 296 | 296 | ||
| 297 | (defun casefiddle-tests--check-syms (init with-words with-symbols) | ||
| 298 | (let ((case-symbols-as-words nil)) | ||
| 299 | (should (string-equal (upcase-initials init) with-words))) | ||
| 300 | (let ((case-symbols-as-words t)) | ||
| 301 | (should (string-equal (upcase-initials init) with-symbols)))) | ||
| 302 | |||
| 303 | (ert-deftest casefiddle-case-symbols-as-words () | ||
| 304 | (casefiddle-tests--check-syms "Aa_bb Cc_dd" "Aa_Bb Cc_Dd" "Aa_bb Cc_dd") | ||
| 305 | (casefiddle-tests--check-syms "Aa_bb cc_DD" "Aa_Bb Cc_DD" "Aa_bb Cc_DD") | ||
| 306 | (casefiddle-tests--check-syms "aa_bb cc_dd" "Aa_Bb Cc_Dd" "Aa_bb Cc_dd") | ||
| 307 | (casefiddle-tests--check-syms "Aa_Bb Cc_Dd" "Aa_Bb Cc_Dd" "Aa_Bb Cc_Dd")) | ||
| 308 | |||
| 297 | ;;; casefiddle-tests.el ends here | 309 | ;;; casefiddle-tests.el ends here |