diff options
| author | Simon Marshall | 1995-03-23 08:43:08 +0000 |
|---|---|---|
| committer | Simon Marshall | 1995-03-23 08:43:08 +0000 |
| commit | 993713ce0a74253af0cc50f397193b70280f13f3 (patch) | |
| tree | 3a9210a8abc801a136592f1118d4570bd632703d | |
| parent | 73d2bf95bb31b2fb894f6d24c6c8e4348335411d (diff) | |
| download | emacs-993713ce0a74253af0cc50f397193b70280f13f3.tar.gz emacs-993713ce0a74253af0cc50f397193b70280f13f3.zip | |
Change to macro, and return nil if there was no match at the specified depth.
| -rw-r--r-- | lisp/subr.el | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index 09a32af1f43..79da03d5027 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -826,19 +826,20 @@ Wildcards and redirection are handled as usual in the shell." | |||
| 826 | (defmacro save-match-data (&rest body) | 826 | (defmacro save-match-data (&rest body) |
| 827 | "Execute the BODY forms, restoring the global value of the match data." | 827 | "Execute the BODY forms, restoring the global value of the match data." |
| 828 | (let ((original (make-symbol "match-data"))) | 828 | (let ((original (make-symbol "match-data"))) |
| 829 | (list | 829 | (list 'let (list (list original '(match-data))) |
| 830 | 'let (list (list original '(match-data))) | 830 | (list 'unwind-protect |
| 831 | (list 'unwind-protect | 831 | (cons 'progn body) |
| 832 | (cons 'progn body) | 832 | (list 'store-match-data original))))) |
| 833 | (list 'store-match-data original))))) | 833 | |
| 834 | 834 | (defmacro match-string (num &optional string) | |
| 835 | (defun match-string (n &optional string) | 835 | "Return string of text matched by last search. |
| 836 | "Return the Nth subexpression matched by the last regexp search or match. | 836 | NUM specifies which parenthesized expression in the last regexp. |
| 837 | If the last search or match was done against a string, | 837 | Value is nil if NUMth pair didn't match, or there were less than NUM pairs. |
| 838 | specify that string as the second argument STRING." | 838 | Zero means the entire text matched by the whole regexp or whole string. |
| 839 | (if string | 839 | STRING should be given if the last search was by `string-match' on STRING." |
| 840 | (substring string (match-beginning n) (match-end n)) | 840 | (list 'and (list 'match-beginning num) |
| 841 | (buffer-substring (match-beginning n) (match-end n)))) | 841 | (append (if string (list 'substring string) '(buffer-substring)) |
| 842 | (list (list 'match-beginning num) (list 'match-end num))))) | ||
| 842 | 843 | ||
| 843 | (defun shell-quote-argument (argument) | 844 | (defun shell-quote-argument (argument) |
| 844 | "Quote an argument for passing as argument to an inferior shell." | 845 | "Quote an argument for passing as argument to an inferior shell." |