diff options
Diffstat (limited to 'src/buffer.h')
| -rw-r--r-- | src/buffer.h | 77 |
1 files changed, 61 insertions, 16 deletions
diff --git a/src/buffer.h b/src/buffer.h index cf571e06b53..7a6bddee5ec 100644 --- a/src/buffer.h +++ b/src/buffer.h | |||
| @@ -21,6 +21,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 21 | #include <sys/types.h> /* for off_t, time_t */ | 21 | #include <sys/types.h> /* for off_t, time_t */ |
| 22 | #include "systime.h" /* for EMACS_TIME */ | 22 | #include "systime.h" /* for EMACS_TIME */ |
| 23 | 23 | ||
| 24 | INLINE_HEADER_BEGIN | ||
| 25 | #ifndef BUFFER_INLINE | ||
| 26 | # define BUFFER_INLINE INLINE | ||
| 27 | #endif | ||
| 28 | |||
| 24 | /* Accessing the parameters of the current buffer. */ | 29 | /* Accessing the parameters of the current buffer. */ |
| 25 | 30 | ||
| 26 | /* These macros come in pairs, one for the char position | 31 | /* These macros come in pairs, one for the char position |
| @@ -188,9 +193,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 188 | /* FIXME: should we move this into ->text->auto_save_modiff? */ | 193 | /* FIXME: should we move this into ->text->auto_save_modiff? */ |
| 189 | #define BUF_AUTOSAVE_MODIFF(buf) ((buf)->auto_save_modified) | 194 | #define BUF_AUTOSAVE_MODIFF(buf) ((buf)->auto_save_modified) |
| 190 | 195 | ||
| 191 | /* Interval tree of buffer. */ | ||
| 192 | #define BUF_INTERVALS(buf) ((buf)->text->intervals) | ||
| 193 | |||
| 194 | /* Marker chain of buffer. */ | 196 | /* Marker chain of buffer. */ |
| 195 | #define BUF_MARKERS(buf) ((buf)->text->markers) | 197 | #define BUF_MARKERS(buf) ((buf)->text->markers) |
| 196 | 198 | ||
| @@ -475,6 +477,7 @@ struct buffer_text | |||
| 475 | /* Most code should use this macro to access Lisp fields in struct buffer. */ | 477 | /* Most code should use this macro to access Lisp fields in struct buffer. */ |
| 476 | 478 | ||
| 477 | #define BVAR(buf, field) ((buf)->INTERNAL_FIELD (field)) | 479 | #define BVAR(buf, field) ((buf)->INTERNAL_FIELD (field)) |
| 480 | #define BSET(buf, field, value) ((buf)->INTERNAL_FIELD (field) = (value)) | ||
| 478 | 481 | ||
| 479 | /* This is the structure that the buffer Lisp object points to. */ | 482 | /* This is the structure that the buffer Lisp object points to. */ |
| 480 | 483 | ||
| @@ -773,7 +776,7 @@ struct buffer | |||
| 773 | /* In an indirect buffer, this is -1. In an ordinary buffer, | 776 | /* In an indirect buffer, this is -1. In an ordinary buffer, |
| 774 | it's the number of indirect buffers that share our text; | 777 | it's the number of indirect buffers that share our text; |
| 775 | zero means that we're the only owner of this text. */ | 778 | zero means that we're the only owner of this text. */ |
| 776 | ptrdiff_t indirections; | 779 | int indirections; |
| 777 | 780 | ||
| 778 | /* A non-zero value in slot IDX means that per-buffer variable | 781 | /* A non-zero value in slot IDX means that per-buffer variable |
| 779 | with index IDX has a local value in this buffer. The index IDX | 782 | with index IDX has a local value in this buffer. The index IDX |
| @@ -946,7 +949,47 @@ extern void mmap_set_vars (int); | |||
| 946 | extern Lisp_Object Qbefore_change_functions; | 949 | extern Lisp_Object Qbefore_change_functions; |
| 947 | extern Lisp_Object Qafter_change_functions; | 950 | extern Lisp_Object Qafter_change_functions; |
| 948 | extern Lisp_Object Qfirst_change_hook; | 951 | extern Lisp_Object Qfirst_change_hook; |
| 949 | 952 | ||
| 953 | /* Get text properties of B. */ | ||
| 954 | |||
| 955 | BUFFER_INLINE INTERVAL | ||
| 956 | buffer_get_intervals (struct buffer *b) | ||
| 957 | { | ||
| 958 | eassert (b->text != NULL); | ||
| 959 | return b->text->intervals; | ||
| 960 | } | ||
| 961 | |||
| 962 | /* Set text properties of B to I. */ | ||
| 963 | |||
| 964 | BUFFER_INLINE void | ||
| 965 | buffer_set_intervals (struct buffer *b, INTERVAL i) | ||
| 966 | { | ||
| 967 | eassert (b->text != NULL); | ||
| 968 | b->text->intervals = i; | ||
| 969 | } | ||
| 970 | |||
| 971 | /* Set an appropriate overlay of B. */ | ||
| 972 | |||
| 973 | BUFFER_INLINE void | ||
| 974 | buffer_set_overlays_before (struct buffer *b, struct Lisp_Overlay *o) | ||
| 975 | { | ||
| 976 | b->overlays_before = o; | ||
| 977 | } | ||
| 978 | |||
| 979 | BUFFER_INLINE void | ||
| 980 | buffer_set_overlays_after (struct buffer *b, struct Lisp_Overlay *o) | ||
| 981 | { | ||
| 982 | b->overlays_after = o; | ||
| 983 | } | ||
| 984 | |||
| 985 | /* Non-zero if current buffer has overlays. */ | ||
| 986 | |||
| 987 | BUFFER_INLINE int | ||
| 988 | buffer_has_overlays (void) | ||
| 989 | { | ||
| 990 | return current_buffer->overlays_before || current_buffer->overlays_after; | ||
| 991 | } | ||
| 992 | |||
| 950 | /* Return character code of multi-byte form at byte position POS. If POS | 993 | /* Return character code of multi-byte form at byte position POS. If POS |
| 951 | doesn't point the head of valid multi-byte form, only the byte at | 994 | doesn't point the head of valid multi-byte form, only the byte at |
| 952 | POS is returned. No range checking. | 995 | POS is returned. No range checking. |
| @@ -961,7 +1004,7 @@ extern Lisp_Object Qfirst_change_hook; | |||
| 961 | the buffer to the next character after fetching this one. Instead, | 1004 | the buffer to the next character after fetching this one. Instead, |
| 962 | use either FETCH_CHAR_ADVANCE or STRING_CHAR_AND_LENGTH. */ | 1005 | use either FETCH_CHAR_ADVANCE or STRING_CHAR_AND_LENGTH. */ |
| 963 | 1006 | ||
| 964 | static inline int | 1007 | BUFFER_INLINE int |
| 965 | FETCH_MULTIBYTE_CHAR (ptrdiff_t pos) | 1008 | FETCH_MULTIBYTE_CHAR (ptrdiff_t pos) |
| 966 | { | 1009 | { |
| 967 | unsigned char *p = ((pos >= GPT_BYTE ? GAP_SIZE : 0) | 1010 | unsigned char *p = ((pos >= GPT_BYTE ? GAP_SIZE : 0) |
| @@ -973,7 +1016,7 @@ FETCH_MULTIBYTE_CHAR (ptrdiff_t pos) | |||
| 973 | If POS doesn't point the head of valid multi-byte form, only the byte at | 1016 | If POS doesn't point the head of valid multi-byte form, only the byte at |
| 974 | POS is returned. No range checking. */ | 1017 | POS is returned. No range checking. */ |
| 975 | 1018 | ||
| 976 | static inline int | 1019 | BUFFER_INLINE int |
| 977 | BUF_FETCH_MULTIBYTE_CHAR (struct buffer *buf, ptrdiff_t pos) | 1020 | BUF_FETCH_MULTIBYTE_CHAR (struct buffer *buf, ptrdiff_t pos) |
| 978 | { | 1021 | { |
| 979 | unsigned char *p | 1022 | unsigned char *p |
| @@ -986,15 +1029,15 @@ BUF_FETCH_MULTIBYTE_CHAR (struct buffer *buf, ptrdiff_t pos) | |||
| 986 | 1029 | ||
| 987 | /* Return the marker that stands for where OV starts in the buffer. */ | 1030 | /* Return the marker that stands for where OV starts in the buffer. */ |
| 988 | 1031 | ||
| 989 | #define OVERLAY_START(OV) MVAR (XOVERLAY (OV), start) | 1032 | #define OVERLAY_START(OV) XOVERLAY (OV)->start |
| 990 | 1033 | ||
| 991 | /* Return the marker that stands for where OV ends in the buffer. */ | 1034 | /* Return the marker that stands for where OV ends in the buffer. */ |
| 992 | 1035 | ||
| 993 | #define OVERLAY_END(OV) MVAR (XOVERLAY (OV), end) | 1036 | #define OVERLAY_END(OV) XOVERLAY (OV)->end |
| 994 | 1037 | ||
| 995 | /* Return the plist of overlay OV. */ | 1038 | /* Return the plist of overlay OV. */ |
| 996 | 1039 | ||
| 997 | #define OVERLAY_PLIST(OV) MVAR (XOVERLAY (OV), plist) | 1040 | #define OVERLAY_PLIST(OV) XOVERLAY (OV)->plist |
| 998 | 1041 | ||
| 999 | /* Return the actual buffer position for the marker P. | 1042 | /* Return the actual buffer position for the marker P. |
| 1000 | We assume you know which buffer it's pointing into. */ | 1043 | We assume you know which buffer it's pointing into. */ |
| @@ -1024,7 +1067,7 @@ extern int last_per_buffer_idx; | |||
| 1024 | #define FOR_EACH_PER_BUFFER_OBJECT_AT(offset) \ | 1067 | #define FOR_EACH_PER_BUFFER_OBJECT_AT(offset) \ |
| 1025 | for (offset = PER_BUFFER_VAR_OFFSET (name); \ | 1068 | for (offset = PER_BUFFER_VAR_OFFSET (name); \ |
| 1026 | offset <= PER_BUFFER_VAR_OFFSET (cursor_in_non_selected_windows); \ | 1069 | offset <= PER_BUFFER_VAR_OFFSET (cursor_in_non_selected_windows); \ |
| 1027 | offset += sizeof (Lisp_Object)) | 1070 | offset += word_size) |
| 1028 | 1071 | ||
| 1029 | /* Return the index of buffer-local variable VAR. Each per-buffer | 1072 | /* Return the index of buffer-local variable VAR. Each per-buffer |
| 1030 | variable has an index > 0 associated with it, except when it always | 1073 | variable has an index > 0 associated with it, except when it always |
| @@ -1090,7 +1133,7 @@ extern int last_per_buffer_idx; | |||
| 1090 | (*(Lisp_Object *)((OFFSET) + (char *) (BUFFER))) | 1133 | (*(Lisp_Object *)((OFFSET) + (char *) (BUFFER))) |
| 1091 | 1134 | ||
| 1092 | /* Downcase a character C, or make no change if that cannot be done. */ | 1135 | /* Downcase a character C, or make no change if that cannot be done. */ |
| 1093 | static inline int | 1136 | BUFFER_INLINE int |
| 1094 | downcase (int c) | 1137 | downcase (int c) |
| 1095 | { | 1138 | { |
| 1096 | Lisp_Object downcase_table = BVAR (current_buffer, downcase_table); | 1139 | Lisp_Object downcase_table = BVAR (current_buffer, downcase_table); |
| @@ -1099,10 +1142,10 @@ downcase (int c) | |||
| 1099 | } | 1142 | } |
| 1100 | 1143 | ||
| 1101 | /* 1 if C is upper case. */ | 1144 | /* 1 if C is upper case. */ |
| 1102 | static inline int uppercasep (int c) { return downcase (c) != c; } | 1145 | BUFFER_INLINE int uppercasep (int c) { return downcase (c) != c; } |
| 1103 | 1146 | ||
| 1104 | /* Upcase a character C known to be not upper case. */ | 1147 | /* Upcase a character C known to be not upper case. */ |
| 1105 | static inline int | 1148 | BUFFER_INLINE int |
| 1106 | upcase1 (int c) | 1149 | upcase1 (int c) |
| 1107 | { | 1150 | { |
| 1108 | Lisp_Object upcase_table = BVAR (current_buffer, upcase_table); | 1151 | Lisp_Object upcase_table = BVAR (current_buffer, upcase_table); |
| @@ -1111,8 +1154,10 @@ upcase1 (int c) | |||
| 1111 | } | 1154 | } |
| 1112 | 1155 | ||
| 1113 | /* 1 if C is lower case. */ | 1156 | /* 1 if C is lower case. */ |
| 1114 | static inline int lowercasep (int c) | 1157 | BUFFER_INLINE int lowercasep (int c) |
| 1115 | { return !uppercasep (c) && upcase1 (c) != c; } | 1158 | { return !uppercasep (c) && upcase1 (c) != c; } |
| 1116 | 1159 | ||
| 1117 | /* Upcase a character C, or make no change if that cannot be done. */ | 1160 | /* Upcase a character C, or make no change if that cannot be done. */ |
| 1118 | static inline int upcase (int c) { return uppercasep (c) ? c : upcase1 (c); } | 1161 | BUFFER_INLINE int upcase (int c) { return uppercasep (c) ? c : upcase1 (c); } |
| 1162 | |||
| 1163 | INLINE_HEADER_END | ||