# HG changeset patch # User Juanma Barranquero # Date 1054336295 0 # Node ID 14976a54566811ca5ee16a0433fbe95b91b880e3 # Parent 950cb49c5824a4d6338d164610747ca6e2a9c59c (looking-back): New function to check for regular expression before point. diff -r 950cb49c5824 -r 14976a545668 lisp/subr.el --- a/lisp/subr.el Fri May 30 22:00:20 2003 +0000 +++ b/lisp/subr.el Fri May 30 23:11:35 2003 +0000 @@ -1820,6 +1820,19 @@ (buffer-substring-no-properties (match-beginning num) (match-end num))))) +(defun looking-back (regexp) + "Return t if text before point matches regular expression REGEXP. +This function modifies the match data that `match-beginning', +`match-end' and `match-data' access; save and restore the match +data if you want to preserve them." + (save-excursion + (let ((beg (point))) + (if (re-search-backward regexp nil t) + (if (= (match-end 0) beg) + t + nil) + nil)))) + (defconst split-string-default-separators "[ \f\t\n\r\v]+" "The default value of separators for `split-string'.