annotate src/indent.c @ 5464:e79916901603 r21-5-30

XEmacs 21.5.30 "garlic" is released.
author Stephen J. Turnbull <stephen@xemacs.org>
date Wed, 27 Apr 2011 01:24:28 +0900
parents c096d8051f89
children 8d29f1c4bb98
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* Indentation functions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1995 Board of Trustees, University of Illinois.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Copyright (C) 1985, 1986, 1987, 1988, 1992, 1993, 1994, 1995
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 793
diff changeset
4 Free Software Foundation, Inc.
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2506
diff changeset
5 Copyright (C) 2002, 2005 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 /* This file has been Mule-ized. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 /* Synched up with: 19.30. Diverges significantly from FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 #include "buffer.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 #include "device.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 #include "extents.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 #include "faces.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #include "frame.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 #include "glyphs.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 #include "insdel.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 #ifdef REGION_CACHE_NEEDS_WORK
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 #include "region-cache.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 #include "window.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 /* Indentation can insert tabs if this is non-zero;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 otherwise always uses spaces */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 int indent_tabs_mode;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 /* Avoid recalculation by remembering things in these variables. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 /* Last value returned by current_column.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 Some things set last_known_column_point to -1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 to mark the memoized value as invalid */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 static int last_known_column;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 /* Last buffer searched by current_column */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 static struct buffer *last_known_column_buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 /* Value of point when current_column was called */
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
60 static Charbpos last_known_column_point;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 /* Value of MODIFF when current_column was called */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 static int last_known_column_modified;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
65 static Charbpos
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
66 last_visible_position (Charbpos pos, struct buffer *buf)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 Lisp_Object buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 Lisp_Object value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 665
diff changeset
71 buffer = wrap_buffer (buf);
2506
8c96bdabcaf9 [xemacs-hg @ 2005-01-26 05:11:01 by ben]
ben
parents: 1268
diff changeset
72 value = Fprevious_single_char_property_change (make_int (pos), Qinvisible,
8c96bdabcaf9 [xemacs-hg @ 2005-01-26 05:11:01 by ben]
ben
parents: 1268
diff changeset
73 buffer, Qnil);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 if (NILP (value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 return 0; /* no visible position found */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 /* #### bug bug bug!!! This will return the position of the beginning
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 of an invisible extent; this extent is very likely to be start-closed,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 and thus the spaces inserted in `indent-to' will go inside the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 invisible extent.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 Not sure what the correct solution is here. Rethink indent-to? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 return XINT (value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 #ifdef REGION_CACHE_NEEDS_WORK
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 /* Allocate or free the width run cache, as requested by the current
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 state of current_buffer's cache_long_line_scans variable. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 width_run_cache_on_off (struct buffer *buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 if (NILP (buf->cache_long_line_scans))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 /* It should be off. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 if (buf->width_run_cache)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 free_region_cache (buf->width_run_cache);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 buf->width_run_cache = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 buf->width_table = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 /* It should be on. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 if (buf->width_run_cache == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 buf->width_run_cache = new_region_cache ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 recompute_width_table (buf, buffer_display_table ());
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 #endif /* REGION_CACHE_NEEDS_WORK */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 /* Cancel any recorded value of the horizontal position. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 invalidate_current_column (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 last_known_column_point = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 int
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
126 column_at_point (struct buffer *buf, Charbpos init_pos, int cur_col)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 int col;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 int tab_seen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 int tab_width = XINT (buf->tab_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 int post_tab;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
132 Charbpos pos = init_pos;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
133 Ichar c;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 col = tab_seen = post_tab = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 if (pos <= BUF_BEGV (buf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 pos--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 c = BUF_FETCH_CHAR (buf, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 if (c == '\t')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 if (tab_seen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 col = ((col + tab_width) / tab_width) * tab_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 post_tab += col;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 col = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 tab_seen = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 else if (c == '\n' ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 (EQ (buf->selective_display, Qt) && c == '\r'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 /* #### This needs updating to handle the new redisplay. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 /* #### FSFmacs looks at ctl_arrow, display tables.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 We need to do similar. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 #if 0
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
163 displayed_glyphs = glyphs_from_charbpos (sel_frame, buf,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 XWINDOW (selected_window),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 pos, dp, 0, col, 0, 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 col += (displayed_glyphs->columns
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 - (displayed_glyphs->begin_columns
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 + displayed_glyphs->end_columns));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 #else /* XEmacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 #ifdef MULE
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
171 col += XCHARSET_COLUMNS (ichar_charset (c));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 col ++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 #endif /* MULE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 #endif /* XEmacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 if (tab_seen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 col = ((col + tab_width) / tab_width) * tab_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 col += post_tab;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 if (cur_col)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 last_known_column_buffer = buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 last_known_column = col;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 last_known_column_point = init_pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 last_known_column_modified = BUF_MODIFF (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 return col;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 int
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 665
diff changeset
197 string_column_at_point (Lisp_Object s, Charbpos init_pos, int tab_width)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 int col;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 int tab_seen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 int post_tab;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
202 Charbpos pos = init_pos;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
203 Ichar c;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 col = tab_seen = post_tab = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 if (pos <= 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 pos--;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
214 c = string_ichar (s, pos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 if (c == '\t')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 if (tab_seen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 col = ((col + tab_width) / tab_width) * tab_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 post_tab += col;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 col = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 tab_seen = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 else if (c == '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 #ifdef MULE
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
228 col += XCHARSET_COLUMNS (ichar_charset (c));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 col ++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 #endif /* MULE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 if (tab_seen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 col = ((col + tab_width) / tab_width) * tab_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 col += post_tab;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 return col;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 current_column (struct buffer *buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 if (buf == last_known_column_buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 && BUF_PT (buf) == last_known_column_point
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 && BUF_MODIFF (buf) == last_known_column_modified)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 return last_known_column;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 return column_at_point (buf, BUF_PT (buf), 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 DEFUN ("current-column", Fcurrent_column, 0, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 Return the horizontal position of point. Beginning of line is column 0.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 This is calculated by adding together the widths of all the displayed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 representations of the character between the start of the previous line
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 and point. (e.g. control characters will have a width of 2 or 4, tabs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 will have a variable width.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 Ignores finite width of frame, which means that this function may return
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 values greater than (frame-width).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 Whether the line is visible (if `selective-display' is t) has no effect;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 however, ^M is treated as end of line when `selective-display' is t.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 If BUFFER is nil, the current buffer is assumed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 return make_int (current_column (decode_buffer (buffer, 0)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 DEFUN ("indent-to", Findent_to, 1, 3, "NIndent to column: ", /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 Indent from point with tabs and spaces until COLUMN is reached.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
274 Optional second argument MINIMUM says always do at least MINIMUM spaces
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
275 even if that goes past COLUMN; by default, MINIMUM is zero.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 If BUFFER is nil, the current buffer is assumed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
278 (column, minimum, buffer))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 int mincol;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 int fromcol;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 struct buffer *buf = decode_buffer (buffer, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 int tab_width = XINT (buf->tab_width);
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
285 Charbpos opoint = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
287 CHECK_INT (column);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 if (NILP (minimum))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 minimum = Qzero;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 CHECK_INT (minimum);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 665
diff changeset
293 buffer = wrap_buffer (buf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 fromcol = current_column (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 mincol = fromcol + XINT (minimum);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
297 if (mincol < XINT (column)) mincol = XINT (column);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 if (fromcol == mincol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 return make_int (mincol);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 if (!NILP (Fextent_at (make_int (BUF_PT (buf)), buffer, Qinvisible,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 Qnil, Qnil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
307 Charbpos last_visible = last_visible_position (BUF_PT (buf), buf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 opoint = BUF_PT (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 if (last_visible >= BUF_BEGV (buf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 BUF_SET_PT (buf, last_visible);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 444
diff changeset
313 invalid_operation ("Visible portion of buffer not modifiable", Qunbound);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 if (indent_tabs_mode)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 int n = mincol / tab_width - fromcol / tab_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 if (n != 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 Finsert_char (make_char ('\t'), make_int (n), Qnil, buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 fromcol = (mincol / tab_width) * tab_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 Finsert_char (make_char (' '), make_int (mincol - fromcol), Qnil, buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 last_known_column_buffer = buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 last_known_column = mincol;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 last_known_column_point = BUF_PT (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 last_known_column_modified = BUF_MODIFF (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 /* Not in FSF: */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 if (opoint > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 BUF_SET_PT (buf, opoint);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 return make_int (mincol);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 int
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 793
diff changeset
342 byte_spaces_at_point (struct buffer *b, Bytebpos byte_pos)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 793
diff changeset
344 Bytebpos byte_end = BYTE_BUF_ZV (b);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 int col = 0;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
346 Ichar c;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 int tab_width = XINT (b->tab_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 if (tab_width <= 0 || tab_width > 1000)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 tab_width = 8;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 793
diff changeset
352 while (byte_pos < byte_end &&
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 793
diff changeset
353 (c = BYTE_BUF_FETCH_CHAR (b, byte_pos),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 (c == '\t'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 ? (col += tab_width - col % tab_width)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 : (c == ' ' ? ++col : 0))))
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 793
diff changeset
357 INC_BYTEBPOS (b, byte_pos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 return col;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 DEFUN ("current-indentation", Fcurrent_indentation, 0, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 Return the indentation of the current line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 This is the horizontal position of the character
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 following any initial whitespace.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 struct buffer *buf = decode_buffer (buffer, 0);
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
371 Charbpos pos = find_next_newline (buf, BUF_PT (buf), -1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 665
diff changeset
373 buffer = wrap_buffer (buf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 if (!NILP (Fextent_at (make_int (pos), buffer, Qinvisible, Qnil, Qnil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 return Qzero;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 793
diff changeset
378 return make_int (byte_spaces_at_point (buf, charbpos_to_bytebpos (buf, pos)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 DEFUN ("move-to-column", Fmove_to_column, 1, 3, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 Move point to column COLUMN in the current line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 The column of a character is calculated by adding together the widths
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 as displayed of the previous characters in the line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 This function ignores line-continuation;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 there is no upper limit on the column number a character can have
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 and horizontal scrolling has no effect.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 If specified column is within a character, point goes after that character.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 If it's past end of line, point goes to end of line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2506
diff changeset
393 A value of `coerce' for the second (optional) argument FORCE means if
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 COLUMN is in the middle of a tab character, change it to spaces.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 Any other non-nil value means the same, plus if the line is too short to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 reach column COLUMN, then add spaces/tabs to get there.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 Returns the actual column that it moved to.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 (column, force, buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 /* This function can GC */
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
403 Charbpos pos;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 struct buffer *buf = decode_buffer (buffer, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 int col = current_column (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 int goal;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
407 Charbpos end;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 int tab_width = XINT (buf->tab_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 int prev_col = 0;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
411 Ichar c = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 665
diff changeset
413 buffer = wrap_buffer (buf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
5307
c096d8051f89 Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5047
diff changeset
415
c096d8051f89 Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5047
diff changeset
416 check_integer_range (column, Qzero, make_integer (EMACS_INT_MAX));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 goal = XINT (column);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 retry:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 pos = BUF_PT (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 end = BUF_ZV (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 /* If we're starting past the desired column,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 back up to beginning of line and scan from there. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 if (col > goal)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 pos = find_next_newline (buf, pos, -1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 col = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 while (col < goal && pos < end)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 c = BUF_FETCH_CHAR (buf, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 if (c == '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 if (c == '\r' && EQ (buf->selective_display, Qt))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 if (c == '\t')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 prev_col = col;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 col += tab_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 col = col / tab_width * tab_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 /* #### oh for the days of the complete new redisplay */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 /* #### FSFmacs looks at ctl_arrow, display tables.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 We need to do similar. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 #if 0
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
450 displayed_glyphs = glyphs_from_charbpos (selected_frame (),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 buf,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 XWINDOW (Fselected_window (Qnil)),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 pos, dp, 0, col, 0, 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 col += (displayed_glyphs->columns
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 - (displayed_glyphs->begin_columns
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 + displayed_glyphs->end_columns));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 #else /* XEmacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 #ifdef MULE
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
459 col += XCHARSET_COLUMNS (ichar_charset (c));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 col ++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 #endif /* MULE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 #endif /* XEmacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 BUF_SET_PT (buf, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 /* If a tab char made us overshoot, change it to spaces
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 and scan through it again. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 if (!NILP (force) && col > goal && c == '\t' && prev_col < goal)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 buffer_delete_range (buf, BUF_PT (buf) - 1, BUF_PT (buf), 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 Findent_to (make_int (col - 1), Qzero, buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 buffer_insert_emacs_char (buf, ' ');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 goto retry;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 /* If line ends prematurely, add space to the end. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 if (col < goal && !NILP (force) && !EQ (force, Qcoerce))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 col = goal;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 Findent_to (make_int (col), Qzero, buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 last_known_column_buffer = buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 last_known_column = col;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 last_known_column_point = BUF_PT (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 last_known_column_modified = BUF_MODIFF (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 return make_int (col);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 #if 0 /* #### OK boys, this function needs to be present, I think.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 It was there before the 19.12 redisplay rewrite. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 793
diff changeset
499 DEFUN ("compute-motion", Fcompute_motion, 7, 7, 0, /*
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 "Scan through the current buffer, calculating screen position.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 Scan the current buffer forward from offset FROM,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 assuming it is at position FROMPOS--a cons of the form (HPOS . VPOS)--
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 to position TO or position TOPOS--another cons of the form (HPOS . VPOS)--
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 and return the ending buffer position and screen location.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 There are three additional arguments:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 WIDTH is the number of columns available to display text;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 this affects handling of continuation lines.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 This is usually the value returned by `window-width', less one (to allow
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 for the continuation glyph).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 OFFSETS is either nil or a cons cell (HSCROLL . TAB-OFFSET).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 HSCROLL is the number of columns not being displayed at the left
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 margin; this is usually taken from a window's hscroll member.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 TAB-OFFSET is the number of columns of the first tab that aren't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 being displayed, perhaps because the line was continued within it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 If OFFSETS is nil, HSCROLL and TAB-OFFSET are assumed to be zero.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 WINDOW is the window to operate on. Currently this is used only to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 find the display table. It does not matter what buffer WINDOW displays;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 `compute-motion' always operates on the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 The value is a list of five elements:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 (POS HPOS VPOS PREVHPOS CONTIN)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 POS is the buffer position where the scan stopped.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 VPOS is the vertical position where the scan stopped.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 HPOS is the horizontal position where the scan stopped.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 PREVHPOS is the horizontal position one character back from POS.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 CONTIN is t if a line was continued after (or within) the previous character.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 For example, to find the buffer position of column COL of line LINE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 of a certain window, pass the window's starting location as FROM
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 and the window's upper-left coordinates as FROMPOS.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 Pass the buffer's (point-max) as TO, to limit the scan to the end of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 visible section of the buffer, and pass LINE and COL as TOPOS.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 (from, frompos, to, topos, width, offsets, window))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
541 Lisp_Object charbpos, hpos, vpos, prevhpos, contin;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 struct position *pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 int hscroll, tab_offset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 struct window *w = decode_window (window);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 CHECK_INT_COERCE_MARKER (from);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 CHECK_CONS (frompos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 CHECK_INT (XCAR (frompos));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 CHECK_INT (XCDR (frompos));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 CHECK_INT_COERCE_MARKER (to);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 CHECK_CONS (topos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 CHECK_INT (XCAR (topos));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 CHECK_INT (XCDR (topos));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 CHECK_INT (width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 if (!NILP (offsets))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 CHECK_CONS (offsets);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 CHECK_INT (XCAR (offsets));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 CHECK_INT (XCDR (offsets));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 hscroll = XINT (XCAR (offsets));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 tab_offset = XINT (XCDR (offsets));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 hscroll = tab_offset = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 pos = compute_motion (XINT (from), XINT (XCDR (frompos)),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 XINT (XCAR (frompos)),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 XINT (to), XINT (XCDR (topos)),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 XINT (XCAR (topos)),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 XINT (width), hscroll, tab_offset, w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 665
diff changeset
572 charbpos = make_int (pos->charbpos);
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 665
diff changeset
573 hpos = make_int (pos->hpos);
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 665
diff changeset
574 vpos = make_int (pos->vpos);
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 665
diff changeset
575 prevhpos = make_int (pos->prevhpos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
577 return list5 (charbpos, hpos, vpos, prevhpos,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 pos->contin ? Qt : Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 #endif /* 0 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 /* Helper for vmotion_1 - compute vertical pixel motion between
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 START and END in the line start cache CACHE. This just sums
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 the line heights, including both the starting and ending lines.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 vpix_motion (line_start_cache_dynarr *cache, int start, int end)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 int i, vpix;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 assert (start <= end);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 assert (start >= 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 assert (end < Dynarr_length (cache));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 vpix = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 for (i = start; i <= end; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 vpix += Dynarr_atp (cache, i)->height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 return vpix;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 vmotion_1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 Given a starting position ORIG, move point VTARGET lines in WINDOW.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 Returns the new value for point. If the arg ret_vpos is not nil, it is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 taken to be a pointer to an int and the number of lines actually moved is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 returned in it. If the arg ret_vpix is not nil, it is taken to be a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 pointer to an int and the vertical pixel height of the motion which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 took place is returned in it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 ****************************************************************************/
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
613 static Charbpos
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
614 vmotion_1 (struct window *w, Charbpos orig, int vtarget,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 int *ret_vpos, int *ret_vpix)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 struct buffer *b = XBUFFER (w->buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 int elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 elt = point_in_line_start_cache (w, orig, (vtarget < 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 ? -vtarget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 : vtarget));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 /* #### This assertion must be true before the if statements are hit
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 but may possibly be wrong after the call to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 point_in_line_start_cache if orig is outside of the visible
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 region of the buffer. Handle this. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 assert (elt >= 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 /* Moving downward. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 if (vtarget > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 int cur_line = Dynarr_length (w->line_start_cache) - 1 - elt;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
634 Charbpos ret_pt;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 if (cur_line > vtarget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 cur_line = vtarget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 /* The traditional FSF behavior is to return the end of buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 position if we couldn't move far enough because we hit it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 if (cur_line < vtarget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 ret_pt = BUF_ZV (b);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 ret_pt = Dynarr_atp (w->line_start_cache, cur_line + elt)->start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 while (ret_pt > BUF_ZV (b) && cur_line > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 cur_line--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 ret_pt = Dynarr_atp (w->line_start_cache, cur_line + elt)->start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 if (ret_vpos) *ret_vpos = cur_line;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 if (ret_vpix)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 *ret_vpix = vpix_motion (w->line_start_cache, elt, cur_line + elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 return ret_pt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 else if (vtarget < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 if (elt < -vtarget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 if (ret_vpos) *ret_vpos = -elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 if (ret_vpix)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 *ret_vpix = vpix_motion (w->line_start_cache, 0, elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 /* #### This should be BUF_BEGV (b), right? */
4967
0d4c9d0f6a8d rewrite dynarr code
Ben Wing <ben@xemacs.org>
parents: 3025
diff changeset
665 return Dynarr_begin (w->line_start_cache)->start;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 if (ret_vpos) *ret_vpos = vtarget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 if (ret_vpix)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 *ret_vpix = vpix_motion (w->line_start_cache, elt + vtarget, elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 return Dynarr_atp (w->line_start_cache, elt + vtarget)->start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 /* No vertical motion requested so we just return the position
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 of the beginning of the current line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 if (ret_vpos) *ret_vpos = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 if (ret_vpix)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 *ret_vpix = vpix_motion (w->line_start_cache, elt, elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 return Dynarr_atp (w->line_start_cache, elt)->start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 867
diff changeset
686 RETURN_NOT_REACHED(0); /* shut up compiler */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 vmotion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 Given a starting position ORIG, move point VTARGET lines in WINDOW.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 Returns the new value for point. If the arg ret_vpos is not nil, it is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 taken to be a pointer to an int and the number of lines actually moved is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 returned in it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 ****************************************************************************/
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
697 Charbpos
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
698 vmotion (struct window *w, Charbpos orig, int vtarget, int *ret_vpos)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 return vmotion_1 (w, orig, vtarget, ret_vpos, NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703 /* Helper for Fvertical_motion.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 static
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 Lisp_Object vertical_motion_1 (Lisp_Object lines, Lisp_Object window,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 int pixels)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
709 Charbpos charbpos;
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
710 Charbpos orig;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 int selected;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 int *vpos, *vpix;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 int value=0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 struct window *w;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 if (NILP (window))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 window = Fselected_window (Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 CHECK_LIVE_WINDOW (window);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 CHECK_INT (lines);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 selected = (EQ (window, Fselected_window (Qnil)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 w = XWINDOW (window);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 orig = selected ? BUF_PT (XBUFFER (w->buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 : marker_position (w->pointm[CURRENT_DISP]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 vpos = pixels ? NULL : &value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 vpix = pixels ? &value : NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
732 charbpos = vmotion_1 (w, orig, XINT (lines), vpos, vpix);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 /* Note that the buffer's point is set, not the window's point. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 if (selected)
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
736 BUF_SET_PT (XBUFFER (w->buffer), charbpos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 set_marker_restricted (w->pointm[CURRENT_DISP],
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
739 make_int(charbpos),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 w->buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 return make_int (value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 DEFUN ("vertical-motion", Fvertical_motion, 1, 3, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 Move to start of frame line LINES lines down.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 If LINES is negative, this is moving up.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 Optional second argument is WINDOW to move in,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 the default is the selected window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 Sets point to position found; this may be start of line
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 or just the start of a continuation line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 If optional third argument PIXELS is nil, returns number
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 of lines moved; may be closer to zero than LINES if beginning
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 or end of buffer was reached. If PIXELS is non-nil, the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 vertical pixel height of the motion which took place is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 returned instead of the actual number of lines moved. A
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 motion of zero lines returns the height of the current line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759
1268
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1204
diff changeset
760 NOTE NOTE NOTE: GNU Emacs/XEmacs difference.
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1204
diff changeset
761
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1204
diff changeset
762 What `vertical-motion' actually does is set WINDOW's buffer's point
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1204
diff changeset
763 if WINDOW is the selected window; else, it sets WINDOW's point.
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1204
diff changeset
764 This is unfortunately somewhat tricky to work with, and different
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1204
diff changeset
765 from GNU Emacs, which always uses the current buffer, not WINDOW's
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1204
diff changeset
766 buffer, always sets current buffer's point, and, from the
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1204
diff changeset
767 perspective of this function, temporarily makes WINDOW display
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1204
diff changeset
768 the current buffer if it wasn't already.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 (lines, window, pixels))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 return vertical_motion_1 (lines, window, !NILP (pixels));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 * Like vmotion() but requested and returned movement is in pixels.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 * HOW specifies the stopping condition. Positive means move at least
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778 * PIXELS. Negative means at most. Zero means as close as possible.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 */
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
780 Charbpos
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
781 vmotion_pixels (Lisp_Object window, Charbpos start, int pixels, int how,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 int *motion)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784 struct window *w;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
785 Charbpos eobuf, bobuf;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 int defheight;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 int needed;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 int line, next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 int remain, abspix, dirn;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 int elt, nelt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 line_start_cache_dynarr *cache;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 int previous = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 int lines;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796 if (NILP (window))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 window = Fselected_window (Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 CHECK_LIVE_WINDOW (window);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 w = XWINDOW (window);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 eobuf = BUF_ZV (XBUFFER (w->buffer));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803 bobuf = BUF_BEGV (XBUFFER (w->buffer));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804
5047
07dcc7000bbf put width before height consistently, fix a real bug found in the process
Ben Wing <ben@xemacs.org>
parents: 4998
diff changeset
805 default_face_width_and_height (window, NULL, &defheight);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 /* guess num lines needed in line start cache + a few extra */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 abspix = abs (pixels);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 needed = (abspix + defheight-1)/defheight + 3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 dirn = (pixels >= 0) ? 1 : -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 elt = point_in_line_start_cache (w, start, needed);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816 assert (elt >= 0); /* in the cache */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 cache = w->line_start_cache;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 nelt = Dynarr_length (cache);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821 *motion = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823 if (pixels == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824 /* No vertical motion requested so we just return the position
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825 of the beginning of the current display line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826 return Dynarr_atp (cache, elt)->start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828 if ((dirn < 0 && elt == 0 &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 Dynarr_atp (cache, elt)->start <= bobuf) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 (dirn > 0 && elt == nelt-1 &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 Dynarr_atp (cache, elt)->end >= eobuf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832 return Dynarr_atp (cache, elt)->start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834 remain = abspix;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 for (i = elt; (dirn > 0) ? (i < nelt) : (i > 0); i += dirn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837 /* cache line we're considering moving over */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 int ii = (dirn > 0) ? i : i-1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 if (remain < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 return Dynarr_atp (cache, i)->start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 line = Dynarr_atp (cache, ii)->height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 next = remain - line;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 /* is stopping condition satisfied? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 if ((how > 0 && remain <= 0) || /* at least */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 (how < 0 && next < 0) || /* at most */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 (how == 0 && remain <= abs (next))) /* closest */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 return Dynarr_atp (cache, i)->start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 /* moving down and nowhere left to go? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 if (dirn > 0 && Dynarr_atp (cache, ii)->end >= eobuf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 return Dynarr_atp (cache, ii)->start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856 /* take the step */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 remain = next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858 *motion += dirn * line;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 /* moving up and nowhere left to go? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 if (dirn < 0 && Dynarr_atp (cache, ii)->start <= bobuf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 return Dynarr_atp (cache, ii)->start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 /* get here => need more cache lines. try again. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 assert (abs (*motion) > previous); /* progress? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867 previous = abs (*motion);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869 lines = (pixels < 0) ? elt : (nelt - elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 needed += (remain*lines + abspix-1)/abspix + 3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 867
diff changeset
873 RETURN_NOT_REACHED(0); /* shut up compiler */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 DEFUN ("vertical-motion-pixels", Fvertical_motion_pixels, 1, 3, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877 Move to start of frame line PIXELS vertical pixels down.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878 If PIXELS is negative, this is moving up.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 The actual vertical motion in pixels is returned.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 Optional second argument is WINDOW to move in,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 the default is the selected window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 Optional third argument HOW specifies when to stop. A value
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 less than zero indicates that the motion should be no more
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 than PIXELS. A value greater than zero indicates that the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 motion should be at least PIXELS. Any other value indicates
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 that the motion should be as close as possible to PIXELS.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 (pixels, window, how))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
892 Charbpos charbpos;
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
893 Charbpos orig;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 int selected;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 int motion;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896 int howto;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897 struct window *w;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 if (NILP (window))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 window = Fselected_window (Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902 CHECK_LIVE_WINDOW (window);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 CHECK_INT (pixels);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 selected = (EQ (window, Fselected_window (Qnil)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 w = XWINDOW (window);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 orig = selected ? BUF_PT (XBUFFER (w->buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910 : marker_position (w->pointm[CURRENT_DISP]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912 howto = INTP (how) ? XINT (how) : 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
914 charbpos = vmotion_pixels (window, orig, XINT (pixels), howto, &motion);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 if (selected)
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
917 BUF_SET_PT (XBUFFER (w->buffer), charbpos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 set_marker_restricted (w->pointm[CURRENT_DISP],
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
920 make_int(charbpos),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 w->buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923 return make_int (motion);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928 syms_of_indent (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 DEFSUBR (Fcurrent_indentation);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931 DEFSUBR (Findent_to);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 DEFSUBR (Fcurrent_column);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933 DEFSUBR (Fmove_to_column);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 #if 0 /* #### */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 DEFSUBR (Fcompute_motion);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 DEFSUBR (Fvertical_motion);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938 DEFSUBR (Fvertical_motion_pixels);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942 vars_of_indent (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 DEFVAR_BOOL ("indent-tabs-mode", &indent_tabs_mode /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945 *Indentation can insert tabs if this is non-nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946 Setting this variable automatically makes it local to the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 indent_tabs_mode = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949 }