Mercurial > hg > xemacs-beta
annotate src/cmds.c @ 5735:ff13c44ce0d9
Hack in rudimentary group support for WIN32 in support of Mats ID-FORMAT patch
author | Vin Shelton <acs@xemacs.org> |
---|---|
date | Wed, 24 Apr 2013 20:16:14 -0400 |
parents | c65b0329894b |
children | c87b776ab0e1 |
rev | line source |
---|---|
428 | 1 /* Simple built-in editing commands. |
2 Copyright (C) 1985, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. | |
826 | 3 Copyright (C) 2002 Ben Wing. |
428 | 4 |
5 This file is part of XEmacs. | |
6 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
3577
diff
changeset
|
7 XEmacs is free software: you can redistribute it and/or modify it |
428 | 8 under the terms of the GNU General Public License as published by the |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
3577
diff
changeset
|
9 Free Software Foundation, either version 3 of the License, or (at your |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
3577
diff
changeset
|
10 option) any later version. |
428 | 11 |
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
3577
diff
changeset
|
18 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
428 | 19 |
20 /* Synched up with: Mule 2.0, FSF 19.30. */ | |
21 | |
22 #include <config.h> | |
23 #include "lisp.h" | |
24 #include "commands.h" | |
25 #include "buffer.h" | |
872 | 26 #include "extents.h" |
428 | 27 #include "syntax.h" |
28 #include "insdel.h" | |
29 | |
30 Lisp_Object Qkill_forward_chars; | |
31 Lisp_Object Qself_insert_command; | |
32 Lisp_Object Qno_self_insert; | |
33 | |
34 Lisp_Object Vblink_paren_function; | |
35 | |
36 /* A possible value for a buffer's overwrite-mode variable. */ | |
37 Lisp_Object Qoverwrite_mode_binary; | |
38 | |
39 /* Non-nil means put this face on the next self-inserting character. */ | |
40 Lisp_Object Vself_insert_face; | |
41 | |
42 /* This is the command that set up Vself_insert_face. */ | |
43 Lisp_Object Vself_insert_face_command; | |
442 | 44 |
45 /* A char-table for characters which may invoke auto-filling. */ | |
46 Lisp_Object Vauto_fill_chars; | |
428 | 47 |
48 DEFUN ("forward-char", Fforward_char, 0, 2, "_p", /* | |
444 | 49 Move point right COUNT characters (left if COUNT is negative). |
428 | 50 On attempt to pass end of buffer, stop and signal `end-of-buffer'. |
51 On attempt to pass beginning of buffer, stop and signal `beginning-of-buffer'. | |
52 On reaching end of buffer, stop and signal error. | |
462 | 53 |
54 The characters that are moved over may be added to the current selection | |
55 \(i.e. active region) if the Shift key is held down, a motion key is used | |
56 to invoke this command, and `shifted-motion-keys-select-region' is t; see | |
57 the documentation for this variable for more details. | |
428 | 58 */ |
444 | 59 (count, buffer)) |
428 | 60 { |
61 struct buffer *buf = decode_buffer (buffer, 1); | |
444 | 62 EMACS_INT n; |
428 | 63 |
444 | 64 if (NILP (count)) |
65 n = 1; | |
428 | 66 else |
67 { | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5438
diff
changeset
|
68 CHECK_FIXNUM (count); |
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5438
diff
changeset
|
69 n = XFIXNUM (count); |
428 | 70 } |
71 | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5438
diff
changeset
|
72 /* This used to just set point to point + XFIXNUM (count), and then check |
428 | 73 to see if it was within boundaries. But now that SET_PT can |
74 potentially do a lot of stuff (calling entering and exiting | |
75 hooks, etcetera), that's not a good approach. So we validate the | |
76 proposed position, then set point. */ | |
77 { | |
665 | 78 Charbpos new_point = BUF_PT (buf) + n; |
428 | 79 |
80 if (new_point < BUF_BEGV (buf)) | |
81 { | |
82 BUF_SET_PT (buf, BUF_BEGV (buf)); | |
83 Fsignal (Qbeginning_of_buffer, Qnil); | |
84 return Qnil; | |
85 } | |
86 if (new_point > BUF_ZV (buf)) | |
87 { | |
88 BUF_SET_PT (buf, BUF_ZV (buf)); | |
89 Fsignal (Qend_of_buffer, Qnil); | |
90 return Qnil; | |
91 } | |
92 | |
93 BUF_SET_PT (buf, new_point); | |
94 } | |
95 | |
96 return Qnil; | |
97 } | |
98 | |
99 DEFUN ("backward-char", Fbackward_char, 0, 2, "_p", /* | |
444 | 100 Move point left COUNT characters (right if COUNT is negative). |
428 | 101 On attempt to pass end of buffer, stop and signal `end-of-buffer'. |
102 On attempt to pass beginning of buffer, stop and signal `beginning-of-buffer'. | |
462 | 103 |
104 The characters that are moved over may be added to the current selection | |
105 \(i.e. active region) if the Shift key is held down, a motion key is used | |
106 to invoke this command, and `shifted-motion-keys-select-region' is t; see | |
107 the documentation for this variable for more details. | |
428 | 108 */ |
444 | 109 (count, buffer)) |
428 | 110 { |
444 | 111 if (NILP (count)) |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5438
diff
changeset
|
112 count = make_fixnum (-1); |
428 | 113 else |
114 { | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5438
diff
changeset
|
115 CHECK_FIXNUM (count); |
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5438
diff
changeset
|
116 count = make_fixnum (- XFIXNUM (count)); |
428 | 117 } |
444 | 118 return Fforward_char (count, buffer); |
428 | 119 } |
120 | |
121 DEFUN ("forward-line", Fforward_line, 0, 2, "_p", /* | |
444 | 122 Move COUNT lines forward (backward if COUNT is negative). |
123 Precisely, if point is on line I, move to the start of line I + COUNT. | |
428 | 124 If there isn't room, go as far as possible (no error). |
125 Returns the count of lines left to move. If moving forward, | |
444 | 126 that is COUNT - number of lines moved; if backward, COUNT + number moved. |
3577 | 127 \(Note that if COUNT is negative, the return will be non-positive.) |
444 | 128 With positive COUNT, a non-empty line at the end counts as one line |
428 | 129 successfully moved (for the return value). |
130 If BUFFER is nil, the current buffer is assumed. | |
462 | 131 |
132 The characters that are moved over may be added to the current selection | |
133 \(i.e. active region) if the Shift key is held down, a motion key is used | |
134 to invoke this command, and `shifted-motion-keys-select-region' is t; see | |
135 the documentation for this variable for more details. | |
428 | 136 */ |
444 | 137 (count, buffer)) |
428 | 138 { |
139 struct buffer *buf = decode_buffer (buffer, 1); | |
665 | 140 Charbpos pos2 = BUF_PT (buf); |
141 Charbpos pos; | |
444 | 142 EMACS_INT n, shortage, negp; |
428 | 143 |
444 | 144 if (NILP (count)) |
145 n = 1; | |
428 | 146 else |
147 { | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5438
diff
changeset
|
148 CHECK_FIXNUM (count); |
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5438
diff
changeset
|
149 n = XFIXNUM (count); |
428 | 150 } |
151 | |
444 | 152 negp = n <= 0; |
153 pos = scan_buffer (buf, '\n', pos2, 0, n - negp, &shortage, 1); | |
428 | 154 if (shortage > 0 |
155 && (negp | |
156 || (BUF_ZV (buf) > BUF_BEGV (buf) | |
157 && pos != pos2 | |
158 && BUF_FETCH_CHAR (buf, pos - 1) != '\n'))) | |
159 shortage--; | |
160 BUF_SET_PT (buf, pos); | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5438
diff
changeset
|
161 return make_fixnum (negp ? - shortage : shortage); |
428 | 162 } |
163 | |
164 DEFUN ("point-at-bol", Fpoint_at_bol, 0, 2, 0, /* | |
165 Return the character position of the first character on the current line. | |
444 | 166 With argument COUNT not nil or 1, move forward COUNT - 1 lines first. |
428 | 167 If scan reaches end of buffer, return that position. |
168 This function does not move point. | |
169 */ | |
444 | 170 (count, buffer)) |
428 | 171 { |
172 struct buffer *b = decode_buffer (buffer, 1); | |
173 REGISTER int orig, end; | |
174 | |
793 | 175 buffer = wrap_buffer (b); |
444 | 176 if (NILP (count)) |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5438
diff
changeset
|
177 count = make_fixnum (0); |
428 | 178 else |
179 { | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5438
diff
changeset
|
180 CHECK_FIXNUM (count); |
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5438
diff
changeset
|
181 count = make_fixnum (XFIXNUM (count) - 1); |
428 | 182 } |
183 | |
184 orig = BUF_PT (b); | |
444 | 185 Fforward_line (count, buffer); |
428 | 186 end = BUF_PT (b); |
187 BUF_SET_PT (b, orig); | |
188 | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5438
diff
changeset
|
189 return make_fixnum (end); |
428 | 190 } |
191 | |
192 DEFUN ("beginning-of-line", Fbeginning_of_line, 0, 2, "_p", /* | |
193 Move point to beginning of current line. | |
444 | 194 With argument COUNT not nil or 1, move forward COUNT - 1 lines first. |
428 | 195 If scan reaches end of buffer, stop there without error. |
196 If BUFFER is nil, the current buffer is assumed. | |
462 | 197 |
198 The characters that are moved over may be added to the current selection | |
199 \(i.e. active region) if the Shift key is held down, a motion key is used | |
200 to invoke this command, and `shifted-motion-keys-select-region' is t; see | |
201 the documentation for this variable for more details. | |
428 | 202 */ |
444 | 203 (count, buffer)) |
428 | 204 { |
205 struct buffer *b = decode_buffer (buffer, 1); | |
206 | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5438
diff
changeset
|
207 BUF_SET_PT (b, XFIXNUM (Fpoint_at_bol (count, buffer))); |
428 | 208 return Qnil; |
209 } | |
210 | |
211 DEFUN ("point-at-eol", Fpoint_at_eol, 0, 2, 0, /* | |
212 Return the character position of the last character on the current line. | |
444 | 213 With argument COUNT not nil or 1, move forward COUNT - 1 lines first. |
428 | 214 If scan reaches end of buffer, return that position. |
215 This function does not move point. | |
216 */ | |
444 | 217 (count, buffer)) |
428 | 218 { |
219 struct buffer *buf = decode_buffer (buffer, 1); | |
446 | 220 EMACS_INT n; |
428 | 221 |
444 | 222 if (NILP (count)) |
223 n = 1; | |
428 | 224 else |
225 { | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5438
diff
changeset
|
226 CHECK_FIXNUM (count); |
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5438
diff
changeset
|
227 n = XFIXNUM (count); |
428 | 228 } |
229 | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5438
diff
changeset
|
230 return make_fixnum (find_before_next_newline (buf, BUF_PT (buf), 0, |
444 | 231 n - (n <= 0))); |
428 | 232 } |
233 | |
234 DEFUN ("end-of-line", Fend_of_line, 0, 2, "_p", /* | |
235 Move point to end of current line. | |
444 | 236 With argument COUNT not nil or 1, move forward COUNT - 1 lines first. |
428 | 237 If scan reaches end of buffer, stop there without error. |
238 If BUFFER is nil, the current buffer is assumed. | |
462 | 239 |
240 The characters that are moved over may be added to the current selection | |
241 \(i.e. active region) if the Shift key is held down, a motion key is used | |
242 to invoke this command, and `shifted-motion-keys-select-region' is t; see | |
243 the documentation for this variable for more details. | |
428 | 244 */ |
444 | 245 (count, buffer)) |
428 | 246 { |
247 struct buffer *b = decode_buffer (buffer, 1); | |
248 | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5438
diff
changeset
|
249 BUF_SET_PT (b, XFIXNUM (Fpoint_at_eol (count, buffer))); |
428 | 250 return Qnil; |
251 } | |
252 | |
446 | 253 DEFUN ("delete-char", Fdelete_char, 0, 2, "*p\nP", /* |
444 | 254 Delete the following COUNT characters (previous, with negative COUNT). |
255 Optional second arg KILLP non-nil means kill instead (save in kill ring). | |
256 Interactively, COUNT is the prefix arg, and KILLP is set if | |
257 COUNT was explicitly specified. | |
428 | 258 */ |
444 | 259 (count, killp)) |
428 | 260 { |
261 /* This function can GC */ | |
665 | 262 Charbpos pos; |
428 | 263 struct buffer *buf = current_buffer; |
446 | 264 EMACS_INT n; |
428 | 265 |
446 | 266 if (NILP (count)) |
267 n = 1; | |
268 else | |
269 { | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5438
diff
changeset
|
270 CHECK_FIXNUM (count); |
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5438
diff
changeset
|
271 n = XFIXNUM (count); |
446 | 272 } |
428 | 273 |
444 | 274 pos = BUF_PT (buf) + n; |
275 if (NILP (killp)) | |
428 | 276 { |
444 | 277 if (n < 0) |
428 | 278 { |
279 if (pos < BUF_BEGV (buf)) | |
563 | 280 signal_error (Qbeginning_of_buffer, 0, Qunbound); |
428 | 281 else |
282 buffer_delete_range (buf, pos, BUF_PT (buf), 0); | |
283 } | |
284 else | |
285 { | |
286 if (pos > BUF_ZV (buf)) | |
563 | 287 signal_error (Qend_of_buffer, 0, Qunbound); |
428 | 288 else |
289 buffer_delete_range (buf, BUF_PT (buf), pos, 0); | |
290 } | |
291 } | |
292 else | |
293 { | |
444 | 294 call1 (Qkill_forward_chars, count); |
428 | 295 } |
296 return Qnil; | |
297 } | |
298 | |
446 | 299 DEFUN ("delete-backward-char", Fdelete_backward_char, 0, 2, "*p\nP", /* |
444 | 300 Delete the previous COUNT characters (following, with negative COUNT). |
301 Optional second arg KILLP non-nil means kill instead (save in kill ring). | |
302 Interactively, COUNT is the prefix arg, and KILLP is set if | |
303 COUNT was explicitly specified. | |
428 | 304 */ |
444 | 305 (count, killp)) |
428 | 306 { |
307 /* This function can GC */ | |
446 | 308 EMACS_INT n; |
309 | |
310 if (NILP (count)) | |
311 n = 1; | |
312 else | |
313 { | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5438
diff
changeset
|
314 CHECK_FIXNUM (count); |
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5438
diff
changeset
|
315 n = XFIXNUM (count); |
446 | 316 } |
317 | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5438
diff
changeset
|
318 return Fdelete_char (make_fixnum (- n), killp); |
428 | 319 } |
320 | |
867 | 321 static void internal_self_insert (Ichar ch, int noautofill); |
428 | 322 |
323 DEFUN ("self-insert-command", Fself_insert_command, 1, 1, "*p", /* | |
324 Insert the character you type. | |
325 Whichever character you type to run this command is inserted. | |
444 | 326 If a prefix arg COUNT is specified, the character is inserted COUNT times. |
428 | 327 */ |
444 | 328 (count)) |
428 | 329 { |
330 /* This function can GC */ | |
867 | 331 Ichar ch; |
428 | 332 Lisp_Object c; |
446 | 333 EMACS_INT n; |
428 | 334 |
5701
ad35a0cd95f5
Allow self-insert-command to be called noninteractively with null argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
5581
diff
changeset
|
335 /* It is sometimes useful to specify `self-insert-commmand' in Lisp code. |
ad35a0cd95f5
Allow self-insert-command to be called noninteractively with null argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
5581
diff
changeset
|
336 We may as well as all that to be done with default = 1. */ |
5702 | 337 count = NILP (count) ? make_fixnum(1) : count; |
5307
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3577
diff
changeset
|
338 /* Can't insert more than most-positive-fixnum characters, the buffer |
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3577
diff
changeset
|
339 won't hold that many. */ |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5438
diff
changeset
|
340 check_integer_range (count, Qzero, make_fixnum (MOST_POSITIVE_FIXNUM)); |
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5438
diff
changeset
|
341 n = XFIXNUM (count); |
428 | 342 |
343 if (CHAR_OR_CHAR_INTP (Vlast_command_char)) | |
344 c = Vlast_command_char; | |
345 else | |
2862 | 346 c = Fevent_to_character (Vlast_command_event, Qnil, Qnil, Qnil); |
428 | 347 |
348 if (NILP (c)) | |
2828 | 349 invalid_operation ( |
350 "Last typed key has no character equivalent (that we know of)", | |
351 Fcopy_event (Vlast_command_event, Qnil)); | |
428 | 352 |
353 CHECK_CHAR_COERCE_INT (c); | |
354 | |
355 ch = XCHAR (c); | |
356 | |
444 | 357 while (n--) |
358 internal_self_insert (ch, (n != 0)); | |
428 | 359 |
360 return Qnil; | |
361 } | |
362 | |
363 /* Insert character C1. If NOAUTOFILL is nonzero, don't do autofill | |
364 even if it is enabled. | |
365 | |
366 FSF: | |
367 | |
368 If this insertion is suitable for direct output (completely simple), | |
369 return 0. A value of 1 indicates this *might* not have been simple. | |
370 A value of 2 means this did things that call for an undo boundary. */ | |
371 | |
372 static void | |
867 | 373 internal_self_insert (Ichar c1, int noautofill) |
428 | 374 { |
375 /* This function can GC */ | |
376 /* int hairy = 0; -- unused */ | |
377 REGISTER enum syntaxcode synt; | |
867 | 378 REGISTER Ichar c2; |
428 | 379 Lisp_Object overwrite; |
826 | 380 Lisp_Object syntax_table; |
428 | 381 struct buffer *buf = current_buffer; |
382 int tab_width; | |
383 | |
384 overwrite = buf->overwrite_mode; | |
826 | 385 syntax_table = buf->mirror_syntax_table; |
428 | 386 |
387 #if 0 | |
388 /* No, this is very bad, it makes undo *always* undo a character at a time | |
389 instead of grouping consecutive self-inserts together. Nasty nasty. | |
390 */ | |
391 if (!NILP (Vbefore_change_functions) || !NILP (Vafter_change_functions) | |
392 || !NILP (Vbefore_change_function) || !NILP (Vafter_change_function)) | |
393 hairy = 1; | |
394 #endif | |
395 | |
396 if (!NILP (overwrite) | |
397 && BUF_PT (buf) < BUF_ZV (buf) | |
398 && (EQ (overwrite, Qoverwrite_mode_binary) | |
399 || (c1 != '\n' && BUF_FETCH_CHAR (buf, BUF_PT (buf)) != '\n')) | |
400 && (EQ (overwrite, Qoverwrite_mode_binary) | |
401 || BUF_FETCH_CHAR (buf, BUF_PT (buf)) != '\t' | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5438
diff
changeset
|
402 || ((tab_width = XFIXNUM (buf->tab_width), tab_width <= 0) |
428 | 403 || tab_width > 20 |
404 || !((current_column (buf) + 1) % tab_width)))) | |
405 { | |
406 buffer_delete_range (buf, BUF_PT (buf), BUF_PT (buf) + 1, 0); | |
407 /* hairy = 2; */ | |
408 } | |
409 | |
410 if (!NILP (buf->abbrev_mode) | |
411 && !WORD_SYNTAX_P (syntax_table, c1) | |
412 && NILP (buf->read_only) | |
413 && BUF_PT (buf) > BUF_BEGV (buf)) | |
414 { | |
415 c2 = BUF_FETCH_CHAR (buf, BUF_PT (buf) - 1); | |
416 | |
417 if (WORD_SYNTAX_P (syntax_table, c2)) | |
418 { | |
419 #if 1 | |
420 Fexpand_abbrev (); | |
421 #else /* FSFmacs */ | |
422 Lisp_Object sym = Fexpand_abbrev (); | |
423 | |
424 /* I think this is too bogus to add. The function should | |
425 have a way of examining the character to be inserted, so | |
426 it can decide whether to insert it or not. We should | |
427 design it better than that. */ | |
428 | |
429 /* Here FSFmacs remembers MODIFF, compares it after | |
430 Fexpand_abbrev() finishes, and updates HAIRY. */ | |
431 | |
432 /* NOTE: we cannot simply check for Vlast_abbrev, because | |
433 Fexpand_abbrev() can bail out before setting it to | |
434 anything meaningful, leaving us stuck with an old value. | |
435 Thus Fexpand_abbrev() was extended to return the actual | |
436 abbrev symbol. */ | |
437 if (!NILP (sym) | |
438 && !NILP (symbol_function (XSYMBOL (sym))) | |
439 && SYMBOLP (symbol_function (XSYMBOL (sym)))) | |
440 { | |
441 Lisp_Object prop = Fget (symbol_function (XSYMBOL (sym)), | |
442 Qno_self_insert, Qnil); | |
443 if (!NILP (prop)) | |
444 return; | |
445 } | |
446 #endif /* FSFmacs */ | |
447 } | |
448 } | |
442 | 449 if ((CHAR_TABLEP (Vauto_fill_chars) |
826 | 450 ? !NILP (get_char_table (c1, Vauto_fill_chars)) |
442 | 451 : (c1 == ' ' || c1 == '\n')) |
428 | 452 && !noautofill |
453 && !NILP (buf->auto_fill_function)) | |
454 { | |
455 buffer_insert_emacs_char (buf, c1); | |
456 if (c1 == '\n') | |
457 /* After inserting a newline, move to previous line and fill */ | |
458 /* that. Must have the newline in place already so filling and */ | |
459 /* justification, if any, know where the end is going to be. */ | |
460 BUF_SET_PT (buf, BUF_PT (buf) - 1); | |
461 call0 (buf->auto_fill_function); | |
462 if (c1 == '\n') | |
463 BUF_SET_PT (buf, BUF_PT (buf) + 1); | |
464 /* hairy = 2; */ | |
465 } | |
466 else | |
467 buffer_insert_emacs_char (buf, c1); | |
468 | |
469 /* If previous command specified a face to use, use it. */ | |
470 if (!NILP (Vself_insert_face) | |
471 && EQ (Vlast_command, Vself_insert_face_command)) | |
472 { | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5438
diff
changeset
|
473 Lisp_Object before = make_fixnum (BUF_PT (buf) - 1); |
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5438
diff
changeset
|
474 Lisp_Object after = make_fixnum (BUF_PT (buf)); |
428 | 475 Fput_text_property (before, after, Qface, Vself_insert_face, Qnil); |
476 Fput_text_property (before, after, Qstart_open, Qt, Qnil); | |
477 Fput_text_property (before, after, Qend_open, Qnil, Qnil); | |
478 /* #### FSFmacs properties are normally closed ("sticky") on the | |
479 end but not the beginning. It's the opposite for us. */ | |
480 Vself_insert_face = Qnil; | |
481 } | |
482 synt = SYNTAX (syntax_table, c1); | |
483 if ((synt == Sclose || synt == Smath) | |
484 && !NILP (Vblink_paren_function) && INTERACTIVE | |
485 && !noautofill) | |
486 { | |
487 call0 (Vblink_paren_function); | |
488 /* hairy = 2; */ | |
489 } | |
490 | |
491 /* return hairy; */ | |
492 } | |
493 | |
494 /* (this comes from Mule but is a generally good idea) */ | |
495 | |
496 DEFUN ("self-insert-internal", Fself_insert_internal, 1, 1, 0, /* | |
444 | 497 Invoke `self-insert-command' as if CHARACTER is entered from keyboard. |
428 | 498 */ |
444 | 499 (character)) |
428 | 500 { |
501 /* This function can GC */ | |
444 | 502 CHECK_CHAR_COERCE_INT (character); |
503 internal_self_insert (XCHAR (character), 0); | |
428 | 504 return Qnil; |
505 } | |
506 | |
507 /* module initialization */ | |
508 | |
509 void | |
510 syms_of_cmds (void) | |
511 { | |
563 | 512 DEFSYMBOL (Qkill_forward_chars); |
513 DEFSYMBOL (Qself_insert_command); | |
514 DEFSYMBOL (Qoverwrite_mode_binary); | |
515 DEFSYMBOL (Qno_self_insert); | |
428 | 516 |
517 DEFSUBR (Fforward_char); | |
518 DEFSUBR (Fbackward_char); | |
519 DEFSUBR (Fforward_line); | |
520 DEFSUBR (Fbeginning_of_line); | |
521 DEFSUBR (Fend_of_line); | |
522 | |
523 DEFSUBR (Fpoint_at_bol); | |
524 DEFSUBR (Fpoint_at_eol); | |
525 | |
526 DEFSUBR (Fdelete_char); | |
527 DEFSUBR (Fdelete_backward_char); | |
528 | |
529 DEFSUBR (Fself_insert_command); | |
530 DEFSUBR (Fself_insert_internal); | |
531 } | |
532 | |
533 void | |
534 vars_of_cmds (void) | |
535 { | |
536 DEFVAR_LISP ("self-insert-face", &Vself_insert_face /* | |
537 If non-nil, set the face of the next self-inserting character to this. | |
538 See also `self-insert-face-command'. | |
539 */ ); | |
540 Vself_insert_face = Qnil; | |
541 | |
542 DEFVAR_LISP ("self-insert-face-command", &Vself_insert_face_command /* | |
543 This is the command that set up `self-insert-face'. | |
544 If `last-command' does not equal this value, we ignore `self-insert-face'. | |
545 */ ); | |
546 Vself_insert_face_command = Qnil; | |
547 | |
548 DEFVAR_LISP ("blink-paren-function", &Vblink_paren_function /* | |
549 Function called, if non-nil, whenever a close parenthesis is inserted. | |
550 More precisely, a char with closeparen syntax is self-inserted. | |
551 */ ); | |
552 Vblink_paren_function = Qnil; | |
442 | 553 |
554 DEFVAR_LISP ("auto-fill-chars", &Vauto_fill_chars /* | |
555 A char-table for characters which invoke auto-filling. | |
444 | 556 Such characters have value t in this table. |
442 | 557 */); |
558 Vauto_fill_chars = Fmake_char_table (Qgeneric); | |
559 XCHAR_TABLE (Vauto_fill_chars)->ascii[' '] = Qt; | |
560 XCHAR_TABLE (Vauto_fill_chars)->ascii['\n'] = Qt; | |
428 | 561 } |