diff options
| author | Juanma Barranquero | 2003-05-30 23:11:35 +0000 |
|---|---|---|
| committer | Juanma Barranquero | 2003-05-30 23:11:35 +0000 |
| commit | 498535fbfc46cdf47f6874ca69237b639e6daaa0 (patch) | |
| tree | edcbfa1120e8ba45318bfb76fae095debbf9a66c | |
| parent | a44c6ff342ab0a1ae86ff08cf72e8ae9b5ae1016 (diff) | |
| download | emacs-498535fbfc46cdf47f6874ca69237b639e6daaa0.tar.gz emacs-498535fbfc46cdf47f6874ca69237b639e6daaa0.zip | |
(looking-back): New function to check for regular expression before point.
| -rw-r--r-- | lisp/subr.el | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index c03b2ff0a98..2ca79e54b76 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -1820,6 +1820,19 @@ STRING should be given if the last search was by `string-match' on STRING." | |||
| 1820 | (buffer-substring-no-properties (match-beginning num) | 1820 | (buffer-substring-no-properties (match-beginning num) |
| 1821 | (match-end num))))) | 1821 | (match-end num))))) |
| 1822 | 1822 | ||
| 1823 | (defun looking-back (regexp) | ||
| 1824 | "Return t if text before point matches regular expression REGEXP. | ||
| 1825 | This function modifies the match data that `match-beginning', | ||
| 1826 | `match-end' and `match-data' access; save and restore the match | ||
| 1827 | data if you want to preserve them." | ||
| 1828 | (save-excursion | ||
| 1829 | (let ((beg (point))) | ||
| 1830 | (if (re-search-backward regexp nil t) | ||
| 1831 | (if (= (match-end 0) beg) | ||
| 1832 | t | ||
| 1833 | nil) | ||
| 1834 | nil)))) | ||
| 1835 | |||
| 1823 | (defconst split-string-default-separators "[ \f\t\n\r\v]+" | 1836 | (defconst split-string-default-separators "[ \f\t\n\r\v]+" |
| 1824 | "The default value of separators for `split-string'. | 1837 | "The default value of separators for `split-string'. |
| 1825 | 1838 | ||