From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Colin Woodbury" Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] lisp/files.el: Add `file-name-set-extension` Date: Wed, 09 Jun 2021 13:54:23 -0700 Message-ID: References: <6ff4b7d7-03ac-48d1-8d49-de66431d4e5b@www.fastmail.com> <87lf82y9pv.fsf@tcd.ie> <3780a7f9-19f4-4216-baa9-ce00b3dbace9@www.fastmail.com> <6ba4668c-9b39-40e0-a155-f7e583fd33b6@www.fastmail.com> <87czteeyoc.fsf@igel.home> <9a92de1b-e313-468d-aa1f-7f969ed73688@www.fastmail.com> <87h7ipcs3j.fsf@igel.home> <392FB601-CF1D-482F-B373-B443C4131412@gmail.com> <26B660D9-AC76-4AFC-9FFD-2F5D4DCA16C1@acm.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=04ee499aef4d40f3845b7eddfd8c725c Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4238"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Cyrus-JMAP/3.5.0-alpha0-519-g27a961944e-fm-20210531.001-g27a96194 Cc: emacs-devel@gnu.org To: =?UTF-8?Q?Mattias_Engdeg=C3=A5rd?= , Philipp Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jun 09 22:55:40 2021 Return-path: Envelope-to: ged-emacs-devel@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 1lr5Eh-0000th-6F for ged-emacs-devel@m.gmane-mx.org; Wed, 09 Jun 2021 22:55:39 +0200 Original-Received: from localhost ([::1]:33666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lr5Eg-0001DI-7z for ged-emacs-devel@m.gmane-mx.org; Wed, 09 Jun 2021 16:55:38 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54464) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lr5Dr-0008CQ-88 for emacs-devel@gnu.org; Wed, 09 Jun 2021 16:54:47 -0400 Original-Received: from out5-smtp.messagingengine.com ([66.111.4.29]:56635) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lr5Dp-0000ho-1M for emacs-devel@gnu.org; Wed, 09 Jun 2021 16:54:47 -0400 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id A6C1D5C0126; Wed, 9 Jun 2021 16:54:43 -0400 (EDT) Original-Received: from imap1 ([10.202.2.51]) by compute1.internal (MEProxy); Wed, 09 Jun 2021 16:54:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fosskers.ca; h= mime-version:message-id:in-reply-to:references:date:from:to:cc :subject:content-type; s=fm1; bh=IAaiVz8VDiiODYDhAJudPVfe40LHBtl YsPWz9rPId9I=; b=gGZ+06a3zPGAoGikZ8pgBpRnCTQ72tMOpvv99b/uFPLyAwV rgKey3Bn4J0TMtYSspcAuX/A+fhrea25mXKtshXSdQ1b1Y+UL0Ij4Gqa5I+PnoJv avPij3QXxLPFgRWHH9M18Pf6OVaz3mhWRH1UxERJp66iDStR+QneWrizZ7xS3Yun G296Sp8IIkzkgoWV78GxoslXdY8Va/MkIPLATG/CcpCf9OMrHUN+bJHkMT0r4BHG qylVj71Zm8C+KPGlf2E+c2wjKQGK7eTn4cZ35u8+Xsk7I5hwDTh0sPSziTc/4rT/ JUGO0Nbbj8nI/0XinYs4OLlVAAo54qACFVg9Y4A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=IAaiVz 8VDiiODYDhAJudPVfe40LHBtlYsPWz9rPId9I=; b=j0X8+tgqSLqUssY8vzPYen drLYG8MpSnwZgwMyu8jczkhHnMW3AL7RM8/mKYmFaM6pjaX0NAZUCHR0SB/4Oa0Z b8EHKvEx53GffCbLg0dGXrLxX/F5irebxpGawP7dBOp5azaMN64z94LA1usHPbtm 9ASm/UJ5hymcsl6bsPo8u/9/hZdBdCEkRkzfrAFe9XLapj8JFRqtR2tEQCk8Lk6M Kj6EQreMld4I3ihCH1kJrwJx8QAE67GUUHJdkfqu9eeLVsYMy748hEQESgvQjqt0 z2Yxqgmy7E4Y/vP5Gdwy5enO6ot6omjvDj0hm9Pw3NnmvZVHDQOg4US+G9lcYiFg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeduuddgudehudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtsehmtderreerreejnecuhfhrohhmpedfveho lhhinhcuhghoohgusghurhihfdcuoegtohhlihhnsehfohhsshhkvghrshdrtggrqeenuc ggtffrrghtthgvrhhnpefgheeitddvuddvudefkeehgfehueeggeejhfdtvdeludefvedt tddvjeffleehhfenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpegtohhlihhnsehfohhsshhkvghrshdrtggr X-ME-Proxy: Original-Received: by mailuser.nyi.internal (Postfix, from userid 501) id 564DA1300064; Wed, 9 Jun 2021 16:54:43 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface In-Reply-To: <26B660D9-AC76-4AFC-9FFD-2F5D4DCA16C1@acm.org> Received-SPF: none client-ip=66.111.4.29; envelope-from=colin@fosskers.ca; helo=out5-smtp.messagingengine.com 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, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:270615 Archived-At: --04ee499aef4d40f3845b7eddfd8c725c Content-Type: multipart/alternative; boundary=92301e8152ed4b768c611b48c3edff8a --92301e8152ed4b768c611b48c3edff8a Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi all, thanks for the input. I've revised the patch to account for empt= y strings and for filenames that look like directories (i.e. that end in= a slash). I've also begun the copyright assignment process, since adding the unit = tests lengthened the patch past the critical line count. As for the naming of `set-extension`, the best I can think of as an alte= rnative would be `with-extension` as a dual to `sans-extension`, althoug= h I think `set` still signals the intent well enough. I'll defer to othe= rs here. Cheers, Colin On Fri, 4 Jun 2021, at 06:23, Mattias Engdeg=C3=A5rd wrote: > 4 juni 2021 kl. 15.08 skrev Philipp >: >=20 > > Likewise, change the docstring to clarify that a new string is retur= ned. >=20 > Actually we usually don't bother saying that a function creates a new = string unless this is guaranteed and somehow important, since we don't e= ncourage string mutation anyway. For example, functions are usually allo= wed to return an unchanged argument string if that would make sense. >=20 > Conversely, only functions that do mutate strings need to mention that= fact. By default, a user should be able to assume that no string mutati= on takes place. >=20 > I fully agree with the rest of Philipp's excellent points. >=20 >=20 --92301e8152ed4b768c611b48c3edff8a Content-Type: text/html;charset=utf-8 Content-Transfer-Encoding: quoted-printable
Hi all, thanks = for the input. I've revised the patch to account for empty strings and f= or filenames that look like directories (i.e. that end in a slash).
<= /div>

I've also begun the copyright assignment proces= s, since adding the unit tests lengthened the patch past the critical li= ne count.

As for the naming of `set-extensi= on`, the best I can think of as an alternative would be `with-extension`= as a dual to `sans-extension`, although I think `set` still signals the= intent well enough. I'll defer to others here.

=
Cheers,
Colin

On Fri, 4 = Jun 2021, at 06:23, Mattias Engdeg=C3=A5rd wrote:
4 juni 2021 kl. 15.08 skrev Phili= pp <p.stephani2@gmail.com<= /a>>:


Actually we usually don't bother saying that a function creates a new s= tring unless this is guaranteed and somehow important, since we don't en= courage string mutation anyway. For example, functions are usually allow= ed to return an unchanged argument string if that would make sense.
<= /div>

Conversely, only functions that do mutate strin= gs need to mention that fact. By default, a user should be able to assum= e that no string mutation takes place.

I fu= lly agree with the rest of Philipp's excellent points.


--92301e8152ed4b768c611b48c3edff8a-- --04ee499aef4d40f3845b7eddfd8c725c Content-Disposition: attachment;filename="file-name-set-extension.patch" Content-Type: text/x-patch; name="file-name-set-extension.patch" Content-Transfer-Encoding: BASE64 ZGlmZiAtLWdpdCBhL2xpc3AvZmlsZXMuZWwgYi9saXNwL2ZpbGVzLmVsCmluZGV4IDI0NTBk YWY1YmYuLmYzNzI2NGQ3ZDUgMTAwNjQ0Ci0tLSBhL2xpc3AvZmlsZXMuZWwKKysrIGIvbGlz cC9maWxlcy5lbApAQCAtNDg5Miw2ICs0ODkyLDE4IEBAIGV4dGVuc2lvbiwgdGhlIHZhbHVl IGlzIFwiXCIuIgogICAgICAgICAoaWYgcGVyaW9kCiAgICAgICAgICAgICAiIikpKSkpCiAK KyhkZWZ1biBmaWxlLW5hbWUtc2V0LWV4dGVuc2lvbiAoZmlsZW5hbWUgZXh0ZW5zaW9uKQor ICAiU2V0IHRoZSBFWFRFTlNJT04gb2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