annotate src/abbrev.c @ 209:41ff10fd062f r20-4b3

Import from CVS: tag r20-4b3
author cvs
date Mon, 13 Aug 2007 10:04:58 +0200
parents 2d532a89d707
children 0e522484dd2a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* Primitives for word-abbrev mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1985, 1986, 1992, 1993 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 /* Synched up with: FSF 19.30. Note that there are many more functions in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 FSF's abbrev.c. These have been moved into Lisp in XEmacs. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 /* Authorship:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 FSF: Original version; a long time ago.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 JWZ or Mly: Mostly moved into Lisp; maybe 1992.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 Ben Wing: Some changes for Mule for 19.12.
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
29 Hrvoje Niksic: Largely rewritten in June 1997.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 /* This file has been Mule-ized. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 #include <config.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 #include "lisp.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 #include "buffer.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 #include "commands.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 #include "insdel.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 #include "syntax.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 #include "window.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 /* An abbrev table is an obarray.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 Each defined abbrev is represented by a symbol in that obarray
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 whose print name is the abbreviation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 The symbol's value is a string which is the expansion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 If its function definition is non-nil, it is called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 after the expansion is done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 The plist slot of the abbrev symbol is its usage count. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 /* The table of global abbrevs. These are in effect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 in any buffer in which abbrev mode is turned on. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 Lisp_Object Vglobal_abbrev_table;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 int abbrev_all_caps;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 /* Non-nil => use this location as the start of abbrev to expand
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (rather than taking the word before point as the abbrev) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 Lisp_Object Vabbrev_start_location;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 /* Buffer that Vabbrev_start_location applies to */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 Lisp_Object Vabbrev_start_location_buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 /* The symbol representing the abbrev most recently expanded */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 Lisp_Object Vlast_abbrev;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 /* A string for the actual text of the abbrev most recently expanded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 This has more info than Vlast_abbrev since case is significant. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 Lisp_Object Vlast_abbrev_text;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 /* Character address of start of last abbrev expanded */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 int last_abbrev_point;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
74 Lisp_Object oblookup (Lisp_Object, CONST Bufbyte *, Bytecount);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
75
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 /* Hook to run before expanding any abbrev. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 Lisp_Object Vpre_abbrev_expand_hook, Qpre_abbrev_expand_hook;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
80 /* Match the buffer text against names of symbols in obarray. Returns
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
81 the matching symbol, or 0 if not found. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
82
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
83 static struct Lisp_Symbol *
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
84 abbrev_match (struct buffer *buf, Lisp_Object obarray)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
85 {
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
86 Bufpos point = BUF_PT (buf);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
87 Bufpos maxlen = point - BUF_BEGV (buf);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
88 Charcount idx;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
89
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
90 struct Lisp_Char_Table *chartab = XCHAR_TABLE (buf->mirror_syntax_table);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
91 struct Lisp_String *abbrev;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
92 struct Lisp_Vector *obvec;
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 167
diff changeset
93 struct Lisp_Symbol *sym = NULL;
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
94 Charcount abbrev_length;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
95 Lisp_Object tail;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
96 int i, found;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
97
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
98 CHECK_VECTOR (obarray);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
99 obvec = XVECTOR (obarray);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
100
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
101 /* The obarray-traversing code is copied from `map_obarray'. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
102 found = 0;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
103 for (i = vector_length (obvec) - 1; i >= 0; i--)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
104 {
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
105 tail = vector_data (obvec)[i];
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
106 if (SYMBOLP (tail))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
107 while (1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
108 {
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
109 sym = XSYMBOL (tail);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
110 if (UNBOUNDP (symbol_value (sym)) || NILP (symbol_value (sym)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
111 {
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
112 /* The symbol value of nil means that abbrev got
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
113 undefined. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
114 goto next;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
115 }
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
116 abbrev = symbol_name (sym);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
117 abbrev_length = string_char_length (abbrev);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
118 if (abbrev_length > maxlen)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
119 {
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
120 /* This abbrev is too large -- it wouldn't fit. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
121 goto next;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
122 }
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
123 /* If `bar' is an abbrev, and a user presses `fubar<SPC>',
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
124 we don't normally want to expand it. OTOH, if the
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
125 abbrev begins with non-word syntax, it is OK to
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
126 abbreviate it anywhere. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
127 if (abbrev_length < maxlen && abbrev_length > 0
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
128 && (WORD_SYNTAX_P (chartab, string_char (abbrev, 0)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
129 && (WORD_SYNTAX_P (chartab,
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
130 BUF_FETCH_CHAR (buf, point
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
131 - (abbrev_length + 1)))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
132 {
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
133 goto next;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
134 }
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
135 /* Match abbreviation string against buffer text. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
136 for (idx = abbrev_length - 1; idx >= 0; idx--)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
137 {
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
138 if (DOWNCASE (buf, BUF_FETCH_CHAR (buf, point -
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
139 (abbrev_length - idx)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
140 != DOWNCASE (buf, string_char (abbrev, idx)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
141 break;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
142 }
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
143 if (idx < 0)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
144 {
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
145 found = 1;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
146 break;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
147 }
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
148 next:
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
149 sym = symbol_next (XSYMBOL (tail));
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
150 if (!sym)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
151 break;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
152 XSETSYMBOL (tail, sym);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
153 } /* while */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
154 if (found)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
155 break;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
156 } /* for */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
157
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
158 return found ? sym : 0;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
159 }
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
160
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
161 /* Take the word before point, and look it up in OBARRAY, and return
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
162 the symbol (or nil). This used to be the default method of
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
163 searching, with the obvious limitation that the abbrevs may consist
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
164 only of word characters. It is an order of magnitued faster than
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
165 the proper `abbrev_match', but then again, vi is an order of
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
166 magnitude faster than Emacs. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
167 static struct Lisp_Symbol *
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
168 abbrev_oblookup (struct buffer *buf, Lisp_Object obarray)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
169 {
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
170 Bufpos wordstart, wordend;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
171 Bufbyte *word, *p;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
172 Bytecount idx;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
173 Lisp_Object lookup;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
174
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
175 CHECK_VECTOR (obarray);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
176
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
177 if (!NILP (Vabbrev_start_location))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
178 {
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
179 wordstart = get_buffer_pos_char (buf, Vabbrev_start_location,
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
180 GB_COERCE_RANGE);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
181 Vabbrev_start_location = Qnil;
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 175
diff changeset
182 /*
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 175
diff changeset
183 * Previously, abbrev-prefix-mark inserted a dash to indicate the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 175
diff changeset
184 * abbrev start point. It now uses an extent with a begin
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 175
diff changeset
185 * glyph so there's no dash to remove.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 175
diff changeset
186 */
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 175
diff changeset
187 /*
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
188 if (wordstart != BUF_ZV (buf)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
189 && BUF_FETCH_CHAR (buf, wordstart) == '-')
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
190 {
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
191 buffer_delete_range (buf, wordstart, wordstart + 1, 0);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
192 }
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 175
diff changeset
193 */
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
194 wordend = BUF_PT (buf);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
195 }
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
196 else
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
197 {
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
198 Bufpos point = BUF_PT (buf);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
199
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
200 wordstart = scan_words (buf, point, -1);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
201 if (!wordstart)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
202 return 0;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
203
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
204 wordend = scan_words (buf, wordstart, 1);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
205 if (!wordend)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
206 return 0;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
207 if (wordend > BUF_ZV (buf))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
208 wordend = BUF_ZV (buf);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
209 if (wordend > point)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
210 wordend = point;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
211 /* Unlike the original function, we allow expansion only after
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
212 the abbrev, not preceded by a number of spaces. This is
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
213 because of consistency with abbrev_match. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
214 if (wordend < point)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
215 return 0;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
216 if (wordend <= wordstart)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
217 return 0;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
218 }
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
219
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
220 p = word = (Bufbyte *) alloca (MAX_EMCHAR_LEN * (wordend - wordstart));
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
221 for (idx = wordstart; idx < wordend; idx++)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
222 {
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
223 Emchar c = BUF_FETCH_CHAR (buf, idx);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
224 if (UPPERCASEP (buf, c))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
225 c = DOWNCASE (buf, c);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
226 p += set_charptr_emchar (p, c);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
227 }
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
228 lookup = oblookup (obarray, word, p - word);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
229 if (SYMBOLP (lookup) && !NILP (symbol_value (XSYMBOL (lookup))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
230 return XSYMBOL (lookup);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
231 else
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
232 return NULL;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
233 }
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
234
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
235 /* Return non-zero if OBARRAY contains an interned symbol ` '. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
236 static int
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
237 obarray_has_blank_p (Lisp_Object obarray)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
238 {
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
239 Lisp_Object lookup;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
240
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
241 lookup = oblookup (obarray, (Bufbyte *)" ", 1);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
242 return SYMBOLP (lookup);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
243 }
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
244
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
245 /* Analyze case in the buffer substring, and report it. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
246 static void
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
247 abbrev_count_case (struct buffer *buf, Bufpos pos, Charcount length,
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
248 int *lccount, int *uccount)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
249 {
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
250 Emchar c;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
251
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
252 *lccount = *uccount = 0;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
253 while (length--)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
254 {
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
255 c = BUF_FETCH_CHAR (buf, pos);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
256 if (UPPERCASEP (buf, c))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
257 ++*uccount;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
258 else if (LOWERCASEP (buf, c))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
259 ++*lccount;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
260 ++pos;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
261 }
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
262 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
264 DEFUN ("expand-abbrev", Fexpand_abbrev, 0, 0, "", /*
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
265 Expand the abbrev before point, if any.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 Effective when explicitly called even when `abbrev-mode' is nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 Returns t if expansion took place.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
268 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
269 ())
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 struct buffer *buf = current_buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 int oldmodiff = BUF_MODIFF (buf);
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
274 Lisp_Object pre_modiff_p;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
275 Bufpos point; /* position of point */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
276 Bufpos abbrev_start; /* position of abbreviation beginning */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
278 struct Lisp_Symbol *(*fun) (struct buffer *, Lisp_Object);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
279
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
280 struct Lisp_Symbol *abbrev_symbol;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
281 struct Lisp_String *abbrev_string;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
282 Lisp_Object expansion, count, hook;
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 173
diff changeset
283 Charcount abbrev_length;
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
284 int lccount, uccount;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
285
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 run_hook (Qpre_abbrev_expand_hook);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 /* If the hook changes the buffer, treat that as having "done an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 expansion". */
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
289 pre_modiff_p = (BUF_MODIFF (buf) != oldmodiff ? Qt : Qnil);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
291 abbrev_symbol = NULL;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 if (!BUFFERP (Vabbrev_start_location_buffer) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 XBUFFER (Vabbrev_start_location_buffer) != buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 Vabbrev_start_location = Qnil;
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
295 /* We use the more general `abbrev_match' if the obarray blank flag
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
296 is not set, and Vabbrev_start_location is nil. Otherwise, use
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
297 `abbrev_oblookup'. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
298 #define MATCHFUN(tbl) ((obarray_has_blank_p (tbl) \
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
299 && NILP (Vabbrev_start_location)) \
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
300 ? abbrev_match : abbrev_oblookup)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
301 if (!NILP (buf->abbrev_table))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 {
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
303 fun = MATCHFUN (buf->abbrev_table);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
304 abbrev_symbol = fun (buf, buf->abbrev_table);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 }
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
306 if (!abbrev_symbol && !NILP (Vglobal_abbrev_table))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
307 {
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
308 fun = MATCHFUN (Vglobal_abbrev_table);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
309 abbrev_symbol = fun (buf, Vglobal_abbrev_table);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
310 }
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
311 if (!abbrev_symbol)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
312 return pre_modiff_p;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
314 /* NOTE: we hope that `pre-abbrev-expand-hook' didn't do something
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
315 nasty, such as changed (or killed) the buffer. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
316 point = BUF_PT (buf);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
318 /* OK, we're out of the must-be-fast part. An abbreviation matched.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
319 Now find the parameters, insert the expansion, and make it all
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
320 look pretty. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
321 abbrev_string = symbol_name (abbrev_symbol);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
322 abbrev_length = string_char_length (abbrev_string);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
323 abbrev_start = point - abbrev_length;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
325 expansion = symbol_value (abbrev_symbol);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
326 CHECK_STRING (expansion);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
327
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
328 count = symbol_plist (abbrev_symbol); /* Gag */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
329 if (NILP (count))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
330 count = make_int (0);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 else
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
332 CHECK_NATNUM (count);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
333 symbol_plist (abbrev_symbol) = make_int (1 + XINT (count));
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
334
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
335 /* Count the case in the original text. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
336 abbrev_count_case (buf, abbrev_start, abbrev_length, &lccount, &uccount);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
338 /* Remember the last abbrev text, location, etc. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
339 XSETSYMBOL (Vlast_abbrev, abbrev_symbol);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 Vlast_abbrev_text =
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
341 make_string_from_buffer (buf, abbrev_start, abbrev_length);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
342 last_abbrev_point = abbrev_start;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
344 /* Add an undo boundary, in case we are doing this for a
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
345 self-inserting command which has avoided making one so far. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
346 if (INTERACTIVE)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
347 Fundo_boundary ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
349 /* Remove the abbrev */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
350 buffer_delete_range (buf, abbrev_start, point, 0);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
351 /* And insert the expansion. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
352 buffer_insert_lisp_string (buf, expansion);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
353 point = BUF_PT (buf);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
355 /* Now fiddle with the case. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 if (uccount && !lccount)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 /* Abbrev was all caps */
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
359 if (!abbrev_all_caps
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
360 && scan_words (buf, point, -1) > scan_words (buf, abbrev_start, 1))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
361 {
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
362 Fupcase_initials_region (make_int (abbrev_start), make_int (point),
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
363 make_buffer (buf));
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
364 }
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
365 else
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
366 {
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
367 /* If expansion is one word, or if user says so, upcase it all. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
368 Fupcase_region (make_int (abbrev_start), make_int (point),
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
369 make_buffer (buf));
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
370 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 else if (uccount)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 /* Abbrev included some caps. Cap first initial of expansion */
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
375 Bufpos pos = abbrev_start;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 /* Find the initial. */
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
377 while (pos < point
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
378 && !WORD_SYNTAX_P (XCHAR_TABLE (buf->mirror_syntax_table),
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
379 BUF_FETCH_CHAR (buf, pos)))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
380 pos++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 /* Change just that. */
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
382 Fupcase_initials_region (make_int (pos), make_int (pos + 1),
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
383 make_buffer (buf));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
386 hook = symbol_function (abbrev_symbol);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 if (!NILP (hook) && !UNBOUNDP (hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 call0 (hook);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 return Qt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
393
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 syms_of_abbrev (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 defsymbol (&Qpre_abbrev_expand_hook, "pre-abbrev-expand-hook");
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
398 DEFSUBR (Fexpand_abbrev);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 vars_of_abbrev (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 DEFVAR_LISP ("global-abbrev-table", &Vglobal_abbrev_table /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 The abbrev table whose abbrevs affect all buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 Each buffer may also have a local abbrev table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 If it does, the local table overrides the global one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 for any particular abbrev defined in both.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 Vglobal_abbrev_table = Qnil; /* setup by Lisp code */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 DEFVAR_LISP ("last-abbrev", &Vlast_abbrev /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 The abbrev-symbol of the last abbrev expanded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 See the function `abbrev-symbol'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 DEFVAR_LISP ("last-abbrev-text", &Vlast_abbrev_text /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 The exact text of the last abbrev expanded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 nil if the abbrev has already been unexpanded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 DEFVAR_INT ("last-abbrev-location", &last_abbrev_point /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 The location of the start of the last abbrev expanded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 Vlast_abbrev = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 Vlast_abbrev_text = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 last_abbrev_point = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 DEFVAR_LISP ("abbrev-start-location", &Vabbrev_start_location /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 Buffer position for `expand-abbrev' to use as the start of the abbrev.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 nil means use the word before point as the abbrev.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 Calling `expand-abbrev' sets this to nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 Vabbrev_start_location = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 DEFVAR_LISP ("abbrev-start-location-buffer", &Vabbrev_start_location_buffer /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 Buffer that `abbrev-start-location' has been set for.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 Trying to expand an abbrev in any other buffer clears `abbrev-start-location'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 Vabbrev_start_location_buffer = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 DEFVAR_BOOL ("abbrev-all-caps", &abbrev_all_caps /*
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
444 *Non-nil means expand multi-word abbrevs all caps if abbrev was so.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 abbrev_all_caps = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 DEFVAR_LISP ("pre-abbrev-expand-hook", &Vpre_abbrev_expand_hook /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 Function or functions to be called before abbrev expansion is done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 This is the first thing that `expand-abbrev' does, and so this may change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 the current abbrev table before abbrev lookup happens.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 Vpre_abbrev_expand_hook = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 }