diff options
| author | Xue Fuqiao | 2013-09-04 08:39:34 +0800 |
|---|---|---|
| committer | Xue Fuqiao | 2013-09-04 08:39:34 +0800 |
| commit | adf2fc4a01efe77d73cd52bc9173914ed56ff531 (patch) | |
| tree | a5a280a5554a7bffeaf94fccae29fa3ac1a5d066 /src/indent.c | |
| parent | 63191d9f2043d2e67657e85a7b3842805dd1dad6 (diff) | |
| parent | 38726039b77db432989fed106c88e9f1aa463281 (diff) | |
| download | emacs-adf2fc4a01efe77d73cd52bc9173914ed56ff531.tar.gz emacs-adf2fc4a01efe77d73cd52bc9173914ed56ff531.zip | |
Merge from mainline.
Diffstat (limited to 'src/indent.c')
| -rw-r--r-- | src/indent.c | 44 |
1 files changed, 16 insertions, 28 deletions
diff --git a/src/indent.c b/src/indent.c index 47358e17db8..891b42788ed 100644 --- a/src/indent.c +++ b/src/indent.c | |||
| @@ -141,13 +141,13 @@ recompute_width_table (struct buffer *buf, struct Lisp_Char_Table *disptab) | |||
| 141 | XSETFASTINT (widthtab->contents[i], character_width (i, disptab)); | 141 | XSETFASTINT (widthtab->contents[i], character_width (i, disptab)); |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | /* Allocate or free the width run cache, as requested by the current | 144 | /* Allocate or free the width run cache, as requested by the |
| 145 | state of current_buffer's cache_long_line_scans variable. */ | 145 | current state of current_buffer's cache_long_scans variable. */ |
| 146 | 146 | ||
| 147 | static void | 147 | static void |
| 148 | width_run_cache_on_off (void) | 148 | width_run_cache_on_off (void) |
| 149 | { | 149 | { |
| 150 | if (NILP (BVAR (current_buffer, cache_long_line_scans)) | 150 | if (NILP (BVAR (current_buffer, cache_long_scans)) |
| 151 | /* And, for the moment, this feature doesn't work on multibyte | 151 | /* And, for the moment, this feature doesn't work on multibyte |
| 152 | characters. */ | 152 | characters. */ |
| 153 | || !NILP (BVAR (current_buffer, enable_multibyte_characters))) | 153 | || !NILP (BVAR (current_buffer, enable_multibyte_characters))) |
| @@ -510,15 +510,10 @@ scan_for_column (ptrdiff_t *endpos, EMACS_INT *goalcol, ptrdiff_t *prevcol) | |||
| 510 | register ptrdiff_t col = 0, prev_col = 0; | 510 | register ptrdiff_t col = 0, prev_col = 0; |
| 511 | EMACS_INT goal = goalcol ? *goalcol : MOST_POSITIVE_FIXNUM; | 511 | EMACS_INT goal = goalcol ? *goalcol : MOST_POSITIVE_FIXNUM; |
| 512 | ptrdiff_t end = endpos ? *endpos : PT; | 512 | ptrdiff_t end = endpos ? *endpos : PT; |
| 513 | ptrdiff_t scan, scan_byte; | 513 | ptrdiff_t scan, scan_byte, next_boundary; |
| 514 | ptrdiff_t next_boundary; | 514 | |
| 515 | { | 515 | scan = find_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -1, NULL, &scan_byte, 1); |
| 516 | ptrdiff_t opoint = PT, opoint_byte = PT_BYTE; | ||
| 517 | scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -1, 1); | ||
| 518 | scan = PT, scan_byte = PT_BYTE; | ||
| 519 | SET_PT_BOTH (opoint, opoint_byte); | ||
| 520 | next_boundary = scan; | 516 | next_boundary = scan; |
| 521 | } | ||
| 522 | 517 | ||
| 523 | window = Fget_buffer_window (Fcurrent_buffer (), Qnil); | 518 | window = Fget_buffer_window (Fcurrent_buffer (), Qnil); |
| 524 | w = ! NILP (window) ? XWINDOW (window) : NULL; | 519 | w = ! NILP (window) ? XWINDOW (window) : NULL; |
| @@ -835,14 +830,10 @@ This is the horizontal position of the character | |||
| 835 | following any initial whitespace. */) | 830 | following any initial whitespace. */) |
| 836 | (void) | 831 | (void) |
| 837 | { | 832 | { |
| 838 | Lisp_Object val; | 833 | ptrdiff_t posbyte; |
| 839 | ptrdiff_t opoint = PT, opoint_byte = PT_BYTE; | ||
| 840 | |||
| 841 | scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -1, 1); | ||
| 842 | 834 | ||
| 843 | XSETFASTINT (val, position_indentation (PT_BYTE)); | 835 | find_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -1, NULL, &posbyte, 1); |
| 844 | SET_PT_BOTH (opoint, opoint_byte); | 836 | return make_number (position_indentation (posbyte)); |
| 845 | return val; | ||
| 846 | } | 837 | } |
| 847 | 838 | ||
| 848 | static ptrdiff_t | 839 | static ptrdiff_t |
| @@ -935,16 +926,13 @@ position_indentation (ptrdiff_t pos_byte) | |||
| 935 | bool | 926 | bool |
| 936 | indented_beyond_p (ptrdiff_t pos, ptrdiff_t pos_byte, EMACS_INT column) | 927 | indented_beyond_p (ptrdiff_t pos, ptrdiff_t pos_byte, EMACS_INT column) |
| 937 | { | 928 | { |
| 938 | ptrdiff_t val; | 929 | while (pos > BEGV && FETCH_BYTE (pos_byte) == '\n') |
| 939 | ptrdiff_t opoint = PT, opoint_byte = PT_BYTE; | 930 | { |
| 940 | 931 | DEC_BOTH (pos, pos_byte); | |
| 941 | SET_PT_BOTH (pos, pos_byte); | 932 | pos = find_newline (pos, pos_byte, BEGV, BEGV_BYTE, |
| 942 | while (PT > BEGV && FETCH_BYTE (PT_BYTE) == '\n') | 933 | -1, NULL, &pos_byte, 0); |
| 943 | scan_newline (PT - 1, PT_BYTE - 1, BEGV, BEGV_BYTE, -1, 0); | 934 | } |
| 944 | 935 | return position_indentation (pos_byte) >= column; | |
| 945 | val = position_indentation (PT_BYTE); | ||
| 946 | SET_PT_BOTH (opoint, opoint_byte); | ||
| 947 | return val >= column; | ||
| 948 | } | 936 | } |
| 949 | 937 | ||
| 950 | DEFUN ("move-to-column", Fmove_to_column, Smove_to_column, 1, 2, | 938 | DEFUN ("move-to-column", Fmove_to_column, Smove_to_column, 1, 2, |