annotate src/indent.c @ 5518:3cc7470ea71c

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