annotate src/indent.c @ 20:859a2309aef8 r19-15b93

Import from CVS: tag r19-15b93
author cvs
date Mon, 13 Aug 2007 08:50:05 +0200
parents 0293115a14e9
children 131b0175ea99
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* Indentation functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1995 Board of Trustees, University of Illinois.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 Copyright (C) 1985, 1986, 1987, 1988, 1992, 1993, 1994, 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 /* This file has been Mule-ized. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 /* Synched up with: 19.30. Diverges significantly from FSF. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 #include <config.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 #include "lisp.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 #include "buffer.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 #include "device.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 #include "extents.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 #include "faces.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 #include "frame.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 #include "glyphs.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 #include "insdel.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 #ifdef REGION_CACHE_NEEDS_WORK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 #include "region-cache.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 #include "window.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 /* Indentation can insert tabs if this is non-zero;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 otherwise always uses spaces */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 int indent_tabs_mode;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 /* Avoid recalculation by remembering things in these variables. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 /* Last value returned by current_column.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 Some things set last_known_column_point to -1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 to mark the memoized value as invalid */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 static int last_known_column;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 /* Last buffer searched by current_column */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 static struct buffer *last_known_column_buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 /* Value of point when current_column was called */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 static Bufpos last_known_column_point;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 /* Value of MODIFF when current_column was called */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 static int last_known_column_modified;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 static Bufpos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 last_visible_position (Bufpos pos, struct buffer *buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 Lisp_Object buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 Lisp_Object value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 XSETBUFFER (buffer, buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 value = Fprevious_single_property_change (make_int (pos), Qinvisible,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 buffer, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 if (NILP (value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 return 0; /* no visible position found */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 /* #### bug bug bug!!! This will return the position of the beginning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 of an invisible extent; this extent is very likely to be start-closed,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 and thus the spaces inserted in `indent-to' will go inside the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 invisible extent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 Not sure what the correct solution is here. Rethink indent-to? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 return XINT (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 #ifdef REGION_CACHE_NEEDS_WORK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 /* Allocate or free the width run cache, as requested by the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 state of current_buffer's cache_long_line_scans variable. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 width_run_cache_on_off (struct buffer *buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 if (NILP (buf->cache_long_line_scans))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 /* It should be off. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 if (buf->width_run_cache)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 free_region_cache (buf->width_run_cache);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 buf->width_run_cache = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 buf->width_table = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 /* It should be on. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 if (buf->width_run_cache == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 buf->width_run_cache = new_region_cache ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 recompute_width_table (buf, buffer_display_table ());
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 #endif /* REGION_CACHE_NEEDS_WORK */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 /* Cancel any recorded value of the horizontal position. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 invalidate_current_column (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 last_known_column_point = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 column_at_point (struct buffer *buf, Bufpos init_pos, int cur_col)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 int col;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 int tab_seen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 int tab_width = XINT (buf->tab_width);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 int post_tab;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 Bufpos pos = init_pos;
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
132 Emchar c;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 col = tab_seen = post_tab = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 while (1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 if (pos <= BUF_BEGV (buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 pos--;
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
143 c = BUF_FETCH_CHAR (buf, pos);
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
144 if (c == '\t')
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 if (tab_seen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 col = ((col + tab_width) / tab_width) * tab_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 post_tab += col;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 col = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 tab_seen = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 }
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
153 else if (c == '\n' ||
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
154 (EQ (buf->selective_display, Qt) && c == '\r'))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 /* #### This needs updating to handle the new redisplay. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 /* #### FSFmacs looks at ctl_arrow, display tables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 We need to do similar. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 displayed_glyphs = glyphs_from_bufpos (sel_frame, buf,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 XWINDOW (selected_window),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 pos, dp, 0, col, 0, 0, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 col += (displayed_glyphs->columns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 - (displayed_glyphs->begin_columns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 + displayed_glyphs->end_columns));
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
168 #else /* XEmacs */
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
169 col ++;
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
170 #endif /* XEmacs */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 if (tab_seen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 col = ((col + tab_width) / tab_width) * tab_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 col += post_tab;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 if (cur_col)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 last_known_column_buffer = buf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 last_known_column = col;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 last_known_column_point = BUF_PT (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 last_known_column_modified = BUF_MODIFF (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 return col;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 current_column (struct buffer *buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 if (buf == last_known_column_buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 && BUF_PT (buf) == last_known_column_point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 && BUF_MODIFF (buf) == last_known_column_modified)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 return last_known_column;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 return column_at_point (buf, BUF_PT (buf), 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
202 DEFUN ("current-column", Fcurrent_column, 0, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 Return the horizontal position of point. Beginning of line is column 0.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 This is calculated by adding together the widths of all the displayed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 representations of the character between the start of the previous line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 and point. (e.g. control characters will have a width of 2 or 4, tabs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 will have a variable width.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 Ignores finite width of frame, which means that this function may return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 values greater than (frame-width).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 Whether the line is visible (if `selective-display' is t) has no effect;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 however, ^M is treated as end of line when `selective-display' is t.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 If BUFFER is nil, the current buffer is assumed.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
213 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
214 (buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 return (make_int (current_column (decode_buffer (buffer, 0))));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
220 DEFUN ("indent-to", Findent_to, 1, 3, "NIndent to column: ", /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 Indent from point with tabs and spaces until COLUMN is reached.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 Optional second argument MIN says always do at least MIN spaces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 even if that goes past COLUMN; by default, MIN is zero.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 If BUFFER is nil, the current buffer is assumed.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
225 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
226 (col, minimum, buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 int mincol;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 int fromcol;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 struct buffer *buf = decode_buffer (buffer, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 int tab_width = XINT (buf->tab_width);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 Bufpos opoint = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 CHECK_INT (col);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 if (NILP (minimum))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 minimum = Qzero;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 CHECK_INT (minimum);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 XSETBUFFER (buffer, buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 fromcol = current_column (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 mincol = fromcol + XINT (minimum);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 if (mincol < XINT (col)) mincol = XINT (col);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 if (fromcol == mincol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 return make_int (mincol);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 if (!NILP (Fextent_at (make_int (BUF_PT (buf)), buffer, Qinvisible,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 Qnil, Qnil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 Bufpos last_visible = last_visible_position (BUF_PT (buf), buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 opoint = BUF_PT (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 if (last_visible >= BUF_BEGV (buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 BUF_SET_PT (buf, last_visible);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 error ("Visible portion of buffer not modifiable");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 if (indent_tabs_mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 int n = mincol / tab_width - fromcol / tab_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 if (n != 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 Finsert_char (make_char ('\t'), make_int (n), Qnil, buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 fromcol = (mincol / tab_width) * tab_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 Finsert_char (make_char (' '), make_int (mincol - fromcol), Qnil, buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 last_known_column_buffer = buf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 last_known_column = mincol;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 last_known_column_point = BUF_PT (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 last_known_column_modified = BUF_MODIFF (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 /* Not in FSF: */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 if (opoint > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 BUF_SET_PT (buf, opoint);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 return (make_int (mincol));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 bi_spaces_at_point (struct buffer *b, Bytind bi_pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 Bytind bi_end = BI_BUF_ZV (b);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 int col = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 Emchar c;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 int tab_width = XINT (b->tab_width);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 if (tab_width <= 0 || tab_width > 1000)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 tab_width = 8;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 while (bi_pos < bi_end &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (c = BI_BUF_FETCH_CHAR (b, bi_pos),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (c == '\t'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 ? (col += tab_width - col % tab_width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 : (c == ' ' ? ++col : 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 INC_BYTIND (b, bi_pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 return col;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
311 DEFUN ("current-indentation", Fcurrent_indentation, 0, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 Return the indentation of the current line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 This is the horizontal position of the character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 following any initial whitespace.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
315 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
316 (buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 struct buffer *buf = decode_buffer (buffer, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 Bufpos pos = find_next_newline (buf, BUF_PT (buf), -1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 XSETBUFFER (buffer, buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 if (!NILP (Fextent_at (make_int (pos), buffer, Qinvisible, Qnil, Qnil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 return Qzero;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 return make_int (bi_spaces_at_point (buf, bufpos_to_bytind (buf, pos)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
330 DEFUN ("move-to-column", Fmove_to_column, 1, 3, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 Move point to column COLUMN in the current line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 The column of a character is calculated by adding together the widths
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 as displayed of the previous characters in the line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 This function ignores line-continuation;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 there is no upper limit on the column number a character can have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 and horizontal scrolling has no effect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 If specified column is within a character, point goes after that character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 If it's past end of line, point goes to end of line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 A non-nil second (optional) argument FORCE means, if the line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 is too short to reach column COLUMN then add spaces/tabs to get there,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 and if COLUMN is in the middle of a tab character, change it to spaces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 Returns the actual column that it moved to.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
345 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
346 (column, force, buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 Bufpos pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 struct buffer *buf = decode_buffer (buffer, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 int col = current_column (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 int goal;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 Bufpos end;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 int tab_width = XINT (buf->tab_width);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 int prev_col = 0;
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
357 Emchar c;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 XSETBUFFER (buffer, buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 CHECK_NATNUM (column);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 goal = XINT (column);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 retry:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 pos = BUF_PT (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 end = BUF_ZV (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 /* If we're starting past the desired column,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 back up to beginning of line and scan from there. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 if (col > goal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 pos = find_next_newline (buf, pos, -1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 col = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 while (col < goal && pos < end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 c = BUF_FETCH_CHAR (buf, pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 if (c == '\n')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 if (c == '\r' && EQ (buf->selective_display, Qt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 if (c == '\t')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 prev_col = col;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 col += tab_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 col = col / tab_width * tab_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 /* #### oh for the days of the complete new redisplay */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 /* #### FSFmacs looks at ctl_arrow, display tables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 We need to do similar. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 displayed_glyphs = glyphs_from_bufpos (selected_frame (),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 buf,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 XWINDOW (Fselected_window (Qnil)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 pos, dp, 0, col, 0, 0, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 col += (displayed_glyphs->columns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 - (displayed_glyphs->begin_columns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 + displayed_glyphs->end_columns));
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
402 #else /* XEmacs */
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
403 col ++;
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
404 #endif /* XEmacs */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 pos++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 BUF_SET_PT (buf, pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 /* If a tab char made us overshoot, change it to spaces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 and scan through it again. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 if (!NILP (force) && col > goal && c == '\t' && prev_col < goal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 buffer_delete_range (buf, BUF_PT (buf) - 1, BUF_PT (buf), 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 Findent_to (make_int (col - 1), Qzero, buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 buffer_insert_emacs_char (buf, ' ');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 goto retry;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 /* If line ends prematurely, add space to the end. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 if (col < goal && !NILP (force))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 col = goal;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 Findent_to (make_int (col), Qzero, buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 last_known_column_buffer = buf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 last_known_column = col;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 last_known_column_point = BUF_PT (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 last_known_column_modified = BUF_MODIFF (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 return (make_int (col));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 #if 0 /* #### OK boys, this function needs to be present, I think.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 It was there before the 19.12 redisplay rewrite. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 xxDEFUN ("compute-motion", Fcompute_motion, Scompute_motion, 7, 7, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 "Scan through the current buffer, calculating screen position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 Scan the current buffer forward from offset FROM,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 assuming it is at position FROMPOS--a cons of the form (HPOS . VPOS)--
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 to position TO or position TOPOS--another cons of the form (HPOS . VPOS)--
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 and return the ending buffer position and screen location.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 There are three additional arguments:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 WIDTH is the number of columns available to display text;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 this affects handling of continuation lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 This is usually the value returned by `window-width', less one (to allow
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 for the continuation glyph).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 OFFSETS is either nil or a cons cell (HSCROLL . TAB-OFFSET).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 HSCROLL is the number of columns not being displayed at the left
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 margin; this is usually taken from a window's hscroll member.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 TAB-OFFSET is the number of columns of the first tab that aren't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 being displayed, perhaps because the line was continued within it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 If OFFSETS is nil, HSCROLL and TAB-OFFSET are assumed to be zero.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 WINDOW is the window to operate on. Currently this is used only to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 find the display table. It does not matter what buffer WINDOW displays;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 `compute-motion' always operates on the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 The value is a list of five elements:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (POS HPOS VPOS PREVHPOS CONTIN)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 POS is the buffer position where the scan stopped.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 VPOS is the vertical position where the scan stopped.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 HPOS is the horizontal position where the scan stopped.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 PREVHPOS is the horizontal position one character back from POS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 CONTIN is t if a line was continued after (or within) the previous character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 For example, to find the buffer position of column COL of line LINE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 of a certain window, pass the window's starting location as FROM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 and the window's upper-left coordinates as FROMPOS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 Pass the buffer's (point-max) as TO, to limit the scan to the end of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 visible section of the buffer, and pass LINE and COL as TOPOS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (from, frompos, to, topos, width, offsets, window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 Lisp_Object from, frompos, to, topos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 Lisp_Object width, offsets, window;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 Lisp_Object bufpos, hpos, vpos, prevhpos, contin;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 struct position *pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 int hscroll, tab_offset;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 struct window *w = decode_window (window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 CHECK_INT_COERCE_MARKER (from);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 CHECK_CONS (frompos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 CHECK_INT (XCAR (frompos));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 CHECK_INT (XCDR (frompos));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 CHECK_INT_COERCE_MARKER (to);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 CHECK_CONS (topos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 CHECK_INT (XCAR (topos));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 CHECK_INT (XCDR (topos));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 CHECK_INT (width);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 if (!NILP (offsets))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 CHECK_CONS (offsets);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 CHECK_INT (XCAR (offsets));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 CHECK_INT (XCDR (offsets));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 hscroll = XINT (XCAR (offsets));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 tab_offset = XINT (XCDR (offsets));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 hscroll = tab_offset = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 pos = compute_motion (XINT (from), XINT (XCDR (frompos)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 XINT (XCAR (frompos)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 XINT (to), XINT (XCDR (topos)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 XINT (XCAR (topos)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 XINT (width), hscroll, tab_offset, w);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 XSETINT (bufpos, pos->bufpos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 XSETINT (hpos, pos->hpos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 XSETINT (vpos, pos->vpos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 XSETINT (prevhpos, pos->prevhpos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 return list5 (bufpos,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 hpos,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 vpos,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 prevhpos,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 pos->contin ? Qt : Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 #endif /* 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 /*****************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 vmotion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 Given a starting position ORIG, move point VTARGET lines in WINDOW.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 Returns the new value for point. If the arg ret_vpos is not nil, it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 taken to be a pointer to an int and the number of lines actually moved is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 returned in it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 ****************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 Bufpos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 vmotion (struct window *w, Bufpos orig, int vtarget, int *ret_vpos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 struct buffer *b = XBUFFER (w->buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 int elt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 elt = point_in_line_start_cache (w, orig, (vtarget < 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 ? -vtarget
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 : vtarget));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 /* #### This assertion must be true before the if statements are hit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 but may possibly be wrong after the call to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 point_in_line_start_cache if orig is outside of the visible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 region of the buffer. Handle this. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 assert (elt >= 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 /* Moving downward. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 if (vtarget > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 int cur_line = Dynarr_length (w->line_start_cache) - 1 - elt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 Bufpos ret_pt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 if (cur_line > vtarget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 cur_line = vtarget;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 /* The traditional FSF behavior is to return the end of buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 position if we couldn't move far enough because we hit it. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 if (cur_line < vtarget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 ret_pt = BUF_ZV (b);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 ret_pt = Dynarr_atp (w->line_start_cache, cur_line + elt)->start;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 while (ret_pt > BUF_ZV (b) && cur_line > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 cur_line--;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 ret_pt = Dynarr_atp (w->line_start_cache, cur_line + elt)->start;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 if (ret_vpos) *ret_vpos = cur_line;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 return (ret_pt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 else if (vtarget < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 if (elt < -vtarget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 if (ret_vpos) *ret_vpos = -elt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 /* #### This should be BUF_BEGV (b), right? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 return (Dynarr_atp (w->line_start_cache, 0)->start);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 if (ret_vpos) *ret_vpos = vtarget;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 return (Dynarr_atp (w->line_start_cache, elt + vtarget)->start);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 /* No vertical motion requested so we just return the position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 of the beginning of the current line. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 if (ret_vpos) *ret_vpos = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 return (Dynarr_atp (w->line_start_cache, elt)->start);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 RETURN_NOT_REACHED(0) /* shut up compiler */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
605 DEFUN ("vertical-motion", Fvertical_motion, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 Move to start of frame line LINES lines down.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 If LINES is negative, this is moving up.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 The optional second argument WINDOW specifies the window to use for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 parameters such as width, horizontal scrolling, and so on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 the default is the selected window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 Note that `vertical-motion' sets WINDOW's buffer's point, not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 WINDOW's point. (This differs from FSF Emacs, which buggily always
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 sets current buffer's point, regardless of WINDOW.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 Sets point to position found; this may be start of line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 or just the start of a continuation line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 Returns number of lines moved; may be closer to zero than LINES
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 if beginning or end of buffer was reached.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 Optional second argument is WINDOW to move in.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
621 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
622 (lines, window))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 if (NILP (window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 window = Fselected_window (Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 CHECK_WINDOW (window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 Bufpos bufpos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 int vpos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 struct window *w = XWINDOW (window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 CHECK_INT (lines);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 bufpos = vmotion (XWINDOW (window), BUF_PT (XBUFFER (w->buffer)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 XINT (lines), &vpos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 /* Note that the buffer's point is set, not the window's point. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 BUF_SET_PT (XBUFFER (w->buffer), bufpos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 return make_int (vpos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 syms_of_indent (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 {
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
648 DEFSUBR (Fcurrent_indentation);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
649 DEFSUBR (Findent_to);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
650 DEFSUBR (Fcurrent_column);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
651 DEFSUBR (Fmove_to_column);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 #if 0 /* #### */
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
653 DEFSUBR (Fcompute_motion);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 #endif
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
655 DEFSUBR (Fvertical_motion);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 vars_of_indent (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 DEFVAR_BOOL ("indent-tabs-mode", &indent_tabs_mode /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 *Indentation can insert tabs if this is non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 Setting this variable automatically makes it local to the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 indent_tabs_mode = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 }