shin@sgtp.apple.juice.or.jp (Shinichirou Sugou) (12/30/89)
Hello. I think there is a bug in 're-search-backward' function. [System configuration] Sun3/60 with SunOS3.5. Emacs version is 18.55 compiled by Sun's compiler. [Reproduction] (1) Open a empty buffer (says foo); type two characters, SPACE and 'a'; move the cursor just on the character 'a'. (2) Eval (re-search-backward "\\`\\|\\s ") (3) Eval (match-data) and you will see (#<marker at 1 in foo> #<marker at 1 in foo> ) [Bug] In 're-search-backward', not "\\`" but "\\s " should be matched. But 'match-data' says that actual matching is "\\'". If "\\s " were matched correctly, 'match-data' would say (#<marker at 1 in foo> #<marker at 2 in foo> ). [Appendix] (re-search-backward "\\s \\|\\'") works fine. Thank you. CAUTION: (1) Reply-command in the mail system may NOT generate my address correctly. Please use the following address instead. shin%sgtp.apple.juice.or.jp@uunet.uu.net (2) I have no relation to Apple Computer Inc. :-) --- S.Sugou
kjones@talos.uu.net (Kyle Jones) (01/02/90)
Shinichirou Sugou writes: > I think there is a bug in 're-search-backward' function. > [...] > [Reproduction] > (1) Open a empty buffer (says foo); type two characters, SPACE and 'a'; move > the cursor just on the character 'a'. > (2) Eval (re-search-backward "\\`\\|\\s ") > (3) Eval (match-data) > and you will see (#<marker at 1 in foo> #<marker at 1 in foo> ) > > [Bug] > In 're-search-backward', not "\\`" but "\\s " should be matched. But > 'match-data' says that actual matching is "\\'". You seem to be assuming that the alternative operator will always match the largest of the two alternatives. The documentation for `\|' does not guarantee this. From the _GNU Emacs Manual_, Section 13.5, "Syntax of Regular Expressions" `\|' applies to the largest possible surrounding expressions. Only a surrounding `\( ... \)' grouping can limit the grouping power of `\|'. This statement applies to the regular expression itself, not the text that is being matched.
shin@sgtp.apple.juice.or.jp (Shinichirou Sugou) (01/04/90)
Dear Kyle Jones: I have read your opinion. But, I'm still thinking that this feature is a bug. There are two reasons why I think so. First, let's try to see how 'isearch-backward-regexp' (not 're-search-backward') works. Please open a empty buffer, and type 'a' <space> 'b' (that is, three characters). Now, the cursor is positioned at the end of the buffer. Next, please invoke 'isearch-backward-regexp' and tyr to search regexps "a\|b". Watch out how the cursor moves. It goes to 'a', returns back to home position, finally goes to 'b'. Though 'isearch-backward-regexp' and 're-search-backward' are somewhat different functions (yes, the former is interactive while the latter non-interactive), the experiment above implies the desirable feature how regexps should work. Secondary, you say In article <1990Jan2.143701.18670@talos.uu.net> kjones@talos.uu.net (Kyle Jones) writes: >This statement applies to the regular expression itself, not the text >that is being matched. The Emacs manual (chapter 13.5 Syntax of Regular Expressions) says that the text itself (ordinary character) is also regular expression, too. Thank you. CAUTION: (1) Reply-command in the mail system may NOT generate my address correctly. Please use the following address instead. shin%sgtp.apple.juice.or.jp@uunet.uu.net (2) I have no relation to Apple Computer Inc. :-) --- S.Sugou