Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!compass.UUCP!worley From: worley@compass.UUCP (Dale Worley) Newsgroups: comp.emacs Subject: Force exact matching of tag name Message-ID: <9002021705.AA06173@sn1987a.compass.com> Date: 2 Feb 90 17:05:00 GMT Sender: daemon@ucbvax.BERKELEY.EDU Lines: 123 When I try to look up a tag with find-tag, I wind up seeing every tag that contains the tag I'm looking for. (For instance, look up "find-file" in Emacs' tags.) I've made changes to fix this problem. The first change is to change the search in find-tag to be a regexp search rather than a string search. (This should be upward-compatible, since no language that I know of uses any of Emacs regexp special characters as symbol constituents.) The second is to add a new special character "\y" to regexp searching, which means "symbol boundary", just as "\b" matches word boundaries. (Unfortunately, this change is necessary, since there is no simple way to specify "beginning of symbol" or "end of symbol", since symbol constituents can be of two syntax classes.) Then, if you want to find a tag exactly, you can search for, for instance, "\yfind-file\y". Dale Worley Compass, Inc. worley@compass.com -- The great tragedy of science, the slaying of a beautiful theory by an ugly fact. --Thomas Henry Huxley *** regex.h.orig Wed Jan 31 09:37:41 1990 --- regex.h Wed Jan 31 09:38:45 1990 *************** *** 249,255 **** notwordbound, /* Succeeds if not at a word boundary */ syntaxspec, /* Matches any character whose syntax is specified. followed by a byte which contains a syntax code, Sword or such like */ ! notsyntaxspec /* Matches any character whose syntax differs from the specified. */ }; extern char *re_compile_pattern (); --- 249,256 ---- notwordbound, /* Succeeds if not at a word boundary */ syntaxspec, /* Matches any character whose syntax is specified. followed by a byte which contains a syntax code, Sword or such like */ ! notsyntaxspec, /* Matches any character whose syntax differs from the specified. */ ! symbolbound /* Succeeds if at a symbol boundary */ }; extern char *re_compile_pattern (); *** regex.c.orig Wed Jan 31 09:37:49 1990 --- regex.c Wed Jan 31 09:47:43 1990 *************** *** 127,132 **** --- 127,133 ---- #ifndef Sword /* must be non-zero in some of the tests below... */ #define Sword 1 + #define Ssymbol 2 #endif #define SYNTAX(c) re_syntax_table[c] *************** *** 637,642 **** --- 638,647 ---- PATPUSH (notwordbound); break; + case 'y': + PATPUSH (symbolbound); + break; + case '`': PATPUSH (begbuf); break; *************** *** 818,823 **** --- 823,829 ---- case notwordbound: case wordbeg: case wordend: + case symbolbound: continue; case endline: *************** *** 1493,1498 **** --- 1499,1520 ---- || SYNTAX (d == end1 ? *string2 : *d) != Sword) /* Next char not a letter */ break; goto fail; + + case symbolbound: + { + char before_syntax, after_syntax; + + if (d == string1 /* Points to first char */ + || d == end2 /* Points to end */ + || (d == end1 && size2 == 0)) /* Points to end */ + break; + before_syntax = SYNTAX (d[-1]); + after_syntax = SYNTAX (d == end1 ? *string2 : *d); + if ((before_syntax == Sword || before_syntax == Ssymbol) + != (after_syntax == Sword || after_syntax == Ssymbol)) + break; + goto fail; + } #ifdef emacs case before_dot: *** tags.el.orig Fri Feb 2 11:56:15 1990 --- tags.el Fri Feb 2 11:56:52 1990 *************** *** 151,157 **** (setq tagname last-tag)) (setq last-tag tagname) (while (progn ! (if (not (search-forward tagname nil t)) (error "No %sentries containing %s" (if next "more " "") tagname)) (not (looking-at "[^\n\177]*\177")))) --- 151,157 ---- (setq tagname last-tag)) (setq last-tag tagname) (while (progn ! (if (not (re-search-forward tagname nil t)) (error "No %sentries containing %s" (if next "more " "") tagname)) (not (looking-at "[^\n\177]*\177"))))