aboutsummaryrefslogtreecommitdiffstats
path: root/src/syntax.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/syntax.h')
-rw-r--r--src/syntax.h55
1 files changed, 33 insertions, 22 deletions
diff --git a/src/syntax.h b/src/syntax.h
index 1b96284af42..73fbb153338 100644
--- a/src/syntax.h
+++ b/src/syntax.h
@@ -19,9 +19,6 @@ You should have received a copy of the GNU General Public License
19along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 19along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 20
21INLINE_HEADER_BEGIN 21INLINE_HEADER_BEGIN
22#ifndef SYNTAX_INLINE
23# define SYNTAX_INLINE INLINE
24#endif
25 22
26extern void update_syntax_table (ptrdiff_t, EMACS_INT, bool, Lisp_Object); 23extern void update_syntax_table (ptrdiff_t, EMACS_INT, bool, Lisp_Object);
27 24
@@ -86,35 +83,49 @@ struct gl_state_s
86extern struct gl_state_s gl_state; 83extern struct gl_state_s gl_state;
87 84
88/* Fetch the information from the entry for character C 85/* Fetch the information from the entry for character C
89 in syntax table TABLE, or from globally kept data (gl_state). 86 in the current buffer's syntax table,
87 or (if VIA_PROPERTY) from globally kept data (gl_state).
90 Does inheritance. */ 88 Does inheritance. */
91 89
92SYNTAX_INLINE Lisp_Object 90INLINE Lisp_Object
93SYNTAX_ENTRY (int c) 91syntax_property_entry (int c, bool via_property)
94{ 92{
95#ifdef SYNTAX_ENTRY_VIA_PROPERTY 93 if (via_property)
96 return (gl_state.use_global 94 return (gl_state.use_global
97 ? gl_state.global_code 95 ? gl_state.global_code
98 : CHAR_TABLE_REF (gl_state.current_syntax_table, c)); 96 : CHAR_TABLE_REF (gl_state.current_syntax_table, c));
99#else
100 return CHAR_TABLE_REF (BVAR (current_buffer, syntax_table), c); 97 return CHAR_TABLE_REF (BVAR (current_buffer, syntax_table), c);
101#endif 98}
99INLINE Lisp_Object
100SYNTAX_ENTRY (int c)
101{
102 return syntax_property_entry (c, 0);
102} 103}
103 104
104/* Extract the information from the entry for character C 105/* Extract the information from the entry for character C
105 in the current syntax table. */ 106 in the current syntax table. */
106 107
107SYNTAX_INLINE int 108INLINE int
108SYNTAX_WITH_FLAGS (int c) 109syntax_property_with_flags (int c, bool via_property)
109{ 110{
110 Lisp_Object ent = SYNTAX_ENTRY (c); 111 Lisp_Object ent = syntax_property_entry (c, via_property);
111 return CONSP (ent) ? XINT (XCAR (ent)) : Swhitespace; 112 return CONSP (ent) ? XINT (XCAR (ent)) : Swhitespace;
112} 113}
114INLINE int
115SYNTAX_WITH_FLAGS (int c)
116{
117 return syntax_property_with_flags (c, 0);
118}
113 119
114SYNTAX_INLINE enum syntaxcode 120INLINE enum syntaxcode
121syntax_property (int c, bool via_property)
122{
123 return syntax_property_with_flags (c, via_property) & 0xff;
124}
125INLINE enum syntaxcode
115SYNTAX (int c) 126SYNTAX (int c)
116{ 127{
117 return SYNTAX_WITH_FLAGS (c) & 0xff; 128 return syntax_property (c, 0);
118} 129}
119 130
120 131
@@ -137,7 +148,7 @@ extern char const syntax_code_spec[16];
137 The value is meant for use in code that does nothing when 148 The value is meant for use in code that does nothing when
138 parse_sexp_lookup_properties is 0, so return 0 in that case, for speed. */ 149 parse_sexp_lookup_properties is 0, so return 0 in that case, for speed. */
139 150
140SYNTAX_INLINE ptrdiff_t 151INLINE ptrdiff_t
141SYNTAX_TABLE_BYTE_TO_CHAR (ptrdiff_t bytepos) 152SYNTAX_TABLE_BYTE_TO_CHAR (ptrdiff_t bytepos)
142{ 153{
143 return (! parse_sexp_lookup_properties 154 return (! parse_sexp_lookup_properties
@@ -157,7 +168,7 @@ SYNTAX_TABLE_BYTE_TO_CHAR (ptrdiff_t bytepos)
157/* Make syntax table state (gl_state) good for CHARPOS, assuming it is 168/* Make syntax table state (gl_state) good for CHARPOS, assuming it is
158 currently good for a position before CHARPOS. */ 169 currently good for a position before CHARPOS. */
159 170
160SYNTAX_INLINE void 171INLINE void
161UPDATE_SYNTAX_TABLE_FORWARD (ptrdiff_t charpos) 172UPDATE_SYNTAX_TABLE_FORWARD (ptrdiff_t charpos)
162{ 173{
163 if (parse_sexp_lookup_properties && charpos >= gl_state.e_property) 174 if (parse_sexp_lookup_properties && charpos >= gl_state.e_property)
@@ -167,7 +178,7 @@ UPDATE_SYNTAX_TABLE_FORWARD (ptrdiff_t charpos)
167/* Make syntax table state (gl_state) good for CHARPOS, assuming it is 178/* Make syntax table state (gl_state) good for CHARPOS, assuming it is
168 currently good for a position after CHARPOS. */ 179 currently good for a position after CHARPOS. */
169 180
170SYNTAX_INLINE void 181INLINE void
171UPDATE_SYNTAX_TABLE_BACKWARD (ptrdiff_t charpos) 182UPDATE_SYNTAX_TABLE_BACKWARD (ptrdiff_t charpos)
172{ 183{
173 if (parse_sexp_lookup_properties && charpos < gl_state.b_property) 184 if (parse_sexp_lookup_properties && charpos < gl_state.b_property)
@@ -176,7 +187,7 @@ UPDATE_SYNTAX_TABLE_BACKWARD (ptrdiff_t charpos)
176 187
177/* Make syntax table good for CHARPOS. */ 188/* Make syntax table good for CHARPOS. */
178 189
179SYNTAX_INLINE void 190INLINE void
180UPDATE_SYNTAX_TABLE (ptrdiff_t charpos) 191UPDATE_SYNTAX_TABLE (ptrdiff_t charpos)
181{ 192{
182 UPDATE_SYNTAX_TABLE_BACKWARD (charpos); 193 UPDATE_SYNTAX_TABLE_BACKWARD (charpos);
@@ -185,7 +196,7 @@ UPDATE_SYNTAX_TABLE (ptrdiff_t charpos)
185 196
186/* Set up the buffer-global syntax table. */ 197/* Set up the buffer-global syntax table. */
187 198
188SYNTAX_INLINE void 199INLINE void
189SETUP_BUFFER_SYNTAX_TABLE (void) 200SETUP_BUFFER_SYNTAX_TABLE (void)
190{ 201{
191 gl_state.use_global = 0; 202 gl_state.use_global = 0;