Mercurial > emacs
comparison doc/lispref/syntax.texi @ 110310:9b5623e06689
* doc/lispref/syntax.texi (Syntax Flags): Document new `c' flag.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Sat, 11 Sep 2010 15:58:57 +0200 |
parents | 71353caf35e3 |
children | 417b1e4d63cd |
comparison
equal
deleted
inserted
replaced
110309:14a601b405fc | 110310:9b5623e06689 |
---|---|
290 @node Syntax Flags | 290 @node Syntax Flags |
291 @subsection Syntax Flags | 291 @subsection Syntax Flags |
292 @cindex syntax flags | 292 @cindex syntax flags |
293 | 293 |
294 In addition to the classes, entries for characters in a syntax table | 294 In addition to the classes, entries for characters in a syntax table |
295 can specify flags. There are seven possible flags, represented by the | 295 can specify flags. There are eight possible flags, represented by the |
296 characters @samp{1}, @samp{2}, @samp{3}, @samp{4}, @samp{b}, @samp{n}, | 296 characters @samp{1}, @samp{2}, @samp{3}, @samp{4}, @samp{b}, @samp{c}, |
297 and @samp{p}. | 297 @samp{n}, and @samp{p}. |
298 | 298 |
299 All the flags except @samp{n} and @samp{p} are used to describe | 299 All the flags except @samp{p} are used to describe comment |
300 multi-character comment delimiters. The digit flags indicate that a | 300 delimiters. The digit flags are used for comment delimiters made up |
301 character can @emph{also} be part of a comment sequence, in addition to | 301 of 2 characters. They indicate that a character can @emph{also} be |
302 the syntactic properties associated with its character class. The flags | 302 part of a comment sequence, in addition to the syntactic properties |
303 are independent of the class and each other for the sake of characters | 303 associated with its character class. The flags are independent of the |
304 such as @samp{*} in C mode, which is a punctuation character, @emph{and} | 304 class and each other for the sake of characters such as @samp{*} in |
305 the second character of a start-of-comment sequence (@samp{/*}), | 305 C mode, which is a punctuation character, @emph{and} the second |
306 @emph{and} the first character of an end-of-comment sequence | 306 character of a start-of-comment sequence (@samp{/*}), @emph{and} the |
307 (@samp{*/}). | 307 first character of an end-of-comment sequence (@samp{*/}). The flags |
308 @samp{b}, @samp{c}, and @samp{n} are used to qualify the corresponding | |
309 comment delimiter. | |
308 | 310 |
309 Here is a table of the possible flags for a character @var{c}, | 311 Here is a table of the possible flags for a character @var{c}, |
310 and what they mean: | 312 and what they mean: |
311 | 313 |
312 @itemize @bullet | 314 @itemize @bullet |
323 | 325 |
324 @item | 326 @item |
325 @samp{4} means @var{c} is the second character of such a sequence. | 327 @samp{4} means @var{c} is the second character of such a sequence. |
326 | 328 |
327 @item | 329 @item |
328 @c Emacs 19 feature | |
329 @samp{b} means that @var{c} as a comment delimiter belongs to the | 330 @samp{b} means that @var{c} as a comment delimiter belongs to the |
330 alternative ``b'' comment style. | 331 alternative ``b'' comment style. For a two-character comment starter, |
331 | 332 this flag is only significant on the second char, and for a 2-character |
332 Emacs supports two comment styles simultaneously in any one syntax | 333 comment ender it is only significant on the first char. |
333 table. This is for the sake of C++. Each style of comment syntax has | 334 |
334 its own comment-start sequence and its own comment-end sequence. Each | 335 @item |
335 comment must stick to one style or the other; thus, if it starts with | 336 @samp{c} means that @var{c} as a comment delimiter belongs to the |
336 the comment-start sequence of style ``b,'' it must also end with the | 337 alternative ``c'' comment style. For a two-character comment |
337 comment-end sequence of style ``b.'' | 338 delimiter, @samp{c} on either character makes it of style ``c''. |
338 | |
339 The two comment-start sequences must begin with the same character; only | |
340 the second character may differ. Mark the second character of the | |
341 ``b''-style comment-start sequence with the @samp{b} flag. | |
342 | |
343 A comment-end sequence (one or two characters) applies to the ``b'' | |
344 style if its first character has the @samp{b} flag set; otherwise, it | |
345 applies to the ``a'' style. | |
346 | |
347 The appropriate comment syntax settings for C++ are as follows: | |
348 | |
349 @table @asis | |
350 @item @samp{/} | |
351 @samp{124b} | |
352 @item @samp{*} | |
353 @samp{23} | |
354 @item newline | |
355 @samp{>b} | |
356 @end table | |
357 | |
358 This defines four comment-delimiting sequences: | |
359 | |
360 @table @asis | |
361 @item @samp{/*} | |
362 This is a comment-start sequence for ``a'' style because the | |
363 second character, @samp{*}, does not have the @samp{b} flag. | |
364 | |
365 @item @samp{//} | |
366 This is a comment-start sequence for ``b'' style because the second | |
367 character, @samp{/}, does have the @samp{b} flag. | |
368 | |
369 @item @samp{*/} | |
370 This is a comment-end sequence for ``a'' style because the first | |
371 character, @samp{*}, does not have the @samp{b} flag. | |
372 | |
373 @item newline | |
374 This is a comment-end sequence for ``b'' style, because the newline | |
375 character has the @samp{b} flag. | |
376 @end table | |
377 | 339 |
378 @item | 340 @item |
379 @samp{n} on a comment delimiter character specifies | 341 @samp{n} on a comment delimiter character specifies |
380 that this kind of comment can be nested. For a two-character | 342 that this kind of comment can be nested. For a two-character |
381 comment delimiter, @samp{n} on either character makes it | 343 comment delimiter, @samp{n} on either character makes it |
382 nestable. | 344 nestable. |
345 | |
346 Emacs supports several comment styles simultaneously in any one syntax | |
347 table. A comment style is a set of flags @samp{b}, @samp{c}, and | |
348 @samp{n}, so there can be up to 8 different comment styles. | |
349 Each comment delimiter has a style and only matches comment delimiters | |
350 of the same style. Thus if a comment starts with the comment-start | |
351 sequence of style ``bn'', it will extend until the next matching | |
352 comment-end sequence of style ``bn''. | |
353 | |
354 The appropriate comment syntax settings for C++ can be as follows: | |
355 | |
356 @table @asis | |
357 @item @samp{/} | |
358 @samp{124} | |
359 @item @samp{*} | |
360 @samp{23b} | |
361 @item newline | |
362 @samp{>} | |
363 @end table | |
364 | |
365 This defines four comment-delimiting sequences: | |
366 | |
367 @table @asis | |
368 @item @samp{/*} | |
369 This is a comment-start sequence for ``b'' style because the | |
370 second character, @samp{*}, has the @samp{b} flag. | |
371 | |
372 @item @samp{//} | |
373 This is a comment-start sequence for ``a'' style because the second | |
374 character, @samp{/}, does not have the @samp{b} flag. | |
375 | |
376 @item @samp{*/} | |
377 This is a comment-end sequence for ``b'' style because the first | |
378 character, @samp{*}, does have the @samp{b} flag. | |
379 | |
380 @item newline | |
381 This is a comment-end sequence for ``a'' style, because the newline | |
382 character does not have the @samp{b} flag. | |
383 @end table | |
383 | 384 |
384 @item | 385 @item |
385 @c Emacs 19 feature | 386 @c Emacs 19 feature |
386 @samp{p} identifies an additional ``prefix character'' for Lisp syntax. | 387 @samp{p} identifies an additional ``prefix character'' for Lisp syntax. |
387 These characters are treated as whitespace when they appear between | 388 These characters are treated as whitespace when they appear between |