|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T m
Length: 3923 (0xf53) Types: TextFile Names: »magic.doc«
└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki └─⟦this⟧ »EUUGD11/euug-87hel/sec1/uEmacs/magic.doc«
Some notes on the MAGIC mode. In the MAGIC mode of MicroEmacs (versions 3.8 and up), certain characters gain special meanings when used in a search pattern. Collectively they are know as regular expressions, and a limited number of them are supported in MicroEmacs. They grant greater flexability when using the search command. However, they do not affect the incremental search command. The symbols that have special meaning in MAGIC mode are ^, $, ., *, [ (and ], used with it), and \. The characters ^ and $ fix the search pattern to the beginning and end of line, respectively. The ^ character must appear at the beginning of the search string, and the $ must appear at the end, otherwise they loose their meaning and are treated just like any other character. For example, in MAGIC mode, searching for the pattern "t$" would put the cursor at the end of any line that ended with the letter 't'. Note that this is different than searching for "t<NL>", that is, 't' followed by a newline character. The character $ (and ^, for that matter) matches a position, not a character, so the cursor remains at the end of the line. But a newline is a character that must be matched, just like any other character, which means that the cursor is placed just after it - on the beginning of the next line. The character . has a very simple meaning - it matches any single character, except the newline. Thus a search for "bad.er" could match "badger", "badder" (slang), or up to the 'r' of "bad error". The character * is known as closure, and means that zero or more of the preceding character will match. If there is no character preceding, * has no special meaning, and since it will not match with a newline, * will have no special meaning if preceded by the beginning of line symbol ^ or the literal newline character <NL>. The notion of zero or more characters is important. If, for example, your cursor was on the line This line is missing two vowels. and a search was made for "a*", the cursor would not move, because it is guarenteed to match no letter 'a' , which satifies the search conditions. If you wanted to search for one or more of the letter 'a', you would search for "aa*", which would match the letter a, then zero or more of them. The character [ indicates the beginning of a character class. It is similar to the 'any' character ., but you get to choose which characters you want to match. The character class is ended with the character ]. So, while a search for "ba.e" will match "bane", "bade", "bale", "bate", et cetera, you can limit it to matching "babe" and "bake" by searching for "ba[bk]e". Only one of the characters inside the [ and ] will match a character. If in fact you want to match any character except those in the character class, you can put a ^ as the first character. It must be the first character of the class, or else it has no special meaning. So, a search for [^aeiou] will match any character except a vowel, but a search for [aeiou^] will match any vowel or a ^. If you have a lot of characters in order that you want to put in the character class, you may use a dash (-) as a range character. So, [a-z] will match any letter (or any lower case letter if EXACT mode is on), and [0-9a-f] will match any digit or any letter 'a' through 'f', which happen to be the characters for hexadecimal numbers. If the dash is at the beginning or end of a character class, it is taken to be just a dash. The escape character \ is for those times when you want to be in MAGIC mode, but also want to use a regular expression character to be just a character. It turns off the special meaning of the character. So a search for "it\." will search for a line with "it.", and not "it" followed by any other character. The escape character will also let you put ^, -, or ] inside a character class with no special side effects.