337 |
It should be the last one before POS, or nearly the last. |
It should be the last one before POS, or nearly the last. |
338 |
|
|
339 |
When open_paren_in_column_0_is_defun_start is nonzero, |
When open_paren_in_column_0_is_defun_start is nonzero, |
340 |
the beginning of every line is treated as a defun-start. |
only the beginning of the buffer is treated as a defun-start. |
341 |
|
|
342 |
We record the information about where the scan started |
We record the information about where the scan started |
343 |
and what its result was, so that another call in the same area |
and what its result was, so that another call in the same area |
353 |
{ |
{ |
354 |
int opoint = PT, opoint_byte = PT_BYTE; |
int opoint = PT, opoint_byte = PT_BYTE; |
355 |
|
|
356 |
|
if (!open_paren_in_column_0_is_defun_start) |
357 |
|
{ |
358 |
|
find_start_value_byte = BEGV_BYTE; |
359 |
|
return BEGV; |
360 |
|
} |
361 |
|
|
362 |
/* Use previous finding, if it's valid and applies to this inquiry. */ |
/* Use previous finding, if it's valid and applies to this inquiry. */ |
363 |
if (current_buffer == find_start_buffer |
if (current_buffer == find_start_buffer |
364 |
/* Reuse the defun-start even if POS is a little farther on. |
/* Reuse the defun-start even if POS is a little farther on. |
378 |
syntax-tables. */ |
syntax-tables. */ |
379 |
gl_state.current_syntax_table = current_buffer->syntax_table; |
gl_state.current_syntax_table = current_buffer->syntax_table; |
380 |
gl_state.use_global = 0; |
gl_state.use_global = 0; |
381 |
if (open_paren_in_column_0_is_defun_start) |
while (PT > BEGV) |
382 |
{ |
{ |
383 |
while (PT > BEGV) |
/* Open-paren at start of line means we may have found our |
384 |
|
defun-start. */ |
385 |
|
if (SYNTAX (FETCH_CHAR (PT_BYTE)) == Sopen) |
386 |
{ |
{ |
387 |
/* Open-paren at start of line means we may have found our |
SETUP_SYNTAX_TABLE (PT + 1, -1); /* Try again... */ |
|
defun-start. */ |
|
388 |
if (SYNTAX (FETCH_CHAR (PT_BYTE)) == Sopen) |
if (SYNTAX (FETCH_CHAR (PT_BYTE)) == Sopen) |
389 |
{ |
break; |
390 |
SETUP_SYNTAX_TABLE (PT + 1, -1); /* Try again... */ |
/* Now fallback to the default value. */ |
391 |
if (SYNTAX (FETCH_CHAR (PT_BYTE)) == Sopen) |
gl_state.current_syntax_table = current_buffer->syntax_table; |
392 |
break; |
gl_state.use_global = 0; |
|
/* Now fallback to the default value. */ |
|
|
gl_state.current_syntax_table = current_buffer->syntax_table; |
|
|
gl_state.use_global = 0; |
|
|
} |
|
|
/* Move to beg of previous line. */ |
|
|
scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -2, 1); |
|
393 |
} |
} |
394 |
|
/* Move to beg of previous line. */ |
395 |
|
scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -2, 1); |
396 |
} |
} |
397 |
|
|
398 |
/* Record what we found, for the next try. */ |
/* Record what we found, for the next try. */ |
1277 |
return from; |
return from; |
1278 |
} |
} |
1279 |
|
|
1280 |
DEFUN ("forward-word", Fforward_word, Sforward_word, 1, 1, "p", |
DEFUN ("forward-word", Fforward_word, Sforward_word, 0, 1, "p", |
1281 |
doc: /* Move point forward ARG words (backward if ARG is negative). |
doc: /* Move point forward ARG words (backward if ARG is negative). |
1282 |
Normally returns t. |
Normally returns t. |
1283 |
If an edge of the buffer or a field boundary is reached, point is left there |
If an edge of the buffer or a field boundary is reached, point is left there |
1284 |
and the function returns nil. Field boundaries are not noticed if |
and the function returns nil. Field boundaries are not noticed if |
1285 |
`inhibit-field-text-motion' is non-nil. */) |
`inhibit-field-text-motion' is non-nil. */) |
1286 |
(count) |
(arg) |
1287 |
Lisp_Object count; |
Lisp_Object arg; |
1288 |
{ |
{ |
1289 |
int orig_val, val; |
int orig_val, val; |
|
CHECK_NUMBER (count); |
|
1290 |
|
|
1291 |
val = orig_val = scan_words (PT, XINT (count)); |
if (NILP (arg)) |
1292 |
|
XSETFASTINT (arg, 1); |
1293 |
|
else |
1294 |
|
CHECK_NUMBER (arg); |
1295 |
|
|
1296 |
|
val = orig_val = scan_words (PT, XINT (arg)); |
1297 |
if (! orig_val) |
if (! orig_val) |
1298 |
val = XINT (count) > 0 ? ZV : BEGV; |
val = XINT (arg) > 0 ? ZV : BEGV; |
1299 |
|
|
1300 |
/* Avoid jumping out of an input field. */ |
/* Avoid jumping out of an input field. */ |
1301 |
val = XFASTINT (Fconstrain_to_field (make_number (val), make_number (PT), |
val = XFASTINT (Fconstrain_to_field (make_number (val), make_number (PT), |
1511 |
int start_point = PT; |
int start_point = PT; |
1512 |
int pos = PT; |
int pos = PT; |
1513 |
int pos_byte = PT_BYTE; |
int pos_byte = PT_BYTE; |
1514 |
|
unsigned char *p = PT_ADDR, *endp, *stop; |
1515 |
|
|
1516 |
|
if (forwardp) |
1517 |
|
{ |
1518 |
|
endp = (XINT (lim) == GPT) ? GPT_ADDR : CHAR_POS_ADDR (XINT (lim)); |
1519 |
|
stop = (pos < GPT && GPT < XINT (lim)) ? GPT_ADDR : endp; |
1520 |
|
} |
1521 |
|
else |
1522 |
|
{ |
1523 |
|
endp = CHAR_POS_ADDR (XINT (lim)); |
1524 |
|
stop = (pos >= GPT && GPT > XINT (lim)) ? GAP_END_ADDR : endp; |
1525 |
|
} |
1526 |
|
|
1527 |
immediate_quit = 1; |
immediate_quit = 1; |
1528 |
if (syntaxp) |
if (syntaxp) |
1531 |
if (forwardp) |
if (forwardp) |
1532 |
{ |
{ |
1533 |
if (multibyte) |
if (multibyte) |
1534 |
{ |
while (1) |
1535 |
if (pos < XINT (lim)) |
{ |
1536 |
while (fastmap[(int) SYNTAX (FETCH_CHAR (pos_byte))]) |
int nbytes; |
1537 |
|
|
1538 |
|
if (p >= stop) |
1539 |
{ |
{ |
1540 |
/* Since we already checked for multibyteness, |
if (p >= endp) |
1541 |
avoid using INC_BOTH which checks again. */ |
break; |
1542 |
INC_POS (pos_byte); |
p = GAP_END_ADDR; |
1543 |
pos++; |
stop = endp; |
|
if (pos >= XINT (lim)) |
|
|
break; |
|
|
UPDATE_SYNTAX_TABLE_FORWARD (pos); |
|
1544 |
} |
} |
1545 |
} |
c = STRING_CHAR_AND_LENGTH (p, MAX_MULTIBYTE_LENGTH, nbytes); |
1546 |
|
if (! fastmap[(int) SYNTAX (c)]) |
1547 |
|
break; |
1548 |
|
p += nbytes, pos++, pos_byte += nbytes; |
1549 |
|
UPDATE_SYNTAX_TABLE_FORWARD (pos); |
1550 |
|
} |
1551 |
else |
else |
1552 |
{ |
while (1) |
1553 |
while (pos < XINT (lim) |
{ |
1554 |
&& fastmap[(int) SYNTAX (FETCH_BYTE (pos))]) |
if (p >= stop) |
1555 |
{ |
{ |
1556 |
pos++; |
if (p >= endp) |
1557 |
UPDATE_SYNTAX_TABLE_FORWARD (pos); |
break; |
1558 |
} |
p = GAP_END_ADDR; |
1559 |
} |
stop = endp; |
1560 |
|
} |
1561 |
|
if (! fastmap[(int) SYNTAX (*p)]) |
1562 |
|
break; |
1563 |
|
p++, pos++; |
1564 |
|
UPDATE_SYNTAX_TABLE_FORWARD (pos); |
1565 |
|
} |
1566 |
} |
} |
1567 |
else |
else |
1568 |
{ |
{ |
1569 |
if (multibyte) |
if (multibyte) |
1570 |
{ |
while (1) |
1571 |
while (pos > XINT (lim)) |
{ |
1572 |
{ |
unsigned char *prev_p; |
1573 |
int savepos = pos_byte; |
int nbytes; |
1574 |
/* Since we already checked for multibyteness, |
|
1575 |
avoid using DEC_BOTH which checks again. */ |
if (p <= stop) |
1576 |
pos--; |
{ |
1577 |
DEC_POS (pos_byte); |
if (p <= endp) |
|
UPDATE_SYNTAX_TABLE_BACKWARD (pos); |
|
|
if (!fastmap[(int) SYNTAX (FETCH_CHAR (pos_byte))]) |
|
|
{ |
|
|
pos++; |
|
|
pos_byte = savepos; |
|
1578 |
break; |
break; |
1579 |
} |
p = GPT_ADDR; |
1580 |
} |
stop = endp; |
1581 |
} |
} |
1582 |
|
prev_p = p; |
1583 |
|
while (--p >= stop && ! CHAR_HEAD_P (*p)); |
1584 |
|
PARSE_MULTIBYTE_SEQ (p, MAX_MULTIBYTE_LENGTH, nbytes); |
1585 |
|
if (prev_p - p > nbytes) |
1586 |
|
p = prev_p - 1, c = *p, nbytes = 1; |
1587 |
|
else |
1588 |
|
c = STRING_CHAR (p, MAX_MULTIBYTE_LENGTH); |
1589 |
|
pos--, pos_byte -= nbytes; |
1590 |
|
UPDATE_SYNTAX_TABLE_BACKWARD (pos); |
1591 |
|
if (! fastmap[(int) SYNTAX (c)]) |
1592 |
|
{ |
1593 |
|
pos++; |
1594 |
|
pos_byte += nbytes; |
1595 |
|
break; |
1596 |
|
} |
1597 |
|
} |
1598 |
else |
else |
1599 |
{ |
while (1) |
1600 |
if (pos > XINT (lim)) |
{ |
1601 |
while (fastmap[(int) SYNTAX (FETCH_BYTE (pos - 1))]) |
if (p <= stop) |
1602 |
{ |
{ |
1603 |
pos--; |
if (p <= endp) |
|
if (pos <= XINT (lim)) |
|
1604 |
break; |
break; |
1605 |
UPDATE_SYNTAX_TABLE_BACKWARD (pos - 1); |
p = GPT_ADDR; |
1606 |
|
stop = endp; |
1607 |
} |
} |
1608 |
} |
if (! fastmap[(int) SYNTAX (p[-1])]) |
1609 |
|
break; |
1610 |
|
p--, pos--; |
1611 |
|
UPDATE_SYNTAX_TABLE_BACKWARD (pos - 1); |
1612 |
|
} |
1613 |
} |
} |
1614 |
} |
} |
1615 |
else |
else |
1617 |
if (forwardp) |
if (forwardp) |
1618 |
{ |
{ |
1619 |
if (multibyte) |
if (multibyte) |
1620 |
while (pos < XINT (lim)) |
while (1) |
1621 |
{ |
{ |
1622 |
c = FETCH_MULTIBYTE_CHAR (pos_byte); |
int nbytes; |
1623 |
|
|
1624 |
|
if (p >= stop) |
1625 |
|
{ |
1626 |
|
if (p >= endp) |
1627 |
|
break; |
1628 |
|
p = GAP_END_ADDR; |
1629 |
|
stop = endp; |
1630 |
|
} |
1631 |
|
c = STRING_CHAR_AND_LENGTH (p, MAX_MULTIBYTE_LENGTH, nbytes); |
1632 |
if (SINGLE_BYTE_CHAR_P (c)) |
if (SINGLE_BYTE_CHAR_P (c)) |
1633 |
{ |
{ |
1634 |
if (!fastmap[c]) |
if (!fastmap[c]) |
1651 |
if (!(negate ^ (i < n_char_ranges))) |
if (!(negate ^ (i < n_char_ranges))) |
1652 |
break; |
break; |
1653 |
} |
} |
1654 |
INC_BOTH (pos, pos_byte); |
p += nbytes, pos++, pos_byte += nbytes; |
1655 |
} |
} |
1656 |
else |
else |
1657 |
while (pos < XINT (lim) && fastmap[FETCH_BYTE (pos)]) |
while (1) |
1658 |
pos++; |
{ |
1659 |
|
if (p >= stop) |
1660 |
|
{ |
1661 |
|
if (p >= endp) |
1662 |
|
break; |
1663 |
|
p = GAP_END_ADDR; |
1664 |
|
stop = endp; |
1665 |
|
} |
1666 |
|
if (!fastmap[*p]) |
1667 |
|
break; |
1668 |
|
p++, pos++; |
1669 |
|
} |
1670 |
} |
} |
1671 |
else |
else |
1672 |
{ |
{ |
1673 |
if (multibyte) |
if (multibyte) |
1674 |
while (pos > XINT (lim)) |
while (1) |
1675 |
{ |
{ |
1676 |
int prev_pos_byte = pos_byte; |
unsigned char *prev_p; |
1677 |
|
int nbytes; |
1678 |
|
|
1679 |
DEC_POS (prev_pos_byte); |
if (p <= stop) |
1680 |
c = FETCH_MULTIBYTE_CHAR (prev_pos_byte); |
{ |
1681 |
|
if (p <= endp) |
1682 |
|
break; |
1683 |
|
p = GPT_ADDR; |
1684 |
|
stop = endp; |
1685 |
|
} |
1686 |
|
prev_p = p; |
1687 |
|
while (--p >= stop && ! CHAR_HEAD_P (*p)); |
1688 |
|
PARSE_MULTIBYTE_SEQ (p, MAX_MULTIBYTE_LENGTH, nbytes); |
1689 |
|
if (prev_p - p > nbytes) |
1690 |
|
p = prev_p - 1, c = *p, nbytes = 1; |
1691 |
|
else |
1692 |
|
c = STRING_CHAR (p, MAX_MULTIBYTE_LENGTH); |
1693 |
if (SINGLE_BYTE_CHAR_P (c)) |
if (SINGLE_BYTE_CHAR_P (c)) |
1694 |
{ |
{ |
1695 |
if (!fastmap[c]) |
if (!fastmap[c]) |
1704 |
if (!(negate ^ (i < n_char_ranges))) |
if (!(negate ^ (i < n_char_ranges))) |
1705 |
break; |
break; |
1706 |
} |
} |
1707 |
pos--; |
pos--, pos_byte -= nbytes; |
|
pos_byte = prev_pos_byte; |
|
1708 |
} |
} |
1709 |
else |
else |
1710 |
while (pos > XINT (lim) && fastmap[FETCH_BYTE (pos - 1)]) |
while (1) |
1711 |
pos--; |
{ |
1712 |
|
if (p <= stop) |
1713 |
|
{ |
1714 |
|
if (p <= endp) |
1715 |
|
break; |
1716 |
|
p = GPT_ADDR; |
1717 |
|
stop = endp; |
1718 |
|
} |
1719 |
|
if (!fastmap[p[-1]]) |
1720 |
|
break; |
1721 |
|
p--, pos--; |
1722 |
|
} |
1723 |
} |
} |
1724 |
} |
} |
1725 |
|
|
3110 |
defsubr (&Sbackward_prefix_chars); |
defsubr (&Sbackward_prefix_chars); |
3111 |
defsubr (&Sparse_partial_sexp); |
defsubr (&Sparse_partial_sexp); |
3112 |
} |
} |
3113 |
|
|
3114 |
|
/* arch-tag: 3e297b9f-088e-4b64-8f4c-fb0b3443e412 |
3115 |
|
(do not change this comment) */ |