comparison src/abbrev.c @ 440:8de8e3f6228a r21-2-28

Import from CVS: tag r21-2-28
author cvs
date Mon, 13 Aug 2007 11:33:38 +0200
parents 3ecd8885ac67
children c33ae14dd6d0
comparison
equal deleted inserted replaced
439:357dd071b03c 440:8de8e3f6228a
75 Lisp_Object Vpre_abbrev_expand_hook, Qpre_abbrev_expand_hook; 75 Lisp_Object Vpre_abbrev_expand_hook, Qpre_abbrev_expand_hook;
76 76
77 77
78 struct abbrev_match_mapper_closure { 78 struct abbrev_match_mapper_closure {
79 struct buffer *buf; 79 struct buffer *buf;
80 struct Lisp_Char_Table *chartab; 80 Lisp_Char_Table *chartab;
81 Charcount point, maxlen; 81 Charcount point, maxlen;
82 struct Lisp_Symbol *found; 82 Lisp_Symbol *found;
83 }; 83 };
84 84
85 /* For use by abbrev_match(): Match SYMBOL's name against buffer text 85 /* For use by abbrev_match(): Match SYMBOL's name against buffer text
86 before point, case-insensitively. When found, return non-zero, so 86 before point, case-insensitively. When found, return non-zero, so
87 that map_obarray terminates mapping. */ 87 that map_obarray terminates mapping. */
89 abbrev_match_mapper (Lisp_Object symbol, void *arg) 89 abbrev_match_mapper (Lisp_Object symbol, void *arg)
90 { 90 {
91 struct abbrev_match_mapper_closure *closure = 91 struct abbrev_match_mapper_closure *closure =
92 (struct abbrev_match_mapper_closure *)arg; 92 (struct abbrev_match_mapper_closure *)arg;
93 Charcount abbrev_length; 93 Charcount abbrev_length;
94 struct Lisp_Symbol *sym = XSYMBOL (symbol); 94 Lisp_Symbol *sym = XSYMBOL (symbol);
95 struct Lisp_String *abbrev; 95 Lisp_String *abbrev;
96 96
97 /* symbol_value should be OK here, because abbrevs are not expected 97 /* symbol_value should be OK here, because abbrevs are not expected
98 to contain any SYMBOL_MAGIC stuff. */ 98 to contain any SYMBOL_MAGIC stuff. */
99 if (UNBOUNDP (symbol_value (sym)) || NILP (symbol_value (sym))) 99 if (UNBOUNDP (symbol_value (sym)) || NILP (symbol_value (sym)))
100 { 100 {
145 return 0; 145 return 0;
146 } 146 }
147 147
148 /* Match the buffer text against names of symbols in obarray. Returns 148 /* Match the buffer text against names of symbols in obarray. Returns
149 the matching symbol, or 0 if not found. */ 149 the matching symbol, or 0 if not found. */
150 static struct Lisp_Symbol * 150 static Lisp_Symbol *
151 abbrev_match (struct buffer *buf, Lisp_Object obarray) 151 abbrev_match (struct buffer *buf, Lisp_Object obarray)
152 { 152 {
153 struct abbrev_match_mapper_closure closure; 153 struct abbrev_match_mapper_closure closure;
154 154
155 /* Precalculate some stuff, so mapper function needn't to it in each 155 /* Precalculate some stuff, so mapper function needn't to it in each
173 but then again, vi is an order of magnitude faster than Emacs. 173 but then again, vi is an order of magnitude faster than Emacs.
174 174
175 This speed difference should be unnoticeable, though. I have tested 175 This speed difference should be unnoticeable, though. I have tested
176 the degenerated cases of thousands of abbrevs being defined, and 176 the degenerated cases of thousands of abbrevs being defined, and
177 abbrev_match() was still fast enough for normal operation. */ 177 abbrev_match() was still fast enough for normal operation. */
178 static struct Lisp_Symbol * 178 static Lisp_Symbol *
179 abbrev_oblookup (struct buffer *buf, Lisp_Object obarray) 179 abbrev_oblookup (struct buffer *buf, Lisp_Object obarray)
180 { 180 {
181 Bufpos wordstart, wordend; 181 Bufpos wordstart, wordend;
182 Bufbyte *word, *p; 182 Bufbyte *word, *p;
183 Bytecount idx; 183 Bytecount idx;
280 int oldmodiff = BUF_MODIFF (buf); 280 int oldmodiff = BUF_MODIFF (buf);
281 Lisp_Object pre_modiff_p; 281 Lisp_Object pre_modiff_p;
282 Bufpos point; /* position of point */ 282 Bufpos point; /* position of point */
283 Bufpos abbrev_start; /* position of abbreviation beginning */ 283 Bufpos abbrev_start; /* position of abbreviation beginning */
284 284
285 struct Lisp_Symbol *(*fun) (struct buffer *, Lisp_Object); 285 Lisp_Symbol *(*fun) (struct buffer *, Lisp_Object);
286 286
287 struct Lisp_Symbol *abbrev_symbol; 287 Lisp_Symbol *abbrev_symbol;
288 struct Lisp_String *abbrev_string; 288 Lisp_String *abbrev_string;
289 Lisp_Object expansion, count, hook; 289 Lisp_Object expansion, count, hook;
290 Charcount abbrev_length; 290 Charcount abbrev_length;
291 int lccount, uccount; 291 int lccount, uccount;
292 292
293 run_hook (Qpre_abbrev_expand_hook); 293 run_hook (Qpre_abbrev_expand_hook);