From 41ce6f702730d95ef62e770a1b8160e3aac9d0a8 Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Sun, 24 Nov 2013 10:49:44 +0200 Subject: [PATCH] * lisp/subr.el (string-suffix-p): New function. --- etc/NEWS | 2 ++ lisp/ChangeLog | 4 ++++ lisp/subr.el | 9 +++++++++ 3 files changed, 15 insertions(+) diff --git a/etc/NEWS b/etc/NEWS index ffbfc64873..01e77a4416 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -790,6 +790,8 @@ The few hooks that used with-wrapper-hook are replaced as follows: The value, if non-nil, is a regexp that specifies what to trim from the start and end of each substring. +** New function `string-suffix-p'. + ** `get-upcase-table' is obsoleted by the new `case-table-get-table'. ** Support for filesystem notifications. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8b67c3ede8..c68a0c402e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,7 @@ +2013-11-24 Bozhidar Batsov + + * subr.el (string-suffix-p): New function. + 2013-11-23 Glenn Morris * progmodes/python.el (python-shell-send-file): diff --git a/lisp/subr.el b/lisp/subr.el index 31798b4484..b22c719f01 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -3635,6 +3635,15 @@ to case differences." (eq t (compare-strings str1 nil nil str2 0 (length str1) ignore-case))) +(defun string-suffix-p (suffix string &optional ignore-case) + "Return non-nil if SUFFIX is a suffix of STRING. +If IGNORE-CASE is non-nil, the comparison is done without paying +attention to case differences." + (let ((start-pos (- (length string) (length suffix)))) + (and (>= start-pos 0) + (eq t (compare-strings suffix nil nil + string start-pos nil ignore-case))))) + (defun bidi-string-mark-left-to-right (str) "Return a string that can be safely inserted in left-to-right text. -- 2.20.1