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