Mercurial > emacs
annotate src/indent.c @ 92898:3aa36f5712f6
(mark-diary-entries): Move some constant variables outside the
diary-date-forms loop.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Fri, 14 Mar 2008 02:52:35 +0000 |
parents | ec0a63595f5b |
children | cc31ce92f833 |
rev | line source |
---|---|
165 | 1 /* Indentation functions. |
59710
dc40d9822125
(Fcurrent_column): Doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59647
diff
changeset
|
2 Copyright (C) 1985, 1986, 1987, 1988, 1993, 1994, 1995, 1998, 2000, 2001, |
79759 | 3 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
4 Free Software Foundation, Inc. | |
165 | 5 |
6 This file is part of GNU Emacs. | |
7 | |
8 GNU Emacs is free software; you can redistribute it and/or modify | |
9 it under the terms of the GNU General Public License as published by | |
78260
922696f363b0
Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
77069
diff
changeset
|
10 the Free Software Foundation; either version 3, or (at your option) |
165 | 11 any later version. |
12 | |
13 GNU Emacs is distributed in the hope that it will be useful, | |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 GNU General Public License for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
19 along with GNU Emacs; see the file COPYING. If not, write to | |
64084 | 20 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
21 Boston, MA 02110-1301, USA. */ | |
165 | 22 |
4696
1fc792473491
Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents:
4385
diff
changeset
|
23 #include <config.h> |
82995
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
24 #include <stdio.h> |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
25 |
165 | 26 #include "lisp.h" |
27 #include "buffer.h" | |
88377
beebc1deb7f2
Include "character.h" instead of "charset.h".
Kenichi Handa <handa@m17n.org>
parents:
41900
diff
changeset
|
28 #include "character.h" |
20256
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
29 #include "category.h" |
165 | 30 #include "indent.h" |
31102
6a0caa788013
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
29405
diff
changeset
|
31 #include "keyboard.h" |
764 | 32 #include "frame.h" |
165 | 33 #include "window.h" |
34 #include "termchar.h" | |
35 #include "termopts.h" | |
36 #include "disptab.h" | |
4385
edffa4f0c5d9
(compute_motion): Compute correctly for invisible text.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
37 #include "intervals.h" |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
38 #include "region-cache.h" |
165 | 39 |
40 /* Indentation can insert tabs if this is non-zero; | |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
41 otherwise always uses spaces. */ |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
42 |
85128
8b61a2e5e365
(indent_tabs_mode, last_known_column, last_known_column_modified): Make static.
Juanma Barranquero <lekktu@gmail.com>
parents:
84952
diff
changeset
|
43 static int indent_tabs_mode; |
165 | 44 |
45 #define CR 015 | |
46 | |
39904 | 47 /* These three values memorize the current column to avoid recalculation. */ |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
48 |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
49 /* Last value returned by current_column. |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
50 Some things in set last_known_column_point to -1 |
39904 | 51 to mark the memorized value as invalid. */ |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
52 |
85128
8b61a2e5e365
(indent_tabs_mode, last_known_column, last_known_column_modified): Make static.
Juanma Barranquero <lekktu@gmail.com>
parents:
84952
diff
changeset
|
53 static double last_known_column; |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
54 |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
55 /* Value of point when current_column was called. */ |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
56 |
84951 | 57 EMACS_INT last_known_column_point; |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
58 |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
59 /* Value of MODIFF when current_column was called. */ |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
60 |
85128
8b61a2e5e365
(indent_tabs_mode, last_known_column, last_known_column_modified): Make static.
Juanma Barranquero <lekktu@gmail.com>
parents:
84952
diff
changeset
|
61 static int last_known_column_modified; |
165 | 62 |
46303
ebb83f095b2a
(last_known_column): Declare as double, not float.
Richard M. Stallman <rms@gnu.org>
parents:
45622
diff
changeset
|
63 static double current_column_1 P_ ((void)); |
ebb83f095b2a
(last_known_column): Declare as double, not float.
Richard M. Stallman <rms@gnu.org>
parents:
45622
diff
changeset
|
64 static double position_indentation P_ ((int)); |
15494
a544bb3eea53
(current_column_1): Add declaration.
Richard M. Stallman <rms@gnu.org>
parents:
15493
diff
changeset
|
65 |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
66 /* Cache of beginning of line found by the last call of |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
67 current_column. */ |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
68 |
84951 | 69 static EMACS_INT current_column_bol_cache; |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
70 |
165 | 71 /* Get the display table to use for the current buffer. */ |
72 | |
13185
5b1671bd3cc1
(buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents:
13124
diff
changeset
|
73 struct Lisp_Char_Table * |
165 | 74 buffer_display_table () |
75 { | |
76 Lisp_Object thisbuf; | |
77 | |
78 thisbuf = current_buffer->display_table; | |
13185
5b1671bd3cc1
(buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents:
13124
diff
changeset
|
79 if (DISP_TABLE_P (thisbuf)) |
5b1671bd3cc1
(buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents:
13124
diff
changeset
|
80 return XCHAR_TABLE (thisbuf); |
5b1671bd3cc1
(buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents:
13124
diff
changeset
|
81 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
|
82 return XCHAR_TABLE (Vstandard_display_table); |
165 | 83 return 0; |
84 } | |
85 | |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
86 /* Width run cache considerations. */ |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
87 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
88 /* 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
|
89 |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
90 static int |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
91 character_width (c, dp) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
92 int c; |
13185
5b1671bd3cc1
(buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents:
13124
diff
changeset
|
93 struct Lisp_Char_Table *dp; |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
94 { |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
95 Lisp_Object elt; |
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 /* 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
|
98 in display_text_line. */ |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
99 |
11037
802a774b44b7
(compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents:
10964
diff
changeset
|
100 /* 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
|
101 present and the element is right. */ |
802a774b44b7
(compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents:
10964
diff
changeset
|
102 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
|
103 return XVECTOR (elt)->size; |
802a774b44b7
(compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents:
10964
diff
changeset
|
104 |
802a774b44b7
(compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents:
10964
diff
changeset
|
105 /* Some characters are special. */ |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
106 if (c == '\n' || c == '\t' || c == '\015') |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
107 return 0; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
108 |
11037
802a774b44b7
(compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents:
10964
diff
changeset
|
109 /* Printing characters have width 1. */ |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
110 else if (c >= 040 && c < 0177) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
111 return 1; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
112 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
113 /* Everybody else (control characters, metacharacters) has other |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
114 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
|
115 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
|
116 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
|
117 widths. */ |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
118 else |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
119 return 0; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
120 } |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
121 |
78501 | 122 /* Return true if the display table DISPTAB specifies the same widths |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
123 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
|
124 invalidate the buffer's width_run_cache. */ |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
125 |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
126 int |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
127 disptab_matches_widthtab (disptab, widthtab) |
13185
5b1671bd3cc1
(buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents:
13124
diff
changeset
|
128 struct Lisp_Char_Table *disptab; |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
129 struct Lisp_Vector *widthtab; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
130 { |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
131 int i; |
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 if (widthtab->size != 256) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
134 abort (); |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
135 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
136 for (i = 0; i < 256; i++) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
137 if (character_width (i, disptab) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
138 != XFASTINT (widthtab->contents[i])) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
139 return 0; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
140 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
141 return 1; |
10538
48c620ae0853
(compute_motion): Don't get hung in selective-display loop.
Karl Heuer <kwzh@gnu.org>
parents:
10011
diff
changeset
|
142 } |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
143 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
144 /* Recompute BUF's width table, using the display table DISPTAB. */ |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
145 |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
146 void |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
147 recompute_width_table (buf, disptab) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
148 struct buffer *buf; |
13185
5b1671bd3cc1
(buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents:
13124
diff
changeset
|
149 struct Lisp_Char_Table *disptab; |
9407
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 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
|
152 struct Lisp_Vector *widthtab; |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
153 |
10011
f4f2563057b8
(recompute_width_table): Do the right thing if no previous table existed.
Karl Heuer <kwzh@gnu.org>
parents:
9407
diff
changeset
|
154 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
|
155 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
|
156 widthtab = XVECTOR (buf->width_table); |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
157 if (widthtab->size != 256) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
158 abort (); |
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 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
|
161 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
|
162 } |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
163 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
164 /* 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
|
165 state of current_buffer's cache_long_line_scans variable. */ |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
166 |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
167 static void |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
168 width_run_cache_on_off () |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
169 { |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
170 if (NILP (current_buffer->cache_long_line_scans) |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
171 /* And, for the moment, this feature doesn't work on multibyte |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
172 characters. */ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
173 || !NILP (current_buffer->enable_multibyte_characters)) |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
174 { |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
175 /* It should be off. */ |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
176 if (current_buffer->width_run_cache) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
177 { |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
178 free_region_cache (current_buffer->width_run_cache); |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
179 current_buffer->width_run_cache = 0; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
180 current_buffer->width_table = Qnil; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
181 } |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
182 } |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
183 else |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
184 { |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
185 /* It should be on. */ |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
186 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
|
187 { |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
188 current_buffer->width_run_cache = new_region_cache (); |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
189 recompute_width_table (current_buffer, buffer_display_table ()); |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
190 } |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
191 } |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
192 } |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
193 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
194 |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
195 /* 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
|
196 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
|
197 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
|
198 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
199 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
|
200 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
|
201 Otherwise return POS itself. |
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 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
|
204 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
|
205 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
206 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
|
207 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
|
208 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
209 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
|
210 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
|
211 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
212 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
|
213 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
|
214 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
|
215 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
|
216 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
|
217 |
84951 | 218 EMACS_INT |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
219 skip_invisible (pos, next_boundary_p, to, window) |
84951 | 220 EMACS_INT pos; |
221 EMACS_INT *next_boundary_p; | |
222 EMACS_INT to; | |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
223 Lisp_Object window; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
224 { |
18613
614b916ff5bf
Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents:
18109
diff
changeset
|
225 Lisp_Object prop, position, overlay_limit, proplimit; |
58451
4fcc66cf0b9c
(skip_invisible): Avoid non-idempotent side-effects in macro arguments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58396
diff
changeset
|
226 Lisp_Object buffer, tmp; |
84951 | 227 EMACS_INT end; |
228 int inv_p; | |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
229 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
230 XSETFASTINT (position, pos); |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
231 XSETBUFFER (buffer, current_buffer); |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
232 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
233 /* 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
|
234 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
|
235 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
236 /* 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
|
237 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
|
238 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
|
239 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
|
240 /* 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
|
241 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
|
242 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
|
243 if (XFASTINT (overlay_limit) < XFASTINT (proplimit)) |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
244 proplimit = overlay_limit; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
245 /* 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
|
246 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
|
247 use that lower bound. */ |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
248 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
|
249 *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
|
250 /* 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
|
251 else |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
252 { |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
253 /* 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
|
254 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
|
255 /* 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
|
256 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
|
257 proplimit = overlay_limit; |
58451
4fcc66cf0b9c
(skip_invisible): Avoid non-idempotent side-effects in macro arguments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58396
diff
changeset
|
258 tmp = Fnext_single_property_change (position, Qinvisible, |
4fcc66cf0b9c
(skip_invisible): Avoid non-idempotent side-effects in macro arguments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58396
diff
changeset
|
259 buffer, proplimit); |
4fcc66cf0b9c
(skip_invisible): Avoid non-idempotent side-effects in macro arguments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58396
diff
changeset
|
260 end = XFASTINT (tmp); |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
261 #if 0 |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
262 /* Don't put the boundary in the middle of multibyte form if |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
263 there is no actual property change. */ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
264 if (end == pos + 100 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
265 && !NILP (current_buffer->enable_multibyte_characters) |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
266 && end < ZV) |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
267 while (pos < end && !CHAR_HEAD_P (POS_ADDR (end))) |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
268 end--; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
269 #endif |
18613
614b916ff5bf
Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents:
18109
diff
changeset
|
270 *next_boundary_p = end; |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
271 } |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
272 /* 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
|
273 the next property change */ |
43735
30053d20015f
(skip_invisible): Fix my brain fart.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41900
diff
changeset
|
274 prop = Fget_char_property (position, Qinvisible, |
30053d20015f
(skip_invisible): Fix my brain fart.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41900
diff
changeset
|
275 (!NILP (window) |
30053d20015f
(skip_invisible): Fix my brain fart.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41900
diff
changeset
|
276 && EQ (XWINDOW (window)->buffer, buffer)) |
30053d20015f
(skip_invisible): Fix my brain fart.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41900
diff
changeset
|
277 ? window : buffer); |
30053d20015f
(skip_invisible): Fix my brain fart.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41900
diff
changeset
|
278 inv_p = TEXT_PROP_MEANS_INVISIBLE (prop); |
30053d20015f
(skip_invisible): Fix my brain fart.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41900
diff
changeset
|
279 /* When counting columns (window == nil), don't skip over ellipsis text. */ |
30053d20015f
(skip_invisible): Fix my brain fart.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41900
diff
changeset
|
280 if (NILP (window) ? inv_p == 1 : inv_p) |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
281 return *next_boundary_p; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
282 return pos; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
283 } |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
284 |
26859
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
285 /* If a composition starts at POS/POS_BYTE and it doesn't stride over |
29405 | 286 POINT, set *LEN / *LEN_BYTE to the character and byte lengths, *WIDTH |
26859
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
287 to the width, and return 1. Otherwise, return 0. */ |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
288 |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
289 static int |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
290 check_composition (pos, pos_byte, point, len, len_byte, width) |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
291 int pos, pos_byte, point; |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
292 int *len, *len_byte, *width; |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
293 { |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
294 Lisp_Object prop; |
89510
7e2d74e52afc
(check_composition): Make start and end EMACS_INT.
Dave Love <fx@gnu.org>
parents:
89483
diff
changeset
|
295 EMACS_INT start, end; |
26859
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
296 int id; |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
297 |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
298 if (! find_composition (pos, -1, &start, &end, &prop, Qnil) |
35405
d11cb64840ee
(check_composition): Check validity of composition.
Kenichi Handa <handa@m17n.org>
parents:
34967
diff
changeset
|
299 || pos != start || point < end |
d11cb64840ee
(check_composition): Check validity of composition.
Kenichi Handa <handa@m17n.org>
parents:
34967
diff
changeset
|
300 || !COMPOSITION_VALID_P (start, end, prop)) |
26859
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
301 return 0; |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
302 if ((id = get_composition_id (pos, pos_byte, end - pos, prop, Qnil)) < 0) |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
303 return 0; |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
304 |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
305 *len = COMPOSITION_LENGTH (prop); |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
306 *len_byte = CHAR_TO_BYTE (end) - pos_byte; |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
307 *width = composition_table[id]->width; |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
308 return 1; |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
309 } |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
310 |
20938
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
311 /* Set variables WIDTH and BYTES for a multibyte sequence starting at P. |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
312 |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
313 DP is a display table or NULL. |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
314 |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
315 This macro is used in current_column_1, Fmove_to_column, and |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
316 compute_motion. */ |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
317 |
26859
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
318 #define MULTIBYTE_BYTES_WIDTH(p, dp) \ |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
319 do { \ |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
320 int c; \ |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
321 \ |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
322 wide_column = 0; \ |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
323 c = STRING_CHAR_AND_LENGTH (p, MAX_MULTIBYTE_LENGTH, bytes); \ |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
324 if (BYTES_BY_CHAR_HEAD (*p) != bytes) \ |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
325 width = bytes * 4; \ |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
326 else \ |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
327 { \ |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
328 if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, c))) \ |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
329 width = XVECTOR (DISP_CHAR_VECTOR (dp, c))->size; \ |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
330 else \ |
88377
beebc1deb7f2
Include "character.h" instead of "charset.h".
Kenichi Handa <handa@m17n.org>
parents:
41900
diff
changeset
|
331 width = CHAR_WIDTH (c); \ |
26859
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
332 if (width > 1) \ |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
333 wide_column = width; \ |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
334 } \ |
20938
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
335 } while (0) |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
336 |
45622
ff3b6311d00f
(last_known_column): Now a float.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
44839
diff
changeset
|
337 |
165 | 338 DEFUN ("current-column", Fcurrent_column, Scurrent_column, 0, 0, 0, |
40123
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
339 doc: /* Return the horizontal position of point. Beginning of line is column 0. |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
340 This is calculated by adding together the widths of all the displayed |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
341 representations of the character between the start of the previous line |
72885
0e86882b32a9
(Fcurrent_column, Findent_to): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
72575
diff
changeset
|
342 and point (eg. control characters will have a width of 2 or 4, tabs |
0e86882b32a9
(Fcurrent_column, Findent_to): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
72575
diff
changeset
|
343 will have a variable width). |
40123
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
344 Ignores finite width of frame, which means that this function may return |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
345 values greater than (frame-width). |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
346 Whether the line is visible (if `selective-display' is t) has no effect; |
59710
dc40d9822125
(Fcurrent_column): Doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59647
diff
changeset
|
347 however, ^M is treated as end of line when `selective-display' is t. |
dc40d9822125
(Fcurrent_column): Doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59647
diff
changeset
|
348 Text that has an invisible property is considered as having width 0, unless |
dc40d9822125
(Fcurrent_column): Doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59647
diff
changeset
|
349 `buffer-invisibility-spec' specifies that it is replaced by an ellipsis. */) |
40123
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
350 () |
165 | 351 { |
352 Lisp_Object temp; | |
45622
ff3b6311d00f
(last_known_column): Now a float.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
44839
diff
changeset
|
353 XSETFASTINT (temp, (int) current_column ()); /* iftc */ |
165 | 354 return temp; |
355 } | |
356 | |
327 | 357 /* Cancel any recorded value of the horizontal position. */ |
358 | |
20371
976eed15d6b5
(invalidate_current_column): Declare it as void.
Kenichi Handa <handa@m17n.org>
parents:
20256
diff
changeset
|
359 void |
327 | 360 invalidate_current_column () |
361 { | |
362 last_known_column_point = 0; | |
363 } | |
364 | |
46303
ebb83f095b2a
(last_known_column): Declare as double, not float.
Richard M. Stallman <rms@gnu.org>
parents:
45622
diff
changeset
|
365 double |
165 | 366 current_column () |
367 { | |
368 register int col; | |
369 register unsigned char *ptr, *stop; | |
370 register int tab_seen; | |
371 int post_tab; | |
372 register int c; | |
373 register int tab_width = XINT (current_buffer->tab_width); | |
488 | 374 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
|
375 register struct Lisp_Char_Table *dp = buffer_display_table (); |
165 | 376 |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15659
diff
changeset
|
377 if (PT == last_known_column_point |
165 | 378 && MODIFF == last_known_column_modified) |
379 return last_known_column; | |
380 | |
20694
83a65a1efdaa
(current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents:
20571
diff
changeset
|
381 /* If the buffer has overlays, text properties, |
83a65a1efdaa
(current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents:
20571
diff
changeset
|
382 or multibyte characters, use a more general algorithm. */ |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
383 if (BUF_INTERVALS (current_buffer) |
51838
d0e8a670d28d
(current_column): Use new type for overlays_(before|after).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51206
diff
changeset
|
384 || current_buffer->overlays_before |
d0e8a670d28d
(current_column): Use new type for overlays_(before|after).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51206
diff
changeset
|
385 || current_buffer->overlays_after |
20694
83a65a1efdaa
(current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents:
20571
diff
changeset
|
386 || Z != Z_BYTE) |
83a65a1efdaa
(current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents:
20571
diff
changeset
|
387 return current_column_1 (); |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
388 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
389 /* 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
|
390 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
|
391 |
165 | 392 /* Make a pointer for decrementing through the chars before point. */ |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
393 ptr = BYTE_POS_ADDR (PT_BYTE - 1) + 1; |
165 | 394 /* Make a pointer to where consecutive chars leave off, |
395 going backwards from point. */ | |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15659
diff
changeset
|
396 if (PT == BEGV) |
165 | 397 stop = ptr; |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15659
diff
changeset
|
398 else if (PT <= GPT || BEGV > GPT) |
165 | 399 stop = BEGV_ADDR; |
400 else | |
401 stop = GAP_END_ADDR; | |
402 | |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
403 if (tab_width <= 0 || tab_width > 1000) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
404 tab_width = 8; |
165 | 405 |
406 col = 0, tab_seen = 0, post_tab = 0; | |
407 | |
408 while (1) | |
409 { | |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
410 EMACS_INT i, n; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
411 Lisp_Object charvec; |
45622
ff3b6311d00f
(last_known_column): Now a float.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
44839
diff
changeset
|
412 |
165 | 413 if (ptr == stop) |
414 { | |
415 /* We stopped either for the beginning of the buffer | |
416 or for the gap. */ | |
417 if (ptr == BEGV_ADDR) | |
418 break; | |
45622
ff3b6311d00f
(last_known_column): Now a float.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
44839
diff
changeset
|
419 |
165 | 420 /* It was the gap. Jump back over it. */ |
421 stop = BEGV_ADDR; | |
422 ptr = GPT_ADDR; | |
45622
ff3b6311d00f
(last_known_column): Now a float.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
44839
diff
changeset
|
423 |
165 | 424 /* Check whether that brings us to beginning of buffer. */ |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
425 if (BEGV >= GPT) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
426 break; |
165 | 427 } |
428 | |
429 c = *--ptr; | |
45622
ff3b6311d00f
(last_known_column): Now a float.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
44839
diff
changeset
|
430 |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
431 if (dp && VECTORP (DISP_CHAR_VECTOR (dp, c))) |
19208
1d24f0a03f75
(current_column): Update ptr differently at newline
Richard M. Stallman <rms@gnu.org>
parents:
19080
diff
changeset
|
432 { |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
433 charvec = DISP_CHAR_VECTOR (dp, c); |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
434 n = ASIZE (charvec); |
165 | 435 } |
436 else | |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
437 { |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
438 charvec = Qnil; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
439 n = 1; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
440 } |
45622
ff3b6311d00f
(last_known_column): Now a float.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
44839
diff
changeset
|
441 |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
442 for (i = n - 1; i >= 0; --i) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
443 { |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
444 if (VECTORP (charvec)) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
445 { |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
446 /* This should be handled the same as |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
447 next_element_from_display_vector does it. */ |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
448 Lisp_Object entry = AREF (charvec, i); |
45622
ff3b6311d00f
(last_known_column): Now a float.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
44839
diff
changeset
|
449 |
92278
ec0a63595f5b
(current_column, current_column_1, Fmove_to_column)
Kim F. Storm <storm@cua.dk>
parents:
91327
diff
changeset
|
450 if (GLYPH_CODE_P (entry) |
ec0a63595f5b
(current_column, current_column_1, Fmove_to_column)
Kim F. Storm <storm@cua.dk>
parents:
91327
diff
changeset
|
451 && GLYPH_CODE_CHAR_VALID_P (entry)) |
ec0a63595f5b
(current_column, current_column_1, Fmove_to_column)
Kim F. Storm <storm@cua.dk>
parents:
91327
diff
changeset
|
452 c = GLYPH_CODE_CHAR (entry); |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
453 else |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
454 c = ' '; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
455 } |
45622
ff3b6311d00f
(last_known_column): Now a float.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
44839
diff
changeset
|
456 |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
457 if (c >= 040 && c < 0177) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
458 col++; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
459 else if (c == '\n' |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
460 || (c == '\r' |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
461 && EQ (current_buffer->selective_display, Qt))) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
462 { |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
463 ptr++; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
464 goto start_of_line_found; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
465 } |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
466 else if (c == '\t') |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
467 { |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
468 if (tab_seen) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
469 col = ((col + tab_width) / tab_width) * tab_width; |
45622
ff3b6311d00f
(last_known_column): Now a float.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
44839
diff
changeset
|
470 |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
471 post_tab += col; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
472 col = 0; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
473 tab_seen = 1; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
474 } |
38530
90ab35fe206c
(current_column): Fix column computation in the
Gerd Moellmann <gerd@gnu.org>
parents:
37917
diff
changeset
|
475 else if (VECTORP (charvec)) |
90ab35fe206c
(current_column): Fix column computation in the
Gerd Moellmann <gerd@gnu.org>
parents:
37917
diff
changeset
|
476 /* With a display table entry, C is displayed as is, and |
90ab35fe206c
(current_column): Fix column computation in the
Gerd Moellmann <gerd@gnu.org>
parents:
37917
diff
changeset
|
477 not displayed as \NNN or as ^N. If C is a single-byte |
90ab35fe206c
(current_column): Fix column computation in the
Gerd Moellmann <gerd@gnu.org>
parents:
37917
diff
changeset
|
478 character, it takes one column. If C is multi-byte in |
90ab35fe206c
(current_column): Fix column computation in the
Gerd Moellmann <gerd@gnu.org>
parents:
37917
diff
changeset
|
479 an unibyte buffer, it's translated to unibyte, so it |
90ab35fe206c
(current_column): Fix column computation in the
Gerd Moellmann <gerd@gnu.org>
parents:
37917
diff
changeset
|
480 also takes one column. */ |
90ab35fe206c
(current_column): Fix column computation in the
Gerd Moellmann <gerd@gnu.org>
parents:
37917
diff
changeset
|
481 ++col; |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
482 else |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
483 col += (ctl_arrow && c < 0200) ? 2 : 4; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
484 } |
165 | 485 } |
486 | |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
487 start_of_line_found: |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
488 |
165 | 489 if (tab_seen) |
490 { | |
491 col = ((col + tab_width) / tab_width) * tab_width; | |
492 col += post_tab; | |
493 } | |
494 | |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
495 if (ptr == BEGV_ADDR) |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
496 current_column_bol_cache = BEGV; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
497 else |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
498 current_column_bol_cache = BYTE_TO_CHAR (PTR_BYTE_POS (ptr)); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
499 |
165 | 500 last_known_column = col; |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15659
diff
changeset
|
501 last_known_column_point = PT; |
165 | 502 last_known_column_modified = MODIFF; |
503 | |
504 return col; | |
505 } | |
506 | |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
507 /* 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
|
508 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
|
509 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
|
510 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
|
511 |
46303
ebb83f095b2a
(last_known_column): Declare as double, not float.
Richard M. Stallman <rms@gnu.org>
parents:
45622
diff
changeset
|
512 static double |
20694
83a65a1efdaa
(current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents:
20571
diff
changeset
|
513 current_column_1 () |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
514 { |
84951 | 515 register EMACS_INT tab_width = XINT (current_buffer->tab_width); |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
516 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
|
517 register struct Lisp_Char_Table *dp = buffer_display_table (); |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
518 int multibyte = !NILP (current_buffer->enable_multibyte_characters); |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
519 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
520 /* Start the scan at the beginning of this line with column number 0. */ |
84951 | 521 register EMACS_INT col = 0; |
522 EMACS_INT scan, scan_byte; | |
523 EMACS_INT next_boundary; | |
524 EMACS_INT opoint = PT, opoint_byte = PT_BYTE; | |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
525 |
20694
83a65a1efdaa
(current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents:
20571
diff
changeset
|
526 scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -1, 1); |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
527 current_column_bol_cache = PT; |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
528 scan = PT, scan_byte = PT_BYTE; |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
529 SET_PT_BOTH (opoint, opoint_byte); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
530 next_boundary = scan; |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
531 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
532 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
|
533 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
534 /* Scan forward to the target position. */ |
20694
83a65a1efdaa
(current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents:
20571
diff
changeset
|
535 while (scan < opoint) |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
536 { |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
537 int c; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
538 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
539 /* 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
|
540 while (scan == next_boundary) |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
541 { |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
542 int old_scan = scan; |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
543 /* 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
|
544 where we might need to skip more invisible text. */ |
20694
83a65a1efdaa
(current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents:
20571
diff
changeset
|
545 scan = skip_invisible (scan, &next_boundary, opoint, Qnil); |
83a65a1efdaa
(current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents:
20571
diff
changeset
|
546 if (scan >= opoint) |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
547 goto endloop; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
548 if (scan != old_scan) |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
549 scan_byte = CHAR_TO_BYTE (scan); |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
550 } |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
551 |
26859
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
552 /* Check composition sequence. */ |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
553 { |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
554 int len, len_byte, width; |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
555 |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
556 if (check_composition (scan, scan_byte, opoint, |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
557 &len, &len_byte, &width)) |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
558 { |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
559 scan += len; |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
560 scan_byte += len_byte; |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
561 if (scan <= opoint) |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
562 col += width; |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
563 continue; |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
564 } |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
565 } |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
566 |
20694
83a65a1efdaa
(current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents:
20571
diff
changeset
|
567 c = FETCH_BYTE (scan_byte); |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
568 |
20938
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
569 if (dp != 0 |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
570 && ! (multibyte && BASE_LEADING_CODE_P (c)) |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
571 && VECTORP (DISP_CHAR_VECTOR (dp, c))) |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
572 { |
40720
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
573 Lisp_Object charvec; |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
574 EMACS_INT i, n; |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
575 |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
576 /* This character is displayed using a vector of glyphs. |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
577 Update the column based on those glyphs. */ |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
578 |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
579 charvec = DISP_CHAR_VECTOR (dp, c); |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
580 n = ASIZE (charvec); |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
581 |
40720
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
582 for (i = 0; i < n; i++) |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
583 { |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
584 /* This should be handled the same as |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
585 next_element_from_display_vector does it. */ |
92278
ec0a63595f5b
(current_column, current_column_1, Fmove_to_column)
Kim F. Storm <storm@cua.dk>
parents:
91327
diff
changeset
|
586 Lisp_Object entry = AREF (charvec, i); |
40720
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
587 |
92278
ec0a63595f5b
(current_column, current_column_1, Fmove_to_column)
Kim F. Storm <storm@cua.dk>
parents:
91327
diff
changeset
|
588 if (GLYPH_CODE_P (entry) |
ec0a63595f5b
(current_column, current_column_1, Fmove_to_column)
Kim F. Storm <storm@cua.dk>
parents:
91327
diff
changeset
|
589 && GLYPH_CODE_CHAR_VALID_P (entry)) |
ec0a63595f5b
(current_column, current_column_1, Fmove_to_column)
Kim F. Storm <storm@cua.dk>
parents:
91327
diff
changeset
|
590 c = GLYPH_CODE_CHAR (entry); |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
591 else |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
592 c = ' '; |
40720
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
593 |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
594 if (c == '\n') |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
595 goto endloop; |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
596 if (c == '\r' && EQ (current_buffer->selective_display, Qt)) |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
597 goto endloop; |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
598 if (c == '\t') |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
599 { |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
600 col += tab_width; |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
601 col = col / tab_width * tab_width; |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
602 } |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
603 else |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
604 ++col; |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
605 } |
40720
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
606 } |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
607 else |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
608 { |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
609 /* The display table says nothing for this character. |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
610 Display it as itself. */ |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
611 |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
612 if (c == '\n') |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
613 goto endloop; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
614 if (c == '\r' && EQ (current_buffer->selective_display, Qt)) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
615 goto endloop; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
616 if (c == '\t') |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
617 { |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
618 col += tab_width; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
619 col = col / tab_width * tab_width; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
620 } |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
621 else if (multibyte && BASE_LEADING_CODE_P (c)) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
622 { |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
623 unsigned char *ptr; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
624 int bytes, width, wide_column; |
45622
ff3b6311d00f
(last_known_column): Now a float.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
44839
diff
changeset
|
625 |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
626 ptr = BYTE_POS_ADDR (scan_byte); |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
627 MULTIBYTE_BYTES_WIDTH (ptr, dp); |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
628 scan_byte += bytes; |
41258
7ed8a77c5b40
(current_column_1): Fix handling of scan_bytes for mb chars.
Richard M. Stallman <rms@gnu.org>
parents:
40836
diff
changeset
|
629 /* Subtract one to compensate for the increment |
7ed8a77c5b40
(current_column_1): Fix handling of scan_bytes for mb chars.
Richard M. Stallman <rms@gnu.org>
parents:
40836
diff
changeset
|
630 that is going to happen below. */ |
7ed8a77c5b40
(current_column_1): Fix handling of scan_bytes for mb chars.
Richard M. Stallman <rms@gnu.org>
parents:
40836
diff
changeset
|
631 scan_byte--; |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
632 col += width; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
633 } |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
634 else if (ctl_arrow && (c < 040 || c == 0177)) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
635 col += 2; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
636 else if (c < 040 || c >= 0177) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
637 col += 4; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
638 else |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
639 col++; |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
640 } |
40720
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
641 scan++; |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
642 scan_byte++; |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
643 |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
644 } |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
645 endloop: |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
646 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
647 last_known_column = col; |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15659
diff
changeset
|
648 last_known_column_point = PT; |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
649 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
|
650 |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
651 return col; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
652 } |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
653 |
37917
5bc9314b5f0a
(string_display_width): Put in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents:
36846
diff
changeset
|
654 |
5bc9314b5f0a
(string_display_width): Put in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents:
36846
diff
changeset
|
655 #if 0 /* Not used. */ |
5bc9314b5f0a
(string_display_width): Put in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents:
36846
diff
changeset
|
656 |
11300
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
657 /* 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
|
658 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
|
659 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
|
660 |
46303
ebb83f095b2a
(last_known_column): Declare as double, not float.
Richard M. Stallman <rms@gnu.org>
parents:
45622
diff
changeset
|
661 static double |
11704
6c9716b7a23d
(string_display_width): Renamed from string_width.
Richard M. Stallman <rms@gnu.org>
parents:
11312
diff
changeset
|
662 string_display_width (string, beg, end) |
11300
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
663 Lisp_Object string, beg, end; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
664 { |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
665 register int col; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
666 register unsigned char *ptr, *stop; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
667 register int tab_seen; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
668 int post_tab; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
669 register int c; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
670 register int tab_width = XINT (current_buffer->tab_width); |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
671 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
|
672 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
|
673 int b, e; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
674 |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
675 if (NILP (end)) |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46303
diff
changeset
|
676 e = SCHARS (string); |
11300
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
677 else |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
678 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40123
diff
changeset
|
679 CHECK_NUMBER (end); |
11300
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
680 e = XINT (end); |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
681 } |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
682 |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
683 if (NILP (beg)) |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
684 b = 0; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
685 else |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
686 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40123
diff
changeset
|
687 CHECK_NUMBER (beg); |
11300
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
688 b = XINT (beg); |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
689 } |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
690 |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
691 /* Make a pointer for decrementing through the chars before point. */ |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46303
diff
changeset
|
692 ptr = SDATA (string) + e; |
11300
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
693 /* Make a pointer to where consecutive chars leave off, |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
694 going backwards from point. */ |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46303
diff
changeset
|
695 stop = SDATA (string) + b; |
11300
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
696 |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
697 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
|
698 |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
699 col = 0, tab_seen = 0, post_tab = 0; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
700 |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
701 while (1) |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
702 { |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
703 if (ptr == stop) |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
704 break; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
705 |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
706 c = *--ptr; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
707 if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, c))) |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
708 col += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
709 else if (c >= 040 && c < 0177) |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
710 col++; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
711 else if (c == '\n') |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
712 break; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
713 else if (c == '\t') |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
714 { |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
715 if (tab_seen) |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
716 col = ((col + tab_width) / tab_width) * tab_width; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
717 |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
718 post_tab += col; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
719 col = 0; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
720 tab_seen = 1; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
721 } |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
722 else |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
723 col += (ctl_arrow && c < 0200) ? 2 : 4; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
724 } |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
725 |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
726 if (tab_seen) |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
727 { |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
728 col = ((col + tab_width) / tab_width) * tab_width; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
729 col += post_tab; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
730 } |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
731 |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
732 return col; |
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
733 } |
37917
5bc9314b5f0a
(string_display_width): Put in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents:
36846
diff
changeset
|
734 |
5bc9314b5f0a
(string_display_width): Put in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents:
36846
diff
changeset
|
735 #endif /* 0 */ |
5bc9314b5f0a
(string_display_width): Put in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents:
36846
diff
changeset
|
736 |
11300
474b17d364db
(string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents:
11037
diff
changeset
|
737 |
165 | 738 DEFUN ("indent-to", Findent_to, Sindent_to, 1, 2, "NIndent to column: ", |
40123
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
739 doc: /* Indent from point with tabs and spaces until COLUMN is reached. |
72885
0e86882b32a9
(Fcurrent_column, Findent_to): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
72575
diff
changeset
|
740 Optional second argument MINIMUM says always do at least MINIMUM spaces |
76707 | 741 even if that goes past COLUMN; by default, MINIMUM is zero. |
742 | |
743 The return value is COLUMN. */) | |
40123
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
744 (column, minimum) |
14078
a46002ac278b
(Findent_to): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
13453
diff
changeset
|
745 Lisp_Object column, minimum; |
165 | 746 { |
747 int mincol; | |
748 register int fromcol; | |
749 register int tab_width = XINT (current_buffer->tab_width); | |
750 | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40123
diff
changeset
|
751 CHECK_NUMBER (column); |
488 | 752 if (NILP (minimum)) |
9310
1dfd9def3467
(Fcurrent_column, Findent_to, Fcurrent_indentation, Fmove_to_column,
Karl Heuer <kwzh@gnu.org>
parents:
9269
diff
changeset
|
753 XSETFASTINT (minimum, 0); |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40123
diff
changeset
|
754 CHECK_NUMBER (minimum); |
165 | 755 |
756 fromcol = current_column (); | |
757 mincol = fromcol + XINT (minimum); | |
14078
a46002ac278b
(Findent_to): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
13453
diff
changeset
|
758 if (mincol < XINT (column)) mincol = XINT (column); |
165 | 759 |
760 if (fromcol == mincol) | |
761 return make_number (mincol); | |
762 | |
2325
7b5299f3a8fc
(current_column, Findent_to, position_indentation):
Richard M. Stallman <rms@gnu.org>
parents:
2017
diff
changeset
|
763 if (tab_width <= 0 || tab_width > 1000) tab_width = 8; |
165 | 764 |
765 if (indent_tabs_mode) | |
766 { | |
767 Lisp_Object n; | |
9310
1dfd9def3467
(Fcurrent_column, Findent_to, Fcurrent_indentation, Fmove_to_column,
Karl Heuer <kwzh@gnu.org>
parents:
9269
diff
changeset
|
768 XSETFASTINT (n, mincol / tab_width - fromcol / tab_width); |
165 | 769 if (XFASTINT (n) != 0) |
770 { | |
8648
f047d8c6db79
(Findent_to): Pass new arg to Finsert_char.
Richard M. Stallman <rms@gnu.org>
parents:
8601
diff
changeset
|
771 Finsert_char (make_number ('\t'), n, Qt); |
165 | 772 |
773 fromcol = (mincol / tab_width) * tab_width; | |
774 } | |
775 } | |
776 | |
14078
a46002ac278b
(Findent_to): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
13453
diff
changeset
|
777 XSETFASTINT (column, mincol - fromcol); |
a46002ac278b
(Findent_to): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
13453
diff
changeset
|
778 Finsert_char (make_number (' '), column, Qt); |
165 | 779 |
780 last_known_column = mincol; | |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15659
diff
changeset
|
781 last_known_column_point = PT; |
165 | 782 last_known_column_modified = MODIFF; |
783 | |
14078
a46002ac278b
(Findent_to): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
13453
diff
changeset
|
784 XSETINT (column, mincol); |
a46002ac278b
(Findent_to): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
13453
diff
changeset
|
785 return column; |
165 | 786 } |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
787 |
165 | 788 |
46303
ebb83f095b2a
(last_known_column): Declare as double, not float.
Richard M. Stallman <rms@gnu.org>
parents:
45622
diff
changeset
|
789 static double position_indentation P_ ((int)); |
21514 | 790 |
165 | 791 DEFUN ("current-indentation", Fcurrent_indentation, Scurrent_indentation, |
40123
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
792 0, 0, 0, |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
793 doc: /* Return the indentation of the current line. |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
794 This is the horizontal position of the character |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
795 following any initial whitespace. */) |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
796 () |
165 | 797 { |
798 Lisp_Object val; | |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
799 int opoint = PT, opoint_byte = PT_BYTE; |
165 | 800 |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
801 scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -1, 1); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
802 |
45622
ff3b6311d00f
(last_known_column): Now a float.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
44839
diff
changeset
|
803 XSETFASTINT (val, (int) position_indentation (PT_BYTE)); /* iftc */ |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
804 SET_PT_BOTH (opoint, opoint_byte); |
165 | 805 return val; |
806 } | |
807 | |
46303
ebb83f095b2a
(last_known_column): Declare as double, not float.
Richard M. Stallman <rms@gnu.org>
parents:
45622
diff
changeset
|
808 static double |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
809 position_indentation (pos_byte) |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
810 register int pos_byte; |
165 | 811 { |
84951 | 812 register EMACS_INT column = 0; |
813 register EMACS_INT tab_width = XINT (current_buffer->tab_width); | |
165 | 814 register unsigned char *p; |
815 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
|
816 unsigned char *start; |
84951 | 817 EMACS_INT next_boundary_byte = pos_byte; |
818 EMACS_INT ceiling = next_boundary_byte; | |
10538
48c620ae0853
(compute_motion): Don't get hung in selective-display loop.
Karl Heuer <kwzh@gnu.org>
parents:
10011
diff
changeset
|
819 |
2325
7b5299f3a8fc
(current_column, Findent_to, position_indentation):
Richard M. Stallman <rms@gnu.org>
parents:
2017
diff
changeset
|
820 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
|
821 |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
822 p = BYTE_POS_ADDR (pos_byte); |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
823 /* 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
|
824 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
|
825 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
|
826 stop = p; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
827 /* 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
|
828 start = p; |
165 | 829 while (1) |
830 { | |
831 while (p == stop) | |
832 { | |
84951 | 833 EMACS_INT stop_pos_byte; |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
834 |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
835 /* If we have updated P, set POS_BYTE to match. |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
836 The first time we enter the loop, POS_BYTE is already right. */ |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
837 if (p != start) |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
838 pos_byte = PTR_BYTE_POS (p); |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
839 /* Consider the various reasons STOP might have been set here. */ |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
840 if (pos_byte == ZV_BYTE) |
165 | 841 return column; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
842 if (pos_byte == next_boundary_byte) |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
843 { |
84951 | 844 EMACS_INT next_boundary; |
845 EMACS_INT pos = BYTE_TO_CHAR (pos_byte); | |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
846 pos = skip_invisible (pos, &next_boundary, ZV, Qnil); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
847 pos_byte = CHAR_TO_BYTE (pos); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
848 next_boundary_byte = CHAR_TO_BYTE (next_boundary); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
849 } |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
850 if (pos_byte >= ceiling) |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
851 ceiling = BUFFER_CEILING_OF (pos_byte) + 1; |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
852 /* 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
|
853 and set STOP accordingly. */ |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
854 stop_pos_byte = min (ceiling, next_boundary_byte); |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
855 /* The -1 and +1 arrange to point at the first byte of gap |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
856 (if STOP_POS_BYTE is the position of the gap) |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
857 rather than at the data after the gap. */ |
45622
ff3b6311d00f
(last_known_column): Now a float.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
44839
diff
changeset
|
858 |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
859 stop = BYTE_POS_ADDR (stop_pos_byte - 1) + 1; |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
860 p = BYTE_POS_ADDR (pos_byte); |
165 | 861 } |
862 switch (*p++) | |
863 { | |
20256
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
864 case 0240: |
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
865 if (! NILP (current_buffer->enable_multibyte_characters)) |
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
866 return column; |
165 | 867 case ' ': |
868 column++; | |
869 break; | |
870 case '\t': | |
871 column += tab_width - column % tab_width; | |
872 break; | |
873 default: | |
20256
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
874 if (ASCII_BYTE_P (p[-1]) |
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
875 || NILP (current_buffer->enable_multibyte_characters)) |
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
876 return column; |
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
877 { |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
878 int c; |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
879 pos_byte = PTR_BYTE_POS (p - 1); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
880 c = FETCH_MULTIBYTE_CHAR (pos_byte); |
20256
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
881 if (CHAR_HAS_CATEGORY (c, ' ')) |
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
882 { |
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
883 column++; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
884 INC_POS (pos_byte); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
885 p = BYTE_POS_ADDR (pos_byte); |
20256
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
886 } |
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
887 else |
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
888 return column; |
f75208097eb5
(position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents:
19938
diff
changeset
|
889 } |
165 | 890 } |
891 } | |
892 } | |
5943
35526ee8b790
(indented_beyond_p): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5941
diff
changeset
|
893 |
35526ee8b790
(indented_beyond_p): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5941
diff
changeset
|
894 /* 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
|
895 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
|
896 preceding line. */ |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
897 |
5943
35526ee8b790
(indented_beyond_p): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5941
diff
changeset
|
898 int |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
899 indented_beyond_p (pos, pos_byte, column) |
45622
ff3b6311d00f
(last_known_column): Now a float.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
44839
diff
changeset
|
900 int pos, pos_byte; |
46303
ebb83f095b2a
(last_known_column): Declare as double, not float.
Richard M. Stallman <rms@gnu.org>
parents:
45622
diff
changeset
|
901 double column; |
5943
35526ee8b790
(indented_beyond_p): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5941
diff
changeset
|
902 { |
46303
ebb83f095b2a
(last_known_column): Declare as double, not float.
Richard M. Stallman <rms@gnu.org>
parents:
45622
diff
changeset
|
903 double val; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
904 int opoint = PT, opoint_byte = PT_BYTE; |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
905 |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
906 SET_PT_BOTH (pos, pos_byte); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
907 while (PT > BEGV && FETCH_BYTE (PT_BYTE) == '\n') |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
908 scan_newline (PT - 1, PT_BYTE - 1, BEGV, BEGV_BYTE, -1, 0); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
909 |
21525
0ed9ea6eeef3
(indented_beyond_p): Fix mixing of Lisp_Object and int.
Andreas Schwab <schwab@suse.de>
parents:
21514
diff
changeset
|
910 val = position_indentation (PT_BYTE); |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
911 SET_PT_BOTH (opoint, opoint_byte); |
45622
ff3b6311d00f
(last_known_column): Now a float.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
44839
diff
changeset
|
912 return val >= column; /* hmm, float comparison */ |
5943
35526ee8b790
(indented_beyond_p): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5941
diff
changeset
|
913 } |
165 | 914 |
13124
e44b06fc718d
(Fmove_to_column): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
915 DEFUN ("move-to-column", Fmove_to_column, Smove_to_column, 1, 2, "p", |
40123
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
916 doc: /* Move point to column COLUMN in the current line. |
75652
bd6d4488b990
(Fmove_to_column): Document that the argument COLUMN is taken from prefix
Eli Zaretskii <eliz@gnu.org>
parents:
75348
diff
changeset
|
917 Interactively, COLUMN is the value of prefix numeric argument. |
40123
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
918 The column of a character is calculated by adding together the widths |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
919 as displayed of the previous characters in the line. |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
920 This function ignores line-continuation; |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
921 there is no upper limit on the column number a character can have |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
922 and horizontal scrolling has no effect. |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
923 |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
924 If specified column is within a character, point goes after that character. |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
925 If it's past end of line, point goes to end of line. |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
926 |
75652
bd6d4488b990
(Fmove_to_column): Document that the argument COLUMN is taken from prefix
Eli Zaretskii <eliz@gnu.org>
parents:
75348
diff
changeset
|
927 Optional second argument FORCE non-nil means if COLUMN is in the |
bd6d4488b990
(Fmove_to_column): Document that the argument COLUMN is taken from prefix
Eli Zaretskii <eliz@gnu.org>
parents:
75348
diff
changeset
|
928 middle of a tab character, change it to spaces. |
bd6d4488b990
(Fmove_to_column): Document that the argument COLUMN is taken from prefix
Eli Zaretskii <eliz@gnu.org>
parents:
75348
diff
changeset
|
929 In addition, if FORCE is t, and the line is too short to reach |
bd6d4488b990
(Fmove_to_column): Document that the argument COLUMN is taken from prefix
Eli Zaretskii <eliz@gnu.org>
parents:
75348
diff
changeset
|
930 COLUMN, add spaces/tabs to get there. |
40123
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
931 |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
932 The return value is the current column. */) |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
933 (column, force) |
165 | 934 Lisp_Object column, force; |
935 { | |
84950
07824eca67a8
(Fmove_to_column): Use EMACS_INT for buffer positions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
83652
diff
changeset
|
936 register EMACS_INT pos; |
07824eca67a8
(Fmove_to_column): Use EMACS_INT for buffer positions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
83652
diff
changeset
|
937 register EMACS_INT col = current_column (); |
07824eca67a8
(Fmove_to_column): Use EMACS_INT for buffer positions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
83652
diff
changeset
|
938 register EMACS_INT goal; |
07824eca67a8
(Fmove_to_column): Use EMACS_INT for buffer positions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
83652
diff
changeset
|
939 register EMACS_INT end; |
165 | 940 register int tab_width = XINT (current_buffer->tab_width); |
488 | 941 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
|
942 register struct Lisp_Char_Table *dp = buffer_display_table (); |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
943 register int multibyte = !NILP (current_buffer->enable_multibyte_characters); |
165 | 944 |
945 Lisp_Object val; | |
84950
07824eca67a8
(Fmove_to_column): Use EMACS_INT for buffer positions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
83652
diff
changeset
|
946 EMACS_INT prev_col = 0; |
31829
43566b0aec59
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
31102
diff
changeset
|
947 int c = 0; |
84950
07824eca67a8
(Fmove_to_column): Use EMACS_INT for buffer positions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
83652
diff
changeset
|
948 EMACS_INT next_boundary, pos_byte; |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
949 |
2325
7b5299f3a8fc
(current_column, Findent_to, position_indentation):
Richard M. Stallman <rms@gnu.org>
parents:
2017
diff
changeset
|
950 if (tab_width <= 0 || tab_width > 1000) tab_width = 8; |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40123
diff
changeset
|
951 CHECK_NATNUM (column); |
165 | 952 goal = XINT (column); |
953 | |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15659
diff
changeset
|
954 pos = PT; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
955 pos_byte = PT_BYTE; |
165 | 956 end = ZV; |
957 | |
958 /* If we're starting past the desired column, | |
959 back up to beginning of line and scan from there. */ | |
960 if (col > goal) | |
961 { | |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
962 end = pos; |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
963 pos = current_column_bol_cache; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
964 pos_byte = CHAR_TO_BYTE (pos); |
165 | 965 col = 0; |
966 } | |
967 | |
77069
50bb3d12f1b1
(Fmove_to_column): Set next_boundary with correct start pt.
Richard M. Stallman <rms@gnu.org>
parents:
76707
diff
changeset
|
968 next_boundary = pos; |
50bb3d12f1b1
(Fmove_to_column): Set next_boundary with correct start pt.
Richard M. Stallman <rms@gnu.org>
parents:
76707
diff
changeset
|
969 |
15554
103a6af424a8
(Fmove_to_column): Go after invis chars at the goal column.
Richard M. Stallman <rms@gnu.org>
parents:
15494
diff
changeset
|
970 while (pos < end) |
165 | 971 { |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
972 while (pos == next_boundary) |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
973 { |
84950
07824eca67a8
(Fmove_to_column): Use EMACS_INT for buffer positions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
83652
diff
changeset
|
974 EMACS_INT prev = pos; |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
975 pos = skip_invisible (pos, &next_boundary, end, Qnil); |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
976 if (pos != prev) |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
977 pos_byte = CHAR_TO_BYTE (pos); |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
978 if (pos >= end) |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
979 goto endloop; |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
980 } |
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
981 |
15554
103a6af424a8
(Fmove_to_column): Go after invis chars at the goal column.
Richard M. Stallman <rms@gnu.org>
parents:
15494
diff
changeset
|
982 /* 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
|
983 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
|
984 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
|
985 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
|
986 break; |
103a6af424a8
(Fmove_to_column): Go after invis chars at the goal column.
Richard M. Stallman <rms@gnu.org>
parents:
15494
diff
changeset
|
987 |
26859
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
988 /* Check composition sequence. */ |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
989 { |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
990 int len, len_byte, width; |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
991 |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
992 if (check_composition (pos, pos_byte, Z, &len, &len_byte, &width)) |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
993 { |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
994 pos += len; |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
995 pos_byte += len_byte; |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
996 col += width; |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
997 continue; |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
998 } |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
999 } |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
1000 |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1001 c = FETCH_BYTE (pos_byte); |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1002 |
40720
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1003 /* See if there is a display table and it relates |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1004 to this character. */ |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1005 |
20938
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
1006 if (dp != 0 |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
1007 && ! (multibyte && BASE_LEADING_CODE_P (c)) |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
1008 && VECTORP (DISP_CHAR_VECTOR (dp, c))) |
11037
802a774b44b7
(compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents:
10964
diff
changeset
|
1009 { |
40720
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1010 Lisp_Object charvec; |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1011 EMACS_INT i, n; |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1012 |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1013 /* This character is displayed using a vector of glyphs. |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1014 Update the position based on those glyphs. */ |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1015 |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1016 charvec = DISP_CHAR_VECTOR (dp, c); |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1017 n = ASIZE (charvec); |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1018 |
40720
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1019 for (i = 0; i < n; i++) |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1020 { |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1021 /* This should be handled the same as |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1022 next_element_from_display_vector does it. */ |
92278
ec0a63595f5b
(current_column, current_column_1, Fmove_to_column)
Kim F. Storm <storm@cua.dk>
parents:
91327
diff
changeset
|
1023 Lisp_Object entry = AREF (charvec, i); |
40720
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1024 |
92278
ec0a63595f5b
(current_column, current_column_1, Fmove_to_column)
Kim F. Storm <storm@cua.dk>
parents:
91327
diff
changeset
|
1025 if (GLYPH_CODE_P (entry) |
ec0a63595f5b
(current_column, current_column_1, Fmove_to_column)
Kim F. Storm <storm@cua.dk>
parents:
91327
diff
changeset
|
1026 && GLYPH_CODE_CHAR_VALID_P (entry)) |
ec0a63595f5b
(current_column, current_column_1, Fmove_to_column)
Kim F. Storm <storm@cua.dk>
parents:
91327
diff
changeset
|
1027 c = GLYPH_CODE_CHAR (entry); |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1028 else |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1029 c = ' '; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1030 |
40720
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1031 if (c == '\n') |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1032 goto endloop; |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1033 if (c == '\r' && EQ (current_buffer->selective_display, Qt)) |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1034 goto endloop; |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1035 if (c == '\t') |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1036 { |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1037 prev_col = col; |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1038 col += tab_width; |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1039 col = col / tab_width * tab_width; |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1040 } |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1041 else |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1042 ++col; |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1043 } |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1044 } |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1045 else |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1046 { |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1047 /* The display table doesn't affect this character; |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1048 it displays as itself. */ |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1049 |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1050 if (c == '\n') |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1051 goto endloop; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1052 if (c == '\r' && EQ (current_buffer->selective_display, Qt)) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1053 goto endloop; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1054 if (c == '\t') |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1055 { |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1056 prev_col = col; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1057 col += tab_width; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1058 col = col / tab_width * tab_width; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1059 } |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1060 else if (ctl_arrow && (c < 040 || c == 0177)) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1061 col += 2; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1062 else if (c < 040 || c == 0177) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1063 col += 4; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1064 else if (c < 0177) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1065 col++; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1066 else if (multibyte && BASE_LEADING_CODE_P (c)) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1067 { |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1068 /* Start of multi-byte form. */ |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1069 unsigned char *ptr; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1070 int bytes, width, wide_column; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1071 |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1072 ptr = BYTE_POS_ADDR (pos_byte); |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1073 MULTIBYTE_BYTES_WIDTH (ptr, dp); |
40720
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1074 pos_byte += bytes - 1; |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1075 col += width; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1076 } |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1077 else |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1078 col += 4; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1079 } |
40720
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1080 |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1081 pos++; |
db9254d9c5d0
(current_column_1, Fmove_to_column): Separate the code
Richard M. Stallman <rms@gnu.org>
parents:
40656
diff
changeset
|
1082 pos_byte++; |
165 | 1083 } |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
1084 endloop: |
165 | 1085 |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1086 SET_PT_BOTH (pos, pos_byte); |
165 | 1087 |
1088 /* If a tab char made us overshoot, change it to spaces | |
1089 and scan through it again. */ | |
488 | 1090 if (!NILP (force) && col > goal && c == '\t' && prev_col < goal) |
165 | 1091 { |
84950
07824eca67a8
(Fmove_to_column): Use EMACS_INT for buffer positions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
83652
diff
changeset
|
1092 EMACS_INT goal_pt, goal_pt_byte; |
28933
bb0cf4868e70
(Fmove_to_column): When ending within a tab, insert
Gerd Moellmann <gerd@gnu.org>
parents:
28537
diff
changeset
|
1093 |
bb0cf4868e70
(Fmove_to_column): When ending within a tab, insert
Gerd Moellmann <gerd@gnu.org>
parents:
28537
diff
changeset
|
1094 /* Insert spaces in front of the tab to reach GOAL. Do this |
bb0cf4868e70
(Fmove_to_column): When ending within a tab, insert
Gerd Moellmann <gerd@gnu.org>
parents:
28537
diff
changeset
|
1095 first so that a marker at the end of the tab gets |
bb0cf4868e70
(Fmove_to_column): When ending within a tab, insert
Gerd Moellmann <gerd@gnu.org>
parents:
28537
diff
changeset
|
1096 adjusted. */ |
bb0cf4868e70
(Fmove_to_column): When ending within a tab, insert
Gerd Moellmann <gerd@gnu.org>
parents:
28537
diff
changeset
|
1097 SET_PT_BOTH (PT - 1, PT_BYTE - 1); |
bb0cf4868e70
(Fmove_to_column): When ending within a tab, insert
Gerd Moellmann <gerd@gnu.org>
parents:
28537
diff
changeset
|
1098 Finsert_char (make_number (' '), make_number (goal - prev_col), Qt); |
573 | 1099 |
28933
bb0cf4868e70
(Fmove_to_column): When ending within a tab, insert
Gerd Moellmann <gerd@gnu.org>
parents:
28537
diff
changeset
|
1100 /* Now delete the tab, and indent to COL. */ |
bb0cf4868e70
(Fmove_to_column): When ending within a tab, insert
Gerd Moellmann <gerd@gnu.org>
parents:
28537
diff
changeset
|
1101 del_range (PT, PT + 1); |
bb0cf4868e70
(Fmove_to_column): When ending within a tab, insert
Gerd Moellmann <gerd@gnu.org>
parents:
28537
diff
changeset
|
1102 goal_pt = PT; |
bb0cf4868e70
(Fmove_to_column): When ending within a tab, insert
Gerd Moellmann <gerd@gnu.org>
parents:
28537
diff
changeset
|
1103 goal_pt_byte = PT_BYTE; |
573 | 1104 Findent_to (make_number (col), Qnil); |
28933
bb0cf4868e70
(Fmove_to_column): When ending within a tab, insert
Gerd Moellmann <gerd@gnu.org>
parents:
28537
diff
changeset
|
1105 SET_PT_BOTH (goal_pt, goal_pt_byte); |
45622
ff3b6311d00f
(last_known_column): Now a float.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
44839
diff
changeset
|
1106 |
4385
edffa4f0c5d9
(compute_motion): Compute correctly for invisible text.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
1107 /* Set the last_known... vars consistently. */ |
edffa4f0c5d9
(compute_motion): Compute correctly for invisible text.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
1108 col = goal; |
165 | 1109 } |
1110 | |
1111 /* If line ends prematurely, add space to the end. */ | |
25073
0cac51b5af77
(Fmove_to_column): Extend end of line only if FORCE is t.
Karl Heuer <kwzh@gnu.org>
parents:
25028
diff
changeset
|
1112 if (col < goal && EQ (force, Qt)) |
1208
fa662930e654
* indent.c (Fmove_to_column): Pass the right number of arguments
Jim Blandy <jimb@redhat.com>
parents:
764
diff
changeset
|
1113 Findent_to (make_number (col = goal), Qnil); |
165 | 1114 |
1115 last_known_column = col; | |
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15659
diff
changeset
|
1116 last_known_column_point = PT; |
165 | 1117 last_known_column_modified = MODIFF; |
1118 | |
9310
1dfd9def3467
(Fcurrent_column, Findent_to, Fcurrent_indentation, Fmove_to_column,
Karl Heuer <kwzh@gnu.org>
parents:
9269
diff
changeset
|
1119 XSETFASTINT (val, col); |
165 | 1120 return val; |
1121 } | |
1122 | |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1123 /* 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
|
1124 |
165 | 1125 struct position val_compute_motion; |
1126 | |
1127 /* Scan the current buffer forward from offset FROM, pretending that | |
1128 this is at line FROMVPOS, column FROMHPOS, until reaching buffer | |
1129 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
|
1130 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
|
1131 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
|
1132 multi-column character), overshoot. |
165 | 1133 |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1134 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
|
1135 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
|
1136 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
|
1137 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
|
1138 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
|
1139 |
165 | 1140 WIDTH is the number of columns available to display text; |
1141 compute_motion uses this to handle continuation lines and such. | |
56584
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1142 If WIDTH is -1, use width of window's text area adjusted for |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1143 continuation glyph when needed. |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1144 |
165 | 1145 HSCROLL is the number of columns not being displayed at the left |
1146 margin; this is usually taken from a window's hscroll member. | |
543 | 1147 TAB_OFFSET is the number of columns of the first tab that aren't |
1148 being displayed, perhaps because of a continuation line or | |
1149 something. | |
165 | 1150 |
1151 compute_motion returns a pointer to a struct position. The bufpos | |
1152 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
|
1153 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
|
1154 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
|
1155 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
|
1156 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1157 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
|
1158 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
|
1159 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
|
1160 -HSCROLL + (HSCROLL > 0). |
165 | 1161 |
1162 For example, to find the buffer position of column COL of line LINE | |
1163 of a certain window, pass the window's starting location as FROM | |
1164 and the window's upper-left coordinates as FROMVPOS and FROMHPOS. | |
1165 Pass the buffer's ZV as TO, to limit the scan to the end of the | |
1166 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
|
1167 TOHPOS. |
165 | 1168 |
1169 When displaying in window w, a typical formula for WIDTH is: | |
1170 | |
1171 window_width - 1 | |
1994
73ce9dd21093
Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents:
1777
diff
changeset
|
1172 - (has_vertical_scroll_bars |
51206
22a5614b558f
Make (few) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
48587
diff
changeset
|
1173 ? WINDOW_CONFIG_SCROLL_BAR_COLS (window) |
22a5614b558f
Make (few) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
48587
diff
changeset
|
1174 : (window_width + window_left != frame_cols)) |
165 | 1175 |
1176 where | |
51206
22a5614b558f
Make (few) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
48587
diff
changeset
|
1177 window_width is XFASTINT (w->total_cols), |
22a5614b558f
Make (few) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
48587
diff
changeset
|
1178 window_left is XFASTINT (w->left_col), |
1994
73ce9dd21093
Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents:
1777
diff
changeset
|
1179 has_vertical_scroll_bars is |
51206
22a5614b558f
Make (few) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
48587
diff
changeset
|
1180 WINDOW_HAS_VERTICAL_SCROLL_BAR (window) |
22a5614b558f
Make (few) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
48587
diff
changeset
|
1181 and frame_cols = FRAME_COLS (XFRAME (window->frame)) |
165 | 1182 |
51206
22a5614b558f
Make (few) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
48587
diff
changeset
|
1183 Or you can let window_box_text_cols do this all for you, and write: |
22a5614b558f
Make (few) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
48587
diff
changeset
|
1184 window_box_text_cols (w) - 1 |
1777
4edfaa19c7a7
* window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents:
1208
diff
changeset
|
1185 |
4edfaa19c7a7
* window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents:
1208
diff
changeset
|
1186 The `-1' accounts for the continuation-line backslashes; the rest |
5941 | 1187 accounts for window borders if the window is split horizontally, and |
6400 | 1188 the scroll bars if they are turned on. */ |
165 | 1189 |
1190 struct position * | |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1191 compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width, hscroll, tab_offset, win) |
84951 | 1192 EMACS_INT from, fromvpos, fromhpos, to, tovpos, tohpos; |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1193 int did_motion; |
84951 | 1194 EMACS_INT width; |
1195 EMACS_INT hscroll, tab_offset; | |
6691
3b56d4742266
(compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents:
6588
diff
changeset
|
1196 struct window *win; |
165 | 1197 { |
84951 | 1198 register EMACS_INT hpos = fromhpos; |
1199 register EMACS_INT vpos = fromvpos; | |
165 | 1200 |
84951 | 1201 register EMACS_INT pos; |
1202 EMACS_INT pos_byte; | |
31829
43566b0aec59
Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents:
31102
diff
changeset
|
1203 register int c = 0; |
84951 | 1204 register EMACS_INT tab_width = XFASTINT (current_buffer->tab_width); |
488 | 1205 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
|
1206 register struct Lisp_Char_Table *dp = window_display_table (win); |
165 | 1207 int selective |
9126
e475f8108156
(buffer_display_table, current_column, Fmove_to_column, compute_motion,
Karl Heuer <kwzh@gnu.org>
parents:
8946
diff
changeset
|
1208 = (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
|
1209 ? 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
|
1210 : !NILP (current_buffer->selective_display) ? -1 : 0); |
165 | 1211 int selective_rlen |
9126
e475f8108156
(buffer_display_table, current_column, Fmove_to_column, compute_motion,
Karl Heuer <kwzh@gnu.org>
parents:
8946
diff
changeset
|
1212 = (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
|
1213 ? XVECTOR (DISP_INVIS_VECTOR (dp))->size : 0); |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1214 /* 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
|
1215 overlay starts or ends. */ |
84951 | 1216 EMACS_INT next_boundary = from; |
165 | 1217 |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1218 /* For computing runs of characters with similar widths. |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1219 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
|
1220 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
|
1221 width_run_width. */ |
84951 | 1222 EMACS_INT width_run_start = from; |
1223 EMACS_INT width_run_end = from; | |
1224 EMACS_INT width_run_width = 0; | |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1225 Lisp_Object *width_table; |
10964
474b6b03a71f
(compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents:
10538
diff
changeset
|
1226 Lisp_Object buffer; |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1227 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1228 /* The next buffer pos where we should consult the width run cache. */ |
84951 | 1229 EMACS_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
|
1230 Lisp_Object window; |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1231 |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1232 int multibyte = !NILP (current_buffer->enable_multibyte_characters); |
21996 | 1233 /* If previous char scanned was a wide character, |
1234 this is the column where it ended. Otherwise, this is 0. */ | |
84951 | 1235 EMACS_INT wide_column_end_hpos = 0; |
1236 EMACS_INT prev_pos; /* Previous buffer position. */ | |
1237 EMACS_INT prev_pos_byte; /* Previous buffer position. */ | |
1238 EMACS_INT prev_hpos = 0; | |
1239 EMACS_INT prev_vpos = 0; | |
1240 EMACS_INT contin_hpos; /* HPOS of last column of continued line. */ | |
1241 EMACS_INT prev_tab_offset; /* Previous tab offset. */ | |
1242 EMACS_INT continuation_glyph_width; | |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1243 |
10964
474b6b03a71f
(compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents:
10538
diff
changeset
|
1244 XSETBUFFER (buffer, current_buffer); |
15059
3b7454f2d662
(compute_motion): Pass window to Fget_char_property.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
1245 XSETWINDOW (window, win); |
10964
474b6b03a71f
(compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents:
10538
diff
changeset
|
1246 |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1247 width_run_cache_on_off (); |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1248 if (dp == buffer_display_table ()) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1249 width_table = (VECTORP (current_buffer->width_table) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1250 ? XVECTOR (current_buffer->width_table)->contents |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1251 : 0); |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1252 else |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1253 /* 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
|
1254 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
|
1255 width_table = 0; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1256 |
28537
862f955dfe92
(compute_motion): Set immediate_quit.
Gerd Moellmann <gerd@gnu.org>
parents:
28293
diff
changeset
|
1257 if (tab_width <= 0 || tab_width > 1000) |
862f955dfe92
(compute_motion): Set immediate_quit.
Gerd Moellmann <gerd@gnu.org>
parents:
28293
diff
changeset
|
1258 tab_width = 8; |
862f955dfe92
(compute_motion): Set immediate_quit.
Gerd Moellmann <gerd@gnu.org>
parents:
28293
diff
changeset
|
1259 |
56584
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1260 /* Negative width means use all available text columns. */ |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1261 if (width < 0) |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1262 { |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1263 width = window_box_text_cols (win); |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1264 /* We must make room for continuation marks if we don't have fringes. */ |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1265 #ifdef HAVE_WINDOW_SYSTEM |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1266 if (!FRAME_WINDOW_P (XFRAME (win->frame))) |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1267 #endif |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1268 width -= 1; |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1269 } |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1270 |
56594
5b9242222549
(compute_motion): Fix last change.
Kim F. Storm <storm@cua.dk>
parents:
56593
diff
changeset
|
1271 continuation_glyph_width = 1; |
56593
47fd67a37101
(compute_motion): Fix check for full width window
Kim F. Storm <storm@cua.dk>
parents:
56584
diff
changeset
|
1272 #ifdef HAVE_WINDOW_SYSTEM |
56594
5b9242222549
(compute_motion): Fix last change.
Kim F. Storm <storm@cua.dk>
parents:
56593
diff
changeset
|
1273 if (FRAME_WINDOW_P (XFRAME (win->frame))) |
5b9242222549
(compute_motion): Fix last change.
Kim F. Storm <storm@cua.dk>
parents:
56593
diff
changeset
|
1274 continuation_glyph_width = 0; /* In the fringe. */ |
56593
47fd67a37101
(compute_motion): Fix check for full width window
Kim F. Storm <storm@cua.dk>
parents:
56584
diff
changeset
|
1275 #endif |
47fd67a37101
(compute_motion): Fix check for full width window
Kim F. Storm <storm@cua.dk>
parents:
56584
diff
changeset
|
1276 |
28537
862f955dfe92
(compute_motion): Set immediate_quit.
Gerd Moellmann <gerd@gnu.org>
parents:
28293
diff
changeset
|
1277 immediate_quit = 1; |
862f955dfe92
(compute_motion): Set immediate_quit.
Gerd Moellmann <gerd@gnu.org>
parents:
28293
diff
changeset
|
1278 QUIT; |
526 | 1279 |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1280 pos = prev_pos = from; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1281 pos_byte = prev_pos_byte = CHAR_TO_BYTE (from); |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1282 contin_hpos = 0; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1283 prev_tab_offset = tab_offset; |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1284 while (1) |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1285 { |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1286 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
|
1287 { |
84951 | 1288 EMACS_INT pos_here = pos; |
1289 EMACS_INT newpos; | |
17966
aaa25a87ae3d
(compute_motion): Return correctly if skip_invisible
Richard M. Stallman <rms@gnu.org>
parents:
17136
diff
changeset
|
1290 |
22245
94da16d936b6
(compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents:
22000
diff
changeset
|
1291 /* Don't skip invisible if we are already at the margin. */ |
41900 | 1292 if (vpos > tovpos || (vpos == tovpos && hpos >= tohpos)) |
22245
94da16d936b6
(compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents:
22000
diff
changeset
|
1293 { |
94da16d936b6
(compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents:
22000
diff
changeset
|
1294 if (contin_hpos && prev_hpos == 0 |
94da16d936b6
(compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents:
22000
diff
changeset
|
1295 && hpos > tohpos |
94da16d936b6
(compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents:
22000
diff
changeset
|
1296 && (contin_hpos == width || wide_column_end_hpos > width)) |
94da16d936b6
(compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents:
22000
diff
changeset
|
1297 { /* Line breaks because we can't put the character at the |
94da16d936b6
(compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents:
22000
diff
changeset
|
1298 previous line any more. It is not the multi-column |
94da16d936b6
(compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents:
22000
diff
changeset
|
1299 character continued in middle. Go back to previous |
94da16d936b6
(compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents:
22000
diff
changeset
|
1300 buffer position, screen position, and set tab offset |
94da16d936b6
(compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents:
22000
diff
changeset
|
1301 to previous value. It's the beginning of the |
94da16d936b6
(compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents:
22000
diff
changeset
|
1302 line. */ |
94da16d936b6
(compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents:
22000
diff
changeset
|
1303 pos = prev_pos; |
94da16d936b6
(compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents:
22000
diff
changeset
|
1304 pos_byte = prev_pos_byte; |
94da16d936b6
(compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents:
22000
diff
changeset
|
1305 hpos = prev_hpos; |
54240
867a22140904
(compute_motion): Save vpos in prev_vpos, like hpos etc.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
1306 vpos = prev_vpos; |
22245
94da16d936b6
(compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents:
22000
diff
changeset
|
1307 tab_offset = prev_tab_offset; |
94da16d936b6
(compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents:
22000
diff
changeset
|
1308 } |
94da16d936b6
(compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents:
22000
diff
changeset
|
1309 break; |
94da16d936b6
(compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents:
22000
diff
changeset
|
1310 } |
94da16d936b6
(compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents:
22000
diff
changeset
|
1311 |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1312 /* 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
|
1313 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
|
1314 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
|
1315 through, so clear the flag after testing it. */ |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1316 if (!did_motion) |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1317 /* We need to skip past the overlay strings. Currently those |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1318 strings must not contain TAB; |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1319 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
|
1320 to be changed here. */ |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1321 { |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1322 unsigned char *ovstr; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1323 int ovlen = overlay_strings (pos, win, &ovstr); |
21283
c431691cbff1
(compute_motion): Call strwidth only when necessary.
Kenichi Handa <handa@m17n.org>
parents:
21275
diff
changeset
|
1324 hpos += ((multibyte && ovlen > 0) |
c431691cbff1
(compute_motion): Call strwidth only when necessary.
Kenichi Handa <handa@m17n.org>
parents:
21275
diff
changeset
|
1325 ? strwidth (ovstr, ovlen) : ovlen); |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1326 } |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1327 did_motion = 0; |
10964
474b6b03a71f
(compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents:
10538
diff
changeset
|
1328 |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1329 if (pos >= to) |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1330 break; |
10964
474b6b03a71f
(compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents:
10538
diff
changeset
|
1331 |
15493
32fe67f92ee1
Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents:
15278
diff
changeset
|
1332 /* 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
|
1333 (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
|
1334 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
|
1335 we need to call skip_invisible. */ |
17966
aaa25a87ae3d
(compute_motion): Return correctly if skip_invisible
Richard M. Stallman <rms@gnu.org>
parents:
17136
diff
changeset
|
1336 newpos = skip_invisible (pos, &next_boundary, to, window); |
aaa25a87ae3d
(compute_motion): Return correctly if skip_invisible
Richard M. Stallman <rms@gnu.org>
parents:
17136
diff
changeset
|
1337 |
aaa25a87ae3d
(compute_motion): Return correctly if skip_invisible
Richard M. Stallman <rms@gnu.org>
parents:
17136
diff
changeset
|
1338 if (newpos >= to) |
21919
0c3d6e2c4176
(compute_motion): When invisible text cross TO,
Richard M. Stallman <rms@gnu.org>
parents:
21525
diff
changeset
|
1339 { |
0c3d6e2c4176
(compute_motion): When invisible text cross TO,
Richard M. Stallman <rms@gnu.org>
parents:
21525
diff
changeset
|
1340 pos = min (to, newpos); |
33871
69c9cd380fd2
(compute_motion): Keep pos_byte in sync with pos.
Miles Bader <miles@gnu.org>
parents:
31829
diff
changeset
|
1341 pos_byte = CHAR_TO_BYTE (pos); |
21919
0c3d6e2c4176
(compute_motion): When invisible text cross TO,
Richard M. Stallman <rms@gnu.org>
parents:
21525
diff
changeset
|
1342 goto after_loop; |
0c3d6e2c4176
(compute_motion): When invisible text cross TO,
Richard M. Stallman <rms@gnu.org>
parents:
21525
diff
changeset
|
1343 } |
17966
aaa25a87ae3d
(compute_motion): Return correctly if skip_invisible
Richard M. Stallman <rms@gnu.org>
parents:
17136
diff
changeset
|
1344 |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1345 if (newpos != pos_here) |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1346 { |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1347 pos = newpos; |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1348 pos_byte = CHAR_TO_BYTE (pos); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1349 } |
5085
82bcf2c36929
(compute_motion): Pass new arg to Fnext_single_property_change.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
1350 } |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1351 |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1352 /* Handle right margin. */ |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1353 /* Note on a wide-column character. |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1354 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1355 Characters are classified into the following three categories |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1356 according to the width (columns occupied on screen). |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1357 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1358 (1) single-column character: ex. `a' |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1359 (2) multi-column character: ex. `^A', TAB, `\033' |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1360 (3) wide-column character: ex. Japanese character, Chinese character |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1361 (In the following example, `W_' stands for them.) |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1362 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1363 Multi-column characters can be divided around the right margin, |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1364 but wide-column characters cannot. |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1365 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1366 NOTE: |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1367 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1368 (*) The cursor is placed on the next character after the point. |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1369 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1370 ---------- |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1371 abcdefghi\ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1372 j ^---- next after the point |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1373 ^--- next char. after the point. |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1374 ---------- |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1375 In case of sigle-column character |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1376 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1377 ---------- |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1378 abcdefgh\\ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1379 033 ^---- next after the point, next char. after the point. |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1380 ---------- |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1381 In case of multi-column character |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1382 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1383 ---------- |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1384 abcdefgh\\ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1385 W_ ^---- next after the point |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1386 ^---- next char. after the point. |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1387 ---------- |
45622
ff3b6311d00f
(last_known_column): Now a float.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
44839
diff
changeset
|
1388 In case of wide-column character |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1389 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1390 The problem here is continuation at a wide-column character. |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1391 In this case, the line may shorter less than WIDTH. |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1392 And we find the continuation AFTER it occurs. |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1393 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1394 */ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1395 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1396 if (hpos > width) |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1397 { |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1398 if (hscroll |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1399 || (truncate_partial_width_windows |
56593
47fd67a37101
(compute_motion): Fix check for full width window
Kim F. Storm <storm@cua.dk>
parents:
56584
diff
changeset
|
1400 && ((width + continuation_glyph_width) |
47fd67a37101
(compute_motion): Fix check for full width window
Kim F. Storm <storm@cua.dk>
parents:
56584
diff
changeset
|
1401 < FRAME_COLS (XFRAME (WINDOW_FRAME (win))))) |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1402 || !NILP (current_buffer->truncate_lines)) |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1403 { |
20876
c80b908e5af5
(compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents:
20706
diff
changeset
|
1404 /* Truncating: skip to newline, unless we are already past |
c80b908e5af5
(compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents:
20706
diff
changeset
|
1405 TO (we need to go back below). */ |
c80b908e5af5
(compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents:
20706
diff
changeset
|
1406 if (pos <= to) |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1407 { |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1408 pos = find_before_next_newline (pos, to, 1); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1409 pos_byte = CHAR_TO_BYTE (pos); |
20876
c80b908e5af5
(compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents:
20706
diff
changeset
|
1410 hpos = width; |
c80b908e5af5
(compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents:
20706
diff
changeset
|
1411 /* If we just skipped next_boundary, |
c80b908e5af5
(compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents:
20706
diff
changeset
|
1412 loop around in the main while |
c80b908e5af5
(compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents:
20706
diff
changeset
|
1413 and handle it. */ |
c80b908e5af5
(compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents:
20706
diff
changeset
|
1414 if (pos >= next_boundary) |
c80b908e5af5
(compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents:
20706
diff
changeset
|
1415 next_boundary = pos + 1; |
c80b908e5af5
(compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents:
20706
diff
changeset
|
1416 prev_hpos = width; |
54240
867a22140904
(compute_motion): Save vpos in prev_vpos, like hpos etc.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
1417 prev_vpos = vpos; |
20876
c80b908e5af5
(compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents:
20706
diff
changeset
|
1418 prev_tab_offset = tab_offset; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1419 } |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1420 } |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1421 else |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1422 { |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1423 /* Continuing. */ |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1424 /* Remember the previous value. */ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1425 prev_tab_offset = tab_offset; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1426 |
20938
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
1427 if (wide_column_end_hpos > width) |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1428 { |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1429 hpos -= prev_hpos; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1430 tab_offset += prev_hpos; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1431 } |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1432 else |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1433 { |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1434 tab_offset += width; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1435 hpos -= width; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1436 } |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1437 vpos++; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1438 contin_hpos = prev_hpos; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1439 prev_hpos = 0; |
55311
d5519e60c9c6
(compute_motion): Save vpos in prev_vpos when dealing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54727
diff
changeset
|
1440 prev_vpos = vpos; |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1441 } |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1442 } |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1443 |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1444 /* Stop if past the target buffer position or screen position. */ |
21994
e244c4d9b0ca
(compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents:
21991
diff
changeset
|
1445 if (pos > to) |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1446 { |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1447 /* Go back to the previous position. */ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1448 pos = prev_pos; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1449 pos_byte = prev_pos_byte; |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1450 hpos = prev_hpos; |
54240
867a22140904
(compute_motion): Save vpos in prev_vpos, like hpos etc.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
1451 vpos = prev_vpos; |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1452 tab_offset = prev_tab_offset; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1453 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1454 /* NOTE on contin_hpos, hpos, and prev_hpos. |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1455 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1456 ---------- |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1457 abcdefgh\\ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1458 W_ ^---- contin_hpos |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1459 | ^----- hpos |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1460 \---- prev_hpos |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1461 ---------- |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1462 */ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1463 |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1464 if (contin_hpos && prev_hpos == 0 |
20938
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
1465 && contin_hpos < width && !wide_column_end_hpos) |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1466 { |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1467 /* Line breaking occurs in the middle of multi-column |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1468 character. Go back to previous line. */ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1469 hpos = contin_hpos; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1470 vpos = vpos - 1; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1471 } |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1472 break; |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1473 } |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1474 |
41900 | 1475 if (vpos > tovpos || (vpos == tovpos && hpos >= tohpos)) |
21994
e244c4d9b0ca
(compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents:
21991
diff
changeset
|
1476 { |
e244c4d9b0ca
(compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents:
21991
diff
changeset
|
1477 if (contin_hpos && prev_hpos == 0 |
22000 | 1478 && hpos > tohpos |
1479 && (contin_hpos == width || wide_column_end_hpos > width)) | |
21994
e244c4d9b0ca
(compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents:
21991
diff
changeset
|
1480 { /* Line breaks because we can't put the character at the |
e244c4d9b0ca
(compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents:
21991
diff
changeset
|
1481 previous line any more. It is not the multi-column |
e244c4d9b0ca
(compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents:
21991
diff
changeset
|
1482 character continued in middle. Go back to previous |
e244c4d9b0ca
(compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents:
21991
diff
changeset
|
1483 buffer position, screen position, and set tab offset |
e244c4d9b0ca
(compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents:
21991
diff
changeset
|
1484 to previous value. It's the beginning of the |
e244c4d9b0ca
(compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents:
21991
diff
changeset
|
1485 line. */ |
e244c4d9b0ca
(compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents:
21991
diff
changeset
|
1486 pos = prev_pos; |
e244c4d9b0ca
(compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents:
21991
diff
changeset
|
1487 pos_byte = prev_pos_byte; |
e244c4d9b0ca
(compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents:
21991
diff
changeset
|
1488 hpos = prev_hpos; |
54240
867a22140904
(compute_motion): Save vpos in prev_vpos, like hpos etc.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
1489 vpos = prev_vpos; |
21994
e244c4d9b0ca
(compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents:
21991
diff
changeset
|
1490 tab_offset = prev_tab_offset; |
e244c4d9b0ca
(compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents:
21991
diff
changeset
|
1491 } |
e244c4d9b0ca
(compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents:
21991
diff
changeset
|
1492 break; |
e244c4d9b0ca
(compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents:
21991
diff
changeset
|
1493 } |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1494 if (pos == ZV) /* We cannot go beyond ZV. Stop here. */ |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1495 break; |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1496 |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1497 prev_hpos = hpos; |
54240
867a22140904
(compute_motion): Save vpos in prev_vpos, like hpos etc.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
1498 prev_vpos = vpos; |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1499 prev_pos = pos; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1500 prev_pos_byte = pos_byte; |
20938
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
1501 wide_column_end_hpos = 0; |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1502 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1503 /* 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
|
1504 the text character-by-character. */ |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1505 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
|
1506 { |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1507 int run_end; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1508 int common_width |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1509 = region_cache_forward (current_buffer, |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1510 current_buffer->width_run_cache, |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1511 pos, &run_end); |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1512 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1513 /* 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
|
1514 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
|
1515 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
|
1516 if (common_width != 0) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1517 { |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1518 int run_end_hpos; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1519 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1520 /* 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
|
1521 requested. */ |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1522 if (run_end > to) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1523 run_end = to; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1524 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1525 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
|
1526 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1527 /* 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
|
1528 requested. */ |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1529 if (vpos == tovpos && run_end_hpos > tohpos) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1530 { |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1531 run_end = pos + (tohpos - hpos) / common_width; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1532 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
|
1533 } |
10538
48c620ae0853
(compute_motion): Don't get hung in selective-display loop.
Karl Heuer <kwzh@gnu.org>
parents:
10011
diff
changeset
|
1534 |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1535 /* Don't go past the margin. */ |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1536 if (run_end_hpos >= width) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1537 { |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1538 run_end = pos + (width - hpos) / common_width; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1539 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
|
1540 } |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1541 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1542 hpos = run_end_hpos; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1543 if (run_end > pos) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1544 prev_hpos = hpos - common_width; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1545 if (pos != run_end) |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1546 { |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1547 pos = run_end; |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1548 pos_byte = CHAR_TO_BYTE (pos); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1549 } |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1550 } |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1551 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1552 next_width_run = run_end + 1; |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1553 } |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1554 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1555 /* We have to scan the text character-by-character. */ |
165 | 1556 else |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1557 { |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1558 EMACS_INT i, n; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1559 Lisp_Object charvec; |
45622
ff3b6311d00f
(last_known_column): Now a float.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
44839
diff
changeset
|
1560 |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1561 c = FETCH_BYTE (pos_byte); |
26859
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
1562 |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
1563 /* Check composition sequence. */ |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
1564 { |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
1565 int len, len_byte, width; |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
1566 |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
1567 if (check_composition (pos, pos_byte, to, &len, &len_byte, &width)) |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
1568 { |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
1569 pos += len; |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
1570 pos_byte += len_byte; |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
1571 hpos += width; |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
1572 continue; |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
1573 } |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
1574 } |
4cf41c98ad2d
(check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents:
26404
diff
changeset
|
1575 |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1576 pos++, pos_byte++; |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1577 |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1578 /* Perhaps add some info to the width_run_cache. */ |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1579 if (current_buffer->width_run_cache) |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1580 { |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1581 /* 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
|
1582 the run. */ |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1583 if (pos - 1 == width_run_end |
18109
b8c70b5f5aba
(compute_motion): Use XFASTINT on width_table elts.
Richard M. Stallman <rms@gnu.org>
parents:
17966
diff
changeset
|
1584 && XFASTINT (width_table[c]) == width_run_width) |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1585 width_run_end = pos; |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1586 |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1587 /* 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
|
1588 different position, or a different width. */ |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1589 else |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1590 { |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1591 /* 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
|
1592 (Currently, we only cache runs of width == 1). */ |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1593 if (width_run_start < width_run_end |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1594 && width_run_width == 1) |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1595 know_region_cache (current_buffer, |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1596 current_buffer->width_run_cache, |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1597 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
|
1598 |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1599 /* Start recording a new width run. */ |
18109
b8c70b5f5aba
(compute_motion): Use XFASTINT on width_table elts.
Richard M. Stallman <rms@gnu.org>
parents:
17966
diff
changeset
|
1600 width_run_width = XFASTINT (width_table[c]); |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1601 width_run_start = pos - 1; |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1602 width_run_end = pos; |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1603 } |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1604 } |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1605 |
20938
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
1606 if (dp != 0 |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
1607 && ! (multibyte && BASE_LEADING_CODE_P (c)) |
12e635300b44
(MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20876
diff
changeset
|
1608 && VECTORP (DISP_CHAR_VECTOR (dp, c))) |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1609 { |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1610 charvec = DISP_CHAR_VECTOR (dp, c); |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1611 n = ASIZE (charvec); |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1612 } |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1613 else |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1614 { |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1615 charvec = Qnil; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1616 n = 1; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1617 } |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1618 |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1619 for (i = n - 1; i >= 0; --i) |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1620 { |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1621 if (VECTORP (charvec)) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1622 { |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1623 /* This should be handled the same as |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1624 next_element_from_display_vector does it. */ |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1625 Lisp_Object entry = AREF (charvec, i); |
45622
ff3b6311d00f
(last_known_column): Now a float.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
44839
diff
changeset
|
1626 |
92278
ec0a63595f5b
(current_column, current_column_1, Fmove_to_column)
Kim F. Storm <storm@cua.dk>
parents:
91327
diff
changeset
|
1627 if (GLYPH_CODE_P (entry) |
ec0a63595f5b
(current_column, current_column_1, Fmove_to_column)
Kim F. Storm <storm@cua.dk>
parents:
91327
diff
changeset
|
1628 && GLYPH_CODE_CHAR_VALID_P (entry)) |
ec0a63595f5b
(current_column, current_column_1, Fmove_to_column)
Kim F. Storm <storm@cua.dk>
parents:
91327
diff
changeset
|
1629 c = GLYPH_CODE_CHAR (entry); |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1630 else |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1631 c = ' '; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1632 } |
45622
ff3b6311d00f
(last_known_column): Now a float.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
44839
diff
changeset
|
1633 |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1634 if (c >= 040 && c < 0177) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1635 hpos++; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1636 else if (c == '\t') |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1637 { |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1638 int tem = ((hpos + tab_offset + hscroll - (hscroll > 0)) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1639 % tab_width); |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1640 if (tem < 0) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1641 tem += tab_width; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1642 hpos += tab_width - tem; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1643 } |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1644 else if (c == '\n') |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1645 { |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1646 if (selective > 0 |
45622
ff3b6311d00f
(last_known_column): Now a float.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
44839
diff
changeset
|
1647 && indented_beyond_p (pos, pos_byte, |
46303
ebb83f095b2a
(last_known_column): Declare as double, not float.
Richard M. Stallman <rms@gnu.org>
parents:
45622
diff
changeset
|
1648 (double) selective)) /* iftc */ |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1649 { |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1650 /* If (pos == to), we don't have to take care of |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1651 selective display. */ |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1652 if (pos < to) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1653 { |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1654 /* Skip any number of invisible lines all at once */ |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1655 do |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1656 { |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1657 pos = find_before_next_newline (pos, to, 1); |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1658 if (pos < to) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1659 pos++; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1660 pos_byte = CHAR_TO_BYTE (pos); |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1661 } |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1662 while (pos < to |
45622
ff3b6311d00f
(last_known_column): Now a float.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
44839
diff
changeset
|
1663 && indented_beyond_p (pos, pos_byte, |
46303
ebb83f095b2a
(last_known_column): Declare as double, not float.
Richard M. Stallman <rms@gnu.org>
parents:
45622
diff
changeset
|
1664 (double) selective)); /* iftc */ |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1665 /* Allow for the " ..." that is displayed for them. */ |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1666 if (selective_rlen) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1667 { |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1668 hpos += selective_rlen; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1669 if (hpos >= width) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1670 hpos = width; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1671 } |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1672 DEC_BOTH (pos, pos_byte); |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1673 /* We have skipped the invis text, but not the |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1674 newline after. */ |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1675 } |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1676 } |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1677 else |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1678 { |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1679 /* A visible line. */ |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1680 vpos++; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1681 hpos = 0; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1682 hpos -= hscroll; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1683 /* Count the truncation glyph on column 0 */ |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1684 if (hscroll > 0) |
56593
47fd67a37101
(compute_motion): Fix check for full width window
Kim F. Storm <storm@cua.dk>
parents:
56584
diff
changeset
|
1685 hpos += continuation_glyph_width; |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1686 tab_offset = 0; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1687 } |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1688 contin_hpos = 0; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1689 } |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1690 else if (c == CR && selective < 0) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1691 { |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1692 /* In selective display mode, |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1693 everything from a ^M to the end of the line is invisible. |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1694 Stop *before* the real newline. */ |
17136
424932eba3e8
(compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents:
17016
diff
changeset
|
1695 if (pos < to) |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1696 { |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1697 pos = find_before_next_newline (pos, to, 1); |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1698 pos_byte = CHAR_TO_BYTE (pos); |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1699 } |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1700 /* If we just skipped next_boundary, |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1701 loop around in the main while |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1702 and handle it. */ |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1703 if (pos > next_boundary) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1704 next_boundary = pos; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1705 /* Allow for the " ..." that is displayed for them. */ |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1706 if (selective_rlen) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1707 { |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1708 hpos += selective_rlen; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1709 if (hpos >= width) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1710 hpos = width; |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1711 } |
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1712 } |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1713 else if (multibyte && BASE_LEADING_CODE_P (c)) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1714 { |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1715 /* Start of multi-byte form. */ |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1716 unsigned char *ptr; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1717 int bytes, width, wide_column; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1718 |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1719 pos_byte--; /* rewind POS_BYTE */ |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1720 ptr = BYTE_POS_ADDR (pos_byte); |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1721 MULTIBYTE_BYTES_WIDTH (ptr, dp); |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1722 pos_byte += bytes; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1723 if (wide_column) |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1724 wide_column_end_hpos = hpos + wide_column; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1725 hpos += width; |
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1726 } |
38530
90ab35fe206c
(current_column): Fix column computation in the
Gerd Moellmann <gerd@gnu.org>
parents:
37917
diff
changeset
|
1727 else if (VECTORP (charvec)) |
90ab35fe206c
(current_column): Fix column computation in the
Gerd Moellmann <gerd@gnu.org>
parents:
37917
diff
changeset
|
1728 ++hpos; |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1729 else |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1730 hpos += (ctl_arrow && c < 0200) ? 2 : 4; |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1731 } |
165 | 1732 } |
1733 } | |
1734 | |
17966
aaa25a87ae3d
(compute_motion): Return correctly if skip_invisible
Richard M. Stallman <rms@gnu.org>
parents:
17136
diff
changeset
|
1735 after_loop: |
aaa25a87ae3d
(compute_motion): Return correctly if skip_invisible
Richard M. Stallman <rms@gnu.org>
parents:
17136
diff
changeset
|
1736 |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1737 /* Remember any final width run in the cache. */ |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1738 if (current_buffer->width_run_cache |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1739 && width_run_width == 1 |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1740 && width_run_start < width_run_end) |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1741 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
|
1742 width_run_start, width_run_end); |
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1743 |
165 | 1744 val_compute_motion.bufpos = pos; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1745 val_compute_motion.bytepos = pos_byte; |
526 | 1746 val_compute_motion.hpos = hpos; |
1747 val_compute_motion.vpos = vpos; | |
20985
020b0eade8c5
(compute_motion): If we just moved over a continuation
Andreas Schwab <schwab@suse.de>
parents:
20938
diff
changeset
|
1748 if (contin_hpos && prev_hpos == 0) |
020b0eade8c5
(compute_motion): If we just moved over a continuation
Andreas Schwab <schwab@suse.de>
parents:
20938
diff
changeset
|
1749 val_compute_motion.prevhpos = contin_hpos; |
020b0eade8c5
(compute_motion): If we just moved over a continuation
Andreas Schwab <schwab@suse.de>
parents:
20938
diff
changeset
|
1750 else |
020b0eade8c5
(compute_motion): If we just moved over a continuation
Andreas Schwab <schwab@suse.de>
parents:
20938
diff
changeset
|
1751 val_compute_motion.prevhpos = prev_hpos; |
16395
c6b901f809da
(vmotion, compute_motion): Fill in ovstring_chars_done in the return value.
Richard M. Stallman <rms@gnu.org>
parents:
16257
diff
changeset
|
1752 /* We alalways handle all of them here; none of them remain to do. */ |
c6b901f809da
(vmotion, compute_motion): Fill in ovstring_chars_done in the return value.
Richard M. Stallman <rms@gnu.org>
parents:
16257
diff
changeset
|
1753 val_compute_motion.ovstring_chars_done = 0; |
165 | 1754 |
1755 /* Nonzero if have just continued a line */ | |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1756 val_compute_motion.contin = (contin_hpos && prev_hpos == 0); |
165 | 1757 |
28537
862f955dfe92
(compute_motion): Set immediate_quit.
Gerd Moellmann <gerd@gnu.org>
parents:
28293
diff
changeset
|
1758 immediate_quit = 0; |
165 | 1759 return &val_compute_motion; |
1760 } | |
1761 | |
25028
ab513f624bc6
(Fvertical_motion): Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents:
24828
diff
changeset
|
1762 |
40123
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1763 DEFUN ("compute-motion", Fcompute_motion, Scompute_motion, 7, 7, 0, |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1764 doc: /* Scan through the current buffer, calculating screen position. |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1765 Scan the current buffer forward from offset FROM, |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1766 assuming it is at position FROMPOS--a cons of the form (HPOS . VPOS)-- |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1767 to position TO or position TOPOS--another cons of the form (HPOS . VPOS)-- |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1768 and return the ending buffer position and screen location. |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1769 |
56584
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1770 If TOPOS is nil, the actual width and height of the window's |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1771 text area are used. |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1772 |
40123
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1773 There are three additional arguments: |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1774 |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1775 WIDTH is the number of columns available to display text; |
56584
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1776 this affects handling of continuation lines. A value of nil |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1777 corresponds to the actual number of available text columns. |
40123
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1778 |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1779 OFFSETS is either nil or a cons cell (HSCROLL . TAB-OFFSET). |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1780 HSCROLL is the number of columns not being displayed at the left |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1781 margin; this is usually taken from a window's hscroll member. |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1782 TAB-OFFSET is the number of columns of the first tab that aren't |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1783 being displayed, perhaps because the line was continued within it. |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1784 If OFFSETS is nil, HSCROLL and TAB-OFFSET are assumed to be zero. |
6587 | 1785 |
40123
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1786 WINDOW is the window to operate on. It is used to choose the display table; |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1787 if it is showing the current buffer, it is used also for |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1788 deciding which overlay properties apply. |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1789 Note that `compute-motion' always operates on the current buffer. |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1790 |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1791 The value is a list of five elements: |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1792 (POS HPOS VPOS PREVHPOS CONTIN) |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1793 POS is the buffer position where the scan stopped. |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1794 VPOS is the vertical position where the scan stopped. |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1795 HPOS is the horizontal position where the scan stopped. |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1796 |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1797 PREVHPOS is the horizontal position one character back from POS. |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1798 CONTIN is t if a line was continued after (or within) the previous character. |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1799 |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1800 For example, to find the buffer position of column COL of line LINE |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1801 of a certain window, pass the window's starting location as FROM |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1802 and the window's upper-left coordinates as FROMPOS. |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1803 Pass the buffer's (point-max) as TO, to limit the scan to the end of the |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1804 visible section of the buffer, and pass LINE and COL as TOPOS. */) |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1805 (from, frompos, to, topos, width, offsets, window) |
6296
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1806 Lisp_Object from, frompos, to, topos; |
6691
3b56d4742266
(compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents:
6588
diff
changeset
|
1807 Lisp_Object width, offsets, window; |
6296
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1808 { |
56584
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1809 struct window *w; |
34967
78e2d17df950
(current_column): Remove unused variable `stopchar'.
Eli Zaretskii <eliz@gnu.org>
parents:
33871
diff
changeset
|
1810 Lisp_Object bufpos, hpos, vpos, prevhpos; |
6296
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1811 struct position *pos; |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1812 int hscroll, tab_offset; |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1813 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40123
diff
changeset
|
1814 CHECK_NUMBER_COERCE_MARKER (from); |
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40123
diff
changeset
|
1815 CHECK_CONS (frompos); |
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40123
diff
changeset
|
1816 CHECK_NUMBER_CAR (frompos); |
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40123
diff
changeset
|
1817 CHECK_NUMBER_CDR (frompos); |
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40123
diff
changeset
|
1818 CHECK_NUMBER_COERCE_MARKER (to); |
56584
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1819 if (!NILP (topos)) |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1820 { |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1821 CHECK_CONS (topos); |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1822 CHECK_NUMBER_CAR (topos); |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1823 CHECK_NUMBER_CDR (topos); |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1824 } |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1825 if (!NILP (width)) |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1826 CHECK_NUMBER (width); |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1827 |
6296
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1828 if (!NILP (offsets)) |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1829 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40123
diff
changeset
|
1830 CHECK_CONS (offsets); |
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40123
diff
changeset
|
1831 CHECK_NUMBER_CAR (offsets); |
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40123
diff
changeset
|
1832 CHECK_NUMBER_CDR (offsets); |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25510
diff
changeset
|
1833 hscroll = XINT (XCAR (offsets)); |
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25510
diff
changeset
|
1834 tab_offset = XINT (XCDR (offsets)); |
6296
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1835 } |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1836 else |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1837 hscroll = tab_offset = 0; |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1838 |
6691
3b56d4742266
(compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents:
6588
diff
changeset
|
1839 if (NILP (window)) |
3b56d4742266
(compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents:
6588
diff
changeset
|
1840 window = Fselected_window (); |
3b56d4742266
(compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents:
6588
diff
changeset
|
1841 else |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40123
diff
changeset
|
1842 CHECK_LIVE_WINDOW (window); |
56584
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1843 w = XWINDOW (window); |
6691
3b56d4742266
(compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents:
6588
diff
changeset
|
1844 |
21496
6ec5e85328a9
(Fcompute_motion): Check that TO and FROM are in range.
Karl Heuer <kwzh@gnu.org>
parents:
21283
diff
changeset
|
1845 if (XINT (from) < BEGV || XINT (from) > ZV) |
6ec5e85328a9
(Fcompute_motion): Check that TO and FROM are in range.
Karl Heuer <kwzh@gnu.org>
parents:
21283
diff
changeset
|
1846 args_out_of_range_3 (from, make_number (BEGV), make_number (ZV)); |
6ec5e85328a9
(Fcompute_motion): Check that TO and FROM are in range.
Karl Heuer <kwzh@gnu.org>
parents:
21283
diff
changeset
|
1847 if (XINT (to) < BEGV || XINT (to) > ZV) |
6ec5e85328a9
(Fcompute_motion): Check that TO and FROM are in range.
Karl Heuer <kwzh@gnu.org>
parents:
21283
diff
changeset
|
1848 args_out_of_range_3 (to, make_number (BEGV), make_number (ZV)); |
6ec5e85328a9
(Fcompute_motion): Check that TO and FROM are in range.
Karl Heuer <kwzh@gnu.org>
parents:
21283
diff
changeset
|
1849 |
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25510
diff
changeset
|
1850 pos = compute_motion (XINT (from), XINT (XCDR (frompos)), |
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25510
diff
changeset
|
1851 XINT (XCAR (frompos)), 0, |
56584
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1852 XINT (to), |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1853 (NILP (topos) |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1854 ? window_internal_height (w) |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1855 : XINT (XCDR (topos))), |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1856 (NILP (topos) |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1857 ? (window_box_text_cols (w) |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1858 - ( |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1859 #ifdef HAVE_WINDOW_SYSTEM |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1860 FRAME_WINDOW_P (XFRAME (w->frame)) ? 0 : |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1861 #endif |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1862 1)) |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1863 : XINT (XCAR (topos))), |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1864 (NILP (width) ? -1 : XINT (width)), |
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1865 hscroll, tab_offset, |
6691
3b56d4742266
(compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents:
6588
diff
changeset
|
1866 XWINDOW (window)); |
6296
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1867 |
9310
1dfd9def3467
(Fcurrent_column, Findent_to, Fcurrent_indentation, Fmove_to_column,
Karl Heuer <kwzh@gnu.org>
parents:
9269
diff
changeset
|
1868 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
|
1869 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
|
1870 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
|
1871 XSETINT (prevhpos, pos->prevhpos); |
6296
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1872 |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1873 return Fcons (bufpos, |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1874 Fcons (hpos, |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1875 Fcons (vpos, |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1876 Fcons (prevhpos, |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1877 Fcons (pos->contin ? Qt : Qnil, Qnil))))); |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1878 |
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
1879 } |
165 | 1880 |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
1881 /* Fvertical_motion and vmotion */ |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
1882 |
165 | 1883 struct position val_vmotion; |
1884 | |
1885 struct position * | |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1886 vmotion (from, vtarget, w) |
84951 | 1887 register EMACS_INT from, vtarget; |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1888 struct window *w; |
165 | 1889 { |
84951 | 1890 EMACS_INT hscroll = XINT (w->hscroll); |
165 | 1891 struct position pos; |
1892 /* vpos is cumulative vertical position, changed as from is changed */ | |
1893 register int vpos = 0; | |
84951 | 1894 EMACS_INT prevline; |
1895 register EMACS_INT first; | |
1896 EMACS_INT from_byte; | |
1897 EMACS_INT lmargin = hscroll > 0 ? 1 - hscroll : 0; | |
165 | 1898 int selective |
9126
e475f8108156
(buffer_display_table, current_column, Fmove_to_column, compute_motion,
Karl Heuer <kwzh@gnu.org>
parents:
8946
diff
changeset
|
1899 = (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
|
1900 ? 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
|
1901 : !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
|
1902 Lisp_Object window; |
84951 | 1903 EMACS_INT start_hpos = 0; |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1904 int did_motion; |
23039
f4262c9a21dd
(vmotion): Don't use WINDOW for Fget_char_property
Richard M. Stallman <rms@gnu.org>
parents:
22560
diff
changeset
|
1905 /* This is the object we use for fetching character properties. */ |
f4262c9a21dd
(vmotion): Don't use WINDOW for Fget_char_property
Richard M. Stallman <rms@gnu.org>
parents:
22560
diff
changeset
|
1906 Lisp_Object text_prop_object; |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1907 |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1908 XSETWINDOW (window, w); |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1909 |
23039
f4262c9a21dd
(vmotion): Don't use WINDOW for Fget_char_property
Richard M. Stallman <rms@gnu.org>
parents:
22560
diff
changeset
|
1910 /* If the window contains this buffer, use it for getting text properties. |
f4262c9a21dd
(vmotion): Don't use WINDOW for Fget_char_property
Richard M. Stallman <rms@gnu.org>
parents:
22560
diff
changeset
|
1911 Otherwise use the current buffer as arg for doing that. */ |
f4262c9a21dd
(vmotion): Don't use WINDOW for Fget_char_property
Richard M. Stallman <rms@gnu.org>
parents:
22560
diff
changeset
|
1912 if (EQ (w->buffer, Fcurrent_buffer ())) |
f4262c9a21dd
(vmotion): Don't use WINDOW for Fget_char_property
Richard M. Stallman <rms@gnu.org>
parents:
22560
diff
changeset
|
1913 text_prop_object = window; |
f4262c9a21dd
(vmotion): Don't use WINDOW for Fget_char_property
Richard M. Stallman <rms@gnu.org>
parents:
22560
diff
changeset
|
1914 else |
f4262c9a21dd
(vmotion): Don't use WINDOW for Fget_char_property
Richard M. Stallman <rms@gnu.org>
parents:
22560
diff
changeset
|
1915 text_prop_object = Fcurrent_buffer (); |
f4262c9a21dd
(vmotion): Don't use WINDOW for Fget_char_property
Richard M. Stallman <rms@gnu.org>
parents:
22560
diff
changeset
|
1916 |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1917 if (vpos >= vtarget) |
165 | 1918 { |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1919 /* To move upward, go a line at a time until |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1920 we have gone at least far enough. */ |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1921 |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1922 first = 1; |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1923 |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1924 while ((vpos > vtarget || first) && from > BEGV) |
165 | 1925 { |
10964
474b6b03a71f
(compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents:
10538
diff
changeset
|
1926 Lisp_Object propval; |
474b6b03a71f
(compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents:
10538
diff
changeset
|
1927 |
57734
32217d296ff3
(vmotion): When moving up, check the newline before.
Richard M. Stallman <rms@gnu.org>
parents:
56594
diff
changeset
|
1928 prevline = find_next_newline_no_quit (from - 1, -1); |
32217d296ff3
(vmotion): When moving up, check the newline before.
Richard M. Stallman <rms@gnu.org>
parents:
56594
diff
changeset
|
1929 while (prevline > BEGV |
4385
edffa4f0c5d9
(compute_motion): Compute correctly for invisible text.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
1930 && ((selective > 0 |
57734
32217d296ff3
(vmotion): When moving up, check the newline before.
Richard M. Stallman <rms@gnu.org>
parents:
56594
diff
changeset
|
1931 && indented_beyond_p (prevline, |
32217d296ff3
(vmotion): When moving up, check the newline before.
Richard M. Stallman <rms@gnu.org>
parents:
56594
diff
changeset
|
1932 CHAR_TO_BYTE (prevline), |
46303
ebb83f095b2a
(last_known_column): Declare as double, not float.
Richard M. Stallman <rms@gnu.org>
parents:
45622
diff
changeset
|
1933 (double) selective)) /* iftc */ |
57734
32217d296ff3
(vmotion): When moving up, check the newline before.
Richard M. Stallman <rms@gnu.org>
parents:
56594
diff
changeset
|
1934 /* Watch out for newlines with `invisible' property. |
32217d296ff3
(vmotion): When moving up, check the newline before.
Richard M. Stallman <rms@gnu.org>
parents:
56594
diff
changeset
|
1935 When moving upward, check the newline before. */ |
32217d296ff3
(vmotion): When moving up, check the newline before.
Richard M. Stallman <rms@gnu.org>
parents:
56594
diff
changeset
|
1936 || (propval = Fget_char_property (make_number (prevline - 1), |
10964
474b6b03a71f
(compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents:
10538
diff
changeset
|
1937 Qinvisible, |
23039
f4262c9a21dd
(vmotion): Don't use WINDOW for Fget_char_property
Richard M. Stallman <rms@gnu.org>
parents:
22560
diff
changeset
|
1938 text_prop_object), |
26404
c3c9cc1c2379
Remove USE_TEXT_PROPERTIES.
Gerd Moellmann <gerd@gnu.org>
parents:
25645
diff
changeset
|
1939 TEXT_PROP_MEANS_INVISIBLE (propval)))) |
57734
32217d296ff3
(vmotion): When moving up, check the newline before.
Richard M. Stallman <rms@gnu.org>
parents:
56594
diff
changeset
|
1940 prevline = find_next_newline_no_quit (prevline - 1, -1); |
32217d296ff3
(vmotion): When moving up, check the newline before.
Richard M. Stallman <rms@gnu.org>
parents:
56594
diff
changeset
|
1941 pos = *compute_motion (prevline, 0, |
32217d296ff3
(vmotion): When moving up, check the newline before.
Richard M. Stallman <rms@gnu.org>
parents:
56594
diff
changeset
|
1942 lmargin + (prevline == BEG ? start_hpos : 0), |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1943 0, |
45622
ff3b6311d00f
(last_known_column): Now a float.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
44839
diff
changeset
|
1944 from, |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1945 /* Don't care for VPOS... */ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1946 1 << (BITS_PER_SHORT - 1), |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1947 /* ... nor HPOS. */ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1948 1 << (BITS_PER_SHORT - 1), |
56584
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
1949 -1, hscroll, |
16926
3baea3418dec
(pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents:
16395
diff
changeset
|
1950 /* This compensates for start_hpos |
3baea3418dec
(pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents:
16395
diff
changeset
|
1951 so that a tab as first character |
3baea3418dec
(pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents:
16395
diff
changeset
|
1952 still occupies 8 columns. */ |
57734
32217d296ff3
(vmotion): When moving up, check the newline before.
Richard M. Stallman <rms@gnu.org>
parents:
56594
diff
changeset
|
1953 (prevline == BEG ? -start_hpos : 0), |
16926
3baea3418dec
(pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents:
16395
diff
changeset
|
1954 w); |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1955 vpos -= pos.vpos; |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1956 first = 0; |
57734
32217d296ff3
(vmotion): When moving up, check the newline before.
Richard M. Stallman <rms@gnu.org>
parents:
56594
diff
changeset
|
1957 from = prevline; |
165 | 1958 } |
1959 | |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1960 /* 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
|
1961 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
|
1962 return point found */ |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1963 if (vpos >= vtarget) |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1964 { |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1965 val_vmotion.bufpos = from; |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1966 val_vmotion.bytepos = CHAR_TO_BYTE (from); |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1967 val_vmotion.vpos = vpos; |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1968 val_vmotion.hpos = lmargin; |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1969 val_vmotion.contin = 0; |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1970 val_vmotion.prevhpos = 0; |
16395
c6b901f809da
(vmotion, compute_motion): Fill in ovstring_chars_done in the return value.
Richard M. Stallman <rms@gnu.org>
parents:
16257
diff
changeset
|
1971 val_vmotion.ovstring_chars_done = 0; |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
1972 val_vmotion.tab_offset = 0; /* For accumulating tab offset. */ |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1973 return &val_vmotion; |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1974 } |
165 | 1975 |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1976 /* 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
|
1977 } |
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1978 /* 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
|
1979 to determine hpos of starting point */ |
20571
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1980 from_byte = CHAR_TO_BYTE (from); |
3e0e568163f5
(current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents:
20371
diff
changeset
|
1981 if (from > BEGV && FETCH_BYTE (from_byte - 1) != '\n') |
165 | 1982 { |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
1983 Lisp_Object propval; |
10964
474b6b03a71f
(compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents:
10538
diff
changeset
|
1984 |
57734
32217d296ff3
(vmotion): When moving up, check the newline before.
Richard M. Stallman <rms@gnu.org>
parents:
56594
diff
changeset
|
1985 prevline = find_next_newline_no_quit (from, -1); |
32217d296ff3
(vmotion): When moving up, check the newline before.
Richard M. Stallman <rms@gnu.org>
parents:
56594
diff
changeset
|
1986 while (prevline > BEGV |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
1987 && ((selective > 0 |
57734
32217d296ff3
(vmotion): When moving up, check the newline before.
Richard M. Stallman <rms@gnu.org>
parents:
56594
diff
changeset
|
1988 && indented_beyond_p (prevline, |
32217d296ff3
(vmotion): When moving up, check the newline before.
Richard M. Stallman <rms@gnu.org>
parents:
56594
diff
changeset
|
1989 CHAR_TO_BYTE (prevline), |
46303
ebb83f095b2a
(last_known_column): Declare as double, not float.
Richard M. Stallman <rms@gnu.org>
parents:
45622
diff
changeset
|
1990 (double) selective)) /* iftc */ |
57734
32217d296ff3
(vmotion): When moving up, check the newline before.
Richard M. Stallman <rms@gnu.org>
parents:
56594
diff
changeset
|
1991 /* Watch out for newlines with `invisible' property. |
32217d296ff3
(vmotion): When moving up, check the newline before.
Richard M. Stallman <rms@gnu.org>
parents:
56594
diff
changeset
|
1992 When moving downward, check the newline after. */ |
32217d296ff3
(vmotion): When moving up, check the newline before.
Richard M. Stallman <rms@gnu.org>
parents:
56594
diff
changeset
|
1993 || (propval = Fget_char_property (make_number (prevline), |
32217d296ff3
(vmotion): When moving up, check the newline before.
Richard M. Stallman <rms@gnu.org>
parents:
56594
diff
changeset
|
1994 Qinvisible, |
23039
f4262c9a21dd
(vmotion): Don't use WINDOW for Fget_char_property
Richard M. Stallman <rms@gnu.org>
parents:
22560
diff
changeset
|
1995 text_prop_object), |
26404
c3c9cc1c2379
Remove USE_TEXT_PROPERTIES.
Gerd Moellmann <gerd@gnu.org>
parents:
25645
diff
changeset
|
1996 TEXT_PROP_MEANS_INVISIBLE (propval)))) |
57734
32217d296ff3
(vmotion): When moving up, check the newline before.
Richard M. Stallman <rms@gnu.org>
parents:
56594
diff
changeset
|
1997 prevline = find_next_newline_no_quit (prevline - 1, -1); |
32217d296ff3
(vmotion): When moving up, check the newline before.
Richard M. Stallman <rms@gnu.org>
parents:
56594
diff
changeset
|
1998 pos = *compute_motion (prevline, 0, |
32217d296ff3
(vmotion): When moving up, check the newline before.
Richard M. Stallman <rms@gnu.org>
parents:
56594
diff
changeset
|
1999 lmargin + (prevline == BEG |
8905
2ef3da79aabb
(vmotion, Fvertical_motion): Fix Lisp_Object vs. int problems.
Karl Heuer <kwzh@gnu.org>
parents:
8648
diff
changeset
|
2000 ? start_hpos : 0), |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
2001 0, |
45622
ff3b6311d00f
(last_known_column): Now a float.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
44839
diff
changeset
|
2002 from, |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
2003 /* Don't care for VPOS... */ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
2004 1 << (BITS_PER_SHORT - 1), |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
2005 /* ... nor HPOS. */ |
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
2006 1 << (BITS_PER_SHORT - 1), |
56584
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
2007 -1, hscroll, |
57734
32217d296ff3
(vmotion): When moving up, check the newline before.
Richard M. Stallman <rms@gnu.org>
parents:
56594
diff
changeset
|
2008 (prevline == BEG ? -start_hpos : 0), |
16926
3baea3418dec
(pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents:
16395
diff
changeset
|
2009 w); |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
2010 did_motion = 1; |
165 | 2011 } |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
2012 else |
165 | 2013 { |
11811
a0db528dfa1c
(vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents:
11704
diff
changeset
|
2014 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
|
2015 pos.vpos = 0; |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
2016 pos.tab_offset = 0; |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
2017 did_motion = 0; |
165 | 2018 } |
11853
6578a356c540
(compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents:
11813
diff
changeset
|
2019 return compute_motion (from, vpos, pos.hpos, did_motion, |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
2020 ZV, vtarget, - (1 << (BITS_PER_SHORT - 1)), |
56584
e22bbc6b44d1
(compute_motion): Use actual window width if WIDTH is -1,
Kim F. Storm <storm@cua.dk>
parents:
55311
diff
changeset
|
2021 -1, hscroll, |
17016
ded89d7e1575
(current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents:
16926
diff
changeset
|
2022 pos.tab_offset - (from == BEG ? start_hpos : 0), |
16926
3baea3418dec
(pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents:
16395
diff
changeset
|
2023 w); |
165 | 2024 } |
2025 | |
6327
d93a087868cb
(Fvertical_motion): New optional arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents:
6296
diff
changeset
|
2026 DEFUN ("vertical-motion", Fvertical_motion, Svertical_motion, 1, 2, 0, |
40123
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2027 doc: /* Move point to start of the screen line LINES lines down. |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2028 If LINES is negative, this means moving up. |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2029 |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2030 This function is an ordinary cursor motion function |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2031 which calculates the new position based on how text would be displayed. |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2032 The new position may be the start of a line, |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2033 or just the start of a continuation line. |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2034 The function returns number of screen lines moved over; |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2035 that usually equals LINES, but may be closer to zero |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2036 if beginning or end of buffer was reached. |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2037 |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2038 The optional second argument WINDOW specifies the window to use for |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2039 parameters such as width, horizontal scrolling, and so on. |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2040 The default is to use the selected window's parameters. |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2041 |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2042 `vertical-motion' always uses the current buffer, |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2043 regardless of which buffer is displayed in WINDOW. |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2044 This is consistent with other cursor motion functions |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2045 and makes it possible to use `vertical-motion' in any buffer, |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2046 whether or not it is currently displayed in some window. */) |
e528f2adeed4
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2047 (lines, window) |
6327
d93a087868cb
(Fvertical_motion): New optional arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents:
6296
diff
changeset
|
2048 Lisp_Object lines, window; |
165 | 2049 { |
25028
ab513f624bc6
(Fvertical_motion): Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents:
24828
diff
changeset
|
2050 struct it it; |
ab513f624bc6
(Fvertical_motion): Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents:
24828
diff
changeset
|
2051 struct text_pos pt; |
ab513f624bc6
(Fvertical_motion): Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents:
24828
diff
changeset
|
2052 struct window *w; |
28293
14eccbd25cae
(Fvertical_motion): Always use the current buffer.
Gerd Moellmann <gerd@gnu.org>
parents:
26859
diff
changeset
|
2053 Lisp_Object old_buffer; |
14eccbd25cae
(Fvertical_motion): Always use the current buffer.
Gerd Moellmann <gerd@gnu.org>
parents:
26859
diff
changeset
|
2054 struct gcpro gcpro1; |
165 | 2055 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40123
diff
changeset
|
2056 CHECK_NUMBER (lines); |
6327
d93a087868cb
(Fvertical_motion): New optional arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents:
6296
diff
changeset
|
2057 if (! NILP (window)) |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40123
diff
changeset
|
2058 CHECK_WINDOW (window); |
6327
d93a087868cb
(Fvertical_motion): New optional arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents:
6296
diff
changeset
|
2059 else |
8905
2ef3da79aabb
(vmotion, Fvertical_motion): Fix Lisp_Object vs. int problems.
Karl Heuer <kwzh@gnu.org>
parents:
8648
diff
changeset
|
2060 window = selected_window; |
28293
14eccbd25cae
(Fvertical_motion): Always use the current buffer.
Gerd Moellmann <gerd@gnu.org>
parents:
26859
diff
changeset
|
2061 w = XWINDOW (window); |
165 | 2062 |
28293
14eccbd25cae
(Fvertical_motion): Always use the current buffer.
Gerd Moellmann <gerd@gnu.org>
parents:
26859
diff
changeset
|
2063 old_buffer = Qnil; |
14eccbd25cae
(Fvertical_motion): Always use the current buffer.
Gerd Moellmann <gerd@gnu.org>
parents:
26859
diff
changeset
|
2064 GCPRO1 (old_buffer); |
14eccbd25cae
(Fvertical_motion): Always use the current buffer.
Gerd Moellmann <gerd@gnu.org>
parents:
26859
diff
changeset
|
2065 if (XBUFFER (w->buffer) != current_buffer) |
25028
ab513f624bc6
(Fvertical_motion): Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents:
24828
diff
changeset
|
2066 { |
28293
14eccbd25cae
(Fvertical_motion): Always use the current buffer.
Gerd Moellmann <gerd@gnu.org>
parents:
26859
diff
changeset
|
2067 /* Set the window's buffer temporarily to the current buffer. */ |
14eccbd25cae
(Fvertical_motion): Always use the current buffer.
Gerd Moellmann <gerd@gnu.org>
parents:
26859
diff
changeset
|
2068 old_buffer = w->buffer; |
14eccbd25cae
(Fvertical_motion): Always use the current buffer.
Gerd Moellmann <gerd@gnu.org>
parents:
26859
diff
changeset
|
2069 XSETBUFFER (w->buffer, current_buffer); |
25028
ab513f624bc6
(Fvertical_motion): Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents:
24828
diff
changeset
|
2070 } |
45622
ff3b6311d00f
(last_known_column): Now a float.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
44839
diff
changeset
|
2071 |
58270
1bc0c9f25148
(Fvertical_motion): In batch mode, use vmotion directly.
Richard M. Stallman <rms@gnu.org>
parents:
58260
diff
changeset
|
2072 if (noninteractive) |
58260
4a90dc7f2941
(Fvertical_motion): Fix last change. Only reseat when
Kim F. Storm <storm@cua.dk>
parents:
58205
diff
changeset
|
2073 { |
58270
1bc0c9f25148
(Fvertical_motion): In batch mode, use vmotion directly.
Richard M. Stallman <rms@gnu.org>
parents:
58260
diff
changeset
|
2074 struct position pos; |
1bc0c9f25148
(Fvertical_motion): In batch mode, use vmotion directly.
Richard M. Stallman <rms@gnu.org>
parents:
58260
diff
changeset
|
2075 pos = *vmotion (PT, XINT (lines), w); |
1bc0c9f25148
(Fvertical_motion): In batch mode, use vmotion directly.
Richard M. Stallman <rms@gnu.org>
parents:
58260
diff
changeset
|
2076 SET_PT_BOTH (pos.bufpos, pos.bytepos); |
58260
4a90dc7f2941
(Fvertical_motion): Fix last change. Only reseat when
Kim F. Storm <storm@cua.dk>
parents:
58205
diff
changeset
|
2077 } |
4a90dc7f2941
(Fvertical_motion): Fix last change. Only reseat when
Kim F. Storm <storm@cua.dk>
parents:
58205
diff
changeset
|
2078 else |
58270
1bc0c9f25148
(Fvertical_motion): In batch mode, use vmotion directly.
Richard M. Stallman <rms@gnu.org>
parents:
58260
diff
changeset
|
2079 { |
58396
60b3e92b3dd4
(Fvertical_motion): Fix last change. Use another
Kim F. Storm <storm@cua.dk>
parents:
58317
diff
changeset
|
2080 int it_start; |
59647
7d7e154e3e7a
(Fvertical_motion): Temporarily disable selective display.
Kim F. Storm <storm@cua.dk>
parents:
58909
diff
changeset
|
2081 int oselective; |
75105
ce5dc7ec8f3d
(Fvertical_motion): Fix IT overshoot check for overlay
Kim F. Storm <storm@cua.dk>
parents:
74091
diff
changeset
|
2082 int it_overshoot_expected; |
58396
60b3e92b3dd4
(Fvertical_motion): Fix last change. Use another
Kim F. Storm <storm@cua.dk>
parents:
58317
diff
changeset
|
2083 |
58270
1bc0c9f25148
(Fvertical_motion): In batch mode, use vmotion directly.
Richard M. Stallman <rms@gnu.org>
parents:
58260
diff
changeset
|
2084 SET_TEXT_POS (pt, PT, PT_BYTE); |
1bc0c9f25148
(Fvertical_motion): In batch mode, use vmotion directly.
Richard M. Stallman <rms@gnu.org>
parents:
58260
diff
changeset
|
2085 start_display (&it, w, pt); |
44837
ae3c74ba491a
(Fvertical_motion): Move to the start of the line
Gerd Moellmann <gerd@gnu.org>
parents:
44701
diff
changeset
|
2086 |
58270
1bc0c9f25148
(Fvertical_motion): In batch mode, use vmotion directly.
Richard M. Stallman <rms@gnu.org>
parents:
58260
diff
changeset
|
2087 /* Scan from the start of the line containing PT. If we don't |
1bc0c9f25148
(Fvertical_motion): In batch mode, use vmotion directly.
Richard M. Stallman <rms@gnu.org>
parents:
58260
diff
changeset
|
2088 do this, we start moving with IT->current_x == 0, while PT is |
1bc0c9f25148
(Fvertical_motion): In batch mode, use vmotion directly.
Richard M. Stallman <rms@gnu.org>
parents:
58260
diff
changeset
|
2089 really at some x > 0. The effect is, in continuation lines, that |
1bc0c9f25148
(Fvertical_motion): In batch mode, use vmotion directly.
Richard M. Stallman <rms@gnu.org>
parents:
58260
diff
changeset
|
2090 we end up with the iterator placed at where it thinks X is 0, |
1bc0c9f25148
(Fvertical_motion): In batch mode, use vmotion directly.
Richard M. Stallman <rms@gnu.org>
parents:
58260
diff
changeset
|
2091 while the end position is really at some X > 0, the same X that |
1bc0c9f25148
(Fvertical_motion): In batch mode, use vmotion directly.
Richard M. Stallman <rms@gnu.org>
parents:
58260
diff
changeset
|
2092 PT had. */ |
58396
60b3e92b3dd4
(Fvertical_motion): Fix last change. Use another
Kim F. Storm <storm@cua.dk>
parents:
58317
diff
changeset
|
2093 it_start = IT_CHARPOS (it); |
73140
c85ee72ad64b
* indent.c (Fvertical_motion): Do move back if the Lisp string
Chong Yidong <cyd@stupidchicken.com>
parents:
72885
diff
changeset
|
2094 |
c85ee72ad64b
* indent.c (Fvertical_motion): Do move back if the Lisp string
Chong Yidong <cyd@stupidchicken.com>
parents:
72885
diff
changeset
|
2095 /* We expect the call to move_it_to, further down, to overshoot |
74091
4cb12ab18c21
(Fvertical_motion): Include composition in the case of
Kenichi Handa <handa@m17n.org>
parents:
73140
diff
changeset
|
2096 if the starting point is on an image, stretch glyph, |
4cb12ab18c21
(Fvertical_motion): Include composition in the case of
Kenichi Handa <handa@m17n.org>
parents:
73140
diff
changeset
|
2097 composition, or Lisp string. We won't need to backtrack in |
4cb12ab18c21
(Fvertical_motion): Include composition in the case of
Kenichi Handa <handa@m17n.org>
parents:
73140
diff
changeset
|
2098 this situation, except for one corner case: when the Lisp |
4cb12ab18c21
(Fvertical_motion): Include composition in the case of
Kenichi Handa <handa@m17n.org>
parents:
73140
diff
changeset
|
2099 string contains a newline. */ |
73140
c85ee72ad64b
* indent.c (Fvertical_motion): Do move back if the Lisp string
Chong Yidong <cyd@stupidchicken.com>
parents:
72885
diff
changeset
|
2100 if (it.method == GET_FROM_STRING) |
c85ee72ad64b
* indent.c (Fvertical_motion): Do move back if the Lisp string
Chong Yidong <cyd@stupidchicken.com>
parents:
72885
diff
changeset
|
2101 { |
c85ee72ad64b
* indent.c (Fvertical_motion): Do move back if the Lisp string
Chong Yidong <cyd@stupidchicken.com>
parents:
72885
diff
changeset
|
2102 const char *s = SDATA (it.string); |
c85ee72ad64b
* indent.c (Fvertical_motion): Do move back if the Lisp string
Chong Yidong <cyd@stupidchicken.com>
parents:
72885
diff
changeset
|
2103 const char *e = s + SBYTES (it.string); |
c85ee72ad64b
* indent.c (Fvertical_motion): Do move back if the Lisp string
Chong Yidong <cyd@stupidchicken.com>
parents:
72885
diff
changeset
|
2104 |
c85ee72ad64b
* indent.c (Fvertical_motion): Do move back if the Lisp string
Chong Yidong <cyd@stupidchicken.com>
parents:
72885
diff
changeset
|
2105 while (s < e && *s != '\n') |
c85ee72ad64b
* indent.c (Fvertical_motion): Do move back if the Lisp string
Chong Yidong <cyd@stupidchicken.com>
parents:
72885
diff
changeset
|
2106 ++s; |
c85ee72ad64b
* indent.c (Fvertical_motion): Do move back if the Lisp string
Chong Yidong <cyd@stupidchicken.com>
parents:
72885
diff
changeset
|
2107 |
75105
ce5dc7ec8f3d
(Fvertical_motion): Fix IT overshoot check for overlay
Kim F. Storm <storm@cua.dk>
parents:
74091
diff
changeset
|
2108 /* If there is no newline in the string, we need to check |
ce5dc7ec8f3d
(Fvertical_motion): Fix IT overshoot check for overlay
Kim F. Storm <storm@cua.dk>
parents:
74091
diff
changeset
|
2109 whether there is a newline immediately after the string |
ce5dc7ec8f3d
(Fvertical_motion): Fix IT overshoot check for overlay
Kim F. Storm <storm@cua.dk>
parents:
74091
diff
changeset
|
2110 in move_it_to below. This may happen if there is an |
ce5dc7ec8f3d
(Fvertical_motion): Fix IT overshoot check for overlay
Kim F. Storm <storm@cua.dk>
parents:
74091
diff
changeset
|
2111 overlay with an after-string just before the newline. */ |
ce5dc7ec8f3d
(Fvertical_motion): Fix IT overshoot check for overlay
Kim F. Storm <storm@cua.dk>
parents:
74091
diff
changeset
|
2112 it_overshoot_expected = (s == e) ? -1 : 0; |
73140
c85ee72ad64b
* indent.c (Fvertical_motion): Do move back if the Lisp string
Chong Yidong <cyd@stupidchicken.com>
parents:
72885
diff
changeset
|
2113 } |
c85ee72ad64b
* indent.c (Fvertical_motion): Do move back if the Lisp string
Chong Yidong <cyd@stupidchicken.com>
parents:
72885
diff
changeset
|
2114 else |
75105
ce5dc7ec8f3d
(Fvertical_motion): Fix IT overshoot check for overlay
Kim F. Storm <storm@cua.dk>
parents:
74091
diff
changeset
|
2115 it_overshoot_expected = (it.method == GET_FROM_IMAGE |
ce5dc7ec8f3d
(Fvertical_motion): Fix IT overshoot check for overlay
Kim F. Storm <storm@cua.dk>
parents:
74091
diff
changeset
|
2116 || it.method == GET_FROM_STRETCH |
ce5dc7ec8f3d
(Fvertical_motion): Fix IT overshoot check for overlay
Kim F. Storm <storm@cua.dk>
parents:
74091
diff
changeset
|
2117 || it.method == GET_FROM_COMPOSITION); |
73140
c85ee72ad64b
* indent.c (Fvertical_motion): Do move back if the Lisp string
Chong Yidong <cyd@stupidchicken.com>
parents:
72885
diff
changeset
|
2118 |
58308
5358f62b0795
(Fvertical_motion): Undo 2004-11-16 change.
Kim F. Storm <storm@cua.dk>
parents:
58270
diff
changeset
|
2119 reseat_at_previous_visible_line_start (&it); |
5358f62b0795
(Fvertical_motion): Undo 2004-11-16 change.
Kim F. Storm <storm@cua.dk>
parents:
58270
diff
changeset
|
2120 it.current_x = it.hpos = 0; |
59647
7d7e154e3e7a
(Fvertical_motion): Temporarily disable selective display.
Kim F. Storm <storm@cua.dk>
parents:
58909
diff
changeset
|
2121 /* Temporarily disable selective display so we don't move too far */ |
7d7e154e3e7a
(Fvertical_motion): Temporarily disable selective display.
Kim F. Storm <storm@cua.dk>
parents:
58909
diff
changeset
|
2122 oselective = it.selective; |
7d7e154e3e7a
(Fvertical_motion): Temporarily disable selective display.
Kim F. Storm <storm@cua.dk>
parents:
58909
diff
changeset
|
2123 it.selective = 0; |
58308
5358f62b0795
(Fvertical_motion): Undo 2004-11-16 change.
Kim F. Storm <storm@cua.dk>
parents:
58270
diff
changeset
|
2124 move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS); |
59647
7d7e154e3e7a
(Fvertical_motion): Temporarily disable selective display.
Kim F. Storm <storm@cua.dk>
parents:
58909
diff
changeset
|
2125 it.selective = oselective; |
45622
ff3b6311d00f
(last_known_column): Now a float.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
44839
diff
changeset
|
2126 |
58308
5358f62b0795
(Fvertical_motion): Undo 2004-11-16 change.
Kim F. Storm <storm@cua.dk>
parents:
58270
diff
changeset
|
2127 /* Move back if we got too far. This may happen if |
64282
769e8d799acf
(Fvertical_motion): If start position is on an image,
Kim F. Storm <storm@cua.dk>
parents:
64084
diff
changeset
|
2128 truncate-lines is on and PT is beyond right margin. |
73140
c85ee72ad64b
* indent.c (Fvertical_motion): Do move back if the Lisp string
Chong Yidong <cyd@stupidchicken.com>
parents:
72885
diff
changeset
|
2129 Don't go back if the overshoot is expected (see above). */ |
67421
a405a1787bef
From: Kyotaro HORIGUCHI (tiny change)
Kim F. Storm <storm@cua.dk>
parents:
64770
diff
changeset
|
2130 if (IT_CHARPOS (it) > it_start && XINT (lines) > 0 |
75105
ce5dc7ec8f3d
(Fvertical_motion): Fix IT overshoot check for overlay
Kim F. Storm <storm@cua.dk>
parents:
74091
diff
changeset
|
2131 && (!it_overshoot_expected |
ce5dc7ec8f3d
(Fvertical_motion): Fix IT overshoot check for overlay
Kim F. Storm <storm@cua.dk>
parents:
74091
diff
changeset
|
2132 || (it_overshoot_expected < 0 |
ce5dc7ec8f3d
(Fvertical_motion): Fix IT overshoot check for overlay
Kim F. Storm <storm@cua.dk>
parents:
74091
diff
changeset
|
2133 && it.method == GET_FROM_BUFFER |
ce5dc7ec8f3d
(Fvertical_motion): Fix IT overshoot check for overlay
Kim F. Storm <storm@cua.dk>
parents:
74091
diff
changeset
|
2134 && it.c == '\n'))) |
58308
5358f62b0795
(Fvertical_motion): Undo 2004-11-16 change.
Kim F. Storm <storm@cua.dk>
parents:
58270
diff
changeset
|
2135 move_it_by_lines (&it, -1, 0); |
5358f62b0795
(Fvertical_motion): Undo 2004-11-16 change.
Kim F. Storm <storm@cua.dk>
parents:
58270
diff
changeset
|
2136 |
5358f62b0795
(Fvertical_motion): Undo 2004-11-16 change.
Kim F. Storm <storm@cua.dk>
parents:
58270
diff
changeset
|
2137 it.vpos = 0; |
58909
e3754638899a
(Fvertical_motion): Call move_it_by_lines even if LINES = 0.
Richard M. Stallman <rms@gnu.org>
parents:
58451
diff
changeset
|
2138 /* Do this even if LINES is 0, so that we move back |
e3754638899a
(Fvertical_motion): Call move_it_by_lines even if LINES = 0.
Richard M. Stallman <rms@gnu.org>
parents:
58451
diff
changeset
|
2139 to the beginning of the current line as we ought. */ |
69103
98dc9c749829
(Fvertical_motion): Only try to move back if we can.
Kim F. Storm <storm@cua.dk>
parents:
68651
diff
changeset
|
2140 if (XINT (lines) >= 0 || IT_CHARPOS (it) > 0) |
98dc9c749829
(Fvertical_motion): Only try to move back if we can.
Kim F. Storm <storm@cua.dk>
parents:
68651
diff
changeset
|
2141 move_it_by_lines (&it, XINT (lines), 0); |
58270
1bc0c9f25148
(Fvertical_motion): In batch mode, use vmotion directly.
Richard M. Stallman <rms@gnu.org>
parents:
58260
diff
changeset
|
2142 |
1bc0c9f25148
(Fvertical_motion): In batch mode, use vmotion directly.
Richard M. Stallman <rms@gnu.org>
parents:
58260
diff
changeset
|
2143 SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); |
1bc0c9f25148
(Fvertical_motion): In batch mode, use vmotion directly.
Richard M. Stallman <rms@gnu.org>
parents:
58260
diff
changeset
|
2144 } |
165 | 2145 |
28293
14eccbd25cae
(Fvertical_motion): Always use the current buffer.
Gerd Moellmann <gerd@gnu.org>
parents:
26859
diff
changeset
|
2146 if (BUFFERP (old_buffer)) |
14eccbd25cae
(Fvertical_motion): Always use the current buffer.
Gerd Moellmann <gerd@gnu.org>
parents:
26859
diff
changeset
|
2147 w->buffer = old_buffer; |
45622
ff3b6311d00f
(last_known_column): Now a float.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
44839
diff
changeset
|
2148 |
28293
14eccbd25cae
(Fvertical_motion): Always use the current buffer.
Gerd Moellmann <gerd@gnu.org>
parents:
26859
diff
changeset
|
2149 RETURN_UNGCPRO (make_number (it.vpos)); |
165 | 2150 } |
25028
ab513f624bc6
(Fvertical_motion): Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents:
24828
diff
changeset
|
2151 |
ab513f624bc6
(Fvertical_motion): Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents:
24828
diff
changeset
|
2152 |
165 | 2153 |
36846
89efd94a5832
(current_column, current_column_1, Fmove_to_column)
Gerd Moellmann <gerd@gnu.org>
parents:
35405
diff
changeset
|
2154 /* File's initialization. */ |
9407
4dcc0221b449
* indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents:
9310
diff
changeset
|
2155 |
21514 | 2156 void |
165 | 2157 syms_of_indent () |
2158 { | |
2159 DEFVAR_BOOL ("indent-tabs-mode", &indent_tabs_mode, | |
85128
8b61a2e5e365
(indent_tabs_mode, last_known_column, last_known_column_modified): Make static.
Juanma Barranquero <lekktu@gmail.com>
parents:
84952
diff
changeset
|
2160 doc: /* *Indentation can insert tabs if this is non-nil. */); |
165 | 2161 indent_tabs_mode = 1; |
2162 | |
2163 defsubr (&Scurrent_indentation); | |
2164 defsubr (&Sindent_to); | |
2165 defsubr (&Scurrent_column); | |
2166 defsubr (&Smove_to_column); | |
2167 defsubr (&Svertical_motion); | |
6296
a1b438e4754b
(compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents:
6092
diff
changeset
|
2168 defsubr (&Scompute_motion); |
165 | 2169 } |
52401 | 2170 |
2171 /* arch-tag: 9adfea44-71f7-4988-8ee3-96da15c502cc | |
2172 (do not change this comment) */ |