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: Tue, 25 May 2021 12:42:05 -0700 Message-ID: References: <6ff4b7d7-03ac-48d1-8d49-de66431d4e5b@www.fastmail.com> <87r1hu3dsm.fsf@igel.home> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=8c24d29834ed45bb852679b213c70033 Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32784"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Cyrus-JMAP/3.5.0-alpha0-448-gae190416c7-fm-20210505.004-gae190416 Cc: emacs-devel@gnu.org To: "Andreas Schwab" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue May 25 21:44:14 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 1llcyL-0008IC-Nb for ged-emacs-devel@m.gmane-mx.org; Tue, 25 May 2021 21:44:14 +0200 Original-Received: from localhost ([::1]:50726 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llcyK-0003fm-N7 for ged-emacs-devel@m.gmane-mx.org; Tue, 25 May 2021 15:44:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37336) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llcwv-0002xo-0B for emacs-devel@gnu.org; Tue, 25 May 2021 15:42:45 -0400 Original-Received: from out4-smtp.messagingengine.com ([66.111.4.28]:35247) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llcwn-00056A-FV for emacs-devel@gnu.org; Tue, 25 May 2021 15:42:44 -0400 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 15BDC5C0199; Tue, 25 May 2021 15:42:36 -0400 (EDT) Original-Received: from imap1 ([10.202.2.51]) by compute1.internal (MEProxy); Tue, 25 May 2021 15:42:36 -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=i6LT7U/c8qn1gxoJ8R1k0QbjJD4d1VK /GBa300zQv04=; b=orH8Kwp6cXyNSMqrFcclFPQBEZWOIQSqEN6bkHOPqwFf+5S rrQHcEQ5mHJ5IYG2KVpow+8VSP3jUat00EsKla9qoFNpXEVJQ+miBIJZUE5Mi8vv B0N3j0uONGGrCOsR0hiKe5Xm4pBL2i5rgAqFpUt2lZX1dFbYPzEQbhXs4hsBkGz0 kSpm9b4hUv/nVe/hQ8woK05S60qgCPDdKm/YtimC+j2tB6VagKyJisitjvBr2zQ6 rNV5VBn7XUX+r9A1fiWcacPYWugPh5xfV3C66wmVmFBI7QtyLgFSsghzyi2yj7z9 6ZSb6v3/3KoJOLMuYoy2eJpKzd+cWT8zX55hsBg== 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=fm2; bh=i6LT7U /c8qn1gxoJ8R1k0QbjJD4d1VK/GBa300zQv04=; b=LssnM0tArZL7pRZewCE8t4 LLtN35aWVmDmASXN++YFUsA74Bjx9ioq69+9WvyIs7/e3N3/vaawkJp1v4lRCIOu pJ2Fn8415tAveVmGhYpFKrsrehmKImvuFtrFbhsV7An81ybyL5v4s4hQiW2DaXvL MxIpYc0ovq08jyzML0gQaGvX8xVRSG5mDCkOH+jvk5fa1Q1mIAyPirO532MQgb/+ knzoTCw+bhcz/0qc1tITyKZrWIJraLVvx0xdzXdgE0HjXbyZUJlI/M7kZoPwEznf XqT9Jvzbw9BzRAgFjRkPaH+KcJ+8F3C8LLd5/h7hwWr9JQv9KdBQLA7lNzcZlV1Q == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdekuddgudegvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtsegrtderreerredtnecuhfhrohhmpedfveho lhhinhcuhghoohgusghurhihfdcuoegtohhlihhnsehfohhsshhkvghrshdrtggrqeenuc ggtffrrghtthgvrhhnpeefhfdvgedtueejffdtiefgheeugedvhfegueevuedtleevgeel geevfeffudejffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpegtohhlihhnsehfohhsshhkvghrshdrtggr X-ME-Proxy: Original-Received: by mailuser.nyi.internal (Postfix, from userid 501) id A615D130005F; Tue, 25 May 2021 15:42:35 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface In-Reply-To: <87r1hu3dsm.fsf@igel.home> Received-SPF: none client-ip=66.111.4.28; envelope-from=colin@fosskers.ca; helo=out4-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_H3=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:269887 Archived-At: --8c24d29834ed45bb852679b213c70033 Content-Type: text/plain Hi Andreas, `nil` seemed more appropriate than returning either an empty string or throwing an error. The intent is to signal a failure in general, as it looks like other related functions in that file do. On Tue, 25 May 2021, at 10:48, Andreas Schwab wrote: > On Mai 25 2021, Colin Woodbury wrote: > > > diff --git a/lisp/files.el b/lisp/files.el > > index 62e1702fdf..f8aefa7930 100644 > > --- a/lisp/files.el > > +++ b/lisp/files.el > > @@ -4889,6 +4889,20 @@ extension, the value is \"\"." > > (if period > > ""))))) > > > > +(defun file-name-set-extension (filename extension) > > + "Change the extension of a FILENAME to EXTENSION. > > +Sanitizes the input to consolidate leading/trailing dots. > > + > > +Returns `nil' if either of the FILENAME or EXTENSION are `nil' > > +before sanitizing, or empty afterwards." > > + (when (and filename extension) > > What is the use-case for nil? > > Andreas. > > -- > Andreas Schwab, schwab@linux-m68k.org > GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 > "And now for something completely different." > --8c24d29834ed45bb852679b213c70033 Content-Type: text/html Content-Transfer-Encoding: quoted-printable
Hi Andreas,
=

`nil` seemed more appropriate than returning e= ither an empty string or throwing an error. The intent is to signal a fa= ilure in general, as it looks like other related functions in that file = do.

On Tue, 25 May 2021, at 10:48, Andreas = Schwab wrote:
On Mai 25 2021, Colin Woodbury wrote:

&g= t; diff --git a/lisp/files.el b/lisp/files.el
> index 6= 2e1702fdf..f8aefa7930 100644
> --- a/lisp/files.el
<= /div>
> +++ b/lisp/files.el
> @@ -4889,6 +4889,2= 0 @@ extension, the value is \"\"."
>   =        (if period
> =             = "")))))
>  
> +(defun file-= name-set-extension (filename extension)
> +  "Chan= ge the extension of a FILENAME to EXTENSION.
> +Sanitiz= es the input to consolidate leading/trailing dots.
> +<= br>
> +Returns `nil' if either of the FILENAME or EXTENSION= are `nil'
> +before sanitizing, or empty afterwards."<= br>
> +  (when (and filename extension)
=
What is the use-case for nil?

Andreas.

-- 
Andreas S= chwab, schwab@linux-m68k= .org
GPG Key fingerprint =3D 7578 EB47 D4E5 4D69 2510&= nbsp; 2552 DF73 E780 A9DA AEC1
"And now for something comp= letely different."


<= /body> --8c24d29834ed45bb852679b213c70033--