annotate src/abbrev.c @ 167:85ec50267440 r20-3b10

Import from CVS: tag r20-3b10
author cvs
date Mon, 13 Aug 2007 09:45:46 +0200
parents 131b0175ea99
children 8eaf7971accc
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;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
93 struct Lisp_Symbol *sym;
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;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
182 if (wordstart != BUF_ZV (buf)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
183 && BUF_FETCH_CHAR (buf, wordstart) == '-')
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
184 {
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
185 buffer_delete_range (buf, wordstart, wordstart + 1, 0);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
186 }
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
187 wordend = BUF_PT (buf);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
188 }
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
189 else
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 Bufpos point = BUF_PT (buf);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
192
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
193 wordstart = scan_words (buf, point, -1);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
194 if (!wordstart)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
195 return 0;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
196
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
197 wordend = scan_words (buf, wordstart, 1);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
198 if (!wordend)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
199 return 0;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
200 if (wordend > BUF_ZV (buf))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
201 wordend = BUF_ZV (buf);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
202 if (wordend > point)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
203 wordend = point;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
204 /* Unlike the original function, we allow expansion only after
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
205 the abbrev, not preceded by a number of spaces. This is
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
206 because of consistency with abbrev_match. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
207 if (wordend < point)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
208 return 0;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
209 if (wordend <= wordstart)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
210 return 0;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
211 }
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
212
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
213 p = word = (Bufbyte *) alloca (MAX_EMCHAR_LEN * (wordend - wordstart));
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
214 for (idx = wordstart; idx < wordend; idx++)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
215 {
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
216 Emchar c = BUF_FETCH_CHAR (buf, idx);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
217 if (UPPERCASEP (buf, c))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
218 c = DOWNCASE (buf, c);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
219 p += set_charptr_emchar (p, c);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
220 }
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
221 lookup = oblookup (obarray, word, p - word);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
222 if (SYMBOLP (lookup) && !NILP (symbol_value (XSYMBOL (lookup))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
223 return XSYMBOL (lookup);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
224 else
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
225 return NULL;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
226 }
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 /* Return non-zero if OBARRAY contains an interned symbol ` '. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
229 static int
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
230 obarray_has_blank_p (Lisp_Object obarray)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
231 {
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
232 Lisp_Object lookup;
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 lookup = oblookup (obarray, (Bufbyte *)" ", 1);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
235 return SYMBOLP (lookup);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
236 }
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
237
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
238 /* Analyze case in the buffer substring, and report it. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
239 static void
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
240 abbrev_count_case (struct buffer *buf, Bufpos pos, Charcount length,
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
241 int *lccount, int *uccount)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
242 {
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
243 Emchar c;
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 *lccount = *uccount = 0;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
246 while (length--)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
247 {
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
248 c = BUF_FETCH_CHAR (buf, pos);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
249 if (UPPERCASEP (buf, c))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
250 ++*uccount;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
251 else if (LOWERCASEP (buf, c))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
252 ++*lccount;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
253 ++pos;
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 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
257 DEFUN ("expand-abbrev", Fexpand_abbrev, 0, 0, "", /*
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
258 Expand the abbrev before point, if any.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 Effective when explicitly called even when `abbrev-mode' is nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 Returns t if expansion took place.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
261 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
262 ())
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 struct buffer *buf = current_buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 int oldmodiff = BUF_MODIFF (buf);
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
267 Lisp_Object pre_modiff_p;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
268 Bufpos point; /* position of point */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
269 Bufpos abbrev_start; /* position of abbreviation beginning */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
271 struct Lisp_Symbol *(*fun) (struct buffer *, Lisp_Object);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
272
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
273 struct Lisp_Symbol *abbrev_symbol;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
274 struct Lisp_String *abbrev_string;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
275 Lisp_Object expansion, count, hook;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
276 Charcount abbrev_length, idx;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
277 int lccount, uccount;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
278
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 run_hook (Qpre_abbrev_expand_hook);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 /* If the hook changes the buffer, treat that as having "done an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 expansion". */
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
282 pre_modiff_p = (BUF_MODIFF (buf) != oldmodiff ? Qt : Qnil);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
284 abbrev_symbol = NULL;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 if (!BUFFERP (Vabbrev_start_location_buffer) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 XBUFFER (Vabbrev_start_location_buffer) != buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 Vabbrev_start_location = Qnil;
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
288 /* We use the more general `abbrev_match' if the obarray blank flag
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
289 is not set, and Vabbrev_start_location is nil. Otherwise, use
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
290 `abbrev_oblookup'. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
291 #define MATCHFUN(tbl) ((obarray_has_blank_p (tbl) \
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
292 && NILP (Vabbrev_start_location)) \
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
293 ? abbrev_match : abbrev_oblookup)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
294 if (!NILP (buf->abbrev_table))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 {
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
296 fun = MATCHFUN (buf->abbrev_table);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
297 abbrev_symbol = fun (buf, buf->abbrev_table);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 }
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
299 if (!abbrev_symbol && !NILP (Vglobal_abbrev_table))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
300 {
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
301 fun = MATCHFUN (Vglobal_abbrev_table);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
302 abbrev_symbol = fun (buf, Vglobal_abbrev_table);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
303 }
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
304 if (!abbrev_symbol)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
305 return pre_modiff_p;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
307 /* NOTE: we hope that `pre-abbrev-expand-hook' didn't do something
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
308 nasty, such as changed (or killed) the buffer. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
309 point = BUF_PT (buf);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
311 /* 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
312 Now find the parameters, insert the expansion, and make it all
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
313 look pretty. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
314 abbrev_string = symbol_name (abbrev_symbol);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
315 abbrev_length = string_char_length (abbrev_string);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
316 abbrev_start = point - abbrev_length;
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 expansion = symbol_value (abbrev_symbol);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
319 CHECK_STRING (expansion);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
320
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
321 count = symbol_plist (abbrev_symbol); /* Gag */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
322 if (NILP (count))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
323 count = make_int (0);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 else
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
325 CHECK_NATNUM (count);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
326 symbol_plist (abbrev_symbol) = make_int (1 + XINT (count));
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 the case in the original text. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
329 abbrev_count_case (buf, abbrev_start, abbrev_length, &lccount, &uccount);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
331 /* Remember the last abbrev text, location, etc. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
332 XSETSYMBOL (Vlast_abbrev, abbrev_symbol);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 Vlast_abbrev_text =
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
334 make_string_from_buffer (buf, abbrev_start, abbrev_length);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
335 last_abbrev_point = abbrev_start;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
337 /* Add an undo boundary, in case we are doing this for a
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
338 self-inserting command which has avoided making one so far. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
339 if (INTERACTIVE)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
340 Fundo_boundary ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
342 /* Remove the abbrev */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
343 buffer_delete_range (buf, abbrev_start, point, 0);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
344 /* And insert the expansion. */
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
345 buffer_insert_lisp_string (buf, expansion);
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
346 point = BUF_PT (buf);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
348 /* Now fiddle with the case. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 if (uccount && !lccount)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 /* Abbrev was all caps */
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
352 if (!abbrev_all_caps
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
353 && scan_words (buf, point, -1) > scan_words (buf, abbrev_start, 1))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
354 {
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
355 Fupcase_initials_region (make_int (abbrev_start), make_int (point),
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
356 make_buffer (buf));
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
357 }
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
358 else
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
359 {
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
360 /* 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
361 Fupcase_region (make_int (abbrev_start), make_int (point),
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
362 make_buffer (buf));
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
363 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 else if (uccount)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 /* Abbrev included some caps. Cap first initial of expansion */
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
368 Bufpos pos = abbrev_start;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 /* Find the initial. */
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
370 while (pos < point
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
371 && !WORD_SYNTAX_P (XCHAR_TABLE (buf->mirror_syntax_table),
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
372 BUF_FETCH_CHAR (buf, pos)))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
373 pos++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 /* Change just that. */
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
375 Fupcase_initials_region (make_int (pos), make_int (pos + 1),
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
376 make_buffer (buf));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
379 hook = symbol_function (abbrev_symbol);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 if (!NILP (hook) && !UNBOUNDP (hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 call0 (hook);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 return Qt;
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
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 syms_of_abbrev (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 defsymbol (&Qpre_abbrev_expand_hook, "pre-abbrev-expand-hook");
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 0
diff changeset
391 DEFSUBR (Fexpand_abbrev);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393
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 vars_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 DEFVAR_LISP ("global-abbrev-table", &Vglobal_abbrev_table /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 The abbrev table whose abbrevs affect all buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 Each buffer may also have a local abbrev table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 If it does, the local table overrides the global one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 for any particular abbrev defined in both.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 Vglobal_abbrev_table = Qnil; /* setup by Lisp code */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 DEFVAR_LISP ("last-abbrev", &Vlast_abbrev /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 The abbrev-symbol of the last abbrev expanded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 See the function `abbrev-symbol'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 DEFVAR_LISP ("last-abbrev-text", &Vlast_abbrev_text /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 The exact text of the last abbrev expanded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 nil if the abbrev has already been unexpanded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 DEFVAR_INT ("last-abbrev-location", &last_abbrev_point /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 The location of the start of the last abbrev expanded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 Vlast_abbrev = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 Vlast_abbrev_text = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 last_abbrev_point = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 DEFVAR_LISP ("abbrev-start-location", &Vabbrev_start_location /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 Buffer position for `expand-abbrev' to use as the start of the abbrev.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 nil means use the word before point as the abbrev.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 Calling `expand-abbrev' sets this to nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 Vabbrev_start_location = Qnil;
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-buffer", &Vabbrev_start_location_buffer /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 Buffer that `abbrev-start-location' has been set for.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 Trying to expand an abbrev in any other buffer clears `abbrev-start-location'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 Vabbrev_start_location_buffer = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 DEFVAR_BOOL ("abbrev-all-caps", &abbrev_all_caps /*
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 70
diff changeset
437 *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
438 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 abbrev_all_caps = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 DEFVAR_LISP ("pre-abbrev-expand-hook", &Vpre_abbrev_expand_hook /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 Function or functions to be called before abbrev expansion is done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 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
444 the current abbrev table before abbrev lookup happens.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 Vpre_abbrev_expand_hook = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 }