aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Monnier2014-07-04 22:17:14 -0400
committerStefan Monnier2014-07-04 22:17:14 -0400
commit6246df666bc864c82e9436f929c1e04d200d1d25 (patch)
tree19f9676fab06f12ceefcd21bc00406776227128e /src
parent661b90d8b657a68fa2101533302728c2c531df3c (diff)
downloademacs-6246df666bc864c82e9436f929c1e04d200d1d25.tar.gz
emacs-6246df666bc864c82e9436f929c1e04d200d1d25.zip
* src/syntax.c (find_defun_start): Try the cache even
if !open_paren_in_column_0_is_defun_start. (back_comment): If find_defun_start was pessimistic, use the scan_sexps_forward result to improve the cache. Fixes: debbugs:16526
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog10
-rw-r--r--src/syntax.c36
2 files changed, 31 insertions, 15 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 3d6311c765b..6048522cdc4 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
12014-07-05 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * syntax.c (find_defun_start): Try the cache even
4 if !open_paren_in_column_0_is_defun_start.
5 (back_comment): If find_defun_start was pessimistic, use the
6 scan_sexps_forward result to improve the cache (bug#16526).
7
12014-07-04 Daniel Colascione <dancol@dancol.org> 82014-07-04 Daniel Colascione <dancol@dancol.org>
2 9
3 Backport from trunk. 10 Backport from trunk.
@@ -7,8 +14,7 @@
7 and stop caching xic_style across different displays (Bug#17928). 14 and stop caching xic_style across different displays (Bug#17928).
8 (supported_xim_styles): Make const. 15 (supported_xim_styles): Make const.
9 (best_xim_style): Remove first parameter: it's always just 16 (best_xim_style): Remove first parameter: it's always just
10 supported_xim_styles. Change to look at supported_xim_styles 17 supported_xim_styles. Change to look at supported_xim_styles directly.
11 directly.
12 18
132014-07-04 Eli Zaretskii <eliz@gnu.org> 192014-07-04 Eli Zaretskii <eliz@gnu.org>
14 20
diff --git a/src/syntax.c b/src/syntax.c
index f2451332b19..0ee48bb3725 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -530,17 +530,6 @@ find_defun_start (ptrdiff_t pos, ptrdiff_t pos_byte)
530{ 530{
531 ptrdiff_t opoint = PT, opoint_byte = PT_BYTE; 531 ptrdiff_t opoint = PT, opoint_byte = PT_BYTE;
532 532
533 if (!open_paren_in_column_0_is_defun_start)
534 {
535 find_start_value = BEGV;
536 find_start_value_byte = BEGV_BYTE;
537 find_start_buffer = current_buffer;
538 find_start_modiff = MODIFF;
539 find_start_begv = BEGV;
540 find_start_pos = pos;
541 return BEGV;
542 }
543
544 /* Use previous finding, if it's valid and applies to this inquiry. */ 533 /* Use previous finding, if it's valid and applies to this inquiry. */
545 if (current_buffer == find_start_buffer 534 if (current_buffer == find_start_buffer
546 /* Reuse the defun-start even if POS is a little farther on. 535 /* Reuse the defun-start even if POS is a little farther on.
@@ -552,6 +541,13 @@ find_defun_start (ptrdiff_t pos, ptrdiff_t pos_byte)
552 && MODIFF == find_start_modiff) 541 && MODIFF == find_start_modiff)
553 return find_start_value; 542 return find_start_value;
554 543
544 if (!open_paren_in_column_0_is_defun_start)
545 {
546 find_start_value = BEGV;
547 find_start_value_byte = BEGV_BYTE;
548 goto found;
549 }
550
555 /* Back up to start of line. */ 551 /* Back up to start of line. */
556 scan_newline (pos, pos_byte, BEGV, BEGV_BYTE, -1, 1); 552 scan_newline (pos, pos_byte, BEGV, BEGV_BYTE, -1, 1);
557 553
@@ -582,13 +578,14 @@ find_defun_start (ptrdiff_t pos, ptrdiff_t pos_byte)
582 /* Record what we found, for the next try. */ 578 /* Record what we found, for the next try. */
583 find_start_value = PT; 579 find_start_value = PT;
584 find_start_value_byte = PT_BYTE; 580 find_start_value_byte = PT_BYTE;
581 TEMP_SET_PT_BOTH (opoint, opoint_byte);
582
583 found:
585 find_start_buffer = current_buffer; 584 find_start_buffer = current_buffer;
586 find_start_modiff = MODIFF; 585 find_start_modiff = MODIFF;
587 find_start_begv = BEGV; 586 find_start_begv = BEGV;
588 find_start_pos = pos; 587 find_start_pos = pos;
589 588
590 TEMP_SET_PT_BOTH (opoint, opoint_byte);
591
592 return find_start_value; 589 return find_start_value;
593} 590}
594 591
@@ -841,7 +838,9 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop,
841 else 838 else
842 { 839 {
843 struct lisp_parse_state state; 840 struct lisp_parse_state state;
841 bool adjusted;
844 lossage: 842 lossage:
843 adjusted = true;
845 /* We had two kinds of string delimiters mixed up 844 /* We had two kinds of string delimiters mixed up
846 together. Decode this going forwards. 845 together. Decode this going forwards.
847 Scan fwd from a known safe place (beginning-of-defun) 846 Scan fwd from a known safe place (beginning-of-defun)
@@ -852,6 +851,7 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop,
852 { 851 {
853 defun_start = find_defun_start (comment_end, comment_end_byte); 852 defun_start = find_defun_start (comment_end, comment_end_byte);
854 defun_start_byte = find_start_value_byte; 853 defun_start_byte = find_start_value_byte;
854 adjusted = (defun_start > BEGV);
855 } 855 }
856 do 856 do
857 { 857 {
@@ -860,6 +860,16 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop,
860 comment_end, TYPE_MINIMUM (EMACS_INT), 860 comment_end, TYPE_MINIMUM (EMACS_INT),
861 0, Qnil, 0); 861 0, Qnil, 0);
862 defun_start = comment_end; 862 defun_start = comment_end;
863 if (!adjusted)
864 {
865 adjusted = true;
866 find_start_value
867 = CONSP (state.levelstarts) ? XINT (XCAR (state.levelstarts))
868 : state.thislevelstart >= 0 ? state.thislevelstart
869 : find_start_value;
870 find_start_value_byte = CHAR_TO_BYTE (find_start_value);
871 }
872
863 if (state.incomment == (comnested ? 1 : -1) 873 if (state.incomment == (comnested ? 1 : -1)
864 && state.comstyle == comstyle) 874 && state.comstyle == comstyle)
865 from = state.comstr_start; 875 from = state.comstr_start;