annotate src/indent.c @ 112328:ba9f26694b92

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