* bug#26908: Fwd: Trimming strings, /emacs/lisp/emacs-lisp/subr-x.el modification
[not found] <98EBD2BF-A0ED-4726-9EDA-380058B517F0@gmail.com>
@ 2017-05-13 13:36 ` Jean-Christophe Helary
2017-05-16 22:21 ` Jean-Christophe Helary
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Jean-Christophe Helary @ 2017-05-13 13:36 UTC (permalink / raw)
To: 26908
[-- Attachment #1: Type: text/plain, Size: 883 bytes --]
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
>
>
> ===========================
> 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.
> ===========================
>
>
>
[-- Attachment #2.1: Type: text/html, Size: 3045 bytes --]
[-- Attachment #2.2: subr-x.el.diff --]
[-- Type: application/octet-stream, Size: 1625 bytes --]
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."
[-- Attachment #2.3: Type: text/html, Size: 343 bytes --]
^ permalink raw reply related [flat|nested] 5+ messages in thread
* bug#26908: Fwd: Trimming strings, /emacs/lisp/emacs-lisp/subr-x.el modification
2017-05-13 13:36 ` bug#26908: Fwd: Trimming strings, /emacs/lisp/emacs-lisp/subr-x.el modification Jean-Christophe Helary
@ 2017-05-16 22:21 ` Jean-Christophe Helary
[not found] ` <94609823-9378-4095-BC3F-74E189F10377@gmail.com>
2017-05-19 11:30 ` Eli Zaretskii
2 siblings, 0 replies; 5+ messages in thread
From: Jean-Christophe Helary @ 2017-05-16 22:21 UTC (permalink / raw)
To: 26908; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1281 bytes --]
Nobody is interested in checking/commiting that ? If it's something I should not have touched in the first place, please somebody tell me to drop it...
Jean-Christophe
> On May 13, 2017, at 22:36, Jean-Christophe Helary <jean.christophe.helary@gmail.com> wrote:
>
> 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 <mailto: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 <mailto: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
>>
>>
>> ===========================
>> 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.
>> ===========================
>>
>>
> <subr-x.el.diff>
>>
[-- Attachment #2: Type: text/html, Size: 4126 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#26908: Fwd: Trimming strings, /emacs/lisp/emacs-lisp/subr-x.el modification
[not found] ` <94609823-9378-4095-BC3F-74E189F10377@gmail.com>
@ 2017-05-17 2:26 ` Eli Zaretskii
[not found] ` <83pof85ico.fsf@gnu.org>
1 sibling, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2017-05-17 2:26 UTC (permalink / raw)
To: Jean-Christophe Helary; +Cc: 26908, emacs-devel
> From: Jean-Christophe Helary <jean.christophe.helary@gmail.com>
> Date: Wed, 17 May 2017 07:21:19 +0900
> Cc: emacs-devel <emacs-devel@gnu.org>
>
> Nobody is interested in checking/commiting that ?
I usually wait for a week at least, to let people comment. So please
be a bit more patient.
Thanks for working on this.
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#26908: Fwd: Trimming strings, /emacs/lisp/emacs-lisp/subr-x.el modification
[not found] ` <83pof85ico.fsf@gnu.org>
@ 2017-05-17 3:41 ` Jean-Christophe Helary
0 siblings, 0 replies; 5+ messages in thread
From: Jean-Christophe Helary @ 2017-05-17 3:41 UTC (permalink / raw)
To: 26908; +Cc: emacs-devel
Thank you Eli. I was not aware of the procedure. I have no problem waiting :)
JC
> On May 17, 2017, at 11:26, Eli Zaretskii <eliz@gnu.org> wrote:
>
>> From: Jean-Christophe Helary <jean.christophe.helary@gmail.com>
>> Date: Wed, 17 May 2017 07:21:19 +0900
>> Cc: emacs-devel <emacs-devel@gnu.org>
>>
>> Nobody is interested in checking/commiting that ?
>
> I usually wait for a week at least, to let people comment. So please
> be a bit more patient.
>
> Thanks for working on this.
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#26908: Fwd: Trimming strings, /emacs/lisp/emacs-lisp/subr-x.el modification
2017-05-13 13:36 ` bug#26908: Fwd: Trimming strings, /emacs/lisp/emacs-lisp/subr-x.el modification Jean-Christophe Helary
2017-05-16 22:21 ` Jean-Christophe Helary
[not found] ` <94609823-9378-4095-BC3F-74E189F10377@gmail.com>
@ 2017-05-19 11:30 ` Eli Zaretskii
2 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2017-05-19 11:30 UTC (permalink / raw)
To: Jean-Christophe Helary; +Cc: 26908-done
> From: Jean-Christophe Helary <jean.christophe.helary@gmail.com>
> Date: Sat, 13 May 2017 22:36:11 +0900
>
> Since nobody reacted in the last 3 days, I guess that means there is nothing to change, so I'm sending the patch here.
Thanks, pushed.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-05-19 11:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <98EBD2BF-A0ED-4726-9EDA-380058B517F0@gmail.com>
2017-05-13 13:36 ` bug#26908: Fwd: Trimming strings, /emacs/lisp/emacs-lisp/subr-x.el modification Jean-Christophe Helary
2017-05-16 22:21 ` Jean-Christophe Helary
[not found] ` <94609823-9378-4095-BC3F-74E189F10377@gmail.com>
2017-05-17 2:26 ` Eli Zaretskii
[not found] ` <83pof85ico.fsf@gnu.org>
2017-05-17 3:41 ` Jean-Christophe Helary
2017-05-19 11:30 ` Eli Zaretskii
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).