* lisp/subr.el (string-suffix-p): New function.
authorBozhidar Batsov <bozhidar@batsov.com>
Sun, 24 Nov 2013 08:49:44 +0000 (10:49 +0200)
committerBozhidar Batsov <bozhidar@batsov.com>
Sun, 24 Nov 2013 08:49:44 +0000 (10:49 +0200)
etc/NEWS
lisp/ChangeLog
lisp/subr.el

index ffbfc64..01e77a4 100644 (file)
--- 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.
index 8b67c3e..c68a0c4 100644 (file)
@@ -1,3 +1,7 @@
+2013-11-24  Bozhidar Batsov  <bozhidar@batsov.com>
+
+       * subr.el (string-suffix-p): New function.
+
 2013-11-23  Glenn Morris  <rgm@gnu.org>
 
        * progmodes/python.el (python-shell-send-file):
index 31798b4..b22c719 100644 (file)
@@ -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.