Path: utzoo!telly!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!gatech!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!ginosko!cs.utexas.edu!uunet!talos!kjones From: kjones@talos.uucp (Kyle Jones) Newsgroups: gnu.emacs.bug Subject: Re: match data cannot always be restored Message-ID: <1989Oct24.132350.16056@talos.uucp> Date: 24 Oct 89 13:23:50 GMT References: <8910201435.AA02459@ttds.tds.kth.se> Reply-To: kjones@talos.uu.net Distribution: gnu Lines: 30 Juha Sarlin writes: > After a string-match the value of (match-beginning 0) can be zero. > The zero is changed into one by: > (store-match-data (match-data)) This applies to clipping regions in general. If a match-datum falls outside the clipping region of the current buffer, it will be changed to point-min or point-max, whichever is closer. This is because match-data returns match pairs as a list of markers, instead of a list of integers. Markers, at the time of their creation, are constrained to be within the clipping region of the buffer in which they reside. Since match-beginning and match-end return integers, you can almost get around this problem by building your own match-data list, i.e. (defun integer-match-data () (let ((index '(9 8 7 6 5 4 3 2 1 0)) (list)) (while index (setq list (cons (match-beginning (car index)) (cons (match-end (car index)) list)) index (cdr index))) list )) Unfortunately store-match-data only accepts a list of MARKERS, so you can't feed this list back into the regexp system. Changing the match-data function to return integers would probably break existing code, therefore I suggest that store-match-data be allowed to accept integers as well as markers.