diff options
| author | Chong Yidong | 2011-03-13 18:25:16 -0400 |
|---|---|---|
| committer | Chong Yidong | 2011-03-13 18:25:16 -0400 |
| commit | cffc6f3bd9b5dbb9825502928bd9dd58ddbac02e (patch) | |
| tree | ab220f926b665ef94b698e925d442e75aadfa864 /src/buffer.h | |
| parent | eebc475df54de7ad5c04ef7cddc083c865235540 (diff) | |
| download | emacs-cffc6f3bd9b5dbb9825502928bd9dd58ddbac02e.tar.gz emacs-cffc6f3bd9b5dbb9825502928bd9dd58ddbac02e.zip | |
Fix BUF_* macros to handle indirect buffers properly (Bug#8219).
* buffer.h (BUF_BEGV, BUF_BEGV_BYTE, BUF_ZV, BUF_ZV_BYTE, BUF_PT)
(BUF_PT_BYTE): Rewrite to handle indirect buffers (Bug#8219).
These macros can no longer be used for assignment.
* buffer.c (Fget_buffer_create, Fmake_indirect_buffer): Assign
struct members directly, instead of using BUF_BEGV etc.
(record_buffer_markers, fetch_buffer_markers): New functions for
recording and fetching special buffer markers.
(set_buffer_internal_1, set_buffer_temp): Use them.
* lread.c (unreadchar): Use SET_BUF_PT_BOTH.
* insdel.c (adjust_point): Use SET_BUF_PT_BOTH.
* intervals.c (temp_set_point_both): Use SET_BUF_PT_BOTH.
(get_local_map): Use SET_BUF_BEGV_BOTH and SET_BUF_ZV_BOTH.
* xdisp.c (hscroll_window_tree):
(reconsider_clip_changes): Use PT instead of BUF_PT.
Diffstat (limited to 'src/buffer.h')
| -rw-r--r-- | src/buffer.h | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/src/buffer.h b/src/buffer.h index 65c7168d60a..0975d2e3adc 100644 --- a/src/buffer.h +++ b/src/buffer.h | |||
| @@ -107,27 +107,46 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 107 | #define BUF_BEG(buf) (BEG) | 107 | #define BUF_BEG(buf) (BEG) |
| 108 | #define BUF_BEG_BYTE(buf) (BEG_BYTE) | 108 | #define BUF_BEG_BYTE(buf) (BEG_BYTE) |
| 109 | 109 | ||
| 110 | /* !!!FIXME: all the BUF_BEGV/BUF_ZV/BUF_PT macros are flawed: | 110 | /* The BUF_BEGV[_BYTE], BUF_ZV[_BYTE], and BUF_PT[_BYTE] macros cannot |
| 111 | on indirect (or base) buffers, that value is only correct if that buffer | 111 | be used for assignment; use SET_BUF_* macros below for that. */ |
| 112 | is the current_buffer, or if the buffer's text hasn't been modified (via | ||
| 113 | an indirect buffer) since it was last current. */ | ||
| 114 | 112 | ||
| 115 | /* Position of beginning of accessible range of buffer. */ | 113 | /* Position of beginning of accessible range of buffer. */ |
| 116 | #define BUF_BEGV(buf) ((buf)->begv) | 114 | #define BUF_BEGV(buf) \ |
| 117 | #define BUF_BEGV_BYTE(buf) ((buf)->begv_byte) | 115 | (buf == current_buffer ? BEGV \ |
| 116 | : NILP (BVAR (buf, begv_marker)) ? buf->begv \ | ||
| 117 | : marker_position (BVAR (buf, begv_marker))) | ||
| 118 | |||
| 119 | #define BUF_BEGV_BYTE(buf) \ | ||
| 120 | (buf == current_buffer ? BEGV_BYTE \ | ||
| 121 | : NILP (BVAR (buf, begv_marker)) ? buf->begv_byte \ | ||
| 122 | : marker_byte_position (BVAR (buf, begv_marker))) | ||
| 118 | 123 | ||
| 119 | /* Position of point in buffer. */ | 124 | /* Position of point in buffer. */ |
| 120 | #define BUF_PT(buf) ((buf)->pt) | 125 | #define BUF_PT(buf) \ |
| 121 | #define BUF_PT_BYTE(buf) ((buf)->pt_byte) | 126 | (buf == current_buffer ? PT \ |
| 127 | : NILP (BVAR (buf, pt_marker)) ? buf->pt \ | ||
| 128 | : marker_position (BVAR (buf, pt_marker))) | ||
| 129 | |||
| 130 | #define BUF_PT_BYTE(buf) \ | ||
| 131 | (buf == current_buffer ? PT_BYTE \ | ||
| 132 | : NILP (BVAR (buf, pt_marker)) ? buf->pt_byte \ | ||
| 133 | : marker_byte_position (BVAR (buf, pt_marker))) | ||
| 134 | |||
| 135 | /* Position of end of accessible range of buffer. */ | ||
| 136 | #define BUF_ZV(buf) \ | ||
| 137 | (buf == current_buffer ? ZV \ | ||
| 138 | : NILP (BVAR (buf, zv_marker)) ? buf->zv \ | ||
| 139 | : marker_position (BVAR (buf, zv_marker))) | ||
| 140 | |||
| 141 | #define BUF_ZV_BYTE(buf) \ | ||
| 142 | (buf == current_buffer ? ZV_BYTE \ | ||
| 143 | : NILP (BVAR (buf, zv_marker)) ? buf->zv_byte \ | ||
| 144 | : marker_byte_position (BVAR (buf, zv_marker))) | ||
| 122 | 145 | ||
| 123 | /* Position of gap in buffer. */ | 146 | /* Position of gap in buffer. */ |
| 124 | #define BUF_GPT(buf) ((buf)->text->gpt) | 147 | #define BUF_GPT(buf) ((buf)->text->gpt) |
| 125 | #define BUF_GPT_BYTE(buf) ((buf)->text->gpt_byte) | 148 | #define BUF_GPT_BYTE(buf) ((buf)->text->gpt_byte) |
| 126 | 149 | ||
| 127 | /* Position of end of accessible range of buffer. */ | ||
| 128 | #define BUF_ZV(buf) ((buf)->zv) | ||
| 129 | #define BUF_ZV_BYTE(buf) ((buf)->zv_byte) | ||
| 130 | |||
| 131 | /* Position of end of buffer. */ | 150 | /* Position of end of buffer. */ |
| 132 | #define BUF_Z(buf) ((buf)->text->z) | 151 | #define BUF_Z(buf) ((buf)->text->z) |
| 133 | #define BUF_Z_BYTE(buf) ((buf)->text->z_byte) | 152 | #define BUF_Z_BYTE(buf) ((buf)->text->z_byte) |
| @@ -235,8 +254,6 @@ extern void enlarge_buffer_text (struct buffer *, EMACS_INT); | |||
| 235 | 254 | ||
| 236 | /* Macros for setting the BEGV, ZV or PT of a given buffer. | 255 | /* Macros for setting the BEGV, ZV or PT of a given buffer. |
| 237 | 256 | ||
| 238 | SET_BUF_PT* seet to be redundant. Get rid of them? | ||
| 239 | |||
| 240 | The ..._BOTH macros take both a charpos and a bytepos, | 257 | The ..._BOTH macros take both a charpos and a bytepos, |
| 241 | which must correspond to each other. | 258 | which must correspond to each other. |
| 242 | 259 | ||