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