diff options
| author | Richard M. Stallman | 1998-01-19 19:38:40 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-01-19 19:38:40 +0000 |
| commit | 3ac81adbcc0cdea2ef8a731176fce6ece1762ba9 (patch) | |
| tree | 47280c9c8f14ea9bb829c1a7492633450c195b5a | |
| parent | 31f8ab72fb4fb6c13bca39a3adb5b05b92dccebb (diff) | |
| download | emacs-3ac81adbcc0cdea2ef8a731176fce6ece1762ba9.tar.gz emacs-3ac81adbcc0cdea2ef8a731176fce6ece1762ba9.zip | |
(Fset_buffer_multibyte): New function.
(syms_of_buffer): defsubr it.
| -rw-r--r-- | src/buffer.c | 78 |
1 files changed, 77 insertions, 1 deletions
diff --git a/src/buffer.c b/src/buffer.c index dd5026cf6e4..1950ff365ac 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -1661,6 +1661,81 @@ validate_region (b, e) | |||
| 1661 | args_out_of_range (*b, *e); | 1661 | args_out_of_range (*b, *e); |
| 1662 | } | 1662 | } |
| 1663 | 1663 | ||
| 1664 | DEFUN ("set-buffer-multibyte", Fset_buffer_multibyte, Sset_buffer_multibyte, | ||
| 1665 | 1, 1, 0, | ||
| 1666 | "Set the multibyte flag of the current buffer to FLAG.\n\ | ||
| 1667 | If FLAG is t, this makes the buffer a multibyte buffer.\n\ | ||
| 1668 | If FLAG is nil, this makes the buffer a single-byte buffer.\n\ | ||
| 1669 | The buffer contents remain unchanged as a sequence of bytes\n\ | ||
| 1670 | but the contents viewed as characters do change.") | ||
| 1671 | (flag) | ||
| 1672 | Lisp_Object flag; | ||
| 1673 | { | ||
| 1674 | Lisp_Object tail, markers; | ||
| 1675 | |||
| 1676 | /* If the cached position is for this buffer, clear it out. */ | ||
| 1677 | clear_charpos_cache (current_buffer); | ||
| 1678 | |||
| 1679 | if (NILP (flag)) | ||
| 1680 | { | ||
| 1681 | /* Do this first, so it can use CHAR_TO_BYTE | ||
| 1682 | to calculate the old correspondences. */ | ||
| 1683 | set_intervals_multibyte (0); | ||
| 1684 | |||
| 1685 | current_buffer->enable_multibyte_characters = Qnil; | ||
| 1686 | |||
| 1687 | Z = Z_BYTE; | ||
| 1688 | BEGV = BEGV_BYTE; | ||
| 1689 | ZV = ZV_BYTE; | ||
| 1690 | GPT = GPT_BYTE; | ||
| 1691 | TEMP_SET_PT_BOTH (PT_BYTE, PT_BYTE); | ||
| 1692 | |||
| 1693 | tail = BUF_MARKERS (current_buffer); | ||
| 1694 | while (XSYMBOL (tail) != XSYMBOL (Qnil)) | ||
| 1695 | { | ||
| 1696 | XMARKER (tail)->charpos = XMARKER (tail)->bytepos; | ||
| 1697 | tail = XMARKER (tail)->chain; | ||
| 1698 | } | ||
| 1699 | } | ||
| 1700 | else | ||
| 1701 | { | ||
| 1702 | /* Do this first, so that chars_in_text asks the right question. | ||
| 1703 | set_intervals_multibyte needs it too. */ | ||
| 1704 | current_buffer->enable_multibyte_characters = Qt; | ||
| 1705 | |||
| 1706 | GPT = chars_in_text (BEG_ADDR, GPT_BYTE - BEG_BYTE) + BEG; | ||
| 1707 | Z = chars_in_text (GPT_ADDR, Z_BYTE - GPT_BYTE) + GPT; | ||
| 1708 | if (BEGV_BYTE > GPT_BYTE) | ||
| 1709 | BEGV = chars_in_text (GPT_ADDR, BEGV_BYTE - GPT_BYTE) + GPT; | ||
| 1710 | else | ||
| 1711 | BEGV = chars_in_text (BEG_ADDR, BEGV_BYTE - BEG_BYTE) + BEG; | ||
| 1712 | if (ZV_BYTE > GPT_BYTE) | ||
| 1713 | ZV = chars_in_text (GPT_ADDR, ZV_BYTE - GPT_BYTE) + GPT; | ||
| 1714 | else | ||
| 1715 | ZV = chars_in_text (BEG_ADDR, ZV_BYTE - BEG_BYTE) + BEG; | ||
| 1716 | if (PT_BYTE > GPT_BYTE) | ||
| 1717 | current_buffer->pt = chars_in_text (GPT_ADDR, PT_BYTE - GPT_BYTE) + GPT; | ||
| 1718 | else | ||
| 1719 | current_buffer->pt = chars_in_text (BEG_ADDR, PT_BYTE - BEG_BYTE) + BEG; | ||
| 1720 | |||
| 1721 | tail = markers = BUF_MARKERS (current_buffer); | ||
| 1722 | BUF_MARKERS (current_buffer) = Qnil; | ||
| 1723 | |||
| 1724 | while (XSYMBOL (tail) != XSYMBOL (Qnil)) | ||
| 1725 | { | ||
| 1726 | XMARKER (tail)->charpos = BYTE_TO_CHAR (XMARKER (tail)->bytepos); | ||
| 1727 | tail = XMARKER (tail)->chain; | ||
| 1728 | } | ||
| 1729 | BUF_MARKERS (current_buffer) = markers; | ||
| 1730 | |||
| 1731 | /* Do this last, so it can calculate the new correspondences | ||
| 1732 | between chars and bytes. */ | ||
| 1733 | set_intervals_multibyte (1); | ||
| 1734 | } | ||
| 1735 | |||
| 1736 | return flag; | ||
| 1737 | } | ||
| 1738 | |||
| 1664 | DEFUN ("kill-all-local-variables", Fkill_all_local_variables, Skill_all_local_variables, | 1739 | DEFUN ("kill-all-local-variables", Fkill_all_local_variables, Skill_all_local_variables, |
| 1665 | 0, 0, 0, | 1740 | 0, 0, 0, |
| 1666 | "Switch to Fundamental mode by killing current buffer's local variables.\n\ | 1741 | "Switch to Fundamental mode by killing current buffer's local variables.\n\ |
| @@ -4358,7 +4433,6 @@ is a member of the list."); | |||
| 4358 | defsubr (&Sbuffer_disable_undo); | 4433 | defsubr (&Sbuffer_disable_undo); |
| 4359 | defsubr (&Sbuffer_enable_undo); | 4434 | defsubr (&Sbuffer_enable_undo); |
| 4360 | defsubr (&Skill_buffer); | 4435 | defsubr (&Skill_buffer); |
| 4361 | defsubr (&Serase_buffer); | ||
| 4362 | defsubr (&Sset_buffer_major_mode); | 4436 | defsubr (&Sset_buffer_major_mode); |
| 4363 | defsubr (&Sswitch_to_buffer); | 4437 | defsubr (&Sswitch_to_buffer); |
| 4364 | defsubr (&Spop_to_buffer); | 4438 | defsubr (&Spop_to_buffer); |
| @@ -4366,6 +4440,8 @@ is a member of the list."); | |||
| 4366 | defsubr (&Sset_buffer); | 4440 | defsubr (&Sset_buffer); |
| 4367 | defsubr (&Sbarf_if_buffer_read_only); | 4441 | defsubr (&Sbarf_if_buffer_read_only); |
| 4368 | defsubr (&Sbury_buffer); | 4442 | defsubr (&Sbury_buffer); |
| 4443 | defsubr (&Serase_buffer); | ||
| 4444 | defsubr (&Sset_buffer_multibyte); | ||
| 4369 | defsubr (&Skill_all_local_variables); | 4445 | defsubr (&Skill_all_local_variables); |
| 4370 | 4446 | ||
| 4371 | defsubr (&Soverlayp); | 4447 | defsubr (&Soverlayp); |