summaryrefslogtreecommitdiff
path: root/lisp/subr.el
diff options
context:
space:
mode:
authorSimon Marshall <simon@gnu.org>1995-03-24 09:01:09 +0000
committerSimon Marshall <simon@gnu.org>1995-03-24 09:01:09 +0000
commit262f42dee643227aeb7ac10d11592741510b5aa7 (patch)
tree7f0da4c98a37f3b24638d3fb8561cc0b267043ef /lisp/subr.el
parent531f5ac903b48e5e017990f80b7c73da9cb17708 (diff)
downloademacs-262f42dee643227aeb7ac10d11592741510b5aa7.tar.gz
Changed match-string to defun, but still return nil (no error) if no match.
Diffstat (limited to 'lisp/subr.el')
-rw-r--r--lisp/subr.el11
1 files changed, 6 insertions, 5 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index 79da03d5027..b30fc965edb 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -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 @@ Wildcards and redirection are handled as usual in the shell."
(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."