vindarel / cl-str

Modern, simple and consistent Common Lisp string manipulation library.
https://vindarel.github.io/cl-str/
MIT License
305 stars 37 forks source link

Feature request (remove commented out part of the line) #98

Closed Gleefre closed 10 months ago

Gleefre commented 1 year ago

Hello!

I stumbled upon a simple operation that is somewhat tedious to write manually and hopefully can be of interest to this library. I can't come up with a name though :(

The idea is simple - remove "commented out" part of the string:

(subseq line 0 (position +comment-char+ line))
;; and similar, though doesn't have a nice analogy with a one-line comment
(subseq line (1+ (position +uncomment-char+ line)))
vindarel commented 1 year ago

Hello,

For something similar I often split by a character and take the first part:

(first (str:split +comment-char+ line))
(first (str:split "#" "hello # comment" ))
;; "hello"

However by "commented out" I think "programming or markup language", and I fear this would be out of scope for this library.

What to do with a line (insert "# title") # comment?

Gleefre commented 1 year ago

It would work for sure, but it is doing a lot of extra work (it splits the whole string, creates a new list that ends up unused).

"Commented out" part is for a very simple text format that can't contain # anywhere except for comments (it deals with numbers and symbols, can't have arbitrary strings)

Gleefre commented 1 year ago

If you think it is out of scope for this library - of course I don't insist, feel free to close the issue :)