branch: externals/compat commit 9925d1d67987e8eb30c44a3e4d6cc1e7770ce864 Author: Philip Kaludercic <phil...@posteo.net> Commit: Philip Kaludercic <phil...@posteo.net>
Transform string-trim{,-left,-right} into prefixed functions --- MANUAL | 15 ++++++++++--- compat-26.el | 3 +++ compat.texi | 70 ++++++++++++++++++++++++++++++++++-------------------------- 3 files changed, 55 insertions(+), 33 deletions(-) diff --git a/MANUAL b/MANUAL index 1650c8acc4..c3224dae89 100644 --- a/MANUAL +++ b/MANUAL @@ -164,6 +164,9 @@ implemented in 24.4: - The ~get-pos-property~ function. - The ~define-advice~ macro. - Support for generators. +- The ~string-trim~, ~string-trim-left~ and ~string-trim-right~ + functions. These are instead provided as prefixed function as part + of [[*Emacs 26.1][Emacs 26.1]] support. ** Emacs 24.5 :PROPERTIES: @@ -232,9 +235,6 @@ provided by Compat by default: - Function: func-arity :: See [[info:elisp#What Is a Function][(elisp) What Is a Function]]. - Function: mapcan :: See [[info:elisp#Mapping Functions][(elisp) Mapping Functions]]. -- Function: string-trim-left :: See [[info:elisp#Creating Strings][(elisp) Creating Strings]]. -- Function: string-trim-right :: See [[info:elisp#Creating Strings][(elisp) Creating Strings]]. -- Function: string-trim :: See [[info:elisp#Creating Strings][(elisp) Creating Strings]]. - Function: cXXXr :: - Function: cXXXXr :: See [[info:elisp#List Elements][(elisp) List Elements]]. @@ -267,6 +267,15 @@ when ~compat-26~ is required: Handle the optional argument TESTFN. Can also be used as a generalised variable. +- Function: compat-string-trim-left :: See [[info:elisp#Creating Strings][(elisp) Creating Strings]]. + + Handles the optional argument REGEXP. +- Function: compat-string-trim-right :: See [[info:elisp#Creating Strings][(elisp) Creating Strings]]. + + Handles the optional argument REGEXP. +- Function: compat-string-trim :: See [[info:elisp#Creating Strings][(elisp) Creating Strings]]. + + Handles the optional arguments TRIM-LEFT and TRIM-RIGHT. Compat does not provide support for the following Lisp features implemented in 26.1: diff --git a/compat-26.el b/compat-26.el index bab65df98b..18c53e446b 100644 --- a/compat-26.el +++ b/compat-26.el @@ -190,6 +190,7 @@ from the absolute start of the buffer, disregarding the narrowing." REGEXP defaults to \"[ \\t\\n\\r]+\"." :realname compat--string-trim-left + :prefix t (if (string-match (concat "\\`\\(?:" (or regexp "[ \t\n\r]+") "\\)") string) (substring string (match-end 0)) string)) @@ -199,6 +200,7 @@ REGEXP defaults to \"[ \\t\\n\\r]+\"." REGEXP defaults to \"[ \\t\\n\\r]+\"." :realname compat--string-trim-right + :prefix t (let ((i (string-match-p (concat "\\(?:" (or regexp "[ \t\n\r]+") "\\)\\'") string))) @@ -208,6 +210,7 @@ REGEXP defaults to \"[ \\t\\n\\r]+\"." "Trim STRING of leading with and trailing matching TRIM-LEFT and TRIM-RIGHT. TRIM-LEFT and TRIM-RIGHT default to \"[ \\t\\n\\r]+\"." + :prefix t ;; `string-trim-left' and `string-trim-right' were moved from subr-x ;; to subr in Emacs 27, so to avoid loading subr-x we use the ;; compatibility function here: diff --git a/compat.texi b/compat.texi index 61f173db01..4fbe7ce372 100644 --- a/compat.texi +++ b/compat.texi @@ -73,12 +73,12 @@ Usage Support -* Emacs 24.4:: Compatibility support for Emacs 24.4 -* Emacs 24.5:: Compatibility support for Emacs 24.5 -* Emacs 25.1:: Compatibility support for Emacs 25.1 -* Emacs 26.1:: Compatibility support for Emacs 26.1 -* Emacs 27.1:: Compatibility support for Emacs 27.1 -* Emacs 28.1:: Compatibility support for Emacs 28.1 +* Emacs 24.4: Emacs 244. Compatibility support for Emacs 24.4 +* Emacs 24.5: Emacs 245. Compatibility support for Emacs 24.5 +* Emacs 25.1: Emacs 251. Compatibility support for Emacs 25.1 +* Emacs 26.1: Emacs 261. Compatibility support for Emacs 26.1 +* Emacs 27.1: Emacs 271. Compatibility support for Emacs 27.1 +* Emacs 28.1: Emacs 281. Compatibility support for Emacs 28.1 @end detailmenu @end menu @@ -215,15 +215,15 @@ This section goes into the features that Compat manages and doesn't manage to provide for each Emacs version. @menu -* Emacs 24.4:: Compatibility support for Emacs 24.4 -* Emacs 24.5:: Compatibility support for Emacs 24.5 -* Emacs 25.1:: Compatibility support for Emacs 25.1 -* Emacs 26.1:: Compatibility support for Emacs 26.1 -* Emacs 27.1:: Compatibility support for Emacs 27.1 -* Emacs 28.1:: Compatibility support for Emacs 28.1 +* Emacs 24.4: Emacs 244. Compatibility support for Emacs 24.4 +* Emacs 24.5: Emacs 245. Compatibility support for Emacs 24.5 +* Emacs 25.1: Emacs 251. Compatibility support for Emacs 25.1 +* Emacs 26.1: Emacs 261. Compatibility support for Emacs 26.1 +* Emacs 27.1: Emacs 271. Compatibility support for Emacs 27.1 +* Emacs 28.1: Emacs 281. Compatibility support for Emacs 28.1 @end menu -@node Emacs 24.4 +@node Emacs 244 @section Emacs 24.4 The following functions and macros implemented in 24.4, and are @@ -346,14 +346,18 @@ The @code{get-pos-property} function. The @code{define-advice} macro. @item Support for generators. +@item +The @code{string-trim}, @code{string-trim-left} and @code{string-trim-right} +functions. These are instead provided as prefixed function as part +of @ref{Emacs 261, , Emacs 26.1} support. @end itemize -@node Emacs 24.5 +@node Emacs 245 @section Emacs 24.5 No special support for 24.5 was deemed necessary. -@node Emacs 25.1 +@node Emacs 251 @section Emacs 25.1 The following functions and macros implemented in 25.1, and are @@ -459,7 +463,7 @@ The functions @code{bufferpos-to-filepos} and @code{filepos-to-bufferpos}. Note that the changes in Emacs 25.2 and 25.3 are also included here, for the sake of simplicity. -@node Emacs 26.1 +@node Emacs 261 @section Emacs 26.1 The following functions and macros implemented in 26.1, and are @@ -473,18 +477,6 @@ See @ref{What Is a Function,(elisp) What Is a Function,,elisp,}. See @ref{Mapping Functions,(elisp) Mapping Functions,,elisp,}. @end defun -@defun string-trim-left -See @ref{Creating Strings,(elisp) Creating Strings,,elisp,}. -@end defun - -@defun string-trim-right -See @ref{Creating Strings,(elisp) Creating Strings,,elisp,}. -@end defun - -@defun string-trim -See @ref{Creating Strings,(elisp) Creating Strings,,elisp,}. -@end defun - @defun cXXXr @end defun @defun cXXXXr @@ -564,6 +556,24 @@ Handle the optional argument TESTFN@. Can also be used as a generalised variable. @end defun +@defun compat-string-trim-left +See @ref{Creating Strings,(elisp) Creating Strings,,elisp,}. + +Handles the optional argument REGEXP@. +@end defun + +@defun compat-string-trim-right +See @ref{Creating Strings,(elisp) Creating Strings,,elisp,}. + +Handles the optional argument REGEXP@. +@end defun + +@defun compat-string-trim +See @ref{Creating Strings,(elisp) Creating Strings,,elisp,}. + +Handles the optional arguments TRIM-LEFT and TRIM-RIGHT@. +@end defun + Compat does not provide support for the following Lisp features implemented in 26.1: @@ -607,7 +617,7 @@ The function @code{window-swap-states}. Note that the changes in Emacs 26.2 and 26.3 are also included here, for the sake of simplicity. -@node Emacs 27.1 +@node Emacs 271 @section Emacs 27.1 The following functions and macros implemented in 27.1, and are @@ -807,7 +817,7 @@ functionality. Note that the changes in Emacs 27.2 are also included here, for the sake of simplicity. -@node Emacs 28.1 +@node Emacs 281 @section Emacs 28.1 The following functions and macros implemented in 28.1, and are