]> git.eshelyaron.com Git - emacs.git/commitdiff
* 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 ffbfc64873c1466212b10488d628dddae81ad961..01e77a441694b925dc68d5a800eb53a7731f5fe4 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 8b67c3ede81d6903e4d6356f63db8092b1c4bb9f..c68a0c402ebfcb8906856dab84a1cd8073884a5b 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 31798b4484949758ec2d7085a8fb5aa01c22d48e..b22c719f01060e6006c097df4a3d17ec01bf08af 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.