annotate src/indent.c @ 5066:545ec923b4eb

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