Mercurial > emacs
comparison lisp/subr.el @ 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 | 67231dca5f32 |
children | 370e1016aba2 |
comparison
equal
deleted
inserted
replaced
11114:c8ab5c627f74 | 11115:9414f249cd8b |
---|---|
1 ;;; subr.el --- basic lisp subroutines for Emacs | 1 ;;; subr.el --- basic lisp subroutines for Emacs |
2 | 2 |
3 ;;; Copyright (C) 1985, 1986, 1992, 1994 Free Software Foundation, Inc. | 3 ;;; Copyright (C) 1985, 1986, 1992, 1994, 1995 Free Software Foundation, Inc. |
4 | 4 |
5 ;; This file is part of GNU Emacs. | 5 ;; This file is part of GNU Emacs. |
6 | 6 |
7 ;; GNU Emacs is free software; you can redistribute it and/or modify | 7 ;; GNU Emacs is free software; you can redistribute it and/or modify |
8 ;; it under the terms of the GNU General Public License as published by | 8 ;; it under the terms of the GNU General Public License as published by |
829 (list 'let (list (list original '(match-data))) | 829 (list 'let (list (list original '(match-data))) |
830 (list 'unwind-protect | 830 (list 'unwind-protect |
831 (cons 'progn body) | 831 (cons 'progn body) |
832 (list 'store-match-data original))))) | 832 (list 'store-match-data original))))) |
833 | 833 |
834 (defmacro match-string (num &optional string) | 834 (defun match-string (num &optional string) |
835 "Return string of text matched by last search. | 835 "Return string of text matched by last search. |
836 NUM specifies which parenthesized expression in the last regexp. | 836 NUM specifies which parenthesized expression in the last regexp. |
837 Value is nil if NUMth pair didn't match, or there were less than NUM pairs. | 837 Value is nil if NUMth pair didn't match, or there were less than NUM pairs. |
838 Zero means the entire text matched by the whole regexp or whole string. | 838 Zero means the entire text matched by the whole regexp or whole string. |
839 STRING should be given if the last search was by `string-match' on STRING." | 839 STRING should be given if the last search was by `string-match' on STRING." |
840 (list 'and (list 'match-beginning num) | 840 (if (match-beginning num) |
841 (append (if string (list 'substring string) '(buffer-substring)) | 841 (if string |
842 (list (list 'match-beginning num) (list 'match-end num))))) | 842 (substring string (match-beginning num) (match-end num)) |
843 (buffer-substring (match-beginning num) (match-end num))))) | |
843 | 844 |
844 (defun shell-quote-argument (argument) | 845 (defun shell-quote-argument (argument) |
845 "Quote an argument for passing as argument to an inferior shell." | 846 "Quote an argument for passing as argument to an inferior shell." |
846 ;; Quote everything except POSIX filename characters. | 847 ;; Quote everything except POSIX filename characters. |
847 ;; This should be safe enough even for really weird shells. | 848 ;; This should be safe enough even for really weird shells. |