From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: Adding String to Beginning of Lines Date: Tue, 10 Nov 2020 20:42:01 +0100 Message-ID: <87y2j9f186.fsf@web.de> References: <20201110111024.GA15992@tuxteam.de> <87zh3pctr1.fsf@web.de> <87o8k5csqj.fsf@web.de> <87tutxb7yz.fsf@web.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37412"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: help-gnu-emacs@gnu.org To: Jean Louis Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Nov 10 20:54:28 2020 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kcZil-0009cJ-VX for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 10 Nov 2020 20:54:27 +0100 Original-Received: from localhost ([::1]:39558 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kcZil-0008Cr-1r for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 10 Nov 2020 14:54:27 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53758) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcZXI-0008IE-UG for help-gnu-emacs@gnu.org; Tue, 10 Nov 2020 14:42:36 -0500 Original-Received: from mout.web.de ([212.227.15.4]:60831) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcZXG-0001XR-R7 for help-gnu-emacs@gnu.org; Tue, 10 Nov 2020 14:42:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1605037321; bh=Cipx0AuRl7uB2WjlebmDNGXKFA8fo+sqy9yZM99S1zk=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=j4yRqYfDEcMIDQEJxcjCEcGKy08HWa5pSJ1og2mMRaMYiBWEzEKwGOj2yL0eeW9bd yH8XrV0vL7aDuomyxwD8syCiZRFTEIgr6cUNeBHr1d6AhGhZibKK93bvZhuRDRTXCk 7JgXQJKtcnAkTKzlHfgRAMtQNfI1M1zoKo7DUfUE= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Original-Received: from drachen.dragon ([94.218.215.213]) by smtp.web.de (mrweb004 [213.165.67.108]) with ESMTPSA (Nemesis) id 0Lv7eE-1kBO0Z2g1C-010Isq; Tue, 10 Nov 2020 20:42:01 +0100 In-Reply-To: (Jean Louis's message of "Tue, 10 Nov 2020 22:12:33 +0300") X-Provags-ID: V03:K1:6ouFQTBA4CFtbMQKhA7txIAyvUH2OhuSmH3SwekQLYYKjGcoHaP Ddp/Piu2FmlNKOWG9rDyH6AQe8Zxf0WCZNOFOusRT5a68HoMiS6rlCSggx5tZZa3BDEfFRR 8loCD6fr6imSPWXnCrkaVlofNQ5ggubHobXKasg2zRRtdAZuWqWE4KKVN8v43wFixa/DUGI F2oRPX2d/98BgFgVjGj0A== X-UI-Out-Filterresults: notjunk:1;V03:K0:7Fcq5G516iI=:y895tXzicf9NE6mYEql5EE yqC/kq+KtFRLwEBFa9jb6OjlCz+E4lt1i9e8VqKLsv3OAFrJpOg/Zveun31LYcHEpgQ4S0gfT AhNDx2pA362IRS/kalWkGWtYBZznSaxRx3pMTY5g+o7MTVfQZI4w+C3DO/HctOgiVwVYs/mYV qsCcFxF5EjOhsyR8P5RXjKroAPKyIOCwYNIPpEn0YpnQd5pI+mKkMMxSAMCeBL+/c7w7SVzNU wxxIOKqiidkIION56fvojCa+vADVCC08Sw/KSx8Cco48vUTs0v/+lmXPLta5HHGH+5ImqKXVX HDRQo/QjISac4/PYO7y+N3wEFnFkEw4B7H71YaSmo9pZ0jp0RYcFJ+PuYDjZD1XzAwyzNiuU9 YhIIwu3rYD9nwTSS6pmcZ9No54qbdp4e1NCcm/2JfXJ7KcN7w4tBf18UN6aWObcb9Xn4vL3hd 1EGtx48aH9lFpQQGXuKGyE6SQIsP0/FnBm0opq7fyT63S0qwl0EiL8XXLe6cR09esL9wE3y8u MK9KY8bpKB6lnr9AcZjmOAbKZV38TkPNml44zl/VvaTV1dmMS1N44vQqSlqIApOrepDa5eRPu x5kKbBmQ56mw+/274/8qje3+gGt4i6MIfDr9o6jd2Q4tKYBH6dgVglE+cupuf+y66Y1osKj58 /GbyHi0sTZSwUwIJ/wKDsYIF6D6HZ2qk9jUhwJ0C6t1h0Tr904B0V9Zt9Ae/JNVHjEaYJDr2+ TvsCR7vrcBmMU5RgRdJrxWBvuqL4uqNOqgiOqRoXcU4tK66RE4Rl7DxHG+8tQqyg2ZGEN9Y9 Received-SPF: pass client-ip=212.227.15.4; envelope-from=michael_heerdegen@web.de; helo=mout.web.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/10 14:42:32 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:125209 Archived-At: Jean Louis 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.