changeset 11115:9414f249cd8b

Changed match-string to defun, but still return nil (no error) if no match.
author Simon Marshall <simon@gnu.org>
date Fri, 24 Mar 1995 09:01:09 +0000
parents c8ab5c627f74
children 73b51ad289e3
files lisp/subr.el
diffstat 1 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/subr.el	Fri Mar 24 05:20:27 1995 +0000
+++ b/lisp/subr.el	Fri Mar 24 09:01:09 1995 +0000
@@ -1,6 +1,6 @@
 ;;; subr.el --- basic lisp subroutines for Emacs
 
-;;; Copyright (C) 1985, 1986, 1992, 1994 Free Software Foundation, Inc.
+;;; Copyright (C) 1985, 1986, 1992, 1994, 1995 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -831,15 +831,16 @@
 		(cons 'progn body)
 		(list 'store-match-data original)))))
 
-(defmacro match-string (num &optional string)
+(defun match-string (num &optional string)
   "Return string of text matched by last search.
 NUM specifies which parenthesized expression in the last regexp.
  Value is nil if NUMth pair didn't match, or there were less than NUM pairs.
 Zero means the entire text matched by the whole regexp or whole string.
 STRING should be given if the last search was by `string-match' on STRING."
-  (list 'and (list 'match-beginning num)
-	(append (if string (list 'substring string) '(buffer-substring))
-		(list (list 'match-beginning num) (list 'match-end num)))))
+  (if (match-beginning num)
+      (if string
+	  (substring string (match-beginning num) (match-end num))
+	(buffer-substring (match-beginning num) (match-end num)))))
 
 (defun shell-quote-argument (argument)
   "Quote an argument for passing as argument to an inferior shell."