Mercurial > emacs
annotate src/indent.c @ 21353:2cdadff1ea25
(report-emacs-bug-hook): Don't bind enable-multibyte-characters.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 04 Apr 1998 00:07:57 +0000 |
parents | c431691cbff1 |
children | 6ec5e85328a9 |
rev | line source |
---|---|
165 | 1 /* Indentation functions. |
20706 | 2 Copyright (C) 1985,86,87,88,93,94,95,98 Free Software Foundation, Inc. |
165 | 3 |
4 This file is part of GNU Emacs. | |
5 | |
6 GNU Emacs is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
12244 | 8 the Free Software Foundation; either version 2, or (at your option) |
165 | 9 any later version. |
10 | |
11 GNU Emacs is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14078
diff
changeset
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14078
diff
changeset
|
19 Boston, MA 02111-1307, USA. */ |
165 | 20 |
21 | |
4696
1fc792473491
Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents:
4385
diff
changeset
|
22 #include <config.h> |
165 | 23 #include "lisp.h" |
24 #include "buffer.h" | |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
25 #include "charset.h" |
20256
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
26 #include "category.h" |
165 | 27 #include "indent.h" |
764 | 28 #include "frame.h" |
165 | 29 #include "window.h" |
30 #include "termchar.h" | |
31 #include "termopts.h" | |
32 #include "disptab.h" | |
4385
edffa4f0c5d9
(compute_motion): Compute correctly for invisible text.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
33 #include "intervals.h" |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
34 #include "region-cache.h" |
165 | 35 |
36 /* Indentation can insert tabs if this is non-zero; | |
37 otherwise always uses spaces */ | |
38 int indent_tabs_mode; | |
39 | |
40 #define min(a, b) ((a) < (b) ? (a) : (b)) | |
41 #define max(a, b) ((a) > (b) ? (a) : (b)) | |
42 | |
43 #define CR 015 | |
44 | |
45 /* These three values memoize the current column to avoid recalculation */ | |
46 /* Some things in set last_known_column_point to -1 | |
47 to mark the memoized value as invalid */ | |
48 /* Last value returned by current_column */ | |
49 int last_known_column; | |
50 /* Value of point when current_column was called */ | |
51 int last_known_column_point; | |
52 /* Value of MODIFF when current_column was called */ | |
53 int last_known_column_modified; | |
54 | |
15494
a544bb3eea53
(current_column_1): Add declaration.
Richard M. Stallman <rms@gnu.org>
parents:
15493
diff
changeset
|
55 static int current_column_1 (); |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
56 static int position_indentation (); |
15494
a544bb3eea53
(current_column_1): Add declaration.
Richard M. Stallman <rms@gnu.org>
parents:
15493
diff
changeset
|
57 |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
58 /* Cache of beginning of line found by the last call of |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
59 current_column. */ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
60 int current_column_bol_cache; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
61 |
165 | 62 /* Get the display table to use for the current buffer. */ |
63 | |
13185
5b1671bd3cc1
(buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents:
13124
diff
changeset
|
64 struct Lisp_Char_Table * |
165 | 65 buffer_display_table () |
66 { | |
67 Lisp_Object thisbuf; | |
68 | |
69 thisbuf = current_buffer->display_table; | |
13185
5b1671bd3cc1
(buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents:
13124
diff
changeset
|
70 if (DISP_TABLE_P (thisbuf)) |
5b1671bd3cc1
(buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents:
13124
diff
changeset
|
71 return XCHAR_TABLE (thisbuf); |
5b1671bd3cc1
(buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents:
13124
diff
changeset
|
72 if (DISP_TABLE_P (Vstandard_display_table)) |
5b1671bd3cc1
(buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents:
13124
diff
changeset
|
73 return XCHAR_TABLE (Vstandard_display_table); |
165 | 74 return 0; |
75 } | |
76 | |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
77 /* Width run cache considerations. */ |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
78 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
79 /* Return the width of character C under display table DP. */ |
11037
802a774b44b7
(compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents:
10964
diff
changeset
|
80 |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
81 static int |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
82 character_width (c, dp) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
83 int c; |
13185
5b1671bd3cc1
(buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents:
13124
diff
changeset
|
84 struct Lisp_Char_Table *dp; |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
85 { |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
86 Lisp_Object elt; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
87 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
88 /* These width computations were determined by examining the cases |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
89 in display_text_line. */ |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
90 |
11037
802a774b44b7
(compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents:
10964
diff
changeset
|
91 /* Everything can be handled by the display table, if it's |
802a774b44b7
(compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents:
10964
diff
changeset
|
92 present and the element is right. */ |
802a774b44b7
(compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents:
10964
diff
changeset
|
93 if (dp && (elt = DISP_CHAR_VECTOR (dp, c), VECTORP (elt))) |
802a774b44b7
(compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents:
10964
diff
changeset
|
94 return XVECTOR (elt)->size; |
802a774b44b7
(compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents:
10964
diff
changeset
|
95 |
802a774b44b7
(compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents:
10964
diff
changeset
|
96 /* Some characters are special. */ |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
97 if (c == '\n' || c == '\t' || c == '\015') |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
98 return 0; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
99 |
11037
802a774b44b7
(compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents:
10964
diff
changeset
|
100 /* Printing characters have width 1. */ |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
101 else if (c >= 040 && c < 0177) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
102 return 1; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
103 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
104 /* Everybody else (control characters, metacharacters) has other |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
105 widths. We could return their actual widths here, but they |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
106 depend on things like ctl_arrow and crud like that, and they're |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
107 not very common at all. So we'll just claim we don't know their |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
108 widths. */ |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
109 else |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
110 return 0; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
111 } |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
112 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
113 /* Return true iff the display table DISPTAB specifies the same widths |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
114 for characters as WIDTHTAB. We use this to decide when to |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
115 invalidate the buffer's width_run_cache. */ |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
116 int |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
117 disptab_matches_widthtab (disptab, widthtab) |
13185
5b1671bd3cc1
(buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents:
13124
diff
changeset
|
118 struct Lisp_Char_Table *disptab; |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
119 struct Lisp_Vector *widthtab; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
120 { |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
121 int i; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
122 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
123 if (widthtab->size != 256) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
124 abort (); |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
125 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
126 for (i = 0; i < 256; i++) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
127 if (character_width (i, disptab) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
128 != XFASTINT (widthtab->contents[i])) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
129 return 0; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
130 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
131 return 1; |
10538
48c620ae0853
(compute_motion): Don't get hung in selective-display loop.
Karl Heuer <kwzh@gnu.org>
parents:
10011
diff
changeset
|
132 } |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
133 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
134 /* Recompute BUF's width table, using the display table DISPTAB. */ |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
135 void |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
136 recompute_width_table (buf, disptab) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
137 struct buffer *buf; |
13185
5b1671bd3cc1
(buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents:
13124
diff
changeset
|
138 struct Lisp_Char_Table *disptab; |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
139 { |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
140 int i; |
10011
f4f2563057b8
(recompute_width_table): Do the right thing if no previous table existed.
Karl Heuer <kwzh@gnu.org>
parents:
9407
diff
changeset
|
141 struct Lisp_Vector *widthtab; |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
142 |
10011
f4f2563057b8
(recompute_width_table): Do the right thing if no previous table existed.
Karl Heuer <kwzh@gnu.org>
parents:
9407
diff
changeset
|
143 if (!VECTORP (buf->width_table)) |
f4f2563057b8
(recompute_width_table): Do the right thing if no previous table existed.
Karl Heuer <kwzh@gnu.org>
parents:
9407
diff
changeset
|
144 buf->width_table = Fmake_vector (make_number (256), make_number (0)); |
f4f2563057b8
(recompute_width_table): Do the right thing if no previous table existed.
Karl Heuer <kwzh@gnu.org>
parents:
9407
diff
changeset
|
145 widthtab = XVECTOR (buf->width_table); |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
146 if (widthtab->size != 256) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
147 abort (); |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
148 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
149 for (i = 0; i < 256; i++) |
10011
f4f2563057b8
(recompute_width_table): Do the right thing if no previous table existed.
Karl Heuer <kwzh@gnu.org>
parents:
9407
diff
changeset
|
150 XSETFASTINT (widthtab->contents[i], character_width (i, disptab)); |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
151 } |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
152 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
153 /* Allocate or free the width run cache, as requested by the current |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
154 state of current_buffer's cache_long_line_scans variable. */ |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
155 static void |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
156 width_run_cache_on_off () |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
157 { |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
158 if (NILP (current_buffer->cache_long_line_scans) |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
159 /* And, for the moment, this feature doesn't work on multibyte |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
160 characters. */ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
161 || !NILP (current_buffer->enable_multibyte_characters)) |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
162 { |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
163 /* It should be off. */ |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
164 if (current_buffer->width_run_cache) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
165 { |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
166 free_region_cache (current_buffer->width_run_cache); |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
167 current_buffer->width_run_cache = 0; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
168 current_buffer->width_table = Qnil; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
169 } |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
170 } |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
171 else |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
172 { |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
173 /* It should be on. */ |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
174 if (current_buffer->width_run_cache == 0) |
10538
48c620ae0853
(compute_motion): Don't get hung in selective-display loop.
Karl Heuer <kwzh@gnu.org>
parents:
10011
diff
changeset
|
175 { |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
176 current_buffer->width_run_cache = new_region_cache (); |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
177 recompute_width_table (current_buffer, buffer_display_table ()); |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
178 } |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
179 } |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
180 } |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
181 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
182 |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
183 /* Skip some invisible characters starting from POS. |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
184 This includes characters invisible because of text properties |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
185 and characters invisible because of overlays. |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
186 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
187 If position POS is followed by invisible characters, |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
188 skip some of them and return the position after them. |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
189 Otherwise return POS itself. |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
190 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
191 Set *NEXT_BOUNDARY_P to the next position at which |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
192 it will be necessary to call this function again. |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
193 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
194 Don't scan past TO, and don't set *NEXT_BOUNDARY_P |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
195 to a value greater than TO. |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
196 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
197 If WINDOW is non-nil, and this buffer is displayed in WINDOW, |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
198 take account of overlays that apply only in WINDOW. |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
199 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
200 We don't necessarily skip all the invisible characters after POS |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
201 because that could take a long time. We skip a reasonable number |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
202 which can be skipped quickly. If there might be more invisible |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
203 characters immediately following, then *NEXT_BOUNDARY_P |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
204 will equal the return value. */ |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
205 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
206 static int |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
207 skip_invisible (pos, next_boundary_p, to, window) |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
208 int pos; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
209 int *next_boundary_p; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
210 int to; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
211 Lisp_Object window; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
212 { |
18613
614b916ff5bf
Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents:
18109
diff
changeset
|
213 Lisp_Object prop, position, overlay_limit, proplimit; |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
214 Lisp_Object buffer; |
18613
614b916ff5bf
Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents:
18109
diff
changeset
|
215 int end; |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
216 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
217 XSETFASTINT (position, pos); |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
218 XSETBUFFER (buffer, current_buffer); |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
219 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
220 /* Give faster response for overlay lookup near POS. */ |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
221 recenter_overlay_lists (current_buffer, pos); |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
222 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
223 /* We must not advance farther than the next overlay change. |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
224 The overlay change might change the invisible property; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
225 or there might be overlay strings to be displayed there. */ |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
226 overlay_limit = Fnext_overlay_change (position); |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
227 /* As for text properties, this gives a lower bound |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
228 for where the invisible text property could change. */ |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
229 proplimit = Fnext_property_change (position, buffer, Qt); |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
230 if (XFASTINT (overlay_limit) < XFASTINT (proplimit)) |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
231 proplimit = overlay_limit; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
232 /* PROPLIMIT is now a lower bound for the next change |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
233 in invisible status. If that is plenty far away, |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
234 use that lower bound. */ |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
235 if (XFASTINT (proplimit) > pos + 100 || XFASTINT (proplimit) >= to) |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
236 *next_boundary_p = XFASTINT (proplimit); |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
237 /* Otherwise, scan for the next `invisible' property change. */ |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
238 else |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
239 { |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
240 /* Don't scan terribly far. */ |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
241 XSETFASTINT (proplimit, min (pos + 100, to)); |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
242 /* No matter what. don't go past next overlay change. */ |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
243 if (XFASTINT (overlay_limit) < XFASTINT (proplimit)) |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
244 proplimit = overlay_limit; |
18613
614b916ff5bf
Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents:
18109
diff
changeset
|
245 end = XFASTINT (Fnext_single_property_change (position, Qinvisible, |
614b916ff5bf
Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents:
18109
diff
changeset
|
246 buffer, proplimit)); |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
247 #if 0 |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
248 /* Don't put the boundary in the middle of multibyte form if |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
249 there is no actual property change. */ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
250 if (end == pos + 100 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
251 && !NILP (current_buffer->enable_multibyte_characters) |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
252 && end < ZV) |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
253 while (pos < end && !CHAR_HEAD_P (POS_ADDR (end))) |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
254 end--; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
255 #endif |
18613
614b916ff5bf
Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents:
18109
diff
changeset
|
256 *next_boundary_p = end; |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
257 } |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
258 /* if the `invisible' property is set, we can skip to |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
259 the next property change */ |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
260 if (!NILP (window) && EQ (XWINDOW (window)->buffer, buffer)) |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
261 prop = Fget_char_property (position, Qinvisible, window); |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
262 else |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
263 prop = Fget_char_property (position, Qinvisible, buffer); |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
264 if (TEXT_PROP_MEANS_INVISIBLE (prop)) |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
265 return *next_boundary_p; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
266 return pos; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
267 } |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
268 |
20938
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
269 /* Set variables WIDTH and BYTES for a multibyte sequence starting at P. |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
270 |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
271 C is *P which should satisfy `BASE_LEADING_CODE_P (c)'. |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
272 |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
273 DP is a display table or NULL. |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
274 |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
275 This macro is used in current_column_1, Fmove_to_column, and |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
276 compute_motion. */ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
277 |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
278 #define MULTIBYTE_BYTES_WIDTH(p, c, dp) \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
279 do { \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
280 unsigned char *pend = p + 1; \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
281 \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
282 wide_column = 0; \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
283 while (! CHAR_HEAD_P (*pend)) pend++; \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
284 \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
285 if (c == LEADING_CODE_COMPOSITION) \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
286 { \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
287 int id = str_cmpchar_id (p, pend - p); \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
288 int ch = MAKE_COMPOSITE_CHAR (id); \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
289 \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
290 if (id >= 0) \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
291 { \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
292 bytes = cmpchar_table[id]->len; \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
293 if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, ch))) \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
294 width = XVECTOR (DISP_CHAR_VECTOR (dp, ch))->size; \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
295 else \ |
21275
66f5ac2310fd
(MULTIBYTE_BYTES_WIDTH): Set wide_column only when we
Kenichi Handa <handa@m17n.org>
parents:
20985
diff
changeset
|
296 width = cmpchar_table[id]->width; \ |
66f5ac2310fd
(MULTIBYTE_BYTES_WIDTH): Set wide_column only when we
Kenichi Handa <handa@m17n.org>
parents:
20985
diff
changeset
|
297 if (width > 1) \ |
66f5ac2310fd
(MULTIBYTE_BYTES_WIDTH): Set wide_column only when we
Kenichi Handa <handa@m17n.org>
parents:
20985
diff
changeset
|
298 wide_column = width; \ |
20938
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
299 } \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
300 else \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
301 { \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
302 bytes = 1; \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
303 width = 4; \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
304 } \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
305 } \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
306 else \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
307 { \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
308 bytes = BYTES_BY_CHAR_HEAD (c); \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
309 if (bytes >= 2 && bytes <= pend - p) \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
310 { \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
311 int ch; \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
312 \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
313 if (dp && (ch = STRING_CHAR (p, bytes), \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
314 VECTORP (DISP_CHAR_VECTOR (dp, ch)))) \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
315 width = XVECTOR (DISP_CHAR_VECTOR (dp, ch))->size; \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
316 else \ |
21275
66f5ac2310fd
(MULTIBYTE_BYTES_WIDTH): Set wide_column only when we
Kenichi Handa <handa@m17n.org>
parents:
20985
diff
changeset
|
317 width = WIDTH_BY_CHAR_HEAD (c); \ |
66f5ac2310fd
(MULTIBYTE_BYTES_WIDTH): Set wide_column only when we
Kenichi Handa <handa@m17n.org>
parents:
20985
diff
changeset
|
318 if (width > 1) \ |
66f5ac2310fd
(MULTIBYTE_BYTES_WIDTH): Set wide_column only when we
Kenichi Handa <handa@m17n.org>
parents:
20985
diff
changeset
|
319 wide_column = width; \ |
20938
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
320 } \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
321 else \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
322 { \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
323 bytes = 1; \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
324 width = 4; \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
325 } \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
326 } \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
327 if (p + bytes < pend) \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
328 { \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
329 width += 4 * (pend - (p + bytes)); \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
330 bytes = pend - p; \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
331 } \ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
332 } while (0) |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
333 |
165 | 334 DEFUN ("current-column", Fcurrent_column, Scurrent_column, 0, 0, 0, |
335 "Return the horizontal position of point. Beginning of line is column 0.\n\ | |
336 This is calculated by adding together the widths of all the displayed\n\ | |
337 representations of the character between the start of the previous line\n\ | |
338 and point. (eg control characters will have a width of 2 or 4, tabs\n\ | |
339 will have a variable width)\n\ | |
764 | 340 Ignores finite width of frame, which means that this function may return\n\ |
341 values greater than (frame-width).\n\ | |
165 | 342 Whether the line is visible (if `selective-display' is t) has no effect;\n\ |
343 however, ^M is treated as end of line when `selective-display' is t.") | |
344 () | |
345 { | |
346 Lisp_Object temp; | |
9310
1dfd9def3467
(Fcurrent_column, Findent_to, Fcurrent_indentation, Fmove_to_column,
Karl Heuer <kwzh@gnu.org>
parents:
9269
diff
changeset
|
347 XSETFASTINT (temp, current_column ()); |
165 | 348 return temp; |
349 } | |
350 | |
327 | 351 /* Cancel any recorded value of the horizontal position. */ |
352 | |
20371
976eed15d6b5
(invalidate_current_column): Declare it as void.
Kenichi Handa <handa@m17n.org>
parents:
20256
diff
changeset
|
353 void |
327 | 354 invalidate_current_column () |
355 { | |
356 last_known_column_point = 0; | |
357 } | |
358 | |
165 | 359 int |
360 current_column () | |
361 { | |
362 register int col; | |
363 register unsigned char *ptr, *stop; | |
364 register int tab_seen; | |
365 int post_tab; | |
366 register int c; | |
367 register int tab_width = XINT (current_buffer->tab_width); | |
488 | 368 int ctl_arrow = !NILP (current_buffer->ctl_arrow); |
13185
5b1671bd3cc1
(buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents:
13124
diff
changeset
|
369 register struct Lisp_Char_Table *dp = buffer_display_table (); |
165 | 370 int stopchar; |
371 | |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15659
diff
changeset
|
372 if (PT == last_known_column_point |
165 | 373 && MODIFF == last_known_column_modified) |
374 return last_known_column; | |
375 | |
20694
83a65a1efdaa
(current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents:
20571
diff
changeset
|
376 /* If the buffer has overlays, text properties, |
83a65a1efdaa
(current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents:
20571
diff
changeset
|
377 or multibyte characters, use a more general algorithm. */ |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
378 if (BUF_INTERVALS (current_buffer) |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
379 || !NILP (current_buffer->overlays_before) |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
380 || !NILP (current_buffer->overlays_after) |
20694
83a65a1efdaa
(current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents:
20571
diff
changeset
|
381 || Z != Z_BYTE) |
83a65a1efdaa
(current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents:
20571
diff
changeset
|
382 return current_column_1 (); |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
383 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
384 /* Scan backwards from point to the previous newline, |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
385 counting width. Tab characters are the only complicated case. */ |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
386 |
165 | 387 /* Make a pointer for decrementing through the chars before point. */ |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
388 ptr = BYTE_POS_ADDR (PT_BYTE - 1) + 1; |
165 | 389 /* Make a pointer to where consecutive chars leave off, |
390 going backwards from point. */ | |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15659
diff
changeset
|
391 if (PT == BEGV) |
165 | 392 stop = ptr; |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15659
diff
changeset
|
393 else if (PT <= GPT || BEGV > GPT) |
165 | 394 stop = BEGV_ADDR; |
395 else | |
396 stop = GAP_END_ADDR; | |
397 | |
2325
7b5299f3a8fc
(current_column, Findent_to, position_indentation):
Richard M. Stallman <rms@gnu.org>
parents:
2017
diff
changeset
|
398 if (tab_width <= 0 || tab_width > 1000) tab_width = 8; |
165 | 399 |
400 col = 0, tab_seen = 0, post_tab = 0; | |
401 | |
402 while (1) | |
403 { | |
404 if (ptr == stop) | |
405 { | |
406 /* We stopped either for the beginning of the buffer | |
407 or for the gap. */ | |
408 if (ptr == BEGV_ADDR) | |
409 break; | |
410 /* It was the gap. Jump back over it. */ | |
411 stop = BEGV_ADDR; | |
412 ptr = GPT_ADDR; | |
413 /* Check whether that brings us to beginning of buffer. */ | |
414 if (BEGV >= GPT) break; | |
415 } | |
416 | |
417 c = *--ptr; | |
11037
802a774b44b7
(compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents:
10964
diff
changeset
|
418 if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, c))) |
802a774b44b7
(compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents:
10964
diff
changeset
|
419 col += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size; |
802a774b44b7
(compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents:
10964
diff
changeset
|
420 else if (c >= 040 && c < 0177) |
802a774b44b7
(compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents:
10964
diff
changeset
|
421 col++; |
19208
1d24f0a03f75
(current_column): Update ptr differently at newline
Richard M. Stallman <rms@gnu.org>
parents:
19080
diff
changeset
|
422 else if (c == '\n' |
1d24f0a03f75
(current_column): Update ptr differently at newline
Richard M. Stallman <rms@gnu.org>
parents:
19080
diff
changeset
|
423 || (c == '\r' && EQ (current_buffer->selective_display, Qt))) |
1d24f0a03f75
(current_column): Update ptr differently at newline
Richard M. Stallman <rms@gnu.org>
parents:
19080
diff
changeset
|
424 { |
1d24f0a03f75
(current_column): Update ptr differently at newline
Richard M. Stallman <rms@gnu.org>
parents:
19080
diff
changeset
|
425 ptr++; |
1d24f0a03f75
(current_column): Update ptr differently at newline
Richard M. Stallman <rms@gnu.org>
parents:
19080
diff
changeset
|
426 break; |
1d24f0a03f75
(current_column): Update ptr differently at newline
Richard M. Stallman <rms@gnu.org>
parents:
19080
diff
changeset
|
427 } |
165 | 428 else if (c == '\t') |
429 { | |
430 if (tab_seen) | |
431 col = ((col + tab_width) / tab_width) * tab_width; | |
432 | |
433 post_tab += col; | |
434 col = 0; | |
435 tab_seen = 1; | |
436 } | |
437 else | |
438 col += (ctl_arrow && c < 0200) ? 2 : 4; | |
439 } | |
440 | |
441 if (tab_seen) | |
442 { | |
443 col = ((col + tab_width) / tab_width) * tab_width; | |
444 col += post_tab; | |
445 } | |
446 | |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
447 if (ptr == BEGV_ADDR) |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
448 current_column_bol_cache = BEGV; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
449 else |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
450 current_column_bol_cache = BYTE_TO_CHAR (PTR_BYTE_POS (ptr)); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
451 |
165 | 452 last_known_column = col; |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15659
diff
changeset
|
453 last_known_column_point = PT; |
165 | 454 last_known_column_modified = MODIFF; |
455 | |
456 return col; | |
457 } | |
458 | |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
459 /* Return the column number of position POS |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
460 by scanning forward from the beginning of the line. |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
461 This function handles characters that are invisible |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
462 due to text properties or overlays. */ |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
463 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
464 static int |
20694
83a65a1efdaa
(current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents:
20571
diff
changeset
|
465 current_column_1 () |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
466 { |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
467 register int tab_width = XINT (current_buffer->tab_width); |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
468 register int ctl_arrow = !NILP (current_buffer->ctl_arrow); |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
469 register struct Lisp_Char_Table *dp = buffer_display_table (); |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
470 int multibyte = !NILP (current_buffer->enable_multibyte_characters); |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
471 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
472 /* Start the scan at the beginning of this line with column number 0. */ |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
473 register int col = 0; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
474 int scan, scan_byte; |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
475 int next_boundary, next_boundary_byte; |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
476 int opoint = PT, opoint_byte = PT_BYTE; |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
477 |
20694
83a65a1efdaa
(current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents:
20571
diff
changeset
|
478 scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -1, 1); |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
479 current_column_bol_cache = PT; |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
480 scan = PT, scan_byte = PT_BYTE; |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
481 SET_PT_BOTH (opoint, opoint_byte); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
482 next_boundary = scan; |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
483 next_boundary_byte = scan_byte; |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
484 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
485 if (tab_width <= 0 || tab_width > 1000) tab_width = 8; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
486 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
487 /* Scan forward to the target position. */ |
20694
83a65a1efdaa
(current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents:
20571
diff
changeset
|
488 while (scan < opoint) |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
489 { |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
490 int c; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
491 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
492 /* Occasionally we may need to skip invisible text. */ |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
493 while (scan == next_boundary) |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
494 { |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
495 int old_scan = scan; |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
496 /* This updates NEXT_BOUNDARY to the next place |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
497 where we might need to skip more invisible text. */ |
20694
83a65a1efdaa
(current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents:
20571
diff
changeset
|
498 scan = skip_invisible (scan, &next_boundary, opoint, Qnil); |
83a65a1efdaa
(current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents:
20571
diff
changeset
|
499 if (scan >= opoint) |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
500 goto endloop; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
501 if (scan != old_scan) |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
502 scan_byte = CHAR_TO_BYTE (scan); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
503 next_boundary_byte = CHAR_TO_BYTE (next_boundary); |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
504 } |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
505 |
20694
83a65a1efdaa
(current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents:
20571
diff
changeset
|
506 c = FETCH_BYTE (scan_byte); |
20938
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
507 if (dp != 0 |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
508 && ! (multibyte && BASE_LEADING_CODE_P (c)) |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
509 && VECTORP (DISP_CHAR_VECTOR (dp, c))) |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
510 { |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
511 col += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
512 scan++; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
513 scan_byte++; |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
514 continue; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
515 } |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
516 if (c == '\n') |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
517 break; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
518 if (c == '\r' && EQ (current_buffer->selective_display, Qt)) |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
519 break; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
520 scan++; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
521 scan_byte++; |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
522 if (c == '\t') |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
523 { |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
524 int prev_col = col; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
525 col += tab_width; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
526 col = col / tab_width * tab_width; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
527 } |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
528 else if (multibyte && BASE_LEADING_CODE_P (c)) |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
529 { |
20938
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
530 unsigned char *ptr; |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
531 int bytes, width, wide_column; |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
532 |
20938
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
533 scan_byte--; |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
534 ptr = BYTE_POS_ADDR (scan_byte); |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
535 MULTIBYTE_BYTES_WIDTH (ptr, c, dp); |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
536 scan_byte += bytes; |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
537 col += width; |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
538 } |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
539 else if (ctl_arrow && (c < 040 || c == 0177)) |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
540 col += 2; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
541 else if (c < 040 || c >= 0177) |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
542 col += 4; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
543 else |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
544 col++; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
545 } |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
546 endloop: |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
547 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
548 last_known_column = col; |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15659
diff
changeset
|
549 last_known_column_point = PT; |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
550 last_known_column_modified = MODIFF; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
551 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
552 return col; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
553 } |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
554 |
11300
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
555 /* Return the width in columns of the part of STRING from BEG to END. |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
556 If BEG is nil, that stands for the beginning of STRING. |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
557 If END is nil, that stands for the end of STRING. */ |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
558 |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
559 static int |
11704
6c9716b7a23d
(string_display_width): Renamed from string_width.
Richard M. Stallman <rms@gnu.org>
parents:
11312
diff
changeset
|
560 string_display_width (string, beg, end) |
11300
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
561 Lisp_Object string, beg, end; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
562 { |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
563 register int col; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
564 register unsigned char *ptr, *stop; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
565 register int tab_seen; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
566 int post_tab; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
567 register int c; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
568 register int tab_width = XINT (current_buffer->tab_width); |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
569 int ctl_arrow = !NILP (current_buffer->ctl_arrow); |
13185
5b1671bd3cc1
(buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents:
13124
diff
changeset
|
570 register struct Lisp_Char_Table *dp = buffer_display_table (); |
11300
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
571 int b, e; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
572 |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
573 if (NILP (end)) |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
574 e = XSTRING (string)->size; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
575 else |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
576 { |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
577 CHECK_NUMBER (end, 0); |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
578 e = XINT (end); |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
579 } |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
580 |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
581 if (NILP (beg)) |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
582 b = 0; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
583 else |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
584 { |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
585 CHECK_NUMBER (beg, 0); |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
586 b = XINT (beg); |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
587 } |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
588 |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
589 /* Make a pointer for decrementing through the chars before point. */ |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
590 ptr = XSTRING (string)->data + e; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
591 /* Make a pointer to where consecutive chars leave off, |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
592 going backwards from point. */ |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
593 stop = XSTRING (string)->data + b; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
594 |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
595 if (tab_width <= 0 || tab_width > 1000) tab_width = 8; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
596 |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
597 col = 0, tab_seen = 0, post_tab = 0; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
598 |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
599 while (1) |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
600 { |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
601 if (ptr == stop) |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
602 break; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
603 |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
604 c = *--ptr; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
605 if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, c))) |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
606 col += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
607 else if (c >= 040 && c < 0177) |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
608 col++; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
609 else if (c == '\n') |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
610 break; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
611 else if (c == '\t') |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
612 { |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
613 if (tab_seen) |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
614 col = ((col + tab_width) / tab_width) * tab_width; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
615 |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
616 post_tab += col; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
617 col = 0; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
618 tab_seen = 1; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
619 } |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
620 else |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
621 col += (ctl_arrow && c < 0200) ? 2 : 4; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
622 } |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
623 |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
624 if (tab_seen) |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
625 { |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
626 col = ((col + tab_width) / tab_width) * tab_width; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
627 col += post_tab; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
628 } |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
629 |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
630 return col; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
631 } |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
632 |
165 | 633 DEFUN ("indent-to", Findent_to, Sindent_to, 1, 2, "NIndent to column: ", |
634 "Indent from point with tabs and spaces until COLUMN is reached.\n\ | |
14078
a46002ac278b
(Findent_to): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
13453
diff
changeset
|
635 Optional second argument MININUM says always do at least MININUM spaces\n\ |
a46002ac278b
(Findent_to): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
13453
diff
changeset
|
636 even if that goes past COLUMN; by default, MININUM is zero.") |
a46002ac278b
(Findent_to): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
13453
diff
changeset
|
637 (column, minimum) |
a46002ac278b
(Findent_to): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
13453
diff
changeset
|
638 Lisp_Object column, minimum; |
165 | 639 { |
640 int mincol; | |
641 register int fromcol; | |
642 register int tab_width = XINT (current_buffer->tab_width); | |
643 | |
14078
a46002ac278b
(Findent_to): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
13453
diff
changeset
|
644 CHECK_NUMBER (column, 0); |
488 | 645 if (NILP (minimum)) |
9310
1dfd9def3467
(Fcurrent_column, Findent_to, Fcurrent_indentation, Fmove_to_column,
Karl Heuer <kwzh@gnu.org>
parents:
9269
diff
changeset
|
646 XSETFASTINT (minimum, 0); |
165 | 647 CHECK_NUMBER (minimum, 1); |
648 | |
649 fromcol = current_column (); | |
650 mincol = fromcol + XINT (minimum); | |
14078
a46002ac278b
(Findent_to): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
13453
diff
changeset
|
651 if (mincol < XINT (column)) mincol = XINT (column); |
165 | 652 |
653 if (fromcol == mincol) | |
654 return make_number (mincol); | |
655 | |
2325
7b5299f3a8fc
(current_column, Findent_to, position_indentation):
Richard M. Stallman <rms@gnu.org>
parents:
2017
diff
changeset
|
656 if (tab_width <= 0 || tab_width > 1000) tab_width = 8; |
165 | 657 |
658 if (indent_tabs_mode) | |
659 { | |
660 Lisp_Object n; | |
9310
1dfd9def3467
(Fcurrent_column, Findent_to, Fcurrent_indentation, Fmove_to_column,
Karl Heuer <kwzh@gnu.org>
parents:
9269
diff
changeset
|
661 XSETFASTINT (n, mincol / tab_width - fromcol / tab_width); |
165 | 662 if (XFASTINT (n) != 0) |
663 { | |
8648
f047d8c6db79
(Findent_to): Pass new arg to Finsert_char.
Richard M. Stallman <rms@gnu.org>
parents:
8601
diff
changeset
|
664 Finsert_char (make_number ('\t'), n, Qt); |
165 | 665 |
666 fromcol = (mincol / tab_width) * tab_width; | |
667 } | |
668 } | |
669 | |
14078
a46002ac278b
(Findent_to): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
13453
diff
changeset
|
670 XSETFASTINT (column, mincol - fromcol); |
a46002ac278b
(Findent_to): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
13453
diff
changeset
|
671 Finsert_char (make_number (' '), column, Qt); |
165 | 672 |
673 last_known_column = mincol; | |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15659
diff
changeset
|
674 last_known_column_point = PT; |
165 | 675 last_known_column_modified = MODIFF; |
676 | |
14078
a46002ac278b
(Findent_to): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
13453
diff
changeset
|
677 XSETINT (column, mincol); |
a46002ac278b
(Findent_to): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
13453
diff
changeset
|
678 return column; |
165 | 679 } |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
680 |
165 | 681 |
682 DEFUN ("current-indentation", Fcurrent_indentation, Scurrent_indentation, | |
683 0, 0, 0, | |
684 "Return the indentation of the current line.\n\ | |
685 This is the horizontal position of the character\n\ | |
686 following any initial whitespace.") | |
687 () | |
688 { | |
689 Lisp_Object val; | |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
690 int opoint = PT, opoint_byte = PT_BYTE; |
165 | 691 |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
692 scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -1, 1); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
693 |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
694 XSETFASTINT (val, position_indentation (PT_BYTE)); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
695 SET_PT_BOTH (opoint, opoint_byte); |
165 | 696 return val; |
697 } | |
698 | |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
699 static int |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
700 position_indentation (pos_byte) |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
701 register int pos_byte; |
165 | 702 { |
703 register int column = 0; | |
704 register int tab_width = XINT (current_buffer->tab_width); | |
705 register unsigned char *p; | |
706 register unsigned char *stop; | |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
707 unsigned char *start; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
708 int next_boundary_byte = pos_byte; |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
709 int ceiling = next_boundary_byte; |
10538
48c620ae0853
(compute_motion): Don't get hung in selective-display loop.
Karl Heuer <kwzh@gnu.org>
parents:
10011
diff
changeset
|
710 |
2325
7b5299f3a8fc
(current_column, Findent_to, position_indentation):
Richard M. Stallman <rms@gnu.org>
parents:
2017
diff
changeset
|
711 if (tab_width <= 0 || tab_width > 1000) tab_width = 8; |
10538
48c620ae0853
(compute_motion): Don't get hung in selective-display loop.
Karl Heuer <kwzh@gnu.org>
parents:
10011
diff
changeset
|
712 |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
713 p = BYTE_POS_ADDR (pos_byte); |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
714 /* STOP records the value of P at which we will need |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
715 to think about the gap, or about invisible text, |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
716 or about the end of the buffer. */ |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
717 stop = p; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
718 /* START records the starting value of P. */ |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
719 start = p; |
165 | 720 while (1) |
721 { | |
722 while (p == stop) | |
723 { | |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
724 int stop_pos_byte; |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
725 |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
726 /* If we have updated P, set POS_BYTE to match. |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
727 The first time we enter the loop, POS_BYTE is already right. */ |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
728 if (p != start) |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
729 pos_byte = PTR_BYTE_POS (p); |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
730 /* Consider the various reasons STOP might have been set here. */ |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
731 if (pos_byte == ZV_BYTE) |
165 | 732 return column; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
733 if (pos_byte == next_boundary_byte) |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
734 { |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
735 int next_boundary; |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
736 int pos = BYTE_TO_CHAR (pos_byte); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
737 pos = skip_invisible (pos, &next_boundary, ZV, Qnil); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
738 pos_byte = CHAR_TO_BYTE (pos); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
739 next_boundary_byte = CHAR_TO_BYTE (next_boundary); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
740 } |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
741 if (pos_byte >= ceiling) |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
742 ceiling = BUFFER_CEILING_OF (pos_byte) + 1; |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
743 /* Compute the next place we need to stop and think, |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
744 and set STOP accordingly. */ |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
745 stop_pos_byte = min (ceiling, next_boundary_byte); |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
746 /* The -1 and +1 arrange to point at the first byte of gap |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
747 (if STOP_POS_BYTE is the position of the gap) |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
748 rather than at the data after the gap. */ |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
749 |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
750 stop = BYTE_POS_ADDR (stop_pos_byte - 1) + 1; |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
751 p = BYTE_POS_ADDR (pos_byte); |
165 | 752 } |
753 switch (*p++) | |
754 { | |
20256
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
755 case 0240: |
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
756 if (! NILP (current_buffer->enable_multibyte_characters)) |
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
757 return column; |
165 | 758 case ' ': |
759 column++; | |
760 break; | |
761 case '\t': | |
762 column += tab_width - column % tab_width; | |
763 break; | |
764 default: | |
20256
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
765 if (ASCII_BYTE_P (p[-1]) |
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
766 || NILP (current_buffer->enable_multibyte_characters)) |
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
767 return column; |
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
768 { |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
769 int c; |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
770 pos_byte = PTR_BYTE_POS (p - 1); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
771 c = FETCH_MULTIBYTE_CHAR (pos_byte); |
20256
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
772 if (CHAR_HAS_CATEGORY (c, ' ')) |
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
773 { |
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
774 column++; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
775 INC_POS (pos_byte); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
776 p = BYTE_POS_ADDR (pos_byte); |
20256
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
777 } |
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
778 else |
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
779 return column; |
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
780 } |
165 | 781 } |
782 } | |
783 } | |
5943
35526ee8b790
(indented_beyond_p): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5941
diff
changeset
|
784 |
35526ee8b790
(indented_beyond_p): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5941
diff
changeset
|
785 /* Test whether the line beginning at POS is indented beyond COLUMN. |
35526ee8b790
(indented_beyond_p): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5941
diff
changeset
|
786 Blank lines are treated as if they had the same indentation as the |
35526ee8b790
(indented_beyond_p): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5941
diff
changeset
|
787 preceding line. */ |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
788 |
5943
35526ee8b790
(indented_beyond_p): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5941
diff
changeset
|
789 int |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
790 indented_beyond_p (pos, pos_byte, column) |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
791 int pos, pos_byte, column; |
5943
35526ee8b790
(indented_beyond_p): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5941
diff
changeset
|
792 { |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
793 Lisp_Object val; |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
794 int opoint = PT, opoint_byte = PT_BYTE; |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
795 |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
796 SET_PT_BOTH (pos, pos_byte); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
797 while (PT > BEGV && FETCH_BYTE (PT_BYTE) == '\n') |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
798 scan_newline (PT - 1, PT_BYTE - 1, BEGV, BEGV_BYTE, -1, 0); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
799 |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
800 XSETFASTINT (val, position_indentation (PT_BYTE)); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
801 SET_PT_BOTH (opoint, opoint_byte); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
802 return val; |
5943
35526ee8b790
(indented_beyond_p): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5941
diff
changeset
|
803 } |
165 | 804 |
13124
e44b06fc718d
(Fmove_to_column): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
805 DEFUN ("move-to-column", Fmove_to_column, Smove_to_column, 1, 2, "p", |
165 | 806 "Move point to column COLUMN in the current line.\n\ |
807 The column of a character is calculated by adding together the widths\n\ | |
808 as displayed of the previous characters in the line.\n\ | |
809 This function ignores line-continuation;\n\ | |
810 there is no upper limit on the column number a character can have\n\ | |
1208
fa662930e654
* indent.c (Fmove_to_column): Pass the right number of arguments
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
811 and horizontal scrolling has no effect.\n\ |
fa662930e654
* indent.c (Fmove_to_column): Pass the right number of arguments
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
812 \n\ |
165 | 813 If specified column is within a character, point goes after that character.\n\ |
814 If it's past end of line, point goes to end of line.\n\n\ | |
815 A non-nil second (optional) argument FORCE means, if the line\n\ | |
816 is too short to reach column COLUMN then add spaces/tabs to get there,\n\ | |
13453
ea373c55ed95
(Fmove_to_column): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
13363
diff
changeset
|
817 and if COLUMN is in the middle of a tab character, change it to spaces.\n\ |
ea373c55ed95
(Fmove_to_column): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
13363
diff
changeset
|
818 \n\ |
ea373c55ed95
(Fmove_to_column): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
13363
diff
changeset
|
819 The return value is the current column.") |
165 | 820 (column, force) |
821 Lisp_Object column, force; | |
822 { | |
823 register int pos; | |
824 register int col = current_column (); | |
825 register int goal; | |
826 register int end; | |
827 register int tab_width = XINT (current_buffer->tab_width); | |
488 | 828 register int ctl_arrow = !NILP (current_buffer->ctl_arrow); |
13185
5b1671bd3cc1
(buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents:
13124
diff
changeset
|
829 register struct Lisp_Char_Table *dp = buffer_display_table (); |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
830 register int multibyte = !NILP (current_buffer->enable_multibyte_characters); |
165 | 831 |
832 Lisp_Object val; | |
833 int prev_col; | |
834 int c; | |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
835 int next_boundary; |
165 | 836 |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
837 int pos_byte, end_byte, next_boundary_byte; |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
838 |
2325
7b5299f3a8fc
(current_column, Findent_to, position_indentation):
Richard M. Stallman <rms@gnu.org>
parents:
2017
diff
changeset
|
839 if (tab_width <= 0 || tab_width > 1000) tab_width = 8; |
165 | 840 CHECK_NATNUM (column, 0); |
841 goal = XINT (column); | |
842 | |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15659
diff
changeset
|
843 pos = PT; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
844 pos_byte = PT_BYTE; |
165 | 845 end = ZV; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
846 end_byte = ZV_BYTE; |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
847 next_boundary = pos; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
848 next_boundary_byte = PT_BYTE; |
165 | 849 |
850 /* If we're starting past the desired column, | |
851 back up to beginning of line and scan from there. */ | |
852 if (col > goal) | |
853 { | |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
854 end = pos; |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
855 pos = current_column_bol_cache; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
856 pos_byte = CHAR_TO_BYTE (pos); |
165 | 857 col = 0; |
858 } | |
859 | |
15554
103a6af424a8
(Fmove_to_column): Go after invis chars at the goal column.
Richard M. Stallman <rms@gnu.org>
parents:
15494
diff
changeset
|
860 while (pos < end) |
165 | 861 { |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
862 while (pos == next_boundary) |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
863 { |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
864 int prev = pos; |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
865 pos = skip_invisible (pos, &next_boundary, end, Qnil); |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
866 if (pos != prev) |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
867 pos_byte = CHAR_TO_BYTE (pos); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
868 next_boundary_byte = CHAR_TO_BYTE (next_boundary); |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
869 if (pos >= end) |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
870 goto endloop; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
871 } |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
872 |
15554
103a6af424a8
(Fmove_to_column): Go after invis chars at the goal column.
Richard M. Stallman <rms@gnu.org>
parents:
15494
diff
changeset
|
873 /* Test reaching the goal column. We do this after skipping |
103a6af424a8
(Fmove_to_column): Go after invis chars at the goal column.
Richard M. Stallman <rms@gnu.org>
parents:
15494
diff
changeset
|
874 invisible characters, so that we put point before the |
103a6af424a8
(Fmove_to_column): Go after invis chars at the goal column.
Richard M. Stallman <rms@gnu.org>
parents:
15494
diff
changeset
|
875 character on which the cursor will appear. */ |
103a6af424a8
(Fmove_to_column): Go after invis chars at the goal column.
Richard M. Stallman <rms@gnu.org>
parents:
15494
diff
changeset
|
876 if (col >= goal) |
103a6af424a8
(Fmove_to_column): Go after invis chars at the goal column.
Richard M. Stallman <rms@gnu.org>
parents:
15494
diff
changeset
|
877 break; |
103a6af424a8
(Fmove_to_column): Go after invis chars at the goal column.
Richard M. Stallman <rms@gnu.org>
parents:
15494
diff
changeset
|
878 |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
879 c = FETCH_BYTE (pos_byte); |
20938
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
880 if (dp != 0 |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
881 && ! (multibyte && BASE_LEADING_CODE_P (c)) |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
882 && VECTORP (DISP_CHAR_VECTOR (dp, c))) |
11037
802a774b44b7
(compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents:
10964
diff
changeset
|
883 { |
802a774b44b7
(compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents:
10964
diff
changeset
|
884 col += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
885 pos_byte++; |
11037
802a774b44b7
(compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents:
10964
diff
changeset
|
886 pos++; |
11312
f48922d85166
(Fmove_to_column): Fix minor bug in prev change.
Richard M. Stallman <rms@gnu.org>
parents:
11300
diff
changeset
|
887 continue; |
11037
802a774b44b7
(compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents:
10964
diff
changeset
|
888 } |
165 | 889 if (c == '\n') |
890 break; | |
891 if (c == '\r' && EQ (current_buffer->selective_display, Qt)) | |
892 break; | |
893 pos++; | |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
894 pos_byte++; |
165 | 895 if (c == '\t') |
896 { | |
897 prev_col = col; | |
898 col += tab_width; | |
899 col = col / tab_width * tab_width; | |
900 } | |
901 else if (ctl_arrow && (c < 040 || c == 0177)) | |
5162
9672138155c1
(Fmove_to_column): Increments for control characters
Richard M. Stallman <rms@gnu.org>
parents:
5085
diff
changeset
|
902 col += 2; |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
903 else if (c < 040 || c == 0177) |
5162
9672138155c1
(Fmove_to_column): Increments for control characters
Richard M. Stallman <rms@gnu.org>
parents:
5085
diff
changeset
|
904 col += 4; |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
905 else if (c < 0177) |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
906 col++; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
907 else if (multibyte && BASE_LEADING_CODE_P (c)) |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
908 { |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
909 /* Start of multi-byte form. */ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
910 unsigned char *ptr; |
20938
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
911 int bytes, width, wide_column; |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
912 |
20938
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
913 pos_byte--; |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
914 ptr = BYTE_POS_ADDR (pos_byte); |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
915 MULTIBYTE_BYTES_WIDTH (ptr, c, dp); |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
916 pos_byte += bytes; |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
917 col += width; |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
918 } |
165 | 919 else |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
920 col += 4; |
165 | 921 } |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
922 endloop: |
165 | 923 |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
924 SET_PT_BOTH (pos, pos_byte); |
165 | 925 |
926 /* If a tab char made us overshoot, change it to spaces | |
927 and scan through it again. */ | |
488 | 928 if (!NILP (force) && col > goal && c == '\t' && prev_col < goal) |
165 | 929 { |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
930 int old_point, old_point_byte; |
573 | 931 |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15659
diff
changeset
|
932 del_range (PT - 1, PT); |
573 | 933 Findent_to (make_number (goal), Qnil); |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15659
diff
changeset
|
934 old_point = PT; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
935 old_point_byte = PT_BYTE; |
573 | 936 Findent_to (make_number (col), Qnil); |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
937 SET_PT_BOTH (old_point, old_point_byte); |
4385
edffa4f0c5d9
(compute_motion): Compute correctly for invisible text.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
938 /* Set the last_known... vars consistently. */ |
edffa4f0c5d9
(compute_motion): Compute correctly for invisible text.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
939 col = goal; |
165 | 940 } |
941 | |
942 /* If line ends prematurely, add space to the end. */ | |
488 | 943 if (col < goal && !NILP (force)) |
1208
fa662930e654
* indent.c (Fmove_to_column): Pass the right number of arguments
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
944 Findent_to (make_number (col = goal), Qnil); |
165 | 945 |
946 last_known_column = col; | |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15659
diff
changeset
|
947 last_known_column_point = PT; |
165 | 948 last_known_column_modified = MODIFF; |
949 | |
9310
1dfd9def3467
(Fcurrent_column, Findent_to, Fcurrent_indentation, Fmove_to_column,
Karl Heuer <kwzh@gnu.org>
parents:
9269
diff
changeset
|
950 XSETFASTINT (val, col); |
165 | 951 return val; |
952 } | |
953 | |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
954 /* compute_motion: compute buffer posn given screen posn and vice versa */ |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
955 |
165 | 956 struct position val_compute_motion; |
957 | |
958 /* Scan the current buffer forward from offset FROM, pretending that | |
959 this is at line FROMVPOS, column FROMHPOS, until reaching buffer | |
960 offset TO or line TOVPOS, column TOHPOS (whichever comes first), | |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
961 and return the ending buffer position and screen location. If we |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
962 can't hit the requested column exactly (because of a tab or other |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
963 multi-column character), overshoot. |
165 | 964 |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
965 DID_MOTION is 1 if FROMHPOS has already accounted for overlay strings |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
966 at FROM. This is the case if FROMVPOS and FROMVPOS came from an |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
967 earlier call to compute_motion. The other common case is that FROMHPOS |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
968 is zero and FROM is a position that "belongs" at column zero, but might |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
969 be shifted by overlay strings; in this case DID_MOTION should be 0. |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
970 |
165 | 971 WIDTH is the number of columns available to display text; |
972 compute_motion uses this to handle continuation lines and such. | |
973 HSCROLL is the number of columns not being displayed at the left | |
974 margin; this is usually taken from a window's hscroll member. | |
543 | 975 TAB_OFFSET is the number of columns of the first tab that aren't |
976 being displayed, perhaps because of a continuation line or | |
977 something. | |
165 | 978 |
979 compute_motion returns a pointer to a struct position. The bufpos | |
980 member gives the buffer position at the end of the scan, and hpos | |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
981 and vpos give its cartesian location. prevhpos is the column at |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
982 which the character before bufpos started, and contin is non-zero |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
983 if we reached the current line by continuing the previous. |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
984 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
985 Note that FROMHPOS and TOHPOS should be expressed in real screen |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
986 columns, taking HSCROLL and the truncation glyph at the left margin |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
987 into account. That is, beginning-of-line moves you to the hpos |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
988 -HSCROLL + (HSCROLL > 0). |
165 | 989 |
990 For example, to find the buffer position of column COL of line LINE | |
991 of a certain window, pass the window's starting location as FROM | |
992 and the window's upper-left coordinates as FROMVPOS and FROMHPOS. | |
993 Pass the buffer's ZV as TO, to limit the scan to the end of the | |
994 visible section of the buffer, and pass LINE and COL as TOVPOS and | |
10538
48c620ae0853
(compute_motion): Don't get hung in selective-display loop.
Karl Heuer <kwzh@gnu.org>
parents:
10011
diff
changeset
|
995 TOHPOS. |
165 | 996 |
997 When displaying in window w, a typical formula for WIDTH is: | |
998 | |
999 window_width - 1 | |
1994
73ce9dd21093
Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents:
1777
diff
changeset
|
1000 - (has_vertical_scroll_bars |
8946 | 1001 ? FRAME_SCROLL_BAR_COLS (XFRAME (window->frame)) |
1777
4edfaa19c7a7
* window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents:
1208
diff
changeset
|
1002 : (window_width + window_left != frame_width)) |
165 | 1003 |
1004 where | |
1005 window_width is XFASTINT (w->width), | |
1006 window_left is XFASTINT (w->left), | |
1994
73ce9dd21093
Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents:
1777
diff
changeset
|
1007 has_vertical_scroll_bars is |
73ce9dd21093
Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents:
1777
diff
changeset
|
1008 FRAME_HAS_VERTICAL_SCROLL_BARS (XFRAME (WINDOW_FRAME (window))) |
1777
4edfaa19c7a7
* window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents:
1208
diff
changeset
|
1009 and frame_width = FRAME_WIDTH (XFRAME (window->frame)) |
165 | 1010 |
6400 | 1011 Or you can let window_internal_width do this all for you, and write: |
1012 window_internal_width (w) - 1 | |
1777
4edfaa19c7a7
* window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents:
1208
diff
changeset
|
1013 |
4edfaa19c7a7
* window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents:
1208
diff
changeset
|
1014 The `-1' accounts for the continuation-line backslashes; the rest |
5941 | 1015 accounts for window borders if the window is split horizontally, and |
6400 | 1016 the scroll bars if they are turned on. */ |
165 | 1017 |
1018 struct position * | |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1019 compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width, hscroll, tab_offset, win) |
165 | 1020 int from, fromvpos, fromhpos, to, tovpos, tohpos; |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1021 int did_motion; |
165 | 1022 register int width; |
1023 int hscroll, tab_offset; | |
6691
3b56d4742266
(compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents:
6588
diff
changeset
|
1024 struct window *win; |
165 | 1025 { |
526 | 1026 register int hpos = fromhpos; |
1027 register int vpos = fromvpos; | |
165 | 1028 |
1029 register int pos; | |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1030 int pos_byte; |
165 | 1031 register int c; |
1032 register int tab_width = XFASTINT (current_buffer->tab_width); | |
488 | 1033 register int ctl_arrow = !NILP (current_buffer->ctl_arrow); |
13185
5b1671bd3cc1
(buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents:
13124
diff
changeset
|
1034 register struct Lisp_Char_Table *dp = window_display_table (win); |
165 | 1035 int selective |
9126
e475f8108156
(buffer_display_table, current_column, Fmove_to_column, compute_motion,
Karl Heuer <kwzh@gnu.org>
parents:
8946
diff
changeset
|
1036 = (INTEGERP (current_buffer->selective_display) |
6846
a6803ff29cca
(compute_motion): Do not abort if window shows some other buffer.
Richard M. Stallman <rms@gnu.org>
parents:
6811
diff
changeset
|
1037 ? XINT (current_buffer->selective_display) |
a6803ff29cca
(compute_motion): Do not abort if window shows some other buffer.
Richard M. Stallman <rms@gnu.org>
parents:
6811
diff
changeset
|
1038 : !NILP (current_buffer->selective_display) ? -1 : 0); |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1039 int prev_hpos = 0; |
165 | 1040 int selective_rlen |
9126
e475f8108156
(buffer_display_table, current_column, Fmove_to_column, compute_motion,
Karl Heuer <kwzh@gnu.org>
parents:
8946
diff
changeset
|
1041 = (selective && dp && VECTORP (DISP_INVIS_VECTOR (dp)) |
2017
ffa43acb7de7
(current_column, Fmove_to_column, compute_motion):
Richard M. Stallman <rms@gnu.org>
parents:
1994
diff
changeset
|
1042 ? XVECTOR (DISP_INVIS_VECTOR (dp))->size : 0); |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1043 /* The next location where the `invisible' property changes, or an |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1044 overlay starts or ends. */ |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1045 int next_boundary = from; |
165 | 1046 |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1047 /* For computing runs of characters with similar widths. |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1048 Invariant: width_run_width is zero, or all the characters |
10538
48c620ae0853
(compute_motion): Don't get hung in selective-display loop.
Karl Heuer <kwzh@gnu.org>
parents:
10011
diff
changeset
|
1049 from width_run_start to width_run_end have a fixed width of |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1050 width_run_width. */ |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1051 int width_run_start = from; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1052 int width_run_end = from; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1053 int width_run_width = 0; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1054 Lisp_Object *width_table; |
10964
474b6b03a71f
(compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents:
10538
diff
changeset
|
1055 Lisp_Object buffer; |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1056 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1057 /* The next buffer pos where we should consult the width run cache. */ |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1058 int next_width_run = from; |
15059
3b7454f2d662
(compute_motion): Pass window to Fget_char_property.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
1059 Lisp_Object window; |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1060 |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1061 int multibyte = !NILP (current_buffer->enable_multibyte_characters); |
20938
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
1062 int wide_column_end_hpos = 0; /* Horizontal position at the end of |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
1063 last wide-column character. */ |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1064 int prev_pos; /* Previous buffer position. */ |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1065 int prev_pos_byte; /* Previous buffer position. */ |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1066 int contin_hpos; /* HPOS of last column of continued line. */ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1067 int prev_tab_offset; /* Previous tab offset. */ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1068 |
10964
474b6b03a71f
(compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents:
10538
diff
changeset
|
1069 XSETBUFFER (buffer, current_buffer); |
15059
3b7454f2d662
(compute_motion): Pass window to Fget_char_property.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
1070 XSETWINDOW (window, win); |
10964
474b6b03a71f
(compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents:
10538
diff
changeset
|
1071 |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1072 width_run_cache_on_off (); |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1073 if (dp == buffer_display_table ()) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1074 width_table = (VECTORP (current_buffer->width_table) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1075 ? XVECTOR (current_buffer->width_table)->contents |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1076 : 0); |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1077 else |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1078 /* If the window has its own display table, we can't use the width |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1079 run cache, because that's based on the buffer's display table. */ |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1080 width_table = 0; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1081 |
2325
7b5299f3a8fc
(current_column, Findent_to, position_indentation):
Richard M. Stallman <rms@gnu.org>
parents:
2017
diff
changeset
|
1082 if (tab_width <= 0 || tab_width > 1000) tab_width = 8; |
526 | 1083 |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1084 pos = prev_pos = from; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1085 pos_byte = prev_pos_byte = CHAR_TO_BYTE (from); |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1086 contin_hpos = 0; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1087 prev_tab_offset = tab_offset; |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1088 while (1) |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1089 { |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1090 while (pos == next_boundary) |
5085
82bcf2c36929
(compute_motion): Pass new arg to Fnext_single_property_change.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
1091 { |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1092 int pos_here = pos; |
17966
aaa25a87ae3d
(compute_motion): Return correctly if skip_invisible
Richard M. Stallman <rms@gnu.org>
parents:
17136
diff
changeset
|
1093 int newpos; |
aaa25a87ae3d
(compute_motion): Return correctly if skip_invisible
Richard M. Stallman <rms@gnu.org>
parents:
17136
diff
changeset
|
1094 |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1095 /* If the caller says that the screen position came from an earlier |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1096 call to compute_motion, then we've already accounted for the |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1097 overlay strings at point. This is only true the first time |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1098 through, so clear the flag after testing it. */ |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1099 if (!did_motion) |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1100 /* We need to skip past the overlay strings. Currently those |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1101 strings must not contain TAB; |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1102 if we want to relax that restriction, something will have |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1103 to be changed here. */ |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1104 { |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1105 unsigned char *ovstr; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1106 int ovlen = overlay_strings (pos, win, &ovstr); |
21283
c431691cbff1
(compute_motion): Call strwidth only when necessary.
Kenichi Handa <handa@m17n.org>
parents:
21275
diff
changeset
|
1107 hpos += ((multibyte && ovlen > 0) |
c431691cbff1
(compute_motion): Call strwidth only when necessary.
Kenichi Handa <handa@m17n.org>
parents:
21275
diff
changeset
|
1108 ? strwidth (ovstr, ovlen) : ovlen); |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1109 } |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1110 did_motion = 0; |
10964
474b6b03a71f
(compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents:
10538
diff
changeset
|
1111 |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1112 if (pos >= to) |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1113 break; |
10964
474b6b03a71f
(compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents:
10538
diff
changeset
|
1114 |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
1115 /* Advance POS past invisible characters |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
1116 (but not necessarily all that there are here), |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
1117 and store in next_boundary the next position where |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
1118 we need to call skip_invisible. */ |
17966
aaa25a87ae3d
(compute_motion): Return correctly if skip_invisible
Richard M. Stallman <rms@gnu.org>
parents:
17136
diff
changeset
|
1119 newpos = skip_invisible (pos, &next_boundary, to, window); |
aaa25a87ae3d
(compute_motion): Return correctly if skip_invisible
Richard M. Stallman <rms@gnu.org>
parents:
17136
diff
changeset
|
1120 |
aaa25a87ae3d
(compute_motion): Return correctly if skip_invisible
Richard M. Stallman <rms@gnu.org>
parents:
17136
diff
changeset
|
1121 if (newpos >= to) |
aaa25a87ae3d
(compute_motion): Return correctly if skip_invisible
Richard M. Stallman <rms@gnu.org>
parents:
17136
diff
changeset
|
1122 goto after_loop; |
aaa25a87ae3d
(compute_motion): Return correctly if skip_invisible
Richard M. Stallman <rms@gnu.org>
parents:
17136
diff
changeset
|
1123 |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1124 if (newpos != pos_here) |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1125 { |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1126 pos = newpos; |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1127 pos_byte = CHAR_TO_BYTE (pos); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1128 } |
5085
82bcf2c36929
(compute_motion): Pass new arg to Fnext_single_property_change.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
1129 } |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1130 |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1131 /* Handle right margin. */ |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1132 /* Note on a wide-column character. |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1133 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1134 Characters are classified into the following three categories |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1135 according to the width (columns occupied on screen). |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1136 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1137 (1) single-column character: ex. `a' |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1138 (2) multi-column character: ex. `^A', TAB, `\033' |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1139 (3) wide-column character: ex. Japanese character, Chinese character |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1140 (In the following example, `W_' stands for them.) |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1141 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1142 Multi-column characters can be divided around the right margin, |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1143 but wide-column characters cannot. |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1144 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1145 NOTE: |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1146 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1147 (*) The cursor is placed on the next character after the point. |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1148 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1149 ---------- |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1150 abcdefghi\ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1151 j ^---- next after the point |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1152 ^--- next char. after the point. |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1153 ---------- |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1154 In case of sigle-column character |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1155 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1156 ---------- |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1157 abcdefgh\\ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1158 033 ^---- next after the point, next char. after the point. |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1159 ---------- |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1160 In case of multi-column character |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1161 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1162 ---------- |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1163 abcdefgh\\ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1164 W_ ^---- next after the point |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1165 ^---- next char. after the point. |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1166 ---------- |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1167 In case of wide-column character |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1168 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1169 The problem here is continuation at a wide-column character. |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1170 In this case, the line may shorter less than WIDTH. |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1171 And we find the continuation AFTER it occurs. |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1172 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1173 */ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1174 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1175 if (hpos > width) |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1176 { |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1177 if (hscroll |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1178 || (truncate_partial_width_windows |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1179 && width + 1 < FRAME_WIDTH (XFRAME (WINDOW_FRAME (win)))) |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1180 || !NILP (current_buffer->truncate_lines)) |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1181 { |
20876
c80b908e5af5
(compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents:
20706
diff
changeset
|
1182 /* Truncating: skip to newline, unless we are already past |
c80b908e5af5
(compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents:
20706
diff
changeset
|
1183 TO (we need to go back below). */ |
c80b908e5af5
(compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents:
20706
diff
changeset
|
1184 if (pos <= to) |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1185 { |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1186 pos = find_before_next_newline (pos, to, 1); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1187 pos_byte = CHAR_TO_BYTE (pos); |
20876
c80b908e5af5
(compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents:
20706
diff
changeset
|
1188 hpos = width; |
c80b908e5af5
(compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents:
20706
diff
changeset
|
1189 /* If we just skipped next_boundary, |
c80b908e5af5
(compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents:
20706
diff
changeset
|
1190 loop around in the main while |
c80b908e5af5
(compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents:
20706
diff
changeset
|
1191 and handle it. */ |
c80b908e5af5
(compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents:
20706
diff
changeset
|
1192 if (pos >= next_boundary) |
c80b908e5af5
(compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents:
20706
diff
changeset
|
1193 next_boundary = pos + 1; |
c80b908e5af5
(compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents:
20706
diff
changeset
|
1194 prev_hpos = width; |
c80b908e5af5
(compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents:
20706
diff
changeset
|
1195 prev_tab_offset = tab_offset; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1196 } |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1197 } |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1198 else |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1199 { |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1200 /* Continuing. */ |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1201 /* Remember the previous value. */ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1202 prev_tab_offset = tab_offset; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1203 |
20938
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
1204 if (wide_column_end_hpos > width) |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1205 { |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1206 hpos -= prev_hpos; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1207 tab_offset += prev_hpos; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1208 } |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1209 else |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1210 { |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1211 tab_offset += width; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1212 hpos -= width; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1213 } |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1214 vpos++; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1215 contin_hpos = prev_hpos; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1216 prev_hpos = 0; |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1217 } |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1218 } |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1219 |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1220 /* Stop if past the target buffer position or screen position. */ |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1221 if (pos > to) |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1222 { |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1223 /* Go back to the previous position. */ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1224 pos = prev_pos; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1225 pos_byte = prev_pos_byte; |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1226 hpos = prev_hpos; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1227 tab_offset = prev_tab_offset; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1228 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1229 /* NOTE on contin_hpos, hpos, and prev_hpos. |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1230 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1231 ---------- |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1232 abcdefgh\\ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1233 W_ ^---- contin_hpos |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1234 | ^----- hpos |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1235 \---- prev_hpos |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1236 ---------- |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1237 */ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1238 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1239 if (contin_hpos && prev_hpos == 0 |
20938
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
1240 && contin_hpos < width && !wide_column_end_hpos) |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1241 { |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1242 /* Line breaking occurs in the middle of multi-column |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1243 character. Go back to previous line. */ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1244 hpos = contin_hpos; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1245 vpos = vpos - 1; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1246 } |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1247 else if (c == '\n') |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1248 /* If previous character is NEWLINE, |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1249 set VPOS back to previous line */ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1250 vpos = vpos - 1; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1251 break; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1252 } |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1253 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1254 if (vpos > tovpos || vpos == tovpos && hpos >= tohpos) |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1255 { |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1256 if (contin_hpos && prev_hpos == 0 |
20938
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
1257 && ((hpos > tohpos && contin_hpos == width) |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
1258 || (wide_column_end_hpos > width))) |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1259 { /* Line breaks because we can't put the character at the |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1260 previous line any more. It is not the multi-column |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1261 character continued in middle. Go back to previous |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1262 buffer position, screen position, and set tab offset |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1263 to previous value. It's the beginning of the |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1264 line. */ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1265 pos = prev_pos; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1266 pos_byte = prev_pos_byte; |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1267 hpos = prev_hpos; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1268 tab_offset = prev_tab_offset; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1269 } |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1270 break; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1271 } |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1272 if (pos == ZV) /* We cannot go beyond ZV. Stop here. */ |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1273 break; |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1274 |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1275 prev_hpos = hpos; |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1276 prev_pos = pos; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1277 prev_pos_byte = pos_byte; |
20938
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
1278 wide_column_end_hpos = 0; |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1279 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1280 /* Consult the width run cache to see if we can avoid inspecting |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1281 the text character-by-character. */ |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1282 if (current_buffer->width_run_cache && pos >= next_width_run) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1283 { |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1284 int run_end; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1285 int common_width |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1286 = region_cache_forward (current_buffer, |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1287 current_buffer->width_run_cache, |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1288 pos, &run_end); |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1289 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1290 /* A width of zero means the character's width varies (like |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1291 a tab), is meaningless (like a newline), or we just don't |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1292 want to skip over it for some other reason. */ |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1293 if (common_width != 0) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1294 { |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1295 int run_end_hpos; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1296 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1297 /* Don't go past the final buffer posn the user |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1298 requested. */ |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1299 if (run_end > to) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1300 run_end = to; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1301 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1302 run_end_hpos = hpos + (run_end - pos) * common_width; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1303 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1304 /* Don't go past the final horizontal position the user |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1305 requested. */ |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1306 if (vpos == tovpos && run_end_hpos > tohpos) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1307 { |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1308 run_end = pos + (tohpos - hpos) / common_width; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1309 run_end_hpos = hpos + (run_end - pos) * common_width; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1310 } |
10538
48c620ae0853
(compute_motion): Don't get hung in selective-display loop.
Karl Heuer <kwzh@gnu.org>
parents:
10011
diff
changeset
|
1311 |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1312 /* Don't go past the margin. */ |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1313 if (run_end_hpos >= width) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1314 { |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1315 run_end = pos + (width - hpos) / common_width; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1316 run_end_hpos = hpos + (run_end - pos) * common_width; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1317 } |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1318 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1319 hpos = run_end_hpos; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1320 if (run_end > pos) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1321 prev_hpos = hpos - common_width; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1322 if (pos != run_end) |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1323 { |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1324 pos = run_end; |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1325 pos_byte = CHAR_TO_BYTE (pos); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1326 } |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1327 } |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1328 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1329 next_width_run = run_end + 1; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1330 } |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1331 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1332 /* We have to scan the text character-by-character. */ |
165 | 1333 else |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1334 { |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1335 c = FETCH_BYTE (pos_byte); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1336 pos++, pos_byte++; |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1337 |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1338 /* Perhaps add some info to the width_run_cache. */ |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1339 if (current_buffer->width_run_cache) |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1340 { |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1341 /* Is this character part of the current run? If so, extend |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1342 the run. */ |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1343 if (pos - 1 == width_run_end |
18109
b8c70b5f5aba
(compute_motion): Use XFASTINT on width_table elts.
Richard M. Stallman <rms@gnu.org>
parents:
17966
diff
changeset
|
1344 && XFASTINT (width_table[c]) == width_run_width) |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1345 width_run_end = pos; |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1346 |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1347 /* The previous run is over, since this is a character at a |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1348 different position, or a different width. */ |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1349 else |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1350 { |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1351 /* Have we accumulated a run to put in the cache? |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1352 (Currently, we only cache runs of width == 1). */ |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1353 if (width_run_start < width_run_end |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1354 && width_run_width == 1) |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1355 know_region_cache (current_buffer, |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1356 current_buffer->width_run_cache, |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1357 width_run_start, width_run_end); |
10538
48c620ae0853
(compute_motion): Don't get hung in selective-display loop.
Karl Heuer <kwzh@gnu.org>
parents:
10011
diff
changeset
|
1358 |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1359 /* Start recording a new width run. */ |
18109
b8c70b5f5aba
(compute_motion): Use XFASTINT on width_table elts.
Richard M. Stallman <rms@gnu.org>
parents:
17966
diff
changeset
|
1360 width_run_width = XFASTINT (width_table[c]); |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1361 width_run_start = pos - 1; |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1362 width_run_end = pos; |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1363 } |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1364 } |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1365 |
20938
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
1366 if (dp != 0 |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
1367 && ! (multibyte && BASE_LEADING_CODE_P (c)) |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
1368 && VECTORP (DISP_CHAR_VECTOR (dp, c))) |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1369 hpos += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size; |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1370 else if (c >= 040 && c < 0177) |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1371 hpos++; |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1372 else if (c == '\t') |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1373 { |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1374 int tem = (hpos + tab_offset + hscroll - (hscroll > 0)) % tab_width; |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1375 if (tem < 0) |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1376 tem += tab_width; |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1377 hpos += tab_width - tem; |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1378 } |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1379 else if (c == '\n') |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1380 { |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1381 if (selective > 0 |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1382 && indented_beyond_p (pos, pos_byte, selective)) |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1383 { |
17136
424932eba3e8
(compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents:
17016
diff
changeset
|
1384 /* If (pos == to), we don't have to take care of |
424932eba3e8
(compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents:
17016
diff
changeset
|
1385 selective display. */ |
424932eba3e8
(compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents:
17016
diff
changeset
|
1386 if (pos < to) |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1387 { |
17136
424932eba3e8
(compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents:
17016
diff
changeset
|
1388 /* Skip any number of invisible lines all at once */ |
424932eba3e8
(compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents:
17016
diff
changeset
|
1389 do |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1390 { |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1391 pos = find_before_next_newline (pos, to, 1) + 1; |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1392 pos_byte = CHAR_TO_BYTE (pos); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1393 } |
17136
424932eba3e8
(compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents:
17016
diff
changeset
|
1394 while (pos < to |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1395 && indented_beyond_p (pos, pos_byte, selective)); |
17136
424932eba3e8
(compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents:
17016
diff
changeset
|
1396 /* Allow for the " ..." that is displayed for them. */ |
424932eba3e8
(compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents:
17016
diff
changeset
|
1397 if (selective_rlen) |
424932eba3e8
(compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents:
17016
diff
changeset
|
1398 { |
424932eba3e8
(compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents:
17016
diff
changeset
|
1399 hpos += selective_rlen; |
424932eba3e8
(compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents:
17016
diff
changeset
|
1400 if (hpos >= width) |
424932eba3e8
(compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents:
17016
diff
changeset
|
1401 hpos = width; |
424932eba3e8
(compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents:
17016
diff
changeset
|
1402 } |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1403 DEC_BOTH (pos, pos_byte); |
17136
424932eba3e8
(compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents:
17016
diff
changeset
|
1404 /* We have skipped the invis text, but not the |
424932eba3e8
(compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents:
17016
diff
changeset
|
1405 newline after. */ |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1406 } |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1407 } |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1408 else |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1409 { |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1410 /* A visible line. */ |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1411 vpos++; |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1412 hpos = 0; |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1413 hpos -= hscroll; |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1414 /* Count the truncation glyph on column 0 */ |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1415 if (hscroll > 0) |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1416 hpos++; |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1417 tab_offset = 0; |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1418 } |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1419 contin_hpos = 0; |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1420 } |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1421 else if (c == CR && selective < 0) |
165 | 1422 { |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1423 /* In selective display mode, |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1424 everything from a ^M to the end of the line is invisible. |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1425 Stop *before* the real newline. */ |
17136
424932eba3e8
(compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents:
17016
diff
changeset
|
1426 if (pos < to) |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1427 { |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1428 pos = find_before_next_newline (pos, to, 1); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1429 pos_byte = CHAR_TO_BYTE (pos); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1430 } |
13453
ea373c55ed95
(Fmove_to_column): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
13363
diff
changeset
|
1431 /* If we just skipped next_boundary, |
ea373c55ed95
(Fmove_to_column): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
13363
diff
changeset
|
1432 loop around in the main while |
ea373c55ed95
(Fmove_to_column): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
13363
diff
changeset
|
1433 and handle it. */ |
ea373c55ed95
(Fmove_to_column): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
13363
diff
changeset
|
1434 if (pos > next_boundary) |
ea373c55ed95
(Fmove_to_column): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
13363
diff
changeset
|
1435 next_boundary = pos; |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1436 /* Allow for the " ..." that is displayed for them. */ |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1437 if (selective_rlen) |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1438 { |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1439 hpos += selective_rlen; |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1440 if (hpos >= width) |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1441 hpos = width; |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1442 } |
165 | 1443 } |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1444 else if (multibyte && BASE_LEADING_CODE_P (c)) |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1445 { |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1446 /* Start of multi-byte form. */ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1447 unsigned char *ptr; |
20938
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
1448 int bytes, width, wide_column; |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1449 |
20938
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
1450 pos_byte--; /* rewind POS_BYTE */ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
1451 ptr = BYTE_POS_ADDR (pos_byte); |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
1452 MULTIBYTE_BYTES_WIDTH (ptr, c, dp); |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
1453 pos_byte += bytes; |
21283
c431691cbff1
(compute_motion): Call strwidth only when necessary.
Kenichi Handa <handa@m17n.org>
parents:
21275
diff
changeset
|
1454 if (wide_column) |
c431691cbff1
(compute_motion): Call strwidth only when necessary.
Kenichi Handa <handa@m17n.org>
parents:
21275
diff
changeset
|
1455 wide_column_end_hpos = hpos + wide_column; |
20938
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
1456 hpos += width; |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1457 } |
165 | 1458 else |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1459 hpos += (ctl_arrow && c < 0200) ? 2 : 4; |
165 | 1460 } |
1461 } | |
1462 | |
17966
aaa25a87ae3d
(compute_motion): Return correctly if skip_invisible
Richard M. Stallman <rms@gnu.org>
parents:
17136
diff
changeset
|
1463 after_loop: |
aaa25a87ae3d
(compute_motion): Return correctly if skip_invisible
Richard M. Stallman <rms@gnu.org>
parents:
17136
diff
changeset
|
1464 |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1465 /* Remember any final width run in the cache. */ |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1466 if (current_buffer->width_run_cache |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1467 && width_run_width == 1 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1468 && width_run_start < width_run_end) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1469 know_region_cache (current_buffer, current_buffer->width_run_cache, |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1470 width_run_start, width_run_end); |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1471 |
165 | 1472 val_compute_motion.bufpos = pos; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1473 val_compute_motion.bytepos = pos_byte; |
526 | 1474 val_compute_motion.hpos = hpos; |
1475 val_compute_motion.vpos = vpos; | |
20985
020b0eade8c5
(compute_motion): If we just moved over a continuation
Andreas Schwab <schwab@suse.de>
parents:
20938
diff
changeset
|
1476 if (contin_hpos && prev_hpos == 0) |
020b0eade8c5
(compute_motion): If we just moved over a continuation
Andreas Schwab <schwab@suse.de>
parents:
20938
diff
changeset
|
1477 val_compute_motion.prevhpos = contin_hpos; |
020b0eade8c5
(compute_motion): If we just moved over a continuation
Andreas Schwab <schwab@suse.de>
parents:
20938
diff
changeset
|
1478 else |
020b0eade8c5
(compute_motion): If we just moved over a continuation
Andreas Schwab <schwab@suse.de>
parents:
20938
diff
changeset
|
1479 val_compute_motion.prevhpos = prev_hpos; |
16395
c6b901f809da
(vmotion, compute_motion): Fill in ovstring_chars_done in the return value.
Richard M. Stallman <rms@gnu.org>
parents:
16257
diff
changeset
|
1480 /* We alalways handle all of them here; none of them remain to do. */ |
c6b901f809da
(vmotion, compute_motion): Fill in ovstring_chars_done in the return value.
Richard M. Stallman <rms@gnu.org>
parents:
16257
diff
changeset
|
1481 val_compute_motion.ovstring_chars_done = 0; |
165 | 1482 |
1483 /* Nonzero if have just continued a line */ | |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1484 val_compute_motion.contin = (contin_hpos && prev_hpos == 0); |
165 | 1485 |
1486 return &val_compute_motion; | |
1487 } | |
1488 | |
6587 | 1489 #if 0 /* The doc string is too long for some compilers, |
1490 but make-docfile can find it in this comment. */ | |
6691
3b56d4742266
(compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents:
6588
diff
changeset
|
1491 DEFUN ("compute-motion", Ffoo, Sfoo, 7, 7, 0, |
6296
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1492 "Scan through the current buffer, calculating screen position.\n\ |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1493 Scan the current buffer forward from offset FROM,\n\ |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1494 assuming it is at position FROMPOS--a cons of the form (HPOS . VPOS)--\n\ |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1495 to position TO or position TOPOS--another cons of the form (HPOS . VPOS)--\n\ |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1496 and return the ending buffer position and screen location.\n\ |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1497 \n\ |
6691
3b56d4742266
(compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents:
6588
diff
changeset
|
1498 There are three additional arguments:\n\ |
6296
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1499 \n\ |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1500 WIDTH is the number of columns available to display text;\n\ |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1501 this affects handling of continuation lines.\n\ |
6587 | 1502 This is usually the value returned by `window-width', less one (to allow\n\ |
1503 for the continuation glyph).\n\ | |
6296
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1504 \n\ |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1505 OFFSETS is either nil or a cons cell (HSCROLL . TAB-OFFSET).\n\ |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1506 HSCROLL is the number of columns not being displayed at the left\n\ |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1507 margin; this is usually taken from a window's hscroll member.\n\ |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1508 TAB-OFFSET is the number of columns of the first tab that aren't\n\ |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1509 being displayed, perhaps because the line was continued within it.\n\ |
6585 | 1510 If OFFSETS is nil, HSCROLL and TAB-OFFSET are assumed to be zero.\n\ |
6846
a6803ff29cca
(compute_motion): Do not abort if window shows some other buffer.
Richard M. Stallman <rms@gnu.org>
parents:
6811
diff
changeset
|
1511 \n\ |
15278
dc5e711a109e
(compute_motion): When calling Fget_char_property,
Karl Heuer <kwzh@gnu.org>
parents:
15059
diff
changeset
|
1512 WINDOW is the window to operate on. It is used to choose the display table;\n\ |
dc5e711a109e
(compute_motion): When calling Fget_char_property,
Karl Heuer <kwzh@gnu.org>
parents:
15059
diff
changeset
|
1513 if it is showing the current buffer, it is used also for\n\ |
dc5e711a109e
(compute_motion): When calling Fget_char_property,
Karl Heuer <kwzh@gnu.org>
parents:
15059
diff
changeset
|
1514 deciding which overlay properties apply.\n\ |
dc5e711a109e
(compute_motion): When calling Fget_char_property,
Karl Heuer <kwzh@gnu.org>
parents:
15059
diff
changeset
|
1515 Note that `compute-motion' always operates on the current buffer.\n\ |
6296
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1516 \n\ |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1517 The value is a list of five elements:\n\ |
6586
de99006a8b38
(Fcompute_motion): Don't use XFASTINT on possibly-negative coords.
Karl Heuer <kwzh@gnu.org>
parents:
6585
diff
changeset
|
1518 (POS HPOS VPOS PREVHPOS CONTIN)\n\ |
6296
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1519 POS is the buffer position where the scan stopped.\n\ |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1520 VPOS is the vertical position where the scan stopped.\n\ |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1521 HPOS is the horizontal position where the scan stopped.\n\ |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1522 \n\ |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1523 PREVHPOS is the horizontal position one character back from POS.\n\ |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1524 CONTIN is t if a line was continued after (or within) the previous character.\n\ |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1525 \n\ |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1526 For example, to find the buffer position of column COL of line LINE\n\ |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1527 of a certain window, pass the window's starting location as FROM\n\ |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1528 and the window's upper-left coordinates as FROMPOS.\n\ |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1529 Pass the buffer's (point-max) as TO, to limit the scan to the end of the\n\ |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1530 visible section of the buffer, and pass LINE and COL as TOPOS.") |
7566
8a0a7fb9f7d4
Add "args" to dummy definition of compute-motion.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
1531 (from, frompos, to, topos, width, offsets, window) |
6587 | 1532 #endif |
1533 | |
6691
3b56d4742266
(compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents:
6588
diff
changeset
|
1534 DEFUN ("compute-motion", Fcompute_motion, Scompute_motion, 7, 7, 0, |
6587 | 1535 0) |
6691
3b56d4742266
(compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents:
6588
diff
changeset
|
1536 (from, frompos, to, topos, width, offsets, window) |
6296
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1537 Lisp_Object from, frompos, to, topos; |
6691
3b56d4742266
(compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents:
6588
diff
changeset
|
1538 Lisp_Object width, offsets, window; |
6296
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1539 { |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1540 Lisp_Object bufpos, hpos, vpos, prevhpos, contin; |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1541 struct position *pos; |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1542 int hscroll, tab_offset; |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1543 |
6573
33ae9314b443
Fix glitches in previous change.
Karl Heuer <kwzh@gnu.org>
parents:
6572
diff
changeset
|
1544 CHECK_NUMBER_COERCE_MARKER (from, 0); |
6296
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1545 CHECK_CONS (frompos, 0); |
6573
33ae9314b443
Fix glitches in previous change.
Karl Heuer <kwzh@gnu.org>
parents:
6572
diff
changeset
|
1546 CHECK_NUMBER (XCONS (frompos)->car, 0); |
33ae9314b443
Fix glitches in previous change.
Karl Heuer <kwzh@gnu.org>
parents:
6572
diff
changeset
|
1547 CHECK_NUMBER (XCONS (frompos)->cdr, 0); |
33ae9314b443
Fix glitches in previous change.
Karl Heuer <kwzh@gnu.org>
parents:
6572
diff
changeset
|
1548 CHECK_NUMBER_COERCE_MARKER (to, 0); |
6296
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1549 CHECK_CONS (topos, 0); |
6573
33ae9314b443
Fix glitches in previous change.
Karl Heuer <kwzh@gnu.org>
parents:
6572
diff
changeset
|
1550 CHECK_NUMBER (XCONS (topos)->car, 0); |
33ae9314b443
Fix glitches in previous change.
Karl Heuer <kwzh@gnu.org>
parents:
6572
diff
changeset
|
1551 CHECK_NUMBER (XCONS (topos)->cdr, 0); |
33ae9314b443
Fix glitches in previous change.
Karl Heuer <kwzh@gnu.org>
parents:
6572
diff
changeset
|
1552 CHECK_NUMBER (width, 0); |
6296
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1553 if (!NILP (offsets)) |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1554 { |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1555 CHECK_CONS (offsets, 0); |
6573
33ae9314b443
Fix glitches in previous change.
Karl Heuer <kwzh@gnu.org>
parents:
6572
diff
changeset
|
1556 CHECK_NUMBER (XCONS (offsets)->car, 0); |
33ae9314b443
Fix glitches in previous change.
Karl Heuer <kwzh@gnu.org>
parents:
6572
diff
changeset
|
1557 CHECK_NUMBER (XCONS (offsets)->cdr, 0); |
6296
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1558 hscroll = XINT (XCONS (offsets)->car); |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1559 tab_offset = XINT (XCONS (offsets)->cdr); |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1560 } |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1561 else |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1562 hscroll = tab_offset = 0; |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1563 |
6691
3b56d4742266
(compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents:
6588
diff
changeset
|
1564 if (NILP (window)) |
3b56d4742266
(compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents:
6588
diff
changeset
|
1565 window = Fselected_window (); |
3b56d4742266
(compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents:
6588
diff
changeset
|
1566 else |
3b56d4742266
(compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents:
6588
diff
changeset
|
1567 CHECK_LIVE_WINDOW (window, 0); |
3b56d4742266
(compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents:
6588
diff
changeset
|
1568 |
6296
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1569 pos = compute_motion (XINT (from), XINT (XCONS (frompos)->cdr), |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1570 XINT (XCONS (frompos)->car), 0, |
6296
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1571 XINT (to), XINT (XCONS (topos)->cdr), |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1572 XINT (XCONS (topos)->car), |
6691
3b56d4742266
(compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents:
6588
diff
changeset
|
1573 XINT (width), hscroll, tab_offset, |
3b56d4742266
(compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents:
6588
diff
changeset
|
1574 XWINDOW (window)); |
6296
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1575 |
9310
1dfd9def3467
(Fcurrent_column, Findent_to, Fcurrent_indentation, Fmove_to_column,
Karl Heuer <kwzh@gnu.org>
parents:
9269
diff
changeset
|
1576 XSETFASTINT (bufpos, pos->bufpos); |
9269
0f29bb3f784f
(Fcompute_motion): Use new accessor macros instead of calling XSET directly.
Karl Heuer <kwzh@gnu.org>
parents:
9126
diff
changeset
|
1577 XSETINT (hpos, pos->hpos); |
0f29bb3f784f
(Fcompute_motion): Use new accessor macros instead of calling XSET directly.
Karl Heuer <kwzh@gnu.org>
parents:
9126
diff
changeset
|
1578 XSETINT (vpos, pos->vpos); |
0f29bb3f784f
(Fcompute_motion): Use new accessor macros instead of calling XSET directly.
Karl Heuer <kwzh@gnu.org>
parents:
9126
diff
changeset
|
1579 XSETINT (prevhpos, pos->prevhpos); |
6296
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1580 |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1581 return Fcons (bufpos, |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1582 Fcons (hpos, |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1583 Fcons (vpos, |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1584 Fcons (prevhpos, |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1585 Fcons (pos->contin ? Qt : Qnil, Qnil))))); |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1586 |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1587 } |
165 | 1588 |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1589 /* Fvertical_motion and vmotion */ |
165 | 1590 struct position val_vmotion; |
1591 | |
1592 struct position * | |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1593 vmotion (from, vtarget, w) |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1594 register int from, vtarget; |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1595 struct window *w; |
165 | 1596 { |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1597 int width = window_internal_width (w) - 1; |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1598 int hscroll = XINT (w->hscroll); |
165 | 1599 struct position pos; |
1600 /* vpos is cumulative vertical position, changed as from is changed */ | |
1601 register int vpos = 0; | |
8905
2ef3da79aabb
(vmotion, Fvertical_motion): Fix Lisp_Object vs. int problems.
Karl Heuer <kwzh@gnu.org>
parents:
8648
diff
changeset
|
1602 Lisp_Object prevline; |
165 | 1603 register int first; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1604 int from_byte; |
165 | 1605 int lmargin = hscroll > 0 ? 1 - hscroll : 0; |
1606 int selective | |
9126
e475f8108156
(buffer_display_table, current_column, Fmove_to_column, compute_motion,
Karl Heuer <kwzh@gnu.org>
parents:
8946
diff
changeset
|
1607 = (INTEGERP (current_buffer->selective_display) |
e475f8108156
(buffer_display_table, current_column, Fmove_to_column, compute_motion,
Karl Heuer <kwzh@gnu.org>
parents:
8946
diff
changeset
|
1608 ? XINT (current_buffer->selective_display) |
e475f8108156
(buffer_display_table, current_column, Fmove_to_column, compute_motion,
Karl Heuer <kwzh@gnu.org>
parents:
8946
diff
changeset
|
1609 : !NILP (current_buffer->selective_display) ? -1 : 0); |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1610 Lisp_Object window; |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1611 int start_hpos = 0; |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1612 int did_motion; |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1613 |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1614 XSETWINDOW (window, w); |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1615 |
6811
d84152a9b7e5
(vmotion): Use minibuf_prompt_width despite window-start.
Karl Heuer <kwzh@gnu.org>
parents:
6763
diff
changeset
|
1616 /* The omission of the clause |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1617 && marker_position (w->start) == BEG |
6811
d84152a9b7e5
(vmotion): Use minibuf_prompt_width despite window-start.
Karl Heuer <kwzh@gnu.org>
parents:
6763
diff
changeset
|
1618 here is deliberate; I think we want to measure from the prompt |
d84152a9b7e5
(vmotion): Use minibuf_prompt_width despite window-start.
Karl Heuer <kwzh@gnu.org>
parents:
6763
diff
changeset
|
1619 position even if the minibuffer window has scrolled. */ |
11300
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
1620 if (EQ (window, minibuf_window)) |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
1621 { |
11813
5b7a7c92323d
(vmotion): handle the case where `minibuf_prompt' is nil.
Karl Heuer <kwzh@gnu.org>
parents:
11811
diff
changeset
|
1622 if (minibuf_prompt_width == 0 && STRINGP (minibuf_prompt)) |
11704
6c9716b7a23d
(string_display_width): Renamed from string_width.
Richard M. Stallman <rms@gnu.org>
parents:
11312
diff
changeset
|
1623 minibuf_prompt_width |
6c9716b7a23d
(string_display_width): Renamed from string_width.
Richard M. Stallman <rms@gnu.org>
parents:
11312
diff
changeset
|
1624 = string_display_width (minibuf_prompt, Qnil, Qnil); |
11300
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
1625 |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
1626 start_hpos = minibuf_prompt_width; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
1627 } |
165 | 1628 |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1629 if (vpos >= vtarget) |
165 | 1630 { |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1631 /* To move upward, go a line at a time until |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1632 we have gone at least far enough. */ |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1633 |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1634 first = 1; |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1635 |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1636 while ((vpos > vtarget || first) && from > BEGV) |
165 | 1637 { |
10964
474b6b03a71f
(compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents:
10538
diff
changeset
|
1638 Lisp_Object propval; |
474b6b03a71f
(compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents:
10538
diff
changeset
|
1639 |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1640 XSETFASTINT (prevline, find_next_newline_no_quit (from - 1, -1)); |
8905
2ef3da79aabb
(vmotion, Fvertical_motion): Fix Lisp_Object vs. int problems.
Karl Heuer <kwzh@gnu.org>
parents:
8648
diff
changeset
|
1641 while (XFASTINT (prevline) > BEGV |
4385
edffa4f0c5d9
(compute_motion): Compute correctly for invisible text.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
1642 && ((selective > 0 |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1643 && indented_beyond_p (XFASTINT (prevline), |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1644 CHAR_TO_BYTE (XFASTINT (prevline)), |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1645 selective)) |
4385
edffa4f0c5d9
(compute_motion): Compute correctly for invisible text.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
1646 #ifdef USE_TEXT_PROPERTIES |
edffa4f0c5d9
(compute_motion): Compute correctly for invisible text.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
1647 /* watch out for newlines with `invisible' property */ |
10964
474b6b03a71f
(compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents:
10538
diff
changeset
|
1648 || (propval = Fget_char_property (prevline, |
474b6b03a71f
(compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents:
10538
diff
changeset
|
1649 Qinvisible, |
474b6b03a71f
(compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents:
10538
diff
changeset
|
1650 window), |
474b6b03a71f
(compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents:
10538
diff
changeset
|
1651 TEXT_PROP_MEANS_INVISIBLE (propval)) |
4385
edffa4f0c5d9
(compute_motion): Compute correctly for invisible text.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
1652 #endif |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1653 )) |
9310
1dfd9def3467
(Fcurrent_column, Findent_to, Fcurrent_indentation, Fmove_to_column,
Karl Heuer <kwzh@gnu.org>
parents:
9269
diff
changeset
|
1654 XSETFASTINT (prevline, |
1dfd9def3467
(Fcurrent_column, Findent_to, Fcurrent_indentation, Fmove_to_column,
Karl Heuer <kwzh@gnu.org>
parents:
9269
diff
changeset
|
1655 find_next_newline_no_quit (XFASTINT (prevline) - 1, |
1dfd9def3467
(Fcurrent_column, Findent_to, Fcurrent_indentation, Fmove_to_column,
Karl Heuer <kwzh@gnu.org>
parents:
9269
diff
changeset
|
1656 -1)); |
8905
2ef3da79aabb
(vmotion, Fvertical_motion): Fix Lisp_Object vs. int problems.
Karl Heuer <kwzh@gnu.org>
parents:
8648
diff
changeset
|
1657 pos = *compute_motion (XFASTINT (prevline), 0, |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1658 lmargin + (XFASTINT (prevline) == BEG |
8905
2ef3da79aabb
(vmotion, Fvertical_motion): Fix Lisp_Object vs. int problems.
Karl Heuer <kwzh@gnu.org>
parents:
8648
diff
changeset
|
1659 ? start_hpos : 0), |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1660 0, |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1661 from, |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1662 /* Don't care for VPOS... */ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1663 1 << (BITS_PER_SHORT - 1), |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1664 /* ... nor HPOS. */ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1665 1 << (BITS_PER_SHORT - 1), |
16926
3baea3418dec
(pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents:
16395
diff
changeset
|
1666 width, hscroll, |
3baea3418dec
(pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents:
16395
diff
changeset
|
1667 /* This compensates for start_hpos |
3baea3418dec
(pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents:
16395
diff
changeset
|
1668 so that a tab as first character |
3baea3418dec
(pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents:
16395
diff
changeset
|
1669 still occupies 8 columns. */ |
3baea3418dec
(pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents:
16395
diff
changeset
|
1670 (XFASTINT (prevline) == BEG |
3baea3418dec
(pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents:
16395
diff
changeset
|
1671 ? -start_hpos : 0), |
3baea3418dec
(pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents:
16395
diff
changeset
|
1672 w); |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1673 vpos -= pos.vpos; |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1674 first = 0; |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1675 from = XFASTINT (prevline); |
165 | 1676 } |
1677 | |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1678 /* If we made exactly the desired vertical distance, |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1679 or if we hit beginning of buffer, |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1680 return point found */ |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1681 if (vpos >= vtarget) |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1682 { |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1683 val_vmotion.bufpos = from; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1684 val_vmotion.bytepos = CHAR_TO_BYTE (from); |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1685 val_vmotion.vpos = vpos; |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1686 val_vmotion.hpos = lmargin; |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1687 val_vmotion.contin = 0; |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1688 val_vmotion.prevhpos = 0; |
16395
c6b901f809da
(vmotion, compute_motion): Fill in ovstring_chars_done in the return value.
Richard M. Stallman <rms@gnu.org>
parents:
16257
diff
changeset
|
1689 val_vmotion.ovstring_chars_done = 0; |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1690 val_vmotion.tab_offset = 0; /* For accumulating tab offset. */ |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1691 return &val_vmotion; |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1692 } |
165 | 1693 |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1694 /* Otherwise find the correct spot by moving down */ |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1695 } |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1696 /* Moving downward is simple, but must calculate from beg of line |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1697 to determine hpos of starting point */ |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1698 from_byte = CHAR_TO_BYTE (from); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1699 if (from > BEGV && FETCH_BYTE (from_byte - 1) != '\n') |
165 | 1700 { |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1701 Lisp_Object propval; |
10964
474b6b03a71f
(compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents:
10538
diff
changeset
|
1702 |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1703 XSETFASTINT (prevline, find_next_newline_no_quit (from, -1)); |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1704 while (XFASTINT (prevline) > BEGV |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1705 && ((selective > 0 |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1706 && indented_beyond_p (XFASTINT (prevline), |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1707 CHAR_TO_BYTE (XFASTINT (prevline)), |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1708 selective)) |
4385
edffa4f0c5d9
(compute_motion): Compute correctly for invisible text.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
1709 #ifdef USE_TEXT_PROPERTIES |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1710 /* watch out for newlines with `invisible' property */ |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1711 || (propval = Fget_char_property (prevline, Qinvisible, |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1712 window), |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1713 TEXT_PROP_MEANS_INVISIBLE (propval)) |
4385
edffa4f0c5d9
(compute_motion): Compute correctly for invisible text.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
1714 #endif |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1715 )) |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1716 XSETFASTINT (prevline, |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1717 find_next_newline_no_quit (XFASTINT (prevline) - 1, |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1718 -1)); |
8905
2ef3da79aabb
(vmotion, Fvertical_motion): Fix Lisp_Object vs. int problems.
Karl Heuer <kwzh@gnu.org>
parents:
8648
diff
changeset
|
1719 pos = *compute_motion (XFASTINT (prevline), 0, |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1720 lmargin + (XFASTINT (prevline) == BEG |
8905
2ef3da79aabb
(vmotion, Fvertical_motion): Fix Lisp_Object vs. int problems.
Karl Heuer <kwzh@gnu.org>
parents:
8648
diff
changeset
|
1721 ? start_hpos : 0), |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1722 0, |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1723 from, |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1724 /* Don't care for VPOS... */ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1725 1 << (BITS_PER_SHORT - 1), |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1726 /* ... nor HPOS. */ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1727 1 << (BITS_PER_SHORT - 1), |
16926
3baea3418dec
(pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents:
16395
diff
changeset
|
1728 width, hscroll, |
3baea3418dec
(pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents:
16395
diff
changeset
|
1729 (XFASTINT (prevline) == BEG ? -start_hpos : 0), |
3baea3418dec
(pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents:
16395
diff
changeset
|
1730 w); |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1731 did_motion = 1; |
165 | 1732 } |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1733 else |
165 | 1734 { |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1735 pos.hpos = lmargin + (from == BEG ? start_hpos : 0); |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1736 pos.vpos = 0; |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1737 pos.tab_offset = 0; |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1738 did_motion = 0; |
165 | 1739 } |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1740 return compute_motion (from, vpos, pos.hpos, did_motion, |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1741 ZV, vtarget, - (1 << (BITS_PER_SHORT - 1)), |
16926
3baea3418dec
(pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents:
16395
diff
changeset
|
1742 width, hscroll, |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1743 pos.tab_offset - (from == BEG ? start_hpos : 0), |
16926
3baea3418dec
(pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents:
16395
diff
changeset
|
1744 w); |
165 | 1745 } |
1746 | |
6327
d93a087868cb
(Fvertical_motion): New optional arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents:
6296
diff
changeset
|
1747 DEFUN ("vertical-motion", Fvertical_motion, Svertical_motion, 1, 2, 0, |
15659 | 1748 "Move point to start of the screen line LINES lines down.\n\ |
1749 If LINES is negative, this means moving up.\n\ | |
1750 \n\ | |
1751 This function is an ordinary cursor motion function\n\ | |
1752 which calculates the new position based on how text would be displayed.\n\ | |
1753 The new position may be the start of a line,\n\ | |
1754 or just the start of a continuation line.\n\ | |
1755 The function returns number of screen lines moved over;\n\ | |
1756 that usually equals LINES, but may be closer to zero\n\ | |
1757 if beginning or end of buffer was reached.\n\ | |
6846
a6803ff29cca
(compute_motion): Do not abort if window shows some other buffer.
Richard M. Stallman <rms@gnu.org>
parents:
6811
diff
changeset
|
1758 \n\ |
a6803ff29cca
(compute_motion): Do not abort if window shows some other buffer.
Richard M. Stallman <rms@gnu.org>
parents:
6811
diff
changeset
|
1759 The optional second argument WINDOW specifies the window to use for\n\ |
a6803ff29cca
(compute_motion): Do not abort if window shows some other buffer.
Richard M. Stallman <rms@gnu.org>
parents:
6811
diff
changeset
|
1760 parameters such as width, horizontal scrolling, and so on.\n\ |
15659 | 1761 The default is to use the selected window's parameters.\n\ |
6846
a6803ff29cca
(compute_motion): Do not abort if window shows some other buffer.
Richard M. Stallman <rms@gnu.org>
parents:
6811
diff
changeset
|
1762 \n\ |
15659 | 1763 `vertical-motion' always uses the current buffer,\n\ |
1764 regardless of which buffer is displayed in WINDOW.\n\ | |
1765 This is consistent with other cursor motion functions\n\ | |
1766 and makes it possible to use `vertical-motion' in any buffer,\n\ | |
1767 whether or not it is currently displayed in some window.") | |
6327
d93a087868cb
(Fvertical_motion): New optional arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents:
6296
diff
changeset
|
1768 (lines, window) |
d93a087868cb
(Fvertical_motion): New optional arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents:
6296
diff
changeset
|
1769 Lisp_Object lines, window; |
165 | 1770 { |
1771 struct position pos; | |
1772 | |
1773 CHECK_NUMBER (lines, 0); | |
6327
d93a087868cb
(Fvertical_motion): New optional arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents:
6296
diff
changeset
|
1774 if (! NILP (window)) |
d93a087868cb
(Fvertical_motion): New optional arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents:
6296
diff
changeset
|
1775 CHECK_WINDOW (window, 0); |
d93a087868cb
(Fvertical_motion): New optional arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents:
6296
diff
changeset
|
1776 else |
8905
2ef3da79aabb
(vmotion, Fvertical_motion): Fix Lisp_Object vs. int problems.
Karl Heuer <kwzh@gnu.org>
parents:
8648
diff
changeset
|
1777 window = selected_window; |
165 | 1778 |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15659
diff
changeset
|
1779 pos = *vmotion (PT, (int) XINT (lines), XWINDOW (window)); |
165 | 1780 |
1781 SET_PT (pos.bufpos); | |
1782 return make_number (pos.vpos); | |
1783 } | |
1784 | |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1785 /* file's initialization. */ |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1786 |
165 | 1787 syms_of_indent () |
1788 { | |
1789 DEFVAR_BOOL ("indent-tabs-mode", &indent_tabs_mode, | |
1790 "*Indentation can insert tabs if this is non-nil.\n\ | |
1791 Setting this variable automatically makes it local to the current buffer."); | |
1792 indent_tabs_mode = 1; | |
1793 | |
1794 defsubr (&Scurrent_indentation); | |
1795 defsubr (&Sindent_to); | |
1796 defsubr (&Scurrent_column); | |
1797 defsubr (&Smove_to_column); | |
1798 defsubr (&Svertical_motion); | |
6296
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1799 defsubr (&Scompute_motion); |
165 | 1800 } |