Mercurial > emacs
comparison src/cmds.c @ 10425:f44f048966e8
(Vuse_hard_newlines): New variable.
(Fnewline): If use_hard_newlines is on, mark inserted
newline(s) with `hard' property, marked rear-nonsticky.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 13 Jan 1995 08:45:07 +0000 |
parents | cede2b87231a |
children | caf4440e63e8 |
comparison
equal
deleted
inserted
replaced
10424:6bcb93cec6f8 | 10425:f44f048966e8 |
---|---|
24 #include "buffer.h" | 24 #include "buffer.h" |
25 #include "syntax.h" | 25 #include "syntax.h" |
26 #include "window.h" | 26 #include "window.h" |
27 | 27 |
28 Lisp_Object Qkill_forward_chars, Qkill_backward_chars, Vblink_paren_function; | 28 Lisp_Object Qkill_forward_chars, Qkill_backward_chars, Vblink_paren_function; |
29 Lisp_Object Vuse_hard_newlines; | |
29 | 30 |
30 /* A possible value for a buffer's overwrite-mode variable. */ | 31 /* A possible value for a buffer's overwrite-mode variable. */ |
31 Lisp_Object Qoverwrite_mode_binary; | 32 Lisp_Object Qoverwrite_mode_binary; |
33 | |
34 #ifdef USE_TEXT_PROPERTIES | |
35 Lisp_Object Qhard; | |
36 #endif | |
32 | 37 |
33 | 38 |
34 DEFUN ("forward-char", Fforward_char, Sforward_char, 0, 1, "p", | 39 DEFUN ("forward-char", Fforward_char, Sforward_char, 0, 1, "p", |
35 "Move point right ARG characters (left if ARG negative).\n\ | 40 "Move point right ARG characters (left if ARG negative).\n\ |
36 On reaching end of buffer, stop and signal error.") | 41 On reaching end of buffer, stop and signal error.") |
228 "Insert a newline. With arg, insert that many newlines.\n\ | 233 "Insert a newline. With arg, insert that many newlines.\n\ |
229 In Auto Fill mode, if no numeric arg, break the preceding line if it's long.") | 234 In Auto Fill mode, if no numeric arg, break the preceding line if it's long.") |
230 (arg1) | 235 (arg1) |
231 Lisp_Object arg1; | 236 Lisp_Object arg1; |
232 { | 237 { |
233 int flag; | 238 int flag, i; |
234 Lisp_Object arg; | 239 Lisp_Object arg; |
235 char c1 = '\n'; | 240 char c1 = '\n'; |
236 | 241 |
237 arg = Fprefix_numeric_value (arg1); | 242 arg = Fprefix_numeric_value (arg1); |
238 | 243 |
264 #endif | 269 #endif |
265 | 270 |
266 if (flag) | 271 if (flag) |
267 SET_PT (point - 1); | 272 SET_PT (point - 1); |
268 | 273 |
269 while (XINT (arg) > 0) | 274 for (i = XINT (arg); i > 0; i--) |
270 { | 275 { |
271 if (flag) | 276 if (flag) |
272 insert_and_inherit (&c1, 1); | 277 insert_and_inherit (&c1, 1); |
273 else | 278 else |
274 internal_self_insert ('\n', !NILP (arg1)); | 279 internal_self_insert ('\n', !NILP (arg1)); |
275 /* Ok since old and new vals both nonneg */ | 280 } |
276 XSETFASTINT (arg, XFASTINT (arg) - 1); | 281 |
277 } | 282 #ifdef USE_TEXT_PROPERTIES |
283 if (Vuse_hard_newlines) | |
284 { | |
285 Lisp_Object from, to, sticky; | |
286 XSETFASTINT (from, PT - arg); | |
287 XSETFASTINT (to, PT); | |
288 Fput_text_property (from, to, Qhard, Qt, Qnil); | |
289 /* If rear_nonsticky is not "t", locally add Qhard to the list. */ | |
290 sticky = Fget_text_property (from, Qrear_nonsticky, Qnil); | |
291 if (NILP (sticky) | |
292 || (CONSP (sticky) && NILP (Fmemq (Qhard, sticky)))) | |
293 { | |
294 sticky = Fcons (Qhard, sticky); | |
295 Fput_text_property (from, to, Qrear_nonsticky, sticky, Qnil); | |
296 } | |
297 } | |
298 #endif | |
299 | |
278 | 300 |
279 if (flag) | 301 if (flag) |
280 SET_PT (point + 1); | 302 SET_PT (point + 1); |
281 | 303 |
282 return Qnil; | 304 return Qnil; |
366 staticpro (&Qkill_forward_chars); | 388 staticpro (&Qkill_forward_chars); |
367 | 389 |
368 Qoverwrite_mode_binary = intern ("overwrite-mode-binary"); | 390 Qoverwrite_mode_binary = intern ("overwrite-mode-binary"); |
369 staticpro (&Qoverwrite_mode_binary); | 391 staticpro (&Qoverwrite_mode_binary); |
370 | 392 |
393 Qhard = intern ("hard"); | |
394 staticpro (&Qhard); | |
395 | |
396 DEFVAR_BOOL ("use-hard-newlines", &Vuse_hard_newlines, | |
397 "Non-nil means to distinguish hard and soft newlines. | |
398 When this is non-nil, the functions `newline' and `open-line' add the | |
399 text-property `hard' to newlines that they insert. Also, a line is | |
400 only considered as a candidate to match `paragraph-start' or | |
401 `paragraph-separate' if it follows a hard newline. Newlines not | |
402 marked hard are called \"soft\", and are always internal to | |
403 paragraphs. The fill functions always insert soft newlines."); | |
404 Vuse_hard_newlines = 0; | |
405 | |
371 DEFVAR_LISP ("blink-paren-function", &Vblink_paren_function, | 406 DEFVAR_LISP ("blink-paren-function", &Vblink_paren_function, |
372 "Function called, if non-nil, whenever a close parenthesis is inserted.\n\ | 407 "Function called, if non-nil, whenever a close parenthesis is inserted.\n\ |
373 More precisely, a char with closeparen syntax is self-inserted."); | 408 More precisely, a char with closeparen syntax is self-inserted."); |
374 Vblink_paren_function = Qnil; | 409 Vblink_paren_function = Qnil; |
375 | 410 |
388 | 423 |
389 keys_of_cmds () | 424 keys_of_cmds () |
390 { | 425 { |
391 int n; | 426 int n; |
392 | 427 |
393 initial_define_key (global_map, Ctl('M'), "newline"); | 428 initial_define_key (global_map, Ctl ('M'), "newline"); |
394 initial_define_key (global_map, Ctl('I'), "self-insert-command"); | 429 initial_define_key (global_map, Ctl ('I'), "self-insert-command"); |
395 for (n = 040; n < 0177; n++) | 430 for (n = 040; n < 0177; n++) |
396 initial_define_key (global_map, n, "self-insert-command"); | 431 initial_define_key (global_map, n, "self-insert-command"); |
397 #ifdef MSDOS | 432 #ifdef MSDOS |
398 for (n = 0200; n < 0240; n++) | 433 for (n = 0200; n < 0240; n++) |
399 initial_define_key (global_map, n, "self-insert-command"); | 434 initial_define_key (global_map, n, "self-insert-command"); |