diff options
author | Jason Milkins <jasonm23@users.noreply.github.com> | 2022-08-16 16:43:22 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-16 16:43:22 +0700 |
commit | 3d35d2823ec932c68ea5265a931c9756e8108d65 (patch) | |
tree | 452b5f0f142979ab3627b3fa18c8ac0391acb805 | |
parent | 39340b58c024b08ea6ef812ef26f37bacbeb2d12 (diff) | |
parent | 2c1d2a2c52fd8d40c782c66867d9be93c0e7466b (diff) |
Merge pull request #148 from emacsfodder/s-spaced-words
Added s-spaced-words
-rw-r--r-- | dev/examples.el | 11 | ||||
-rw-r--r-- | s.el | 9 |
2 files changed, 15 insertions, 5 deletions
diff --git a/dev/examples.el b/dev/examples.el index 614c0ce..777e4e8 100644 --- a/dev/examples.el +++ b/dev/examples.el @@ -387,7 +387,7 @@ (s-format "help ${name}! I'm ${malady}" 'gethash - #s(hash-table test equal data ("name" "nic" ))) + #s(hash-table test equal data ("name" "nic"))) (s-format-resolve (car err))) => 's-format-resolve) @@ -405,8 +405,8 @@ ;; Have a literal \ in the replacement (let ((foo "Hello\\nWorld")) (s-lex-format "${foo}")) - => "Hello\\nWorld" - ) + => "Hello\\nWorld") + (defexamples s-count-matches (s-count-matches "a" "aba") => 2 @@ -464,6 +464,11 @@ (s-dashed-words "under_scored_words") => "under-scored-words" (s-dashed-words "camelCasedWords") => "camel-cased-words") + (defexamples s-spaced-words + (s-spaced-words "some_words") => "some words" + (s-spaced-words "dashed-words") => "dashed words" + (s-spaced-words "camelCasedWords") => "camel Cased Words") + (defexamples s-capitalized-words (s-capitalized-words "some words") => "Some words" (s-capitalized-words "under_scored_words") => "Under scored words" @@ -233,9 +233,9 @@ When not specified, ELLIPSIS defaults to ‘...’." (declare (pure t) (side-effect-free t)) (let ((extra (max 0 (- len (length s))))) (concat - (make-string (ceiling extra 2) ? ) + (make-string (ceiling extra 2) ?\s) s - (make-string (floor extra 2) ? )))) + (make-string (floor extra 2) ?\s)))) (defun s-pad-left (len padding s) "If S is shorter than LEN, pad it with PADDING on the left." @@ -585,6 +585,11 @@ When START is non-nil the search will start at that index." (declare (side-effect-free t)) (s-join "-" (mapcar 'downcase (s-split-words s)))) +(defun s-spaced-words (s) + "Convert S to spaced words." + (declare (side-effect-free t)) + (s-join " " (s-split-words s))) + (defun s-capitalized-words (s) "Convert S to Capitalized words." (declare (side-effect-free t)) |