]> code.delx.au - gnu-emacs-elpa/commitdiff
* yasnippet-tests.el (string-suffix-p): Define for older Emacsen.
authorNoam Postavsky <npostavs@users.sourceforge.net>
Sat, 5 Sep 2015 20:20:04 +0000 (16:20 -0400)
committerNoam Postavsky <npostavs@users.sourceforge.net>
Sat, 5 Sep 2015 20:20:04 +0000 (16:20 -0400)
yasnippet-tests.el

index a59cdf7352abc27bd46a2281625c01a89167cb6a..fbf79f8a82119668109dfa6ae42b5073074810df 100644 (file)
@@ -836,6 +836,17 @@ add the snippets associated with the given mode."
   ;; FIXME: Why provide this default definition here?!?
   (defalias 'special-mode 'fundamental))
 
+(unless (fboundp 'string-suffix-p)
+  ;; introduced in Emacs 24.4
+  (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))))))
+
 ;;; btw to test this in emacs22 mac osx:
 ;;; curl -L -O https://github.com/mirrors/emacs/raw/master/lisp/emacs-lisp/ert.el
 ;;; curl -L -O https://github.com/mirrors/emacs/raw/master/lisp/emacs-lisp/ert-x.el