diff options
| author | Richard M. Stallman | 1995-01-13 08:45:07 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1995-01-13 08:45:07 +0000 |
| commit | cbf651156bfc9ea5ffbc7b6e9e3d60ad1f761f96 (patch) | |
| tree | add314915f84b045c6b46e327b90a27a04af0c58 /src | |
| parent | a37669ece7d909bd2830c4b69bd5c53ca8d7270b (diff) | |
| download | emacs-cbf651156bfc9ea5ffbc7b6e9e3d60ad1f761f96.tar.gz emacs-cbf651156bfc9ea5ffbc7b6e9e3d60ad1f761f96.zip | |
(Vuse_hard_newlines): New variable.
(Fnewline): If use_hard_newlines is on, mark inserted
newline(s) with `hard' property, marked rear-nonsticky.
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmds.c | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/src/cmds.c b/src/cmds.c index 487751c618f..34a4facbb6a 100644 --- a/src/cmds.c +++ b/src/cmds.c | |||
| @@ -26,10 +26,15 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |||
| 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; |
| 32 | 33 | ||
| 34 | #ifdef USE_TEXT_PROPERTIES | ||
| 35 | Lisp_Object Qhard; | ||
| 36 | #endif | ||
| 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\ |
| @@ -230,7 +235,7 @@ 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 | ||
| @@ -266,16 +271,33 @@ In Auto Fill mode, if no numeric arg, break the preceding line if it's long.") | |||
| 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 */ | ||
| 276 | XSETFASTINT (arg, XFASTINT (arg) - 1); | ||
| 277 | } | 280 | } |
| 278 | 281 | ||
| 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 | |||
| 300 | |||
| 279 | if (flag) | 301 | if (flag) |
| 280 | SET_PT (point + 1); | 302 | SET_PT (point + 1); |
| 281 | 303 | ||
| @@ -368,6 +390,19 @@ syms_of_cmds () | |||
| 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."); |
| @@ -390,8 +425,8 @@ 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 |