lisp-project-of-the-day icon indicating copy to clipboard operation
lisp-project-of-the-day copied to clipboard

cl-change-case

Open utterances-bot opened this issue 5 years ago • 6 comments

cl-change-case

http://40ants.com/lisp-project-of-the-day/2020/05/0076-cl-change-case.html

utterances-bot avatar May 24 '20 05:05 utterances-bot

Please note that I integrated cl-change-case into str.

While we're at it, another utility much useful in the context of the web is cl-slug https://github.com/EuAndreh/cl-slug, to create slugs, which is composed of other useful operations: "asciify" a sentence (remove accentuated characters) and remove punctuation. There is also str:remove-punctuation.

Cleaning up strings: https://lispcookbook.github.io/cl-cookbook/strings.html#cleaning-up-strings

vindarel avatar May 24 '20 05:05 vindarel

Yes, I found cl-change-case because it is a dependency of cl-str and I'm reviewing these dependencies:

svetlyak40wt avatar May 24 '20 08:05 svetlyak40wt

By the way @vindarel to reexport symbols you might consider to use uiop:define-package:

CL-USER> (uiop:define-package new-str
           (:reexport #:cl-change-case))
#<PACKAGE "NEW-STR">
CL-USER> (rutils:package-external-symbols :new-str)
(NEW-STR:CAMEL-CASE NEW-STR:PATH-CASE NEW-STR:LOWER-CASE NEW-STR:SWAP-CASE
 NEW-STR:SNAKE-CASE NEW-STR:UPPER-CASE NEW-STR:SENTENCE-CASE
 NEW-STR:HEADER-CASE NEW-STR:PASCAL-CASE NEW-STR:NO-CASE NEW-STR:PARAM-CASE
 NEW-STR:LOWER-CASE-FIRST NEW-STR:TITLE-CASE NEW-STR:CONSTANT-CASE
 NEW-STR:DOT-CASE NEW-STR:STRING-LOWER-CASE-P NEW-STR:UPPER-CASE-FIRST
 NEW-STR:STRING-UPPER-CASE-P)

svetlyak40wt avatar May 24 '20 08:05 svetlyak40wt

By the way, @vindarel why are the cl-str depends on cl-ppcre-unicode? What it does?

svetlyak40wt avatar May 24 '20 10:05 svetlyak40wt

Thanks! I had seen https://github.com/takagi/cl-reexport/, but it has a dependency I didn't want to include (Alexandria I guess), now with pure UIOP that's nice.

cl-ppcre is used in various functions: to split by regexp (split by whitespace), to replace strings (and quoting the user input to ignore regexps), then doing some work on strings case (check it is alphanumerical, check if it includes unicode characters, etc).

(defun has-letters-p (s)
  "Return t if `s' contains at least one letter (considering unicode, not only alpha characters)."
  (when (ppcre:scan "\\p{L}" s)
    t))

for this, we need cl-ppcre-unicode.

vindarel avatar May 26 '20 16:05 vindarel

Thank you, @vindarel!

svetlyak40wt avatar May 26 '20 17:05 svetlyak40wt