From: Michael Heerdegen <michael_heerdegen@web.de>
To: Jean Louis <bugs@gnu.support>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Adding String to Beginning of Lines
Date: Tue, 10 Nov 2020 20:42:01 +0100 [thread overview]
Message-ID: <87y2j9f186.fsf@web.de> (raw)
In-Reply-To: <X6rmIUwQoEQN2ed8@protected.rcdrun.com> (Jean Louis's message of "Tue, 10 Nov 2020 22:12:33 +0300")
Jean Louis <bugs@gnu.support> writes:
> 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'?
You are right with everything. But in the meantime I had found out that
the string is actually used as the prefix to prepend to the lines, not
as a regexp. So an empty string here likely indicates that the user
wants to use the default instead.
> Afterthoughts:
>
> 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.
If the arguments don't fit the specification anything may happen. Just
that is the case here I would say. There is no implicit type check.
If you look at the definition:
(defsubst string-empty-p (string)
"Check whether STRING is empty."
(string= string ""))
and check the doc of `string=' you'll see that for symbols (like `nil')
their name is used as string. This is surely not useful for
`string-empty-p', but thus a symbol which has the empty string as name
(the interned one has a reader syntax "##") fulfills the predicate:
(string-empty-p '##) ==> t
No, that's not useful, just a side effect of the implementation.
| (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))))
That's more or less the same as
(defun rcd-string-empty-p (s)
(or (null s) (and (stringp s) (zerop (length s)))))
But why handling an empty list specially, and not other empty sequences,
like the empty vector? That's what `seq-empty-p' in seq.el does, btw.
Regards,
Michael.
next prev parent reply other threads:[~2020-11-10 19:42 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-10 10:43 Adding String to Beginning of Lines Christopher Dimech
2020-11-10 11:10 ` tomas
2020-11-10 11:19 ` Christopher Dimech
2020-11-10 11:29 ` Christopher Dimech
2020-11-10 11:54 ` Michael Heerdegen
2020-11-10 11:58 ` Christopher Dimech
2020-11-10 12:07 ` Michael Heerdegen
2020-11-10 12:03 ` Christopher Dimech
2020-11-10 12:16 ` Michael Heerdegen
2020-11-10 13:40 ` Christopher Dimech
2020-11-10 14:06 ` Jean Louis
2020-11-10 14:29 ` Michael Heerdegen
2020-11-10 19:12 ` Jean Louis
2020-11-10 19:42 ` Michael Heerdegen [this message]
2020-11-10 21:22 ` Jean Louis
2020-11-11 10:59 ` Michael Heerdegen
2020-11-17 16:06 ` Jean Louis
2020-11-17 16:28 ` Michael Heerdegen
2020-11-10 22:31 ` Stefan Monnier
2020-11-10 23:00 ` Drew Adams
2020-11-11 21:37 ` Michael Heerdegen
2020-11-10 14:16 ` Michael Heerdegen
2020-11-10 14:38 ` Christopher Dimech
2020-11-10 14:49 ` Michael Heerdegen
2020-11-10 17:52 ` Christopher Dimech
2020-11-10 18:03 ` Michael Heerdegen
2020-11-10 18:25 ` Christopher Dimech
2020-11-10 18:49 ` Michael Heerdegen
2020-11-10 18:56 ` Christopher Dimech
2020-11-10 19:02 ` Michael Heerdegen
2020-11-10 19:29 ` Christopher Dimech
2020-11-10 20:07 ` Michael Heerdegen
2020-11-10 22:45 ` tomas
2020-11-11 11:16 ` Michael Heerdegen
2020-11-11 13:22 ` Christopher Dimech
2020-11-11 13:56 ` Michael Heerdegen
2020-11-11 14:07 ` tomas
2020-11-11 14:49 ` Christopher Dimech
2020-11-11 17:20 ` Christopher Dimech
2020-11-11 18:12 ` Michael Heerdegen
2020-11-11 18:25 ` Stefan Monnier
2020-11-11 18:35 ` Christopher Dimech
2020-11-10 14:03 ` Jean Louis
2020-11-10 11:42 ` Michael Heerdegen
2020-11-10 18:47 ` H. Dieter Wilhelm
2020-11-12 19:01 ` Dante Catalfamo
2020-11-14 22:09 ` Jamie Beardslee
2020-11-14 23:17 ` Stefan Monnier
2020-11-14 23:39 ` Jamie Beardslee
2020-11-15 9:12 ` tomas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y2j9f186.fsf@web.de \
--to=michael_heerdegen@web.de \
--cc=bugs@gnu.support \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).