[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding String to Beginning of Lines

From: Jean Louis
Subject: Re: Adding String to Beginning of Lines
Date: Tue, 10 Nov 2020 22:12:33 +0300
User-agent: Mutt/2.0 (3d08634) (2020-11-07)

* Michael Heerdegen <> [2020-11-10 17:30]:
> Jean Louis <> writes:
> > (let ((regex (or regex default))))
>                    ^^^^^
> That might possible need to be
>   (string-empty-p regex)
> depending on how the contents of the variable had been read.

Thank you.

User can choose to have "" regex as also plain function allows is.

(string-match "" "something")

If it is "" it is not nil, it would be chosen.

If it is nil it would not be chosen.

Is that right? Do you think it is necessary more than just `or'?


I do not link that string-empty-p function

(string-empty-p nil) => nil

It is not logical to me. I was even surprised to find it just
yesterday because I had my own function.

Of course that NIL is not a string, but it is also not a string to
give NIL if it is empty (I know this sentence may be confusing) as
that means that NIL is not empty string.

If string is NIL I expect that string-empty-p on that string tells me

(defun rcd-string-empty-p (s)
  "Returns T if string is empty or NIL"
  (let ((s (if (null s) "" s)))
    (if (stringp s)
        (if (zerop (length s)) t nil))))

(rcd-string-empty-p nil) => T

That is my expectation in many programs where I am handling the string
which can be also NIL.

I was always loading files and then first time I installed it as
package that uses subr-x (I think function comes from there) so my
personal function string-empty-p collided with subr-x function and
suddenly my program did not behave well. Yesterday I have renamed my

reply via email to

[Prev in Thread] Current Thread [Next in Thread]