[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trimming strings, /emacs/lisp/emacs-lisp/subr-x.el modification

From: Eli Zaretskii
Subject: Re: Trimming strings, /emacs/lisp/emacs-lisp/subr-x.el modification
Date: Sat, 06 May 2017 12:22:21 +0300

> From: Jean-Christophe Helary <address@hidden>
> Date: Sat, 6 May 2017 18:02:37 +0900
> Cc: Mark Oteiza <address@hidden>, emacs-devel <address@hidden>
> > +(defsubst string-trim-left (string &optional regexp)
> > +  "Trim STRING of leading whitespace matching REGEXP.
> > +
> > +REGEXP defaults to \"[ \t\n\r]+\"."
> > +  (if (string-match (concat "\\`" (or regexp "[ \t\n\r]+")) string)
> >       (replace-match "" t t string)
> >     string))
> What I did not like in the original design was that the default regexp was 
> hard-coded (besides for the fact that it did not allow for options). I 
> understand that your proposal *only* makes it the default, but I think it 
> would be more elegant to have the default extracted from the code and visible 
> to the user so as to allow for her to over-ride the default by resetting the 
> value.

Can you tell why you think that defconst is more elegant than a
hard-coded default?  I think they are basically the same.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]