diff options
Diffstat (limited to 'src/editfns.c')
| -rw-r--r-- | src/editfns.c | 69 |
1 files changed, 50 insertions, 19 deletions
diff --git a/src/editfns.c b/src/editfns.c index 2ac0537eddb..80f111774ef 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -3480,33 +3480,54 @@ DEFUN ("delete-and-extract-region", Fdelete_and_extract_region, | |||
| 3480 | return empty_unibyte_string; | 3480 | return empty_unibyte_string; |
| 3481 | return del_range_1 (XINT (start), XINT (end), 1, 1); | 3481 | return del_range_1 (XINT (start), XINT (end), 1, 1); |
| 3482 | } | 3482 | } |
| 3483 | |||
| 3483 | 3484 | ||
| 3484 | DEFUN ("widen", Fwiden, Swiden, 0, 0, "", | 3485 | DEFUN ("widen", Fwiden, Swiden, 0, 1, "", |
| 3485 | doc: /* Remove restrictions (narrowing) from current buffer. | 3486 | doc: /* Remove restrictions (narrowing) from current buffer. |
| 3486 | This allows the buffer's full text to be seen and edited. */) | 3487 | If HARD is non-nil, remove the hard restriction imposed by a previous |
| 3487 | (void) | 3488 | call to \\[narrow-to-region]. If HARD is nil, remove visual |
| 3489 | restriction up to the previously imposed hard limit (if any). */) | ||
| 3490 | (Lisp_Object hard) | ||
| 3488 | { | 3491 | { |
| 3489 | if (BEG != BEGV || Z != ZV) | 3492 | |
| 3490 | current_buffer->clip_changed = 1; | 3493 | if(!NILP (hard)) |
| 3491 | BEGV = BEG; | 3494 | { |
| 3492 | BEGV_BYTE = BEG_BYTE; | 3495 | bset_begh_marker(current_buffer, Qnil); |
| 3493 | SET_BUF_ZV_BOTH (current_buffer, Z, Z_BYTE); | 3496 | bset_zh_marker(current_buffer, Qnil); |
| 3494 | /* Changing the buffer bounds invalidates any recorded current column. */ | 3497 | } |
| 3495 | invalidate_current_column (); | 3498 | else |
| 3499 | { | ||
| 3500 | if (BEG != BEGV || Z != ZV) | ||
| 3501 | current_buffer->clip_changed = 1; | ||
| 3502 | BEGV = BEG; | ||
| 3503 | BEGV_BYTE = BEG_BYTE; | ||
| 3504 | SET_BUF_ZV_BOTH (current_buffer, Z, Z_BYTE); | ||
| 3505 | /* Changing the buffer bounds invalidates any recorded current column. */ | ||
| 3506 | invalidate_current_column (); | ||
| 3507 | } | ||
| 3508 | |||
| 3496 | return Qnil; | 3509 | return Qnil; |
| 3497 | } | 3510 | } |
| 3498 | 3511 | ||
| 3499 | DEFUN ("narrow-to-region", Fnarrow_to_region, Snarrow_to_region, 2, 2, "r", | 3512 | DEFUN ("narrow-to-region", Fnarrow_to_region, Snarrow_to_region, 2, 3, "r", |
| 3500 | doc: /* Restrict editing in this buffer to the current region. | 3513 | doc: /* Restrict editing in this buffer to the current |
| 3501 | The rest of the text becomes temporarily invisible and untouchable | 3514 | region. START and END are positions (integers or markers) bounding the |
| 3502 | but is not deleted; if you save the buffer in a file, the invisible | 3515 | text that should restricted. There can be two types of restrictions, |
| 3503 | text is included in the file. \\[widen] makes all visible again. | 3516 | visual and hard. If HARD is nil, impose visual restriction, otherwise |
| 3504 | See also `save-restriction'. | 3517 | a hard one. |
| 3505 | 3518 | ||
| 3506 | When calling from a program, pass two arguments; positions (integers | 3519 | When visual restriction is in place, the rest of the text is invisible |
| 3507 | or markers) bounding the text that should remain visible. */) | 3520 | and untouchable but is not deleted; if you save the buffer in a file, |
| 3508 | (register Lisp_Object start, Lisp_Object end) | 3521 | the invisible text is included in the file. \\[widen] with nil |
| 3522 | optional argument makes it all visible again. | ||
| 3523 | |||
| 3524 | When hard restriction is in place, invocations of (visual) \\[widen] | ||
| 3525 | with nil argument removes visual narrowing up to the hard | ||
| 3526 | restriction. In order to lift hard restriction, call \\[widen] with | ||
| 3527 | non-nil HARD argument. */) | ||
| 3528 | (register Lisp_Object start, Lisp_Object end, Lisp_Object hard) | ||
| 3509 | { | 3529 | { |
| 3530 | |||
| 3510 | CHECK_NUMBER_COERCE_MARKER (start); | 3531 | CHECK_NUMBER_COERCE_MARKER (start); |
| 3511 | CHECK_NUMBER_COERCE_MARKER (end); | 3532 | CHECK_NUMBER_COERCE_MARKER (end); |
| 3512 | 3533 | ||
| @@ -3519,6 +3540,15 @@ or markers) bounding the text that should remain visible. */) | |||
| 3519 | if (!(BEG <= XINT (start) && XINT (start) <= XINT (end) && XINT (end) <= Z)) | 3540 | if (!(BEG <= XINT (start) && XINT (start) <= XINT (end) && XINT (end) <= Z)) |
| 3520 | args_out_of_range (start, end); | 3541 | args_out_of_range (start, end); |
| 3521 | 3542 | ||
| 3543 | if (!NILP (hard)) | ||
| 3544 | { | ||
| 3545 | SET_BUF_BEGH (current_buffer, XFASTINT (start)); | ||
| 3546 | SET_BUF_ZH (current_buffer, XFASTINT (end)); | ||
| 3547 | if (BEGV >= XFASTINT (start) && ZV <= XFASTINT (end)) | ||
| 3548 | /* Visual narrowing within hard limits. */ | ||
| 3549 | return Qnil; | ||
| 3550 | } | ||
| 3551 | |||
| 3522 | if (BEGV != XFASTINT (start) || ZV != XFASTINT (end)) | 3552 | if (BEGV != XFASTINT (start) || ZV != XFASTINT (end)) |
| 3523 | current_buffer->clip_changed = 1; | 3553 | current_buffer->clip_changed = 1; |
| 3524 | 3554 | ||
| @@ -3533,6 +3563,7 @@ or markers) bounding the text that should remain visible. */) | |||
| 3533 | return Qnil; | 3563 | return Qnil; |
| 3534 | } | 3564 | } |
| 3535 | 3565 | ||
| 3566 | |||
| 3536 | Lisp_Object | 3567 | Lisp_Object |
| 3537 | save_restriction_save (void) | 3568 | save_restriction_save (void) |
| 3538 | { | 3569 | { |