diff options
| author | Stefan Monnier | 2017-12-12 23:03:00 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2017-12-12 23:03:00 -0500 |
| commit | 14b95587520959c5b54356547a0a69932a9bb480 (patch) | |
| tree | 550b3f4dc046acd1cfc0cfb795acb9f08db9b4e7 /src | |
| parent | 735680fa5e33c8c072081631b14f4a57c00e6340 (diff) | |
| download | emacs-14b95587520959c5b54356547a0a69932a9bb480.tar.gz emacs-14b95587520959c5b54356547a0a69932a9bb480.zip | |
* src/syntax.c (find_defun_start): Use syntax-ppss
(syms_of_syntax): New variable comment-use-syntax-ppss.
Diffstat (limited to 'src')
| -rw-r--r-- | src/syntax.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/syntax.c b/src/syntax.c index 80603b4f8b3..91c46f7a738 100644 --- a/src/syntax.c +++ b/src/syntax.c | |||
| @@ -605,6 +605,26 @@ find_defun_start (ptrdiff_t pos, ptrdiff_t pos_byte) | |||
| 605 | && MODIFF == find_start_modiff) | 605 | && MODIFF == find_start_modiff) |
| 606 | return find_start_value; | 606 | return find_start_value; |
| 607 | 607 | ||
| 608 | if (!NILP (Vcomment_use_syntax_ppss)) | ||
| 609 | { | ||
| 610 | EMACS_INT modiffs = CHARS_MODIFF; | ||
| 611 | Lisp_Object ppss = call1 (Qsyntax_ppss, make_number (pos)); | ||
| 612 | if (modiffs != CHARS_MODIFF) | ||
| 613 | error ("syntax-ppss modified the buffer!"); | ||
| 614 | TEMP_SET_PT_BOTH (opoint, opoint_byte); | ||
| 615 | Lisp_Object boc = Fnth (make_number (8), ppss); | ||
| 616 | if (NUMBERP (boc)) | ||
| 617 | { | ||
| 618 | find_start_value = XINT (boc); | ||
| 619 | find_start_value_byte = CHAR_TO_BYTE (find_start_value); | ||
| 620 | } | ||
| 621 | else | ||
| 622 | { | ||
| 623 | find_start_value = pos; | ||
| 624 | find_start_value_byte = pos_byte; | ||
| 625 | } | ||
| 626 | goto found; | ||
| 627 | } | ||
| 608 | if (!open_paren_in_column_0_is_defun_start) | 628 | if (!open_paren_in_column_0_is_defun_start) |
| 609 | { | 629 | { |
| 610 | find_start_value = BEGV; | 630 | find_start_value = BEGV; |
| @@ -874,6 +894,7 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, | |||
| 874 | case Sopen: | 894 | case Sopen: |
| 875 | /* Assume a defun-start point is outside of strings. */ | 895 | /* Assume a defun-start point is outside of strings. */ |
| 876 | if (open_paren_in_column_0_is_defun_start | 896 | if (open_paren_in_column_0_is_defun_start |
| 897 | && NILP (Vcomment_use_syntax_ppss) | ||
| 877 | && (from == stop | 898 | && (from == stop |
| 878 | || (temp_byte = dec_bytepos (from_byte), | 899 | || (temp_byte = dec_bytepos (from_byte), |
| 879 | FETCH_CHAR (temp_byte) == '\n'))) | 900 | FETCH_CHAR (temp_byte) == '\n'))) |
| @@ -3689,6 +3710,11 @@ void | |||
| 3689 | syms_of_syntax (void) | 3710 | syms_of_syntax (void) |
| 3690 | { | 3711 | { |
| 3691 | DEFSYM (Qsyntax_table_p, "syntax-table-p"); | 3712 | DEFSYM (Qsyntax_table_p, "syntax-table-p"); |
| 3713 | DEFSYM (Qsyntax_ppss, "syntax-ppss"); | ||
| 3714 | DEFVAR_LISP ("comment-use-syntax-ppss", | ||
| 3715 | Vcomment_use_syntax_ppss, | ||
| 3716 | doc: /* Non-nil means `forward-comment' can use `syntax-ppss' internally. */); | ||
| 3717 | Vcomment_use_syntax_ppss = Qt; | ||
| 3692 | 3718 | ||
| 3693 | staticpro (&Vsyntax_code_object); | 3719 | staticpro (&Vsyntax_code_object); |
| 3694 | 3720 | ||