annotate src/indent.c @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children 0293115a14e9
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;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 col = tab_seen = post_tab = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 while (1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 if (pos <= BUF_BEGV (buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 pos--;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 if (BUF_FETCH_CHAR (buf, pos) == '\t')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 if (tab_seen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 col = ((col + tab_width) / tab_width) * tab_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 post_tab += col;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 col = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 tab_seen = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 else if (BUF_FETCH_CHAR (buf, pos) == '\n' ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (EQ (buf->selective_display, Qt) &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 BUF_FETCH_CHAR (buf, pos) == '\r'))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 /* #### This needs updating to handle the new redisplay. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 /* #### FSFmacs looks at ctl_arrow, display tables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 We need to do similar. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 displayed_glyphs = glyphs_from_bufpos (sel_frame, buf,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 XWINDOW (selected_window),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 pos, dp, 0, col, 0, 0, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 col += (displayed_glyphs->columns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 - (displayed_glyphs->begin_columns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 + displayed_glyphs->end_columns));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 col++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 }
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 if (tab_seen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 col = ((col + tab_width) / tab_width) * tab_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 col += post_tab;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 if (cur_col)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 last_known_column_buffer = buf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 last_known_column = col;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 last_known_column_point = BUF_PT (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 last_known_column_modified = BUF_MODIFF (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 return col;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 current_column (struct buffer *buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 if (buf == last_known_column_buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 && BUF_PT (buf) == last_known_column_point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 && BUF_MODIFF (buf) == last_known_column_modified)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 return last_known_column;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 return column_at_point (buf, BUF_PT (buf), 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 DEFUN ("current-column", Fcurrent_column, Scurrent_column, 0, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 Return the horizontal position of point. Beginning of line is column 0.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 This is calculated by adding together the widths of all the displayed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 representations of the character between the start of the previous line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 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
206 will have a variable width.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 Ignores finite width of frame, which means that this function may return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 values greater than (frame-width).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 Whether the line is visible (if `selective-display' is t) has no effect;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 however, ^M is treated as end of line when `selective-display' is t.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 If BUFFER is nil, the current buffer is assumed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 Lisp_Object buffer;
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 DEFUN ("indent-to", Findent_to, Sindent_to, 1, 3, "NIndent to column: " /*
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.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (col, minimum, buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 Lisp_Object col, minimum, buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 int mincol;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 int fromcol;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 struct buffer *buf = decode_buffer (buffer, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 int tab_width = XINT (buf->tab_width);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 Bufpos opoint = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 CHECK_INT (col);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 if (NILP (minimum))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 minimum = Qzero;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 CHECK_INT (minimum);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 XSETBUFFER (buffer, buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 fromcol = current_column (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 mincol = fromcol + XINT (minimum);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 if (mincol < XINT (col)) mincol = XINT (col);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 if (fromcol == mincol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 return make_int (mincol);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 if (!NILP (Fextent_at (make_int (BUF_PT (buf)), buffer, Qinvisible,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 Qnil, Qnil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 Bufpos last_visible = last_visible_position (BUF_PT (buf), buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 opoint = BUF_PT (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 if (last_visible >= BUF_BEGV (buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 BUF_SET_PT (buf, last_visible);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 error ("Visible portion of buffer not modifiable");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 if (indent_tabs_mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 int n = mincol / tab_width - fromcol / tab_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 if (n != 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 Finsert_char (make_char ('\t'), make_int (n), Qnil, buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 fromcol = (mincol / tab_width) * tab_width;
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 Finsert_char (make_char (' '), make_int (mincol - fromcol), Qnil, buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 last_known_column_buffer = buf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 last_known_column = mincol;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 last_known_column_point = BUF_PT (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 last_known_column_modified = BUF_MODIFF (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 /* Not in FSF: */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 if (opoint > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 BUF_SET_PT (buf, opoint);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 return (make_int (mincol));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 bi_spaces_at_point (struct buffer *b, Bytind bi_pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 Bytind bi_end = BI_BUF_ZV (b);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 int col = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 Emchar c;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 int tab_width = XINT (b->tab_width);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 if (tab_width <= 0 || tab_width > 1000)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 tab_width = 8;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 while (bi_pos < bi_end &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (c = BI_BUF_FETCH_CHAR (b, bi_pos),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (c == '\t'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 ? (col += tab_width - col % tab_width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 : (c == ' ' ? ++col : 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 INC_BYTIND (b, bi_pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 return col;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 DEFUN ("current-indentation", Fcurrent_indentation, Scurrent_indentation,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 0, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 Return the indentation of the current line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 This is the horizontal position of the character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 following any initial whitespace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 Lisp_Object buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 struct buffer *buf = decode_buffer (buffer, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 Bufpos pos = find_next_newline (buf, BUF_PT (buf), -1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 XSETBUFFER (buffer, buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 if (!NILP (Fextent_at (make_int (pos), buffer, Qinvisible, Qnil, Qnil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 return Qzero;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 return make_int (bi_spaces_at_point (buf, bufpos_to_bytind (buf, pos)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 DEFUN ("move-to-column", Fmove_to_column, Smove_to_column, 1, 3, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 Move point to column COLUMN in the current line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 The column of a character is calculated by adding together the widths
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 as displayed of the previous characters in the line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 This function ignores line-continuation;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 there is no upper limit on the column number a character can have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 and horizontal scrolling has no effect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 If specified column is within a character, point goes after that character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 If it's past end of line, point goes to end of line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 A non-nil second (optional) argument FORCE means, if the line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 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
346 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
347 Returns the actual column that it moved to.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (column, force, buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 Lisp_Object column, force, buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 Bufpos pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 struct buffer *buf = decode_buffer (buffer, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 int col = current_column (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 int goal;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 Bufpos end;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 int tab_width = XINT (buf->tab_width);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 int prev_col = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 Emchar c = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 XSETBUFFER (buffer, buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 CHECK_NATNUM (column);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 goal = XINT (column);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 retry:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 pos = BUF_PT (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 end = BUF_ZV (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 /* If we're starting past the desired column,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 back up to beginning of line and scan from there. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 if (col > goal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 pos = find_next_newline (buf, pos, -1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 col = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 while (col < goal && pos < end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 c = BUF_FETCH_CHAR (buf, pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 if (c == '\n')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 if (c == '\r' && EQ (buf->selective_display, Qt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 if (c == '\t')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 prev_col = col;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 col += tab_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 col = col / tab_width * tab_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 /* #### oh for the days of the complete new redisplay */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 /* #### FSFmacs looks at ctl_arrow, display tables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 We need to do similar. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 displayed_glyphs = glyphs_from_bufpos (selected_frame (),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 buf,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 XWINDOW (Fselected_window (Qnil)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 pos, dp, 0, col, 0, 0, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 col += (displayed_glyphs->columns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 - (displayed_glyphs->begin_columns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 + displayed_glyphs->end_columns));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 col++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 pos++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 BUF_SET_PT (buf, pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 /* If a tab char made us overshoot, change it to spaces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 and scan through it again. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 if (!NILP (force) && col > goal && c == '\t' && prev_col < goal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 buffer_delete_range (buf, BUF_PT (buf) - 1, BUF_PT (buf), 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 Findent_to (make_int (col - 1), Qzero, buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 buffer_insert_emacs_char (buf, ' ');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 goto retry;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 /* If line ends prematurely, add space to the end. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 if (col < goal && !NILP (force))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 col = goal;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 Findent_to (make_int (col), Qzero, buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 last_known_column_buffer = buf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 last_known_column = col;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 last_known_column_point = BUF_PT (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 last_known_column_modified = BUF_MODIFF (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 return (make_int (col));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 #if 0 /* #### OK boys, this function needs to be present, I think.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 It was there before the 19.12 redisplay rewrite. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 xxDEFUN ("compute-motion", Fcompute_motion, Scompute_motion, 7, 7, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 "Scan through the current buffer, calculating screen position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 Scan the current buffer forward from offset FROM,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 assuming it is at position FROMPOS--a cons of the form (HPOS . VPOS)--
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 to position TO or position TOPOS--another cons of the form (HPOS . VPOS)--
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 and return the ending buffer position and screen location.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 There are three additional arguments:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 WIDTH is the number of columns available to display text;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 this affects handling of continuation lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 This is usually the value returned by `window-width', less one (to allow
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 for the continuation glyph).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 OFFSETS is either nil or a cons cell (HSCROLL . TAB-OFFSET).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 HSCROLL is the number of columns not being displayed at the left
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 margin; this is usually taken from a window's hscroll member.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 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
462 being displayed, perhaps because the line was continued within it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 If OFFSETS is nil, HSCROLL and TAB-OFFSET are assumed to be zero.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 WINDOW is the window to operate on. Currently this is used only to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 find the display table. It does not matter what buffer WINDOW displays;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 `compute-motion' always operates on the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 The value is a list of five elements:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (POS HPOS VPOS PREVHPOS CONTIN)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 POS is the buffer position where the scan stopped.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 VPOS is the vertical position where the scan stopped.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 HPOS is the horizontal position where the scan stopped.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 PREVHPOS is the horizontal position one character back from POS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 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
477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 For example, to find the buffer position of column COL of line LINE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 of a certain window, pass the window's starting location as FROM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 and the window's upper-left coordinates as FROMPOS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 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
482 visible section of the buffer, and pass LINE and COL as TOPOS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (from, frompos, to, topos, width, offsets, window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 Lisp_Object from, frompos, to, topos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 Lisp_Object width, offsets, window;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 Lisp_Object bufpos, hpos, vpos, prevhpos, contin;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 struct position *pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 int hscroll, tab_offset;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 struct window *w = decode_window (window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 CHECK_INT_COERCE_MARKER (from);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 CHECK_CONS (frompos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 CHECK_INT (XCAR (frompos));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 CHECK_INT (XCDR (frompos));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 CHECK_INT_COERCE_MARKER (to);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 CHECK_CONS (topos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 CHECK_INT (XCAR (topos));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 CHECK_INT (XCDR (topos));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 CHECK_INT (width);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 if (!NILP (offsets))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 CHECK_CONS (offsets);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 CHECK_INT (XCAR (offsets));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 CHECK_INT (XCDR (offsets));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 hscroll = XINT (XCAR (offsets));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 tab_offset = XINT (XCDR (offsets));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 hscroll = tab_offset = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 pos = compute_motion (XINT (from), XINT (XCDR (frompos)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 XINT (XCAR (frompos)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 XINT (to), XINT (XCDR (topos)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 XINT (XCAR (topos)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 XINT (width), hscroll, tab_offset, w);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 XSETINT (bufpos, pos->bufpos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 XSETINT (hpos, pos->hpos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 XSETINT (vpos, pos->vpos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 XSETINT (prevhpos, pos->prevhpos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 return list5 (bufpos,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 hpos,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 vpos,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 prevhpos,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 pos->contin ? Qt : Qnil);
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 #endif /* 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 /*****************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 vmotion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 Given a starting position ORIG, move point VTARGET lines in WINDOW.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 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
539 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
540 returned in it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 ****************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 Bufpos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 vmotion (struct window *w, Bufpos orig, int vtarget, int *ret_vpos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 struct buffer *b = XBUFFER (w->buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 int elt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 elt = point_in_line_start_cache (w, orig, (vtarget < 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 ? -vtarget
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 : vtarget));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 /* #### This assertion must be true before the if statements are hit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 but may possibly be wrong after the call to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 point_in_line_start_cache if orig is outside of the visible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 region of the buffer. Handle this. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 assert (elt >= 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 /* Moving downward. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 if (vtarget > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 int cur_line = Dynarr_length (w->line_start_cache) - 1 - elt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 Bufpos ret_pt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 if (cur_line > vtarget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 cur_line = vtarget;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 /* The traditional FSF behavior is to return the end of buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 position if we couldn't move far enough because we hit it. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 if (cur_line < vtarget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 ret_pt = BUF_ZV (b);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 ret_pt = Dynarr_atp (w->line_start_cache, cur_line + elt)->start;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 while (ret_pt > BUF_ZV (b) && cur_line > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 cur_line--;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 ret_pt = Dynarr_atp (w->line_start_cache, cur_line + elt)->start;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 if (ret_vpos) *ret_vpos = cur_line;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 return (ret_pt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 else if (vtarget < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 if (elt < -vtarget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 if (ret_vpos) *ret_vpos = -elt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 /* #### This should be BUF_BEGV (b), right? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 return (Dynarr_atp (w->line_start_cache, 0)->start);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 if (ret_vpos) *ret_vpos = vtarget;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 return (Dynarr_atp (w->line_start_cache, elt + vtarget)->start);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 /* No vertical motion requested so we just return the position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 of the beginning of the current line. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 if (ret_vpos) *ret_vpos = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 return (Dynarr_atp (w->line_start_cache, elt)->start);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 RETURN_NOT_REACHED(0) /* shut up compiler */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 DEFUN ("vertical-motion", Fvertical_motion, Svertical_motion, 1, 2, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 Move to start of frame line LINES lines down.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 If LINES is negative, this is moving up.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 The optional second argument WINDOW specifies the window to use for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 parameters such as width, horizontal scrolling, and so on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 the default is the selected window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 Note that `vertical-motion' sets WINDOW's buffer's point, not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 WINDOW's point. (This differs from FSF Emacs, which buggily always
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 sets current buffer's point, regardless of WINDOW.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 Sets point to position found; this may be start of line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 or just the start of a continuation line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 Returns number of lines moved; may be closer to zero than LINES
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 if beginning or end of buffer was reached.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 Optional second argument is WINDOW to move in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (lines, window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 Lisp_Object lines, window;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 if (NILP (window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 window = Fselected_window (Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 CHECK_WINDOW (window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 Bufpos bufpos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 int vpos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 struct window *w = XWINDOW (window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 CHECK_INT (lines);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 bufpos = vmotion (XWINDOW (window), BUF_PT (XBUFFER (w->buffer)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 XINT (lines), &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 /* Note that the buffer's point is set, not the window's point. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 BUF_SET_PT (XBUFFER (w->buffer), bufpos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 return make_int (vpos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 syms_of_indent (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 defsubr (&Scurrent_indentation);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 defsubr (&Sindent_to);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 defsubr (&Scurrent_column);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 defsubr (&Smove_to_column);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 #if 0 /* #### */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 defsubr (&Scompute_motion);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 defsubr (&Svertical_motion);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 vars_of_indent (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 DEFVAR_BOOL ("indent-tabs-mode", &indent_tabs_mode /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 *Indentation can insert tabs if this is non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 Setting this variable automatically makes it local to the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 indent_tabs_mode = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 }