From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Jean-Christophe Helary Newsgroups: gmane.emacs.devel Subject: Re: Trimming strings, /emacs/lisp/emacs-lisp/subr-x.el modification Date: Wed, 3 May 2017 07:48:07 +0900 Message-ID: <0F03B180-9F77-413C-AD6B-D48C79ED3FF8@gmail.com> References: <83a86vi3gv.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1493765328 30012 195.159.176.226 (2 May 2017 22:48:48 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 2 May 2017 22:48:48 +0000 (UTC) To: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed May 03 00:48:45 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d5gb7-0007gs-4U for ged-emacs-devel@m.gmane.org; Wed, 03 May 2017 00:48:45 +0200 Original-Received: from localhost ([::1]:33993 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5gbC-0008Nr-Qh for ged-emacs-devel@m.gmane.org; Tue, 02 May 2017 18:48:50 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56971) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5gac-0008Nm-Sh for emacs-devel@gnu.org; Tue, 02 May 2017 18:48:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5gaZ-0007pV-Qn for emacs-devel@gnu.org; Tue, 02 May 2017 18:48:14 -0400 Original-Received: from mail-pf0-x229.google.com ([2607:f8b0:400e:c00::229]:33186) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d5gaZ-0007ot-K8 for emacs-devel@gnu.org; Tue, 02 May 2017 18:48:11 -0400 Original-Received: by mail-pf0-x229.google.com with SMTP id q20so3759826pfg.0 for ; Tue, 02 May 2017 15:48:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:content-transfer-encoding:mime-version:subject:date:references :to:in-reply-to:message-id; bh=u2BnNJA5qkITOrVN7wVSm6dT/xlbkIgK8T90N5stggU=; b=rLmdVAlbKXZll/0c8iKXf2WRV9TbZKlE/SLiFmo2u9U6Pc45KMlXv0iMkuPmf07NU5 maEHBCf9wBMayqujKbSMNQbA4pt3WMniRT78dlm5MoLz3O7er7I2jj5lmlbPelLQtLkd dnWeuBBShMmEEGwpE7T8ohNZ+bhlKYEvcrsAcjkNitwhByzsIxwIXQhiaI96K9XyXE17 1qLqAanfuw2s+0tXaLuArFTrLE8vezVGTFXoPro9VDIdOxywHd1CcnkxnQv8Zg1XbsuU al2fC15l3tFKKwOLTQtYRLNkpGUhN8l+r5Duq7prrqKKLuoqji1O7zD0NZ87mpuSR+eC mmVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:date:references:to:in-reply-to:message-id; bh=u2BnNJA5qkITOrVN7wVSm6dT/xlbkIgK8T90N5stggU=; b=sEKvWVSmJm8zghHW6JO9ATKaX3VPcujFiOdmGxTFz8tzIeSLysIgdeR7Tt8zxwDLVp SuHQ2apH7vtmGGBcaTxG6c2aNY+uBx3q4iGBZApQQzJe/8AsvzOPGRGH4bgpIKnfLuUN H/uNynuFhMm/H8v5dI/CIjJ/Kk9rpMEDIPIEvD8i0h+Yjhwet+w/P5cnYhzqGJP9SY3L 1fSobpxuqXvjlwsemBm0gBDve4ZgOs8sZj8xC2dALE/Q6HzHUqOLLzQol+r6oX82hdaP YEbCu7XjYbAi6rXD0Kicym5bXyaPsqcfNFySLg/qcNgJtK7uyYG4DUeQWTylL19q68fy uERw== X-Gm-Message-State: AN3rC/7DyZYMz1OIa/1D9SJ3VgzMfMvUcEOc7h81LMAutDjxdBRt+oGT FrIT75wYan2NH+Jl62g= X-Received: by 10.99.115.11 with SMTP id o11mr35522199pgc.10.1493765290041; Tue, 02 May 2017 15:48:10 -0700 (PDT) Original-Received: from [192.168.24.54] (pl25298.ag0304.nttpc.ne.jp. [133.232.153.210]) by smtp.gmail.com with ESMTPSA id s68sm9920844pgc.5.2017.05.02.15.48.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 May 2017 15:48:09 -0700 (PDT) In-Reply-To: <83a86vi3gv.fsf@gnu.org> X-Mailer: Apple Mail (2.3273) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::229 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:214532 Archived-At: > On May 3, 2017, at 2:16, Eli Zaretskii wrote: >> 2) I declared optional "trim-left" and "trim-right" arguments = respectively for the string-trim-left and string-trim-right functions, = and declared both optional for the general string-trim function >=20 > Do we really have use cases for string-trim where trim-left and > trim-right should be different? If not, let's give it only one > optional argument, not 2. I have no clear use case because of my lack of programming experience, = but I can see how TRIM-LEFT could be used to remove the beginning of a = path and TRIM-RIGHT could be used to remove a file extension, for ex. >> +(defsubst string-trim-left (string &optional trim-left) >> + "Trim STRING of leading whitespace matching TRIM-LEFT. >=20 > Since TRIM-LEFT could be anything, the "whitespace" part is no longer > accurate. Suggest to use "delimiters" instead. I overlooked that. In fact, since, as you correctly point out, a regex = can be anything I think "characters" or "the string" is even better. It = seems to me that "delimiter" fits better the concept of "splitting" than = the concept of "trimming". >> +If TRIM-LEFT is non-nil, it should be a regular expression. If nil, >> +it defaults to `string-trim-default-regex', normally \"[ = \t\n\r]+\"." >=20 > This is better worded like this: >=20 > TRIM-LEFT should be a regular expression, and defaults to > `string-trim-default-regex' if omitted or nil. Thank you. I tried to stick to the wording found in subr.el = (split-string)... :-) I'll do as you suggest. >> +(defsubst string-trim (string &optional trim-left trim-right) >> + "Trim STRING of leading and trailing whitespace matching TRIM-LEFT = and TRIM-RIGHT. >=20 > Please make the first line shorter than 80 characters. I overlooked that one. Sorry. Jean-Christophe=20=