Commit 6246df66 authored by Stefan Monnier's avatar Stefan Monnier

* 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
parent 661b90d8
2014-07-05 Stefan Monnier <monnier@iro.umontreal.ca>
* 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 (bug#16526).
2014-07-04 Daniel Colascione <dancol@dancol.org> 2014-07-04 Daniel Colascione <dancol@dancol.org>
Backport from trunk. Backport from trunk.
...@@ -7,8 +14,7 @@ ...@@ -7,8 +14,7 @@
and stop caching xic_style across different displays (Bug#17928). and stop caching xic_style across different displays (Bug#17928).
(supported_xim_styles): Make const. (supported_xim_styles): Make const.
(best_xim_style): Remove first parameter: it's always just (best_xim_style): Remove first parameter: it's always just
supported_xim_styles. Change to look at supported_xim_styles supported_xim_styles. Change to look at supported_xim_styles directly.
directly.
2014-07-04 Eli Zaretskii <eliz@gnu.org> 2014-07-04 Eli Zaretskii <eliz@gnu.org>
......
...@@ -530,17 +530,6 @@ find_defun_start (ptrdiff_t pos, ptrdiff_t pos_byte) ...@@ -530,17 +530,6 @@ find_defun_start (ptrdiff_t pos, ptrdiff_t pos_byte)
{ {
ptrdiff_t opoint = PT, opoint_byte = PT_BYTE; ptrdiff_t opoint = PT, opoint_byte = PT_BYTE;
if (!open_paren_in_column_0_is_defun_start)
{
find_start_value = BEGV;
find_start_value_byte = BEGV_BYTE;
find_start_buffer = current_buffer;
find_start_modiff = MODIFF;
find_start_begv = BEGV;
find_start_pos = pos;
return BEGV;
}
/* Use previous finding, if it's valid and applies to this inquiry. */ /* Use previous finding, if it's valid and applies to this inquiry. */
if (current_buffer == find_start_buffer if (current_buffer == find_start_buffer
/* Reuse the defun-start even if POS is a little farther on. /* 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,6 +541,13 @@ find_defun_start (ptrdiff_t pos, ptrdiff_t pos_byte)
&& MODIFF == find_start_modiff) && MODIFF == find_start_modiff)
return find_start_value; return find_start_value;
if (!open_paren_in_column_0_is_defun_start)
{
find_start_value = BEGV;
find_start_value_byte = BEGV_BYTE;
goto found;
}
/* Back up to start of line. */ /* Back up to start of line. */
scan_newline (pos, pos_byte, BEGV, BEGV_BYTE, -1, 1); scan_newline (pos, pos_byte, BEGV, BEGV_BYTE, -1, 1);
...@@ -582,13 +578,14 @@ find_defun_start (ptrdiff_t pos, ptrdiff_t pos_byte) ...@@ -582,13 +578,14 @@ find_defun_start (ptrdiff_t pos, ptrdiff_t pos_byte)
/* Record what we found, for the next try. */ /* Record what we found, for the next try. */
find_start_value = PT; find_start_value = PT;
find_start_value_byte = PT_BYTE; find_start_value_byte = PT_BYTE;
TEMP_SET_PT_BOTH (opoint, opoint_byte);
found:
find_start_buffer = current_buffer; find_start_buffer = current_buffer;
find_start_modiff = MODIFF; find_start_modiff = MODIFF;
find_start_begv = BEGV; find_start_begv = BEGV;
find_start_pos = pos; find_start_pos = pos;
TEMP_SET_PT_BOTH (opoint, opoint_byte);
return find_start_value; return find_start_value;
} }
...@@ -841,7 +838,9 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, ...@@ -841,7 +838,9 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop,
else else
{ {
struct lisp_parse_state state; struct lisp_parse_state state;
bool adjusted;
lossage: lossage:
adjusted = true;
/* We had two kinds of string delimiters mixed up /* We had two kinds of string delimiters mixed up
together. Decode this going forwards. together. Decode this going forwards.
Scan fwd from a known safe place (beginning-of-defun) 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,6 +851,7 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop,
{ {
defun_start = find_defun_start (comment_end, comment_end_byte); defun_start = find_defun_start (comment_end, comment_end_byte);
defun_start_byte = find_start_value_byte; defun_start_byte = find_start_value_byte;
adjusted = (defun_start > BEGV);
} }
do do
{ {
...@@ -860,6 +860,16 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, ...@@ -860,6 +860,16 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop,
comment_end, TYPE_MINIMUM (EMACS_INT), comment_end, TYPE_MINIMUM (EMACS_INT),
0, Qnil, 0); 0, Qnil, 0);
defun_start = comment_end; defun_start = comment_end;
if (!adjusted)
{
adjusted = true;
find_start_value
= CONSP (state.levelstarts) ? XINT (XCAR (state.levelstarts))
: state.thislevelstart >= 0 ? state.thislevelstart
: find_start_value;
find_start_value_byte = CHAR_TO_BYTE (find_start_value);
}
if (state.incomment == (comnested ? 1 : -1) if (state.incomment == (comnested ? 1 : -1)
&& state.comstyle == comstyle) && state.comstyle == comstyle)
from = state.comstr_start; from = state.comstr_start;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment