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.bugs Subject: bug#26908: Fwd: Trimming strings, /emacs/lisp/emacs-lisp/subr-x.el modification Date: Sat, 13 May 2017 22:36:11 +0900 Message-ID: <95032941-C381-47C3-9554-3E13DE6A5013@gmail.com> References: <98EBD2BF-A0ED-4726-9EDA-380058B517F0@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_2F994F5F-4203-49A3-9CBC-23BB81C921DE" X-Trace: blaine.gmane.org 1494682638 6051 195.159.176.226 (13 May 2017 13:37:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 13 May 2017 13:37:18 +0000 (UTC) To: 26908@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat May 13 15:37:11 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1d9XEJ-0001Kr-Cu for geb-bug-gnu-emacs@m.gmane.org; Sat, 13 May 2017 15:37:07 +0200 Original-Received: from localhost ([::1]:57683 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d9XEO-0006Y1-QP for geb-bug-gnu-emacs@m.gmane.org; Sat, 13 May 2017 09:37:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44562) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d9XEI-0006RY-HB for bug-gnu-emacs@gnu.org; Sat, 13 May 2017 09:37:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d9XEF-0007Gl-C8 for bug-gnu-emacs@gnu.org; Sat, 13 May 2017 09:37:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:39226) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d9XEF-0007Fx-7h for bug-gnu-emacs@gnu.org; Sat, 13 May 2017 09:37:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1d9XED-0006gl-Pb for bug-gnu-emacs@gnu.org; Sat, 13 May 2017 09:37:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jean-Christophe Helary Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 13 May 2017 13:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 26908 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.149468259125672 (code B ref -1); Sat, 13 May 2017 13:37:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 13 May 2017 13:36:31 +0000 Original-Received: from localhost ([127.0.0.1]:41903 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d9XDi-0006g0-Sp for submit@debbugs.gnu.org; Sat, 13 May 2017 09:36:31 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:53461) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d9XDh-0006fn-Kb for submit@debbugs.gnu.org; Sat, 13 May 2017 09:36:30 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d9XDb-0006Tz-LO for submit@debbugs.gnu.org; Sat, 13 May 2017 09:36:24 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:52854) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d9XDb-0006Tm-HP for submit@debbugs.gnu.org; Sat, 13 May 2017 09:36:23 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44431) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d9XDa-0006MM-FO for bug-gnu-emacs@gnu.org; Sat, 13 May 2017 09:36:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d9XDX-0006RD-B4 for bug-gnu-emacs@gnu.org; Sat, 13 May 2017 09:36:22 -0400 Original-Received: from mail-pg0-x22a.google.com ([2607:f8b0:400e:c05::22a]:33977) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d9XDX-0006PZ-1Y for bug-gnu-emacs@gnu.org; Sat, 13 May 2017 09:36:19 -0400 Original-Received: by mail-pg0-x22a.google.com with SMTP id u28so41781694pgn.1 for ; Sat, 13 May 2017 06:36:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:mime-version:subject:message-id:references:to:date; bh=Qn8ZbfxVPn1MeU8GrLzgpZ7NaXZhz3BTceu/gEZIcBw=; b=YfGsNKO3r5Fd2Tg98szhkDJq9sWuXClox6+emuLA5hGEx9W3THwFV1d+aBLSjvYvtO PBuvWi6cytHyIlSdwzQpGTMPPIlcO0DtuQH9UGhTxdX1Ld9n4ZLP655k66NprgGkdEVf 93/DB0QTylxoHzOMvKECopyQuD57XRzQmGxbVbP+4fbDtHPyDvfecQv58DFFmoll4+Fv kUvAT/xJRfF8AJUKKco05irsqVN9TNaqY+nVPQ0Q+c76MmPopMTLoq4olrp1faoZKgSC 8lcNkF+NgWCV7esNRCAYue6/Nu+79AXPThKsgJKGDccu48U7LB8HCJWU06ntsAfELUok CYxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:mime-version:subject:message-id:references :to:date; bh=Qn8ZbfxVPn1MeU8GrLzgpZ7NaXZhz3BTceu/gEZIcBw=; b=sMcYoG5y1kjy1W5Tp6xDVtoX2Kh8FN9cZgOEpbAPd1QQjor6wklgIjMcpcr8NkW/65 dVE/03+PE4UNEFXi9q7lf9uQCCbgAOmwSUOJOkgIhH7dXJTXagKonKFa3SUY0Sx7SVUq zGw5o4dwMDdyASC/OcSJenHucgny1JLxu6BGa0vrR0CKe+z8yfWuBile2l5G6my8ysDS q9ETgUwsNt2yutK563AUwYCvVHgOfkKXTzXjcs6qJMjVqCa5OURT6voHRfBACiSSdA9T iI0XBPMDOrlDZ6W6oGZqQEqD2Xu990/Apeou3bqHdNlD1zDB7BqQ/ZcNSrbS+NjpGVLR QnOw== X-Gm-Message-State: AODbwcAL2r1sTytbqxonKnsVT6LtHjjMYFL3OY9pBxM85sYZoHlOVw5O CJC8GdrED4APs0Kq2dA= X-Received: by 10.99.102.134 with SMTP id a128mr9398723pgc.42.1494682575821; Sat, 13 May 2017 06:36:15 -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 i15sm15247745pfj.51.2017.05.13.06.36.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 May 2017 06:36:14 -0700 (PDT) X-Mailer: Apple Mail (2.3273) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:132468 Archived-At: --Apple-Mail=_2F994F5F-4203-49A3-9CBC-23BB81C921DE Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Since nobody reacted in the last 3 days, I guess that means there is = nothing to change, so I'm sending the patch here. Jean-Christophe=20 > Begin forwarded message: >=20 > From: Jean-Christophe Helary > Subject: Re: Trimming strings, /emacs/lisp/emacs-lisp/subr-x.el = modification > Date: May 10, 2017 23:26:04 GMT+9 > To: Emacs developers >=20 > Hopefully last fixes. >=20 > I've added the \\(?: ... \\) parens to make sure we capture any = potential issue with \|. >=20 > Is there anything else I've missed ? >=20 > Jean-Christophe=20 >=20 >=20 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > Add optional regexps for subr-x.el trimming functions >=20 > * lisp/emacs-lisp/subr-x.el (string-trim-left, string-trim-right, = string-trim): add optional regexps that default on the original = behavior. > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D >=20 >=20 >=20 --Apple-Mail=_2F994F5F-4203-49A3-9CBC-23BB81C921DE Content-Type: multipart/mixed; boundary="Apple-Mail=_916C1400-62BC-40E1-975F-B42873E27EA6" --Apple-Mail=_916C1400-62BC-40E1-975F-B42873E27EA6 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii Since nobody reacted in the last 3 days, I guess that means = there is nothing to change, so I'm sending the patch here.

Jean-Christophe 

Begin forwarded message:

From: = Jean-Christophe Helary <jean.christophe.helary@gmail.com>
Subject: = Re: Trimming = strings, /emacs/lisp/emacs-lisp/subr-x.el modification
Date: = May 10, 2017 23:26:04 GMT+9
To: = Emacs developers <emacs-devel@gnu.org>

Hopefully last fixes.

I've added the \\(?: ... \\) parens to make = sure we capture any potential issue with \|.

Is there anything else I've missed ?

Jean-Christophe


=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D
Add optional regexps for subr-x.el = trimming functions

* = lisp/emacs-lisp/subr-x.el (string-trim-left, string-trim-right, = string-trim): add optional regexps that default on the original = behavior.
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D


= --Apple-Mail=_916C1400-62BC-40E1-975F-B42873E27EA6 Content-Disposition: attachment; filename=subr-x.el.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="subr-x.el.diff" Content-Transfer-Encoding: 7bit diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el index 440213eb38..ded231c475 100644 --- a/lisp/emacs-lisp/subr-x.el +++ b/lisp/emacs-lisp/subr-x.el @@ -179,21 +179,27 @@ VARLIST can just be a plain tuple. (define-obsolete-function-alias 'string-reverse 'reverse "25.1") -(defsubst string-trim-left (string) - "Remove leading whitespace from STRING." - (if (string-match "\\`[ \t\n\r]+" string) +(defsubst string-trim-left (string &optional regexp) + "Trim STRING of leading string matching REGEXP. + +REGEXP defaults to \"[ \\t\\n\\r]+\"." + (if (string-match (concat "\\`\\(?:" (or regexp "[ \t\n\r]+")"\\)") string) (replace-match "" t t string) string)) -(defsubst string-trim-right (string) - "Remove trailing whitespace from STRING." - (if (string-match "[ \t\n\r]+\\'" string) +(defsubst string-trim-right (string &optional regexp) + "Trim STRING of trailing string matching REGEXP. + +REGEXP defaults to \"[ \\t\\n\\r]+\"." + (if (string-match (concat "\\(?:" (or regexp "[ \t\n\r]+") "\\)\\'") string) (replace-match "" t t string) string)) -(defsubst string-trim (string) - "Remove leading and trailing whitespace from STRING." - (string-trim-left (string-trim-right string))) +(defsubst string-trim (string &optional trim-left trim-right) + "Trim STRING of leading and trailing strings matching TRIM-LEFT and TRIM-RIGHT. + +TRIM-LEFT and TRIM-RIGHT default to \"[ \\t\\n\\r]+\"." + (string-trim-left (string-trim-right string trim-right) trim-left)) (defsubst string-blank-p (string) "Check whether STRING is either empty or only whitespace." --Apple-Mail=_916C1400-62BC-40E1-975F-B42873E27EA6 Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=us-ascii

--Apple-Mail=_916C1400-62BC-40E1-975F-B42873E27EA6-- --Apple-Mail=_2F994F5F-4203-49A3-9CBC-23BB81C921DE--