annotate src/indent.c @ 33009:e7cb49941cb1

(frame-notice-user-settings): Don't apply default-frame-alist and initial-frame-alist to MS-DOS frames. Call tty-handle-reverse-video, frame-set-background-mode, and face-set-after-frame-default for non-MS-DOS frames.
author Eli Zaretskii <eliz@gnu.org>
date Sat, 28 Oct 2000 17:18:21 +0000
parents 43566b0aec59
children 69c9cd380fd2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1 /* Indentation functions.
20706
d43ba5d91281 Update copyright year.
Richard M. Stallman <rms@gnu.org>
parents: 20694
diff changeset
2 Copyright (C) 1985,86,87,88,93,94,95,98 Free Software Foundation, Inc.
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4 This file is part of GNU Emacs.
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
12244
ac7375e60931 Update GPL to version 2.
Karl Heuer <kwzh@gnu.org>
parents: 12090
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 any later version.
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 GNU General Public License for more details.
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 14078
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 14078
diff changeset
19 Boston, MA 02111-1307, USA. */
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21
4696
1fc792473491 Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents: 4385
diff changeset
22 #include <config.h>
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 #include "lisp.h"
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 #include "buffer.h"
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
25 #include "charset.h"
20256
f75208097eb5 (position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents: 19938
diff changeset
26 #include "category.h"
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 #include "indent.h"
31102
6a0caa788013 Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents: 29405
diff changeset
28 #include "keyboard.h"
764
bb24f1180bb6 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 617
diff changeset
29 #include "frame.h"
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 #include "window.h"
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 #include "termchar.h"
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 #include "termopts.h"
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 #include "disptab.h"
4385
edffa4f0c5d9 (compute_motion): Compute correctly for invisible text.
Richard M. Stallman <rms@gnu.org>
parents: 2961
diff changeset
34 #include "intervals.h"
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
35 #include "region-cache.h"
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 /* Indentation can insert tabs if this is non-zero;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 otherwise always uses spaces */
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39 int indent_tabs_mode;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 #define min(a, b) ((a) < (b) ? (a) : (b))
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 #define max(a, b) ((a) > (b) ? (a) : (b))
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44 #define CR 015
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46 /* These three values memoize the current column to avoid recalculation */
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 /* Some things in set last_known_column_point to -1
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 to mark the memoized value as invalid */
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 /* Last value returned by current_column */
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 int last_known_column;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 /* Value of point when current_column was called */
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 int last_known_column_point;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 /* Value of MODIFF when current_column was called */
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 int last_known_column_modified;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55
15494
a544bb3eea53 (current_column_1): Add declaration.
Richard M. Stallman <rms@gnu.org>
parents: 15493
diff changeset
56 static int current_column_1 ();
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
57 static int position_indentation ();
15494
a544bb3eea53 (current_column_1): Add declaration.
Richard M. Stallman <rms@gnu.org>
parents: 15493
diff changeset
58
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
59 /* Cache of beginning of line found by the last call of
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
60 current_column. */
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
61 int current_column_bol_cache;
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
62
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 /* Get the display table to use for the current buffer. */
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64
13185
5b1671bd3cc1 (buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents: 13124
diff changeset
65 struct Lisp_Char_Table *
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 buffer_display_table ()
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 {
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68 Lisp_Object thisbuf;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 thisbuf = current_buffer->display_table;
13185
5b1671bd3cc1 (buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents: 13124
diff changeset
71 if (DISP_TABLE_P (thisbuf))
5b1671bd3cc1 (buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents: 13124
diff changeset
72 return XCHAR_TABLE (thisbuf);
5b1671bd3cc1 (buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents: 13124
diff changeset
73 if (DISP_TABLE_P (Vstandard_display_table))
5b1671bd3cc1 (buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents: 13124
diff changeset
74 return XCHAR_TABLE (Vstandard_display_table);
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 return 0;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 }
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
78 /* Width run cache considerations. */
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
79
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
80 /* Return the width of character C under display table DP. */
11037
802a774b44b7 (compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents: 10964
diff changeset
81
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
82 static int
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
83 character_width (c, dp)
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
84 int c;
13185
5b1671bd3cc1 (buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents: 13124
diff changeset
85 struct Lisp_Char_Table *dp;
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
86 {
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
87 Lisp_Object elt;
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
88
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
89 /* These width computations were determined by examining the cases
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
90 in display_text_line. */
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
91
11037
802a774b44b7 (compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents: 10964
diff changeset
92 /* Everything can be handled by the display table, if it's
802a774b44b7 (compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents: 10964
diff changeset
93 present and the element is right. */
802a774b44b7 (compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents: 10964
diff changeset
94 if (dp && (elt = DISP_CHAR_VECTOR (dp, c), VECTORP (elt)))
802a774b44b7 (compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents: 10964
diff changeset
95 return XVECTOR (elt)->size;
802a774b44b7 (compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents: 10964
diff changeset
96
802a774b44b7 (compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents: 10964
diff changeset
97 /* Some characters are special. */
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
98 if (c == '\n' || c == '\t' || c == '\015')
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
99 return 0;
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
100
11037
802a774b44b7 (compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents: 10964
diff changeset
101 /* Printing characters have width 1. */
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
102 else if (c >= 040 && c < 0177)
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
103 return 1;
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
104
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
105 /* Everybody else (control characters, metacharacters) has other
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
106 widths. We could return their actual widths here, but they
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
107 depend on things like ctl_arrow and crud like that, and they're
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
108 not very common at all. So we'll just claim we don't know their
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
109 widths. */
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
110 else
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
111 return 0;
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
112 }
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
113
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
114 /* Return true iff the display table DISPTAB specifies the same widths
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
115 for characters as WIDTHTAB. We use this to decide when to
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
116 invalidate the buffer's width_run_cache. */
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
117 int
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
118 disptab_matches_widthtab (disptab, widthtab)
13185
5b1671bd3cc1 (buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents: 13124
diff changeset
119 struct Lisp_Char_Table *disptab;
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
120 struct Lisp_Vector *widthtab;
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
121 {
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
122 int i;
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
123
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
124 if (widthtab->size != 256)
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
125 abort ();
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
126
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
127 for (i = 0; i < 256; i++)
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
128 if (character_width (i, disptab)
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
129 != XFASTINT (widthtab->contents[i]))
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
130 return 0;
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
131
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
132 return 1;
10538
48c620ae0853 (compute_motion): Don't get hung in selective-display loop.
Karl Heuer <kwzh@gnu.org>
parents: 10011
diff changeset
133 }
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
134
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
135 /* Recompute BUF's width table, using the display table DISPTAB. */
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
136 void
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
137 recompute_width_table (buf, disptab)
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
138 struct buffer *buf;
13185
5b1671bd3cc1 (buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents: 13124
diff changeset
139 struct Lisp_Char_Table *disptab;
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
140 {
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
141 int i;
10011
f4f2563057b8 (recompute_width_table): Do the right thing if no previous table existed.
Karl Heuer <kwzh@gnu.org>
parents: 9407
diff changeset
142 struct Lisp_Vector *widthtab;
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
143
10011
f4f2563057b8 (recompute_width_table): Do the right thing if no previous table existed.
Karl Heuer <kwzh@gnu.org>
parents: 9407
diff changeset
144 if (!VECTORP (buf->width_table))
f4f2563057b8 (recompute_width_table): Do the right thing if no previous table existed.
Karl Heuer <kwzh@gnu.org>
parents: 9407
diff changeset
145 buf->width_table = Fmake_vector (make_number (256), make_number (0));
f4f2563057b8 (recompute_width_table): Do the right thing if no previous table existed.
Karl Heuer <kwzh@gnu.org>
parents: 9407
diff changeset
146 widthtab = XVECTOR (buf->width_table);
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
147 if (widthtab->size != 256)
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
148 abort ();
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
149
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
150 for (i = 0; i < 256; i++)
10011
f4f2563057b8 (recompute_width_table): Do the right thing if no previous table existed.
Karl Heuer <kwzh@gnu.org>
parents: 9407
diff changeset
151 XSETFASTINT (widthtab->contents[i], character_width (i, disptab));
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
152 }
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
153
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
154 /* Allocate or free the width run cache, as requested by the current
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
155 state of current_buffer's cache_long_line_scans variable. */
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
156 static void
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
157 width_run_cache_on_off ()
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
158 {
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
159 if (NILP (current_buffer->cache_long_line_scans)
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
160 /* And, for the moment, this feature doesn't work on multibyte
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
161 characters. */
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
162 || !NILP (current_buffer->enable_multibyte_characters))
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
163 {
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
164 /* It should be off. */
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
165 if (current_buffer->width_run_cache)
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
166 {
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
167 free_region_cache (current_buffer->width_run_cache);
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
168 current_buffer->width_run_cache = 0;
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
169 current_buffer->width_table = Qnil;
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
170 }
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
171 }
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
172 else
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
173 {
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
174 /* It should be on. */
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
175 if (current_buffer->width_run_cache == 0)
10538
48c620ae0853 (compute_motion): Don't get hung in selective-display loop.
Karl Heuer <kwzh@gnu.org>
parents: 10011
diff changeset
176 {
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
177 current_buffer->width_run_cache = new_region_cache ();
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
178 recompute_width_table (current_buffer, buffer_display_table ());
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
179 }
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
180 }
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
181 }
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
182
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
183
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
184 /* Skip some invisible characters starting from POS.
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
185 This includes characters invisible because of text properties
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
186 and characters invisible because of overlays.
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
187
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
188 If position POS is followed by invisible characters,
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
189 skip some of them and return the position after them.
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
190 Otherwise return POS itself.
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
191
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
192 Set *NEXT_BOUNDARY_P to the next position at which
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
193 it will be necessary to call this function again.
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
194
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
195 Don't scan past TO, and don't set *NEXT_BOUNDARY_P
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
196 to a value greater than TO.
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
197
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
198 If WINDOW is non-nil, and this buffer is displayed in WINDOW,
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
199 take account of overlays that apply only in WINDOW.
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
200
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
201 We don't necessarily skip all the invisible characters after POS
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
202 because that could take a long time. We skip a reasonable number
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
203 which can be skipped quickly. If there might be more invisible
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
204 characters immediately following, then *NEXT_BOUNDARY_P
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
205 will equal the return value. */
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
206
25028
ab513f624bc6 (Fvertical_motion): Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 24828
diff changeset
207 int
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
208 skip_invisible (pos, next_boundary_p, to, window)
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
209 int pos;
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
210 int *next_boundary_p;
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
211 int to;
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
212 Lisp_Object window;
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
213 {
18613
614b916ff5bf Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents: 18109
diff changeset
214 Lisp_Object prop, position, overlay_limit, proplimit;
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
215 Lisp_Object buffer;
18613
614b916ff5bf Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents: 18109
diff changeset
216 int end;
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
217
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
218 XSETFASTINT (position, pos);
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
219 XSETBUFFER (buffer, current_buffer);
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
220
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
221 /* Give faster response for overlay lookup near POS. */
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
222 recenter_overlay_lists (current_buffer, pos);
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
223
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
224 /* We must not advance farther than the next overlay change.
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
225 The overlay change might change the invisible property;
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
226 or there might be overlay strings to be displayed there. */
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
227 overlay_limit = Fnext_overlay_change (position);
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
228 /* As for text properties, this gives a lower bound
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
229 for where the invisible text property could change. */
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
230 proplimit = Fnext_property_change (position, buffer, Qt);
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
231 if (XFASTINT (overlay_limit) < XFASTINT (proplimit))
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
232 proplimit = overlay_limit;
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
233 /* PROPLIMIT is now a lower bound for the next change
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
234 in invisible status. If that is plenty far away,
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
235 use that lower bound. */
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
236 if (XFASTINT (proplimit) > pos + 100 || XFASTINT (proplimit) >= to)
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
237 *next_boundary_p = XFASTINT (proplimit);
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
238 /* Otherwise, scan for the next `invisible' property change. */
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
239 else
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
240 {
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
241 /* Don't scan terribly far. */
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
242 XSETFASTINT (proplimit, min (pos + 100, to));
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
243 /* No matter what. don't go past next overlay change. */
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
244 if (XFASTINT (overlay_limit) < XFASTINT (proplimit))
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
245 proplimit = overlay_limit;
18613
614b916ff5bf Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents: 18109
diff changeset
246 end = XFASTINT (Fnext_single_property_change (position, Qinvisible,
614b916ff5bf Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents: 18109
diff changeset
247 buffer, proplimit));
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
248 #if 0
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
249 /* Don't put the boundary in the middle of multibyte form if
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
250 there is no actual property change. */
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
251 if (end == pos + 100
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
252 && !NILP (current_buffer->enable_multibyte_characters)
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
253 && end < ZV)
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
254 while (pos < end && !CHAR_HEAD_P (POS_ADDR (end)))
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
255 end--;
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
256 #endif
18613
614b916ff5bf Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents: 18109
diff changeset
257 *next_boundary_p = end;
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
258 }
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
259 /* if the `invisible' property is set, we can skip to
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
260 the next property change */
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
261 if (!NILP (window) && EQ (XWINDOW (window)->buffer, buffer))
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
262 prop = Fget_char_property (position, Qinvisible, window);
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
263 else
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
264 prop = Fget_char_property (position, Qinvisible, buffer);
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
265 if (TEXT_PROP_MEANS_INVISIBLE (prop))
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
266 return *next_boundary_p;
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
267 return pos;
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
268 }
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
269
26859
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
270 /* If a composition starts at POS/POS_BYTE and it doesn't stride over
29405
b32f6068a250 Fix nested comment.
Dave Love <fx@gnu.org>
parents: 28933
diff changeset
271 POINT, set *LEN / *LEN_BYTE to the character and byte lengths, *WIDTH
26859
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
272 to the width, and return 1. Otherwise, return 0. */
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
273
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
274 static int
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
275 check_composition (pos, pos_byte, point, len, len_byte, width)
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
276 int pos, pos_byte, point;
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
277 int *len, *len_byte, *width;
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
278 {
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
279 Lisp_Object prop;
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
280 int start, end;
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
281 int id;
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
282
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
283 if (! find_composition (pos, -1, &start, &end, &prop, Qnil)
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
284 || pos != start || point < end)
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
285 return 0;
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
286 if ((id = get_composition_id (pos, pos_byte, end - pos, prop, Qnil)) < 0)
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
287 return 0;
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
288
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
289 *len = COMPOSITION_LENGTH (prop);
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
290 *len_byte = CHAR_TO_BYTE (end) - pos_byte;
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
291 *width = composition_table[id]->width;
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
292 return 1;
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
293 }
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
294
20938
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
295 /* Set variables WIDTH and BYTES for a multibyte sequence starting at P.
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
296
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
297 DP is a display table or NULL.
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
298
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
299 This macro is used in current_column_1, Fmove_to_column, and
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
300 compute_motion. */
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
301
26859
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
302 #define MULTIBYTE_BYTES_WIDTH(p, dp) \
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
303 do { \
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
304 int c; \
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
305 \
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
306 wide_column = 0; \
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
307 c = STRING_CHAR_AND_LENGTH (p, MAX_MULTIBYTE_LENGTH, bytes); \
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
308 if (BYTES_BY_CHAR_HEAD (*p) != bytes) \
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
309 width = bytes * 4; \
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
310 else \
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
311 { \
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
312 if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, c))) \
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
313 width = XVECTOR (DISP_CHAR_VECTOR (dp, c))->size; \
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
314 else \
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
315 width = WIDTH_BY_CHAR_HEAD (*p); \
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
316 if (width > 1) \
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
317 wide_column = width; \
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
318 } \
20938
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
319 } while (0)
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
320
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
321 DEFUN ("current-column", Fcurrent_column, Scurrent_column, 0, 0, 0,
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
322 "Return the horizontal position of point. Beginning of line is column 0.\n\
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
323 This is calculated by adding together the widths of all the displayed\n\
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
324 representations of the character between the start of the previous line\n\
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
325 and point. (eg control characters will have a width of 2 or 4, tabs\n\
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
326 will have a variable width)\n\
764
bb24f1180bb6 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 617
diff changeset
327 Ignores finite width of frame, which means that this function may return\n\
bb24f1180bb6 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 617
diff changeset
328 values greater than (frame-width).\n\
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329 Whether the line is visible (if `selective-display' is t) has no effect;\n\
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 however, ^M is treated as end of line when `selective-display' is t.")
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331 ()
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332 {
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
333 Lisp_Object temp;
9310
1dfd9def3467 (Fcurrent_column, Findent_to, Fcurrent_indentation, Fmove_to_column,
Karl Heuer <kwzh@gnu.org>
parents: 9269
diff changeset
334 XSETFASTINT (temp, current_column ());
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335 return temp;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336 }
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
337
327
554b1810e969 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 165
diff changeset
338 /* Cancel any recorded value of the horizontal position. */
554b1810e969 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 165
diff changeset
339
20371
976eed15d6b5 (invalidate_current_column): Declare it as void.
Kenichi Handa <handa@m17n.org>
parents: 20256
diff changeset
340 void
327
554b1810e969 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 165
diff changeset
341 invalidate_current_column ()
554b1810e969 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 165
diff changeset
342 {
554b1810e969 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 165
diff changeset
343 last_known_column_point = 0;
554b1810e969 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 165
diff changeset
344 }
554b1810e969 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 165
diff changeset
345
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
346 int
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
347 current_column ()
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348 {
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
349 register int col;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
350 register unsigned char *ptr, *stop;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
351 register int tab_seen;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
352 int post_tab;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353 register int c;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
354 register int tab_width = XINT (current_buffer->tab_width);
488
4fddd0f0fc33 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 327
diff changeset
355 int ctl_arrow = !NILP (current_buffer->ctl_arrow);
13185
5b1671bd3cc1 (buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents: 13124
diff changeset
356 register struct Lisp_Char_Table *dp = buffer_display_table ();
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
357 int stopchar;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
358
16039
855c8d8ba0f0 Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents: 15659
diff changeset
359 if (PT == last_known_column_point
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
360 && MODIFF == last_known_column_modified)
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
361 return last_known_column;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
362
20694
83a65a1efdaa (current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents: 20571
diff changeset
363 /* If the buffer has overlays, text properties,
83a65a1efdaa (current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents: 20571
diff changeset
364 or multibyte characters, use a more general algorithm. */
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
365 if (BUF_INTERVALS (current_buffer)
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
366 || !NILP (current_buffer->overlays_before)
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
367 || !NILP (current_buffer->overlays_after)
20694
83a65a1efdaa (current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents: 20571
diff changeset
368 || Z != Z_BYTE)
83a65a1efdaa (current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents: 20571
diff changeset
369 return current_column_1 ();
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
370
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
371 /* Scan backwards from point to the previous newline,
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
372 counting width. Tab characters are the only complicated case. */
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
373
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374 /* Make a pointer for decrementing through the chars before point. */
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
375 ptr = BYTE_POS_ADDR (PT_BYTE - 1) + 1;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
376 /* Make a pointer to where consecutive chars leave off,
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
377 going backwards from point. */
16039
855c8d8ba0f0 Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents: 15659
diff changeset
378 if (PT == BEGV)
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
379 stop = ptr;
16039
855c8d8ba0f0 Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents: 15659
diff changeset
380 else if (PT <= GPT || BEGV > GPT)
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
381 stop = BEGV_ADDR;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
382 else
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
383 stop = GAP_END_ADDR;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
384
2325
7b5299f3a8fc (current_column, Findent_to, position_indentation):
Richard M. Stallman <rms@gnu.org>
parents: 2017
diff changeset
385 if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
386
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
387 col = 0, tab_seen = 0, post_tab = 0;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
388
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
389 while (1)
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
390 {
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
391 if (ptr == stop)
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
392 {
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
393 /* We stopped either for the beginning of the buffer
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
394 or for the gap. */
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
395 if (ptr == BEGV_ADDR)
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
396 break;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
397 /* It was the gap. Jump back over it. */
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
398 stop = BEGV_ADDR;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
399 ptr = GPT_ADDR;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
400 /* Check whether that brings us to beginning of buffer. */
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
401 if (BEGV >= GPT) break;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
402 }
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
403
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
404 c = *--ptr;
11037
802a774b44b7 (compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents: 10964
diff changeset
405 if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, c)))
802a774b44b7 (compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents: 10964
diff changeset
406 col += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size;
802a774b44b7 (compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents: 10964
diff changeset
407 else if (c >= 040 && c < 0177)
802a774b44b7 (compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents: 10964
diff changeset
408 col++;
19208
1d24f0a03f75 (current_column): Update ptr differently at newline
Richard M. Stallman <rms@gnu.org>
parents: 19080
diff changeset
409 else if (c == '\n'
1d24f0a03f75 (current_column): Update ptr differently at newline
Richard M. Stallman <rms@gnu.org>
parents: 19080
diff changeset
410 || (c == '\r' && EQ (current_buffer->selective_display, Qt)))
1d24f0a03f75 (current_column): Update ptr differently at newline
Richard M. Stallman <rms@gnu.org>
parents: 19080
diff changeset
411 {
1d24f0a03f75 (current_column): Update ptr differently at newline
Richard M. Stallman <rms@gnu.org>
parents: 19080
diff changeset
412 ptr++;
1d24f0a03f75 (current_column): Update ptr differently at newline
Richard M. Stallman <rms@gnu.org>
parents: 19080
diff changeset
413 break;
1d24f0a03f75 (current_column): Update ptr differently at newline
Richard M. Stallman <rms@gnu.org>
parents: 19080
diff changeset
414 }
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
415 else if (c == '\t')
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
416 {
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
417 if (tab_seen)
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
418 col = ((col + tab_width) / tab_width) * tab_width;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
419
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
420 post_tab += col;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
421 col = 0;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
422 tab_seen = 1;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
423 }
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
424 else
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
425 col += (ctl_arrow && c < 0200) ? 2 : 4;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
426 }
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
427
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
428 if (tab_seen)
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
429 {
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
430 col = ((col + tab_width) / tab_width) * tab_width;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
431 col += post_tab;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
432 }
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
433
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
434 if (ptr == BEGV_ADDR)
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
435 current_column_bol_cache = BEGV;
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
436 else
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
437 current_column_bol_cache = BYTE_TO_CHAR (PTR_BYTE_POS (ptr));
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
438
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
439 last_known_column = col;
16039
855c8d8ba0f0 Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents: 15659
diff changeset
440 last_known_column_point = PT;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
441 last_known_column_modified = MODIFF;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
442
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
443 return col;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
444 }
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
445
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
446 /* Return the column number of position POS
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
447 by scanning forward from the beginning of the line.
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
448 This function handles characters that are invisible
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
449 due to text properties or overlays. */
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
450
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
451 static int
20694
83a65a1efdaa (current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents: 20571
diff changeset
452 current_column_1 ()
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
453 {
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
454 register int tab_width = XINT (current_buffer->tab_width);
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
455 register int ctl_arrow = !NILP (current_buffer->ctl_arrow);
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
456 register struct Lisp_Char_Table *dp = buffer_display_table ();
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
457 int multibyte = !NILP (current_buffer->enable_multibyte_characters);
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
458
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
459 /* Start the scan at the beginning of this line with column number 0. */
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
460 register int col = 0;
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
461 int scan, scan_byte;
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
462 int next_boundary, next_boundary_byte;
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
463 int opoint = PT, opoint_byte = PT_BYTE;
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
464
20694
83a65a1efdaa (current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents: 20571
diff changeset
465 scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -1, 1);
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
466 current_column_bol_cache = PT;
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
467 scan = PT, scan_byte = PT_BYTE;
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
468 SET_PT_BOTH (opoint, opoint_byte);
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
469 next_boundary = scan;
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
470 next_boundary_byte = scan_byte;
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
471
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
472 if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
473
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
474 /* Scan forward to the target position. */
20694
83a65a1efdaa (current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents: 20571
diff changeset
475 while (scan < opoint)
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
476 {
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
477 int c;
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
478
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
479 /* Occasionally we may need to skip invisible text. */
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
480 while (scan == next_boundary)
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
481 {
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
482 int old_scan = scan;
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
483 /* This updates NEXT_BOUNDARY to the next place
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
484 where we might need to skip more invisible text. */
20694
83a65a1efdaa (current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents: 20571
diff changeset
485 scan = skip_invisible (scan, &next_boundary, opoint, Qnil);
83a65a1efdaa (current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents: 20571
diff changeset
486 if (scan >= opoint)
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
487 goto endloop;
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
488 if (scan != old_scan)
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
489 scan_byte = CHAR_TO_BYTE (scan);
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
490 next_boundary_byte = CHAR_TO_BYTE (next_boundary);
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
491 }
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
492
26859
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
493 /* Check composition sequence. */
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
494 {
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
495 int len, len_byte, width;
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
496
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
497 if (check_composition (scan, scan_byte, opoint,
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
498 &len, &len_byte, &width))
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
499 {
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
500 scan += len;
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
501 scan_byte += len_byte;
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
502 if (scan <= opoint)
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
503 col += width;
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
504 continue;
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
505 }
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
506 }
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
507
20694
83a65a1efdaa (current_column_1): Eliminate argument POS; use PT and PT_BYTE.
Richard M. Stallman <rms@gnu.org>
parents: 20571
diff changeset
508 c = FETCH_BYTE (scan_byte);
20938
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
509 if (dp != 0
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
510 && ! (multibyte && BASE_LEADING_CODE_P (c))
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
511 && VECTORP (DISP_CHAR_VECTOR (dp, c)))
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
512 {
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
513 col += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size;
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
514 scan++;
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
515 scan_byte++;
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
516 continue;
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
517 }
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
518 if (c == '\n')
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
519 break;
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
520 if (c == '\r' && EQ (current_buffer->selective_display, Qt))
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
521 break;
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
522 scan++;
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
523 scan_byte++;
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
524 if (c == '\t')
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
525 {
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
526 int prev_col = col;
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
527 col += tab_width;
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
528 col = col / tab_width * tab_width;
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
529 }
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
530 else if (multibyte && BASE_LEADING_CODE_P (c))
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
531 {
20938
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
532 unsigned char *ptr;
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
533 int bytes, width, wide_column;
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
534
20938
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
535 scan_byte--;
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
536 ptr = BYTE_POS_ADDR (scan_byte);
25510
d584d75fc3a7 (MULTIBYTE_BYTES_WIDTH): Delete the 2nd arg C. Use the
Kenichi Handa <handa@m17n.org>
parents: 25351
diff changeset
537 MULTIBYTE_BYTES_WIDTH (ptr, dp);
20938
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
538 scan_byte += bytes;
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
539 col += width;
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
540 }
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
541 else if (ctl_arrow && (c < 040 || c == 0177))
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
542 col += 2;
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
543 else if (c < 040 || c >= 0177)
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
544 col += 4;
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
545 else
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
546 col++;
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
547 }
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
548 endloop:
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
549
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
550 last_known_column = col;
16039
855c8d8ba0f0 Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents: 15659
diff changeset
551 last_known_column_point = PT;
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
552 last_known_column_modified = MODIFF;
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
553
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
554 return col;
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
555 }
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
556
11300
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
557 /* Return the width in columns of the part of STRING from BEG to END.
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
558 If BEG is nil, that stands for the beginning of STRING.
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
559 If END is nil, that stands for the end of STRING. */
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
560
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
561 static int
11704
6c9716b7a23d (string_display_width): Renamed from string_width.
Richard M. Stallman <rms@gnu.org>
parents: 11312
diff changeset
562 string_display_width (string, beg, end)
11300
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
563 Lisp_Object string, beg, end;
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
564 {
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
565 register int col;
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
566 register unsigned char *ptr, *stop;
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
567 register int tab_seen;
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
568 int post_tab;
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
569 register int c;
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
570 register int tab_width = XINT (current_buffer->tab_width);
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
571 int ctl_arrow = !NILP (current_buffer->ctl_arrow);
13185
5b1671bd3cc1 (buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents: 13124
diff changeset
572 register struct Lisp_Char_Table *dp = buffer_display_table ();
11300
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
573 int b, e;
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
574
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
575 if (NILP (end))
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
576 e = XSTRING (string)->size;
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
577 else
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
578 {
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
579 CHECK_NUMBER (end, 0);
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
580 e = XINT (end);
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
581 }
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
582
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
583 if (NILP (beg))
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
584 b = 0;
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
585 else
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
586 {
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
587 CHECK_NUMBER (beg, 0);
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
588 b = XINT (beg);
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
589 }
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
590
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
591 /* Make a pointer for decrementing through the chars before point. */
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
592 ptr = XSTRING (string)->data + e;
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
593 /* Make a pointer to where consecutive chars leave off,
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
594 going backwards from point. */
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
595 stop = XSTRING (string)->data + b;
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
596
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
597 if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
598
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
599 col = 0, tab_seen = 0, post_tab = 0;
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
600
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
601 while (1)
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
602 {
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
603 if (ptr == stop)
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
604 break;
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
605
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
606 c = *--ptr;
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
607 if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, c)))
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
608 col += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size;
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
609 else if (c >= 040 && c < 0177)
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
610 col++;
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
611 else if (c == '\n')
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
612 break;
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
613 else if (c == '\t')
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
614 {
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
615 if (tab_seen)
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
616 col = ((col + tab_width) / tab_width) * tab_width;
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
617
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
618 post_tab += col;
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
619 col = 0;
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
620 tab_seen = 1;
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
621 }
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
622 else
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
623 col += (ctl_arrow && c < 0200) ? 2 : 4;
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
624 }
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
625
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
626 if (tab_seen)
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
627 {
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
628 col = ((col + tab_width) / tab_width) * tab_width;
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
629 col += post_tab;
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
630 }
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
631
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
632 return col;
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
633 }
474b17d364db (string_width): New function.
Richard M. Stallman <rms@gnu.org>
parents: 11037
diff changeset
634
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
635 DEFUN ("indent-to", Findent_to, Sindent_to, 1, 2, "NIndent to column: ",
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
636 "Indent from point with tabs and spaces until COLUMN is reached.\n\
14078
a46002ac278b (Findent_to): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents: 13453
diff changeset
637 Optional second argument MININUM says always do at least MININUM spaces\n\
a46002ac278b (Findent_to): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents: 13453
diff changeset
638 even if that goes past COLUMN; by default, MININUM is zero.")
a46002ac278b (Findent_to): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents: 13453
diff changeset
639 (column, minimum)
a46002ac278b (Findent_to): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents: 13453
diff changeset
640 Lisp_Object column, minimum;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
641 {
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
642 int mincol;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
643 register int fromcol;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
644 register int tab_width = XINT (current_buffer->tab_width);
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
645
14078
a46002ac278b (Findent_to): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents: 13453
diff changeset
646 CHECK_NUMBER (column, 0);
488
4fddd0f0fc33 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 327
diff changeset
647 if (NILP (minimum))
9310
1dfd9def3467 (Fcurrent_column, Findent_to, Fcurrent_indentation, Fmove_to_column,
Karl Heuer <kwzh@gnu.org>
parents: 9269
diff changeset
648 XSETFASTINT (minimum, 0);
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
649 CHECK_NUMBER (minimum, 1);
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
650
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
651 fromcol = current_column ();
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
652 mincol = fromcol + XINT (minimum);
14078
a46002ac278b (Findent_to): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents: 13453
diff changeset
653 if (mincol < XINT (column)) mincol = XINT (column);
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
654
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
655 if (fromcol == mincol)
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
656 return make_number (mincol);
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
657
2325
7b5299f3a8fc (current_column, Findent_to, position_indentation):
Richard M. Stallman <rms@gnu.org>
parents: 2017
diff changeset
658 if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
659
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
660 if (indent_tabs_mode)
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
661 {
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
662 Lisp_Object n;
9310
1dfd9def3467 (Fcurrent_column, Findent_to, Fcurrent_indentation, Fmove_to_column,
Karl Heuer <kwzh@gnu.org>
parents: 9269
diff changeset
663 XSETFASTINT (n, mincol / tab_width - fromcol / tab_width);
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
664 if (XFASTINT (n) != 0)
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
665 {
8648
f047d8c6db79 (Findent_to): Pass new arg to Finsert_char.
Richard M. Stallman <rms@gnu.org>
parents: 8601
diff changeset
666 Finsert_char (make_number ('\t'), n, Qt);
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
667
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
668 fromcol = (mincol / tab_width) * tab_width;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
669 }
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
670 }
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
671
14078
a46002ac278b (Findent_to): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents: 13453
diff changeset
672 XSETFASTINT (column, mincol - fromcol);
a46002ac278b (Findent_to): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents: 13453
diff changeset
673 Finsert_char (make_number (' '), column, Qt);
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
674
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
675 last_known_column = mincol;
16039
855c8d8ba0f0 Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents: 15659
diff changeset
676 last_known_column_point = PT;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
677 last_known_column_modified = MODIFF;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
678
14078
a46002ac278b (Findent_to): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents: 13453
diff changeset
679 XSETINT (column, mincol);
a46002ac278b (Findent_to): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents: 13453
diff changeset
680 return column;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
681 }
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
682
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
683
21514
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21496
diff changeset
684 static int position_indentation P_ ((int));
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21496
diff changeset
685
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
686 DEFUN ("current-indentation", Fcurrent_indentation, Scurrent_indentation,
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
687 0, 0, 0,
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
688 "Return the indentation of the current line.\n\
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
689 This is the horizontal position of the character\n\
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
690 following any initial whitespace.")
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
691 ()
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
692 {
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
693 Lisp_Object val;
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
694 int opoint = PT, opoint_byte = PT_BYTE;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
695
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
696 scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -1, 1);
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
697
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
698 XSETFASTINT (val, position_indentation (PT_BYTE));
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
699 SET_PT_BOTH (opoint, opoint_byte);
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
700 return val;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
701 }
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
702
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
703 static int
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
704 position_indentation (pos_byte)
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
705 register int pos_byte;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
706 {
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
707 register int column = 0;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
708 register int tab_width = XINT (current_buffer->tab_width);
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
709 register unsigned char *p;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
710 register unsigned char *stop;
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
711 unsigned char *start;
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
712 int next_boundary_byte = pos_byte;
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
713 int ceiling = next_boundary_byte;
10538
48c620ae0853 (compute_motion): Don't get hung in selective-display loop.
Karl Heuer <kwzh@gnu.org>
parents: 10011
diff changeset
714
2325
7b5299f3a8fc (current_column, Findent_to, position_indentation):
Richard M. Stallman <rms@gnu.org>
parents: 2017
diff changeset
715 if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
10538
48c620ae0853 (compute_motion): Don't get hung in selective-display loop.
Karl Heuer <kwzh@gnu.org>
parents: 10011
diff changeset
716
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
717 p = BYTE_POS_ADDR (pos_byte);
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
718 /* STOP records the value of P at which we will need
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
719 to think about the gap, or about invisible text,
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
720 or about the end of the buffer. */
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
721 stop = p;
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
722 /* START records the starting value of P. */
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
723 start = p;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
724 while (1)
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
725 {
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
726 while (p == stop)
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
727 {
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
728 int stop_pos_byte;
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
729
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
730 /* If we have updated P, set POS_BYTE to match.
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
731 The first time we enter the loop, POS_BYTE is already right. */
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
732 if (p != start)
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
733 pos_byte = PTR_BYTE_POS (p);
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
734 /* Consider the various reasons STOP might have been set here. */
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
735 if (pos_byte == ZV_BYTE)
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
736 return column;
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
737 if (pos_byte == next_boundary_byte)
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
738 {
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
739 int next_boundary;
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
740 int pos = BYTE_TO_CHAR (pos_byte);
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
741 pos = skip_invisible (pos, &next_boundary, ZV, Qnil);
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
742 pos_byte = CHAR_TO_BYTE (pos);
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
743 next_boundary_byte = CHAR_TO_BYTE (next_boundary);
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
744 }
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
745 if (pos_byte >= ceiling)
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
746 ceiling = BUFFER_CEILING_OF (pos_byte) + 1;
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
747 /* Compute the next place we need to stop and think,
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
748 and set STOP accordingly. */
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
749 stop_pos_byte = min (ceiling, next_boundary_byte);
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
750 /* The -1 and +1 arrange to point at the first byte of gap
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
751 (if STOP_POS_BYTE is the position of the gap)
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
752 rather than at the data after the gap. */
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
753
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
754 stop = BYTE_POS_ADDR (stop_pos_byte - 1) + 1;
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
755 p = BYTE_POS_ADDR (pos_byte);
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
756 }
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
757 switch (*p++)
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
758 {
20256
f75208097eb5 (position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents: 19938
diff changeset
759 case 0240:
f75208097eb5 (position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents: 19938
diff changeset
760 if (! NILP (current_buffer->enable_multibyte_characters))
f75208097eb5 (position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents: 19938
diff changeset
761 return column;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
762 case ' ':
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
763 column++;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
764 break;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
765 case '\t':
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
766 column += tab_width - column % tab_width;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
767 break;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
768 default:
20256
f75208097eb5 (position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents: 19938
diff changeset
769 if (ASCII_BYTE_P (p[-1])
f75208097eb5 (position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents: 19938
diff changeset
770 || NILP (current_buffer->enable_multibyte_characters))
f75208097eb5 (position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents: 19938
diff changeset
771 return column;
f75208097eb5 (position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents: 19938
diff changeset
772 {
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
773 int c;
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
774 pos_byte = PTR_BYTE_POS (p - 1);
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
775 c = FETCH_MULTIBYTE_CHAR (pos_byte);
20256
f75208097eb5 (position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents: 19938
diff changeset
776 if (CHAR_HAS_CATEGORY (c, ' '))
f75208097eb5 (position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents: 19938
diff changeset
777 {
f75208097eb5 (position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents: 19938
diff changeset
778 column++;
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
779 INC_POS (pos_byte);
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
780 p = BYTE_POS_ADDR (pos_byte);
20256
f75208097eb5 (position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents: 19938
diff changeset
781 }
f75208097eb5 (position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents: 19938
diff changeset
782 else
f75208097eb5 (position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents: 19938
diff changeset
783 return column;
f75208097eb5 (position_indentation): Detect non-breaking space,
Karl Heuer <kwzh@gnu.org>
parents: 19938
diff changeset
784 }
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
785 }
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
786 }
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
787 }
5943
35526ee8b790 (indented_beyond_p): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5941
diff changeset
788
35526ee8b790 (indented_beyond_p): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5941
diff changeset
789 /* Test whether the line beginning at POS is indented beyond COLUMN.
35526ee8b790 (indented_beyond_p): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5941
diff changeset
790 Blank lines are treated as if they had the same indentation as the
35526ee8b790 (indented_beyond_p): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5941
diff changeset
791 preceding line. */
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
792
5943
35526ee8b790 (indented_beyond_p): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5941
diff changeset
793 int
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
794 indented_beyond_p (pos, pos_byte, column)
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
795 int pos, pos_byte, column;
5943
35526ee8b790 (indented_beyond_p): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5941
diff changeset
796 {
21525
0ed9ea6eeef3 (indented_beyond_p): Fix mixing of Lisp_Object and int.
Andreas Schwab <schwab@suse.de>
parents: 21514
diff changeset
797 int val;
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
798 int opoint = PT, opoint_byte = PT_BYTE;
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
799
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
800 SET_PT_BOTH (pos, pos_byte);
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
801 while (PT > BEGV && FETCH_BYTE (PT_BYTE) == '\n')
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
802 scan_newline (PT - 1, PT_BYTE - 1, BEGV, BEGV_BYTE, -1, 0);
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
803
21525
0ed9ea6eeef3 (indented_beyond_p): Fix mixing of Lisp_Object and int.
Andreas Schwab <schwab@suse.de>
parents: 21514
diff changeset
804 val = position_indentation (PT_BYTE);
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
805 SET_PT_BOTH (opoint, opoint_byte);
22560
ce6e85fd8036 (indented_beyond_p): Return the right kind of value.
Richard M. Stallman <rms@gnu.org>
parents: 22245
diff changeset
806 return val >= column;
5943
35526ee8b790 (indented_beyond_p): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5941
diff changeset
807 }
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
808
13124
e44b06fc718d (Fmove_to_column): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
809 DEFUN ("move-to-column", Fmove_to_column, Smove_to_column, 1, 2, "p",
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
810 "Move point to column COLUMN in the current line.\n\
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
811 The column of a character is calculated by adding together the widths\n\
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
812 as displayed of the previous characters in the line.\n\
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
813 This function ignores line-continuation;\n\
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
814 there is no upper limit on the column number a character can have\n\
1208
fa662930e654 * indent.c (Fmove_to_column): Pass the right number of arguments
Jim Blandy <jimb@redhat.com>
parents: 764
diff changeset
815 and horizontal scrolling has no effect.\n\
fa662930e654 * indent.c (Fmove_to_column): Pass the right number of arguments
Jim Blandy <jimb@redhat.com>
parents: 764
diff changeset
816 \n\
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
817 If specified column is within a character, point goes after that character.\n\
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
818 If it's past end of line, point goes to end of line.\n\n\
25073
0cac51b5af77 (Fmove_to_column): Extend end of line only if FORCE is t.
Karl Heuer <kwzh@gnu.org>
parents: 25028
diff changeset
819 A non-nil second (optional) argument FORCE means,\n\
0cac51b5af77 (Fmove_to_column): Extend end of line only if FORCE is t.
Karl Heuer <kwzh@gnu.org>
parents: 25028
diff changeset
820 if COLUMN is in the middle of a tab character, change it to spaces.\n\
0cac51b5af77 (Fmove_to_column): Extend end of line only if FORCE is t.
Karl Heuer <kwzh@gnu.org>
parents: 25028
diff changeset
821 In addition, if FORCE is t, and the line is too short\n\
0cac51b5af77 (Fmove_to_column): Extend end of line only if FORCE is t.
Karl Heuer <kwzh@gnu.org>
parents: 25028
diff changeset
822 to reach column COLUMN, add spaces/tabs to get there.\n\
13453
ea373c55ed95 (Fmove_to_column): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 13363
diff changeset
823 \n\
ea373c55ed95 (Fmove_to_column): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 13363
diff changeset
824 The return value is the current column.")
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
825 (column, force)
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
826 Lisp_Object column, force;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
827 {
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
828 register int pos;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
829 register int col = current_column ();
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
830 register int goal;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
831 register int end;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
832 register int tab_width = XINT (current_buffer->tab_width);
488
4fddd0f0fc33 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 327
diff changeset
833 register int ctl_arrow = !NILP (current_buffer->ctl_arrow);
13185
5b1671bd3cc1 (buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents: 13124
diff changeset
834 register struct Lisp_Char_Table *dp = buffer_display_table ();
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
835 register int multibyte = !NILP (current_buffer->enable_multibyte_characters);
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
836
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
837 Lisp_Object val;
31829
43566b0aec59 Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents: 31102
diff changeset
838 int prev_col = 0;
43566b0aec59 Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents: 31102
diff changeset
839 int c = 0;
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
840 int next_boundary;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
841
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
842 int pos_byte, end_byte, next_boundary_byte;
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
843
2325
7b5299f3a8fc (current_column, Findent_to, position_indentation):
Richard M. Stallman <rms@gnu.org>
parents: 2017
diff changeset
844 if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
845 CHECK_NATNUM (column, 0);
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
846 goal = XINT (column);
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
847
16039
855c8d8ba0f0 Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents: 15659
diff changeset
848 pos = PT;
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
849 pos_byte = PT_BYTE;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
850 end = ZV;
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
851 end_byte = ZV_BYTE;
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
852 next_boundary = pos;
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
853 next_boundary_byte = PT_BYTE;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
854
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
855 /* If we're starting past the desired column,
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
856 back up to beginning of line and scan from there. */
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
857 if (col > goal)
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
858 {
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
859 end = pos;
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
860 pos = current_column_bol_cache;
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
861 pos_byte = CHAR_TO_BYTE (pos);
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
862 col = 0;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
863 }
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
864
15554
103a6af424a8 (Fmove_to_column): Go after invis chars at the goal column.
Richard M. Stallman <rms@gnu.org>
parents: 15494
diff changeset
865 while (pos < end)
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
866 {
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
867 while (pos == next_boundary)
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
868 {
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
869 int prev = pos;
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
870 pos = skip_invisible (pos, &next_boundary, end, Qnil);
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
871 if (pos != prev)
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
872 pos_byte = CHAR_TO_BYTE (pos);
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
873 next_boundary_byte = CHAR_TO_BYTE (next_boundary);
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
874 if (pos >= end)
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
875 goto endloop;
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
876 }
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
877
15554
103a6af424a8 (Fmove_to_column): Go after invis chars at the goal column.
Richard M. Stallman <rms@gnu.org>
parents: 15494
diff changeset
878 /* Test reaching the goal column. We do this after skipping
103a6af424a8 (Fmove_to_column): Go after invis chars at the goal column.
Richard M. Stallman <rms@gnu.org>
parents: 15494
diff changeset
879 invisible characters, so that we put point before the
103a6af424a8 (Fmove_to_column): Go after invis chars at the goal column.
Richard M. Stallman <rms@gnu.org>
parents: 15494
diff changeset
880 character on which the cursor will appear. */
103a6af424a8 (Fmove_to_column): Go after invis chars at the goal column.
Richard M. Stallman <rms@gnu.org>
parents: 15494
diff changeset
881 if (col >= goal)
103a6af424a8 (Fmove_to_column): Go after invis chars at the goal column.
Richard M. Stallman <rms@gnu.org>
parents: 15494
diff changeset
882 break;
103a6af424a8 (Fmove_to_column): Go after invis chars at the goal column.
Richard M. Stallman <rms@gnu.org>
parents: 15494
diff changeset
883
26859
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
884 /* Check composition sequence. */
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
885 {
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
886 int len, len_byte, width;
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
887
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
888 if (check_composition (pos, pos_byte, Z, &len, &len_byte, &width))
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
889 {
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
890 pos += len;
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
891 pos_byte += len_byte;
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
892 col += width;
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
893 continue;
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
894 }
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
895 }
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
896
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
897 c = FETCH_BYTE (pos_byte);
20938
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
898 if (dp != 0
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
899 && ! (multibyte && BASE_LEADING_CODE_P (c))
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
900 && VECTORP (DISP_CHAR_VECTOR (dp, c)))
11037
802a774b44b7 (compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents: 10964
diff changeset
901 {
802a774b44b7 (compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents: 10964
diff changeset
902 col += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size;
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
903 pos_byte++;
11037
802a774b44b7 (compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents: 10964
diff changeset
904 pos++;
11312
f48922d85166 (Fmove_to_column): Fix minor bug in prev change.
Richard M. Stallman <rms@gnu.org>
parents: 11300
diff changeset
905 continue;
11037
802a774b44b7 (compute_motion, Fmove_to_column, current_column)
Richard M. Stallman <rms@gnu.org>
parents: 10964
diff changeset
906 }
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
907 if (c == '\n')
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
908 break;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
909 if (c == '\r' && EQ (current_buffer->selective_display, Qt))
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
910 break;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
911 pos++;
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
912 pos_byte++;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
913 if (c == '\t')
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
914 {
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
915 prev_col = col;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
916 col += tab_width;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
917 col = col / tab_width * tab_width;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
918 }
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
919 else if (ctl_arrow && (c < 040 || c == 0177))
5162
9672138155c1 (Fmove_to_column): Increments for control characters
Richard M. Stallman <rms@gnu.org>
parents: 5085
diff changeset
920 col += 2;
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
921 else if (c < 040 || c == 0177)
5162
9672138155c1 (Fmove_to_column): Increments for control characters
Richard M. Stallman <rms@gnu.org>
parents: 5085
diff changeset
922 col += 4;
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
923 else if (c < 0177)
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
924 col++;
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
925 else if (multibyte && BASE_LEADING_CODE_P (c))
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
926 {
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
927 /* Start of multi-byte form. */
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
928 unsigned char *ptr;
20938
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
929 int bytes, width, wide_column;
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
930
20938
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
931 pos_byte--;
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
932 ptr = BYTE_POS_ADDR (pos_byte);
25510
d584d75fc3a7 (MULTIBYTE_BYTES_WIDTH): Delete the 2nd arg C. Use the
Kenichi Handa <handa@m17n.org>
parents: 25351
diff changeset
933 MULTIBYTE_BYTES_WIDTH (ptr, dp);
20938
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
934 pos_byte += bytes;
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
935 col += width;
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
936 }
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
937 else
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
938 col += 4;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
939 }
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
940 endloop:
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
941
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
942 SET_PT_BOTH (pos, pos_byte);
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
943
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
944 /* If a tab char made us overshoot, change it to spaces
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
945 and scan through it again. */
488
4fddd0f0fc33 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 327
diff changeset
946 if (!NILP (force) && col > goal && c == '\t' && prev_col < goal)
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
947 {
28933
bb0cf4868e70 (Fmove_to_column): When ending within a tab, insert
Gerd Moellmann <gerd@gnu.org>
parents: 28537
diff changeset
948 int goal_pt, goal_pt_byte;
bb0cf4868e70 (Fmove_to_column): When ending within a tab, insert
Gerd Moellmann <gerd@gnu.org>
parents: 28537
diff changeset
949
bb0cf4868e70 (Fmove_to_column): When ending within a tab, insert
Gerd Moellmann <gerd@gnu.org>
parents: 28537
diff changeset
950 /* Insert spaces in front of the tab to reach GOAL. Do this
bb0cf4868e70 (Fmove_to_column): When ending within a tab, insert
Gerd Moellmann <gerd@gnu.org>
parents: 28537
diff changeset
951 first so that a marker at the end of the tab gets
bb0cf4868e70 (Fmove_to_column): When ending within a tab, insert
Gerd Moellmann <gerd@gnu.org>
parents: 28537
diff changeset
952 adjusted. */
bb0cf4868e70 (Fmove_to_column): When ending within a tab, insert
Gerd Moellmann <gerd@gnu.org>
parents: 28537
diff changeset
953 SET_PT_BOTH (PT - 1, PT_BYTE - 1);
bb0cf4868e70 (Fmove_to_column): When ending within a tab, insert
Gerd Moellmann <gerd@gnu.org>
parents: 28537
diff changeset
954 Finsert_char (make_number (' '), make_number (goal - prev_col), Qt);
573
f0ffd1764382 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 543
diff changeset
955
28933
bb0cf4868e70 (Fmove_to_column): When ending within a tab, insert
Gerd Moellmann <gerd@gnu.org>
parents: 28537
diff changeset
956 /* Now delete the tab, and indent to COL. */
bb0cf4868e70 (Fmove_to_column): When ending within a tab, insert
Gerd Moellmann <gerd@gnu.org>
parents: 28537
diff changeset
957 del_range (PT, PT + 1);
bb0cf4868e70 (Fmove_to_column): When ending within a tab, insert
Gerd Moellmann <gerd@gnu.org>
parents: 28537
diff changeset
958 goal_pt = PT;
bb0cf4868e70 (Fmove_to_column): When ending within a tab, insert
Gerd Moellmann <gerd@gnu.org>
parents: 28537
diff changeset
959 goal_pt_byte = PT_BYTE;
573
f0ffd1764382 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 543
diff changeset
960 Findent_to (make_number (col), Qnil);
28933
bb0cf4868e70 (Fmove_to_column): When ending within a tab, insert
Gerd Moellmann <gerd@gnu.org>
parents: 28537
diff changeset
961 SET_PT_BOTH (goal_pt, goal_pt_byte);
bb0cf4868e70 (Fmove_to_column): When ending within a tab, insert
Gerd Moellmann <gerd@gnu.org>
parents: 28537
diff changeset
962
4385
edffa4f0c5d9 (compute_motion): Compute correctly for invisible text.
Richard M. Stallman <rms@gnu.org>
parents: 2961
diff changeset
963 /* Set the last_known... vars consistently. */
edffa4f0c5d9 (compute_motion): Compute correctly for invisible text.
Richard M. Stallman <rms@gnu.org>
parents: 2961
diff changeset
964 col = goal;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
965 }
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
966
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
967 /* If line ends prematurely, add space to the end. */
25073
0cac51b5af77 (Fmove_to_column): Extend end of line only if FORCE is t.
Karl Heuer <kwzh@gnu.org>
parents: 25028
diff changeset
968 if (col < goal && EQ (force, Qt))
1208
fa662930e654 * indent.c (Fmove_to_column): Pass the right number of arguments
Jim Blandy <jimb@redhat.com>
parents: 764
diff changeset
969 Findent_to (make_number (col = goal), Qnil);
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
970
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
971 last_known_column = col;
16039
855c8d8ba0f0 Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents: 15659
diff changeset
972 last_known_column_point = PT;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
973 last_known_column_modified = MODIFF;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
974
9310
1dfd9def3467 (Fcurrent_column, Findent_to, Fcurrent_indentation, Fmove_to_column,
Karl Heuer <kwzh@gnu.org>
parents: 9269
diff changeset
975 XSETFASTINT (val, col);
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
976 return val;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
977 }
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
978
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
979 /* compute_motion: compute buffer posn given screen posn and vice versa */
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
980
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
981 struct position val_compute_motion;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
982
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
983 /* Scan the current buffer forward from offset FROM, pretending that
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
984 this is at line FROMVPOS, column FROMHPOS, until reaching buffer
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
985 offset TO or line TOVPOS, column TOHPOS (whichever comes first),
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
986 and return the ending buffer position and screen location. If we
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
987 can't hit the requested column exactly (because of a tab or other
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
988 multi-column character), overshoot.
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
989
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
990 DID_MOTION is 1 if FROMHPOS has already accounted for overlay strings
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
991 at FROM. This is the case if FROMVPOS and FROMVPOS came from an
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
992 earlier call to compute_motion. The other common case is that FROMHPOS
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
993 is zero and FROM is a position that "belongs" at column zero, but might
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
994 be shifted by overlay strings; in this case DID_MOTION should be 0.
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
995
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
996 WIDTH is the number of columns available to display text;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
997 compute_motion uses this to handle continuation lines and such.
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
998 HSCROLL is the number of columns not being displayed at the left
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
999 margin; this is usually taken from a window's hscroll member.
543
937bccff8155 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 526
diff changeset
1000 TAB_OFFSET is the number of columns of the first tab that aren't
937bccff8155 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 526
diff changeset
1001 being displayed, perhaps because of a continuation line or
937bccff8155 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 526
diff changeset
1002 something.
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1003
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1004 compute_motion returns a pointer to a struct position. The bufpos
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1005 member gives the buffer position at the end of the scan, and hpos
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1006 and vpos give its cartesian location. prevhpos is the column at
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1007 which the character before bufpos started, and contin is non-zero
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1008 if we reached the current line by continuing the previous.
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1009
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1010 Note that FROMHPOS and TOHPOS should be expressed in real screen
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1011 columns, taking HSCROLL and the truncation glyph at the left margin
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1012 into account. That is, beginning-of-line moves you to the hpos
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1013 -HSCROLL + (HSCROLL > 0).
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1014
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1015 For example, to find the buffer position of column COL of line LINE
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1016 of a certain window, pass the window's starting location as FROM
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1017 and the window's upper-left coordinates as FROMVPOS and FROMHPOS.
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1018 Pass the buffer's ZV as TO, to limit the scan to the end of the
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1019 visible section of the buffer, and pass LINE and COL as TOVPOS and
10538
48c620ae0853 (compute_motion): Don't get hung in selective-display loop.
Karl Heuer <kwzh@gnu.org>
parents: 10011
diff changeset
1020 TOHPOS.
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1021
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1022 When displaying in window w, a typical formula for WIDTH is:
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1023
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1024 window_width - 1
1994
73ce9dd21093 Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents: 1777
diff changeset
1025 - (has_vertical_scroll_bars
8946
f2249e034d50 (compute_motion): Fix comment.
Karl Heuer <kwzh@gnu.org>
parents: 8905
diff changeset
1026 ? FRAME_SCROLL_BAR_COLS (XFRAME (window->frame))
1777
4edfaa19c7a7 * window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents: 1208
diff changeset
1027 : (window_width + window_left != frame_width))
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1028
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1029 where
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1030 window_width is XFASTINT (w->width),
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1031 window_left is XFASTINT (w->left),
1994
73ce9dd21093 Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents: 1777
diff changeset
1032 has_vertical_scroll_bars is
73ce9dd21093 Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents: 1777
diff changeset
1033 FRAME_HAS_VERTICAL_SCROLL_BARS (XFRAME (WINDOW_FRAME (window)))
1777
4edfaa19c7a7 * window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents: 1208
diff changeset
1034 and frame_width = FRAME_WIDTH (XFRAME (window->frame))
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1035
6400
5ef02598a0ad (compute_motion): Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 6327
diff changeset
1036 Or you can let window_internal_width do this all for you, and write:
5ef02598a0ad (compute_motion): Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 6327
diff changeset
1037 window_internal_width (w) - 1
1777
4edfaa19c7a7 * window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents: 1208
diff changeset
1038
4edfaa19c7a7 * window.c (window_internal_width): New function.
Jim Blandy <jimb@redhat.com>
parents: 1208
diff changeset
1039 The `-1' accounts for the continuation-line backslashes; the rest
5941
c4cceb65fc5a Fix comments.
Karl Heuer <kwzh@gnu.org>
parents: 5845
diff changeset
1040 accounts for window borders if the window is split horizontally, and
6400
5ef02598a0ad (compute_motion): Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 6327
diff changeset
1041 the scroll bars if they are turned on. */
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1042
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1043 struct position *
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1044 compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width, hscroll, tab_offset, win)
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1045 int from, fromvpos, fromhpos, to, tovpos, tohpos;
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1046 int did_motion;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1047 register int width;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1048 int hscroll, tab_offset;
6691
3b56d4742266 (compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents: 6588
diff changeset
1049 struct window *win;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1050 {
526
a41500eed1c5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 488
diff changeset
1051 register int hpos = fromhpos;
a41500eed1c5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 488
diff changeset
1052 register int vpos = fromvpos;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1053
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1054 register int pos;
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1055 int pos_byte;
31829
43566b0aec59 Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents: 31102
diff changeset
1056 register int c = 0;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1057 register int tab_width = XFASTINT (current_buffer->tab_width);
488
4fddd0f0fc33 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 327
diff changeset
1058 register int ctl_arrow = !NILP (current_buffer->ctl_arrow);
13185
5b1671bd3cc1 (buffer_display_table): Use DISP_TABLE_P.
Richard M. Stallman <rms@gnu.org>
parents: 13124
diff changeset
1059 register struct Lisp_Char_Table *dp = window_display_table (win);
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1060 int selective
9126
e475f8108156 (buffer_display_table, current_column, Fmove_to_column, compute_motion,
Karl Heuer <kwzh@gnu.org>
parents: 8946
diff changeset
1061 = (INTEGERP (current_buffer->selective_display)
6846
a6803ff29cca (compute_motion): Do not abort if window shows some other buffer.
Richard M. Stallman <rms@gnu.org>
parents: 6811
diff changeset
1062 ? XINT (current_buffer->selective_display)
a6803ff29cca (compute_motion): Do not abort if window shows some other buffer.
Richard M. Stallman <rms@gnu.org>
parents: 6811
diff changeset
1063 : !NILP (current_buffer->selective_display) ? -1 : 0);
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1064 int prev_hpos = 0;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1065 int selective_rlen
9126
e475f8108156 (buffer_display_table, current_column, Fmove_to_column, compute_motion,
Karl Heuer <kwzh@gnu.org>
parents: 8946
diff changeset
1066 = (selective && dp && VECTORP (DISP_INVIS_VECTOR (dp))
2017
ffa43acb7de7 (current_column, Fmove_to_column, compute_motion):
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
1067 ? XVECTOR (DISP_INVIS_VECTOR (dp))->size : 0);
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1068 /* The next location where the `invisible' property changes, or an
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1069 overlay starts or ends. */
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1070 int next_boundary = from;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1071
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1072 /* For computing runs of characters with similar widths.
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1073 Invariant: width_run_width is zero, or all the characters
10538
48c620ae0853 (compute_motion): Don't get hung in selective-display loop.
Karl Heuer <kwzh@gnu.org>
parents: 10011
diff changeset
1074 from width_run_start to width_run_end have a fixed width of
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1075 width_run_width. */
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1076 int width_run_start = from;
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1077 int width_run_end = from;
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1078 int width_run_width = 0;
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1079 Lisp_Object *width_table;
10964
474b6b03a71f (compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents: 10538
diff changeset
1080 Lisp_Object buffer;
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1081
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1082 /* The next buffer pos where we should consult the width run cache. */
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1083 int next_width_run = from;
15059
3b7454f2d662 (compute_motion): Pass window to Fget_char_property.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
1084 Lisp_Object window;
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1085
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1086 int multibyte = !NILP (current_buffer->enable_multibyte_characters);
21996
60178dff673f Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 21995
diff changeset
1087 /* If previous char scanned was a wide character,
60178dff673f Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 21995
diff changeset
1088 this is the column where it ended. Otherwise, this is 0. */
60178dff673f Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 21995
diff changeset
1089 int wide_column_end_hpos = 0;
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1090 int prev_pos; /* Previous buffer position. */
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1091 int prev_pos_byte; /* Previous buffer position. */
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1092 int contin_hpos; /* HPOS of last column of continued line. */
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1093 int prev_tab_offset; /* Previous tab offset. */
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1094
10964
474b6b03a71f (compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents: 10538
diff changeset
1095 XSETBUFFER (buffer, current_buffer);
15059
3b7454f2d662 (compute_motion): Pass window to Fget_char_property.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
1096 XSETWINDOW (window, win);
10964
474b6b03a71f (compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents: 10538
diff changeset
1097
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1098 width_run_cache_on_off ();
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1099 if (dp == buffer_display_table ())
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1100 width_table = (VECTORP (current_buffer->width_table)
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1101 ? XVECTOR (current_buffer->width_table)->contents
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1102 : 0);
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1103 else
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1104 /* If the window has its own display table, we can't use the width
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1105 run cache, because that's based on the buffer's display table. */
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1106 width_table = 0;
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1107
28537
862f955dfe92 (compute_motion): Set immediate_quit.
Gerd Moellmann <gerd@gnu.org>
parents: 28293
diff changeset
1108 if (tab_width <= 0 || tab_width > 1000)
862f955dfe92 (compute_motion): Set immediate_quit.
Gerd Moellmann <gerd@gnu.org>
parents: 28293
diff changeset
1109 tab_width = 8;
862f955dfe92 (compute_motion): Set immediate_quit.
Gerd Moellmann <gerd@gnu.org>
parents: 28293
diff changeset
1110
862f955dfe92 (compute_motion): Set immediate_quit.
Gerd Moellmann <gerd@gnu.org>
parents: 28293
diff changeset
1111 immediate_quit = 1;
862f955dfe92 (compute_motion): Set immediate_quit.
Gerd Moellmann <gerd@gnu.org>
parents: 28293
diff changeset
1112 QUIT;
526
a41500eed1c5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 488
diff changeset
1113
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1114 pos = prev_pos = from;
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1115 pos_byte = prev_pos_byte = CHAR_TO_BYTE (from);
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1116 contin_hpos = 0;
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1117 prev_tab_offset = tab_offset;
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1118 while (1)
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1119 {
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1120 while (pos == next_boundary)
5085
82bcf2c36929 (compute_motion): Pass new arg to Fnext_single_property_change.
Richard M. Stallman <rms@gnu.org>
parents: 4696
diff changeset
1121 {
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1122 int pos_here = pos;
17966
aaa25a87ae3d (compute_motion): Return correctly if skip_invisible
Richard M. Stallman <rms@gnu.org>
parents: 17136
diff changeset
1123 int newpos;
aaa25a87ae3d (compute_motion): Return correctly if skip_invisible
Richard M. Stallman <rms@gnu.org>
parents: 17136
diff changeset
1124
22245
94da16d936b6 (compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents: 22000
diff changeset
1125 /* Don't skip invisible if we are already at the margin. */
94da16d936b6 (compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents: 22000
diff changeset
1126 if (vpos > tovpos || vpos == tovpos && hpos >= tohpos)
94da16d936b6 (compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents: 22000
diff changeset
1127 {
94da16d936b6 (compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents: 22000
diff changeset
1128 if (contin_hpos && prev_hpos == 0
94da16d936b6 (compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents: 22000
diff changeset
1129 && hpos > tohpos
94da16d936b6 (compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents: 22000
diff changeset
1130 && (contin_hpos == width || wide_column_end_hpos > width))
94da16d936b6 (compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents: 22000
diff changeset
1131 { /* Line breaks because we can't put the character at the
94da16d936b6 (compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents: 22000
diff changeset
1132 previous line any more. It is not the multi-column
94da16d936b6 (compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents: 22000
diff changeset
1133 character continued in middle. Go back to previous
94da16d936b6 (compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents: 22000
diff changeset
1134 buffer position, screen position, and set tab offset
94da16d936b6 (compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents: 22000
diff changeset
1135 to previous value. It's the beginning of the
94da16d936b6 (compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents: 22000
diff changeset
1136 line. */
94da16d936b6 (compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents: 22000
diff changeset
1137 pos = prev_pos;
94da16d936b6 (compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents: 22000
diff changeset
1138 pos_byte = prev_pos_byte;
94da16d936b6 (compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents: 22000
diff changeset
1139 hpos = prev_hpos;
94da16d936b6 (compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents: 22000
diff changeset
1140 tab_offset = prev_tab_offset;
94da16d936b6 (compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents: 22000
diff changeset
1141 }
94da16d936b6 (compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents: 22000
diff changeset
1142 break;
94da16d936b6 (compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents: 22000
diff changeset
1143 }
94da16d936b6 (compute_motion): Check for past vpos/hpos target
Richard M. Stallman <rms@gnu.org>
parents: 22000
diff changeset
1144
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1145 /* If the caller says that the screen position came from an earlier
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1146 call to compute_motion, then we've already accounted for the
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1147 overlay strings at point. This is only true the first time
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1148 through, so clear the flag after testing it. */
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1149 if (!did_motion)
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1150 /* We need to skip past the overlay strings. Currently those
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1151 strings must not contain TAB;
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1152 if we want to relax that restriction, something will have
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1153 to be changed here. */
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1154 {
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1155 unsigned char *ovstr;
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1156 int ovlen = overlay_strings (pos, win, &ovstr);
21283
c431691cbff1 (compute_motion): Call strwidth only when necessary.
Kenichi Handa <handa@m17n.org>
parents: 21275
diff changeset
1157 hpos += ((multibyte && ovlen > 0)
c431691cbff1 (compute_motion): Call strwidth only when necessary.
Kenichi Handa <handa@m17n.org>
parents: 21275
diff changeset
1158 ? strwidth (ovstr, ovlen) : ovlen);
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1159 }
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1160 did_motion = 0;
10964
474b6b03a71f (compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents: 10538
diff changeset
1161
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1162 if (pos >= to)
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1163 break;
10964
474b6b03a71f (compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents: 10538
diff changeset
1164
15493
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
1165 /* Advance POS past invisible characters
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
1166 (but not necessarily all that there are here),
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
1167 and store in next_boundary the next position where
32fe67f92ee1 Make current-column, move-to-column and current-indentation
Richard M. Stallman <rms@gnu.org>
parents: 15278
diff changeset
1168 we need to call skip_invisible. */
17966
aaa25a87ae3d (compute_motion): Return correctly if skip_invisible
Richard M. Stallman <rms@gnu.org>
parents: 17136
diff changeset
1169 newpos = skip_invisible (pos, &next_boundary, to, window);
aaa25a87ae3d (compute_motion): Return correctly if skip_invisible
Richard M. Stallman <rms@gnu.org>
parents: 17136
diff changeset
1170
aaa25a87ae3d (compute_motion): Return correctly if skip_invisible
Richard M. Stallman <rms@gnu.org>
parents: 17136
diff changeset
1171 if (newpos >= to)
21919
0c3d6e2c4176 (compute_motion): When invisible text cross TO,
Richard M. Stallman <rms@gnu.org>
parents: 21525
diff changeset
1172 {
0c3d6e2c4176 (compute_motion): When invisible text cross TO,
Richard M. Stallman <rms@gnu.org>
parents: 21525
diff changeset
1173 pos = min (to, newpos);
0c3d6e2c4176 (compute_motion): When invisible text cross TO,
Richard M. Stallman <rms@gnu.org>
parents: 21525
diff changeset
1174 goto after_loop;
0c3d6e2c4176 (compute_motion): When invisible text cross TO,
Richard M. Stallman <rms@gnu.org>
parents: 21525
diff changeset
1175 }
17966
aaa25a87ae3d (compute_motion): Return correctly if skip_invisible
Richard M. Stallman <rms@gnu.org>
parents: 17136
diff changeset
1176
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1177 if (newpos != pos_here)
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1178 {
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1179 pos = newpos;
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1180 pos_byte = CHAR_TO_BYTE (pos);
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1181 }
5085
82bcf2c36929 (compute_motion): Pass new arg to Fnext_single_property_change.
Richard M. Stallman <rms@gnu.org>
parents: 4696
diff changeset
1182 }
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1183
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1184 /* Handle right margin. */
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1185 /* Note on a wide-column character.
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1186
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1187 Characters are classified into the following three categories
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1188 according to the width (columns occupied on screen).
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1189
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1190 (1) single-column character: ex. `a'
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1191 (2) multi-column character: ex. `^A', TAB, `\033'
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1192 (3) wide-column character: ex. Japanese character, Chinese character
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1193 (In the following example, `W_' stands for them.)
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1194
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1195 Multi-column characters can be divided around the right margin,
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1196 but wide-column characters cannot.
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1197
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1198 NOTE:
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1199
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1200 (*) The cursor is placed on the next character after the point.
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1201
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1202 ----------
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1203 abcdefghi\
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1204 j ^---- next after the point
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1205 ^--- next char. after the point.
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1206 ----------
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1207 In case of sigle-column character
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1208
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1209 ----------
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1210 abcdefgh\\
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1211 033 ^---- next after the point, next char. after the point.
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1212 ----------
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1213 In case of multi-column character
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1214
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1215 ----------
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1216 abcdefgh\\
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1217 W_ ^---- next after the point
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1218 ^---- next char. after the point.
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1219 ----------
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1220 In case of wide-column character
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1221
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1222 The problem here is continuation at a wide-column character.
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1223 In this case, the line may shorter less than WIDTH.
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1224 And we find the continuation AFTER it occurs.
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1225
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1226 */
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1227
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1228 if (hpos > width)
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1229 {
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1230 if (hscroll
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1231 || (truncate_partial_width_windows
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1232 && width + 1 < FRAME_WIDTH (XFRAME (WINDOW_FRAME (win))))
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1233 || !NILP (current_buffer->truncate_lines))
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1234 {
20876
c80b908e5af5 (compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents: 20706
diff changeset
1235 /* Truncating: skip to newline, unless we are already past
c80b908e5af5 (compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents: 20706
diff changeset
1236 TO (we need to go back below). */
c80b908e5af5 (compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents: 20706
diff changeset
1237 if (pos <= to)
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1238 {
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1239 pos = find_before_next_newline (pos, to, 1);
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1240 pos_byte = CHAR_TO_BYTE (pos);
20876
c80b908e5af5 (compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents: 20706
diff changeset
1241 hpos = width;
c80b908e5af5 (compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents: 20706
diff changeset
1242 /* If we just skipped next_boundary,
c80b908e5af5 (compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents: 20706
diff changeset
1243 loop around in the main while
c80b908e5af5 (compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents: 20706
diff changeset
1244 and handle it. */
c80b908e5af5 (compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents: 20706
diff changeset
1245 if (pos >= next_boundary)
c80b908e5af5 (compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents: 20706
diff changeset
1246 next_boundary = pos + 1;
c80b908e5af5 (compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents: 20706
diff changeset
1247 prev_hpos = width;
c80b908e5af5 (compute_motion): If right margin is reached and we are
Andreas Schwab <schwab@suse.de>
parents: 20706
diff changeset
1248 prev_tab_offset = tab_offset;
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1249 }
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1250 }
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1251 else
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1252 {
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1253 /* Continuing. */
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1254 /* Remember the previous value. */
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1255 prev_tab_offset = tab_offset;
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1256
20938
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
1257 if (wide_column_end_hpos > width)
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1258 {
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1259 hpos -= prev_hpos;
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1260 tab_offset += prev_hpos;
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1261 }
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1262 else
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1263 {
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1264 tab_offset += width;
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1265 hpos -= width;
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1266 }
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1267 vpos++;
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1268 contin_hpos = prev_hpos;
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1269 prev_hpos = 0;
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1270 }
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1271 }
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1272
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1273 /* Stop if past the target buffer position or screen position. */
21994
e244c4d9b0ca (compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents: 21991
diff changeset
1274 if (pos > to)
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1275 {
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1276 /* Go back to the previous position. */
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1277 pos = prev_pos;
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1278 pos_byte = prev_pos_byte;
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1279 hpos = prev_hpos;
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1280 tab_offset = prev_tab_offset;
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1281
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1282 /* NOTE on contin_hpos, hpos, and prev_hpos.
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1283
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1284 ----------
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1285 abcdefgh\\
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1286 W_ ^---- contin_hpos
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1287 | ^----- hpos
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1288 \---- prev_hpos
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1289 ----------
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1290 */
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1291
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1292 if (contin_hpos && prev_hpos == 0
20938
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
1293 && contin_hpos < width && !wide_column_end_hpos)
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1294 {
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1295 /* Line breaking occurs in the middle of multi-column
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1296 character. Go back to previous line. */
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1297 hpos = contin_hpos;
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1298 vpos = vpos - 1;
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1299 }
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1300 else if (c == '\n')
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1301 /* If previous character is NEWLINE,
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1302 set VPOS back to previous line */
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1303 vpos = vpos - 1;
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1304 break;
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1305 }
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1306
21994
e244c4d9b0ca (compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents: 21991
diff changeset
1307 if (vpos > tovpos || vpos == tovpos && hpos >= tohpos)
e244c4d9b0ca (compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents: 21991
diff changeset
1308 {
e244c4d9b0ca (compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents: 21991
diff changeset
1309 if (contin_hpos && prev_hpos == 0
22000
55f17d895354 Fix previous change.
Kenichi Handa <handa@m17n.org>
parents: 21996
diff changeset
1310 && hpos > tohpos
55f17d895354 Fix previous change.
Kenichi Handa <handa@m17n.org>
parents: 21996
diff changeset
1311 && (contin_hpos == width || wide_column_end_hpos > width))
21994
e244c4d9b0ca (compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents: 21991
diff changeset
1312 { /* Line breaks because we can't put the character at the
e244c4d9b0ca (compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents: 21991
diff changeset
1313 previous line any more. It is not the multi-column
e244c4d9b0ca (compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents: 21991
diff changeset
1314 character continued in middle. Go back to previous
e244c4d9b0ca (compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents: 21991
diff changeset
1315 buffer position, screen position, and set tab offset
e244c4d9b0ca (compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents: 21991
diff changeset
1316 to previous value. It's the beginning of the
e244c4d9b0ca (compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents: 21991
diff changeset
1317 line. */
e244c4d9b0ca (compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents: 21991
diff changeset
1318 pos = prev_pos;
e244c4d9b0ca (compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents: 21991
diff changeset
1319 pos_byte = prev_pos_byte;
e244c4d9b0ca (compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents: 21991
diff changeset
1320 hpos = prev_hpos;
e244c4d9b0ca (compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents: 21991
diff changeset
1321 tab_offset = prev_tab_offset;
e244c4d9b0ca (compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents: 21991
diff changeset
1322 }
e244c4d9b0ca (compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents: 21991
diff changeset
1323 break;
e244c4d9b0ca (compute_motion): Undo both May 7 changes.
Richard M. Stallman <rms@gnu.org>
parents: 21991
diff changeset
1324 }
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1325 if (pos == ZV) /* We cannot go beyond ZV. Stop here. */
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1326 break;
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1327
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1328 prev_hpos = hpos;
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1329 prev_pos = pos;
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1330 prev_pos_byte = pos_byte;
20938
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
1331 wide_column_end_hpos = 0;
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1332
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1333 /* Consult the width run cache to see if we can avoid inspecting
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1334 the text character-by-character. */
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1335 if (current_buffer->width_run_cache && pos >= next_width_run)
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1336 {
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1337 int run_end;
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1338 int common_width
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1339 = region_cache_forward (current_buffer,
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1340 current_buffer->width_run_cache,
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1341 pos, &run_end);
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1342
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1343 /* A width of zero means the character's width varies (like
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1344 a tab), is meaningless (like a newline), or we just don't
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1345 want to skip over it for some other reason. */
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1346 if (common_width != 0)
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1347 {
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1348 int run_end_hpos;
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1349
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1350 /* Don't go past the final buffer posn the user
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1351 requested. */
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1352 if (run_end > to)
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1353 run_end = to;
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1354
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1355 run_end_hpos = hpos + (run_end - pos) * common_width;
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1356
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1357 /* Don't go past the final horizontal position the user
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1358 requested. */
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1359 if (vpos == tovpos && run_end_hpos > tohpos)
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1360 {
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1361 run_end = pos + (tohpos - hpos) / common_width;
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1362 run_end_hpos = hpos + (run_end - pos) * common_width;
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1363 }
10538
48c620ae0853 (compute_motion): Don't get hung in selective-display loop.
Karl Heuer <kwzh@gnu.org>
parents: 10011
diff changeset
1364
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1365 /* Don't go past the margin. */
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1366 if (run_end_hpos >= width)
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1367 {
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1368 run_end = pos + (width - hpos) / common_width;
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1369 run_end_hpos = hpos + (run_end - pos) * common_width;
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1370 }
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1371
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1372 hpos = run_end_hpos;
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1373 if (run_end > pos)
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1374 prev_hpos = hpos - common_width;
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1375 if (pos != run_end)
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1376 {
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1377 pos = run_end;
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1378 pos_byte = CHAR_TO_BYTE (pos);
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1379 }
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1380 }
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1381
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1382 next_width_run = run_end + 1;
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1383 }
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1384
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1385 /* We have to scan the text character-by-character. */
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1386 else
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1387 {
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1388 c = FETCH_BYTE (pos_byte);
26859
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
1389
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
1390 /* Check composition sequence. */
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
1391 {
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
1392 int len, len_byte, width;
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
1393
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
1394 if (check_composition (pos, pos_byte, to, &len, &len_byte, &width))
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
1395 {
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
1396 pos += len;
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
1397 pos_byte += len_byte;
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
1398 hpos += width;
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
1399 continue;
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
1400 }
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
1401 }
4cf41c98ad2d (check_composition): New function.
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
1402
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1403 pos++, pos_byte++;
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1404
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1405 /* Perhaps add some info to the width_run_cache. */
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1406 if (current_buffer->width_run_cache)
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1407 {
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1408 /* Is this character part of the current run? If so, extend
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1409 the run. */
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1410 if (pos - 1 == width_run_end
18109
b8c70b5f5aba (compute_motion): Use XFASTINT on width_table elts.
Richard M. Stallman <rms@gnu.org>
parents: 17966
diff changeset
1411 && XFASTINT (width_table[c]) == width_run_width)
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1412 width_run_end = pos;
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1413
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1414 /* The previous run is over, since this is a character at a
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1415 different position, or a different width. */
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1416 else
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1417 {
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1418 /* Have we accumulated a run to put in the cache?
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1419 (Currently, we only cache runs of width == 1). */
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1420 if (width_run_start < width_run_end
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1421 && width_run_width == 1)
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1422 know_region_cache (current_buffer,
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1423 current_buffer->width_run_cache,
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1424 width_run_start, width_run_end);
10538
48c620ae0853 (compute_motion): Don't get hung in selective-display loop.
Karl Heuer <kwzh@gnu.org>
parents: 10011
diff changeset
1425
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1426 /* Start recording a new width run. */
18109
b8c70b5f5aba (compute_motion): Use XFASTINT on width_table elts.
Richard M. Stallman <rms@gnu.org>
parents: 17966
diff changeset
1427 width_run_width = XFASTINT (width_table[c]);
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1428 width_run_start = pos - 1;
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1429 width_run_end = pos;
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1430 }
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1431 }
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1432
20938
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
1433 if (dp != 0
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
1434 && ! (multibyte && BASE_LEADING_CODE_P (c))
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
1435 && VECTORP (DISP_CHAR_VECTOR (dp, c)))
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1436 hpos += XVECTOR (DISP_CHAR_VECTOR (dp, c))->size;
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1437 else if (c >= 040 && c < 0177)
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1438 hpos++;
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1439 else if (c == '\t')
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1440 {
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1441 int tem = (hpos + tab_offset + hscroll - (hscroll > 0)) % tab_width;
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1442 if (tem < 0)
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1443 tem += tab_width;
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1444 hpos += tab_width - tem;
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1445 }
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1446 else if (c == '\n')
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1447 {
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1448 if (selective > 0
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1449 && indented_beyond_p (pos, pos_byte, selective))
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1450 {
17136
424932eba3e8 (compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents: 17016
diff changeset
1451 /* If (pos == to), we don't have to take care of
424932eba3e8 (compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents: 17016
diff changeset
1452 selective display. */
424932eba3e8 (compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents: 17016
diff changeset
1453 if (pos < to)
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1454 {
17136
424932eba3e8 (compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents: 17016
diff changeset
1455 /* Skip any number of invisible lines all at once */
424932eba3e8 (compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents: 17016
diff changeset
1456 do
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1457 {
24828
a3ddcd017066 (compute_motion): Fix boundary case.
Karl Heuer <kwzh@gnu.org>
parents: 23651
diff changeset
1458 pos = find_before_next_newline (pos, to, 1);
a3ddcd017066 (compute_motion): Fix boundary case.
Karl Heuer <kwzh@gnu.org>
parents: 23651
diff changeset
1459 if (pos < to)
a3ddcd017066 (compute_motion): Fix boundary case.
Karl Heuer <kwzh@gnu.org>
parents: 23651
diff changeset
1460 pos++;
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1461 pos_byte = CHAR_TO_BYTE (pos);
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1462 }
17136
424932eba3e8 (compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents: 17016
diff changeset
1463 while (pos < to
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1464 && indented_beyond_p (pos, pos_byte, selective));
17136
424932eba3e8 (compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents: 17016
diff changeset
1465 /* Allow for the " ..." that is displayed for them. */
424932eba3e8 (compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents: 17016
diff changeset
1466 if (selective_rlen)
424932eba3e8 (compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents: 17016
diff changeset
1467 {
424932eba3e8 (compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents: 17016
diff changeset
1468 hpos += selective_rlen;
424932eba3e8 (compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents: 17016
diff changeset
1469 if (hpos >= width)
424932eba3e8 (compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents: 17016
diff changeset
1470 hpos = width;
424932eba3e8 (compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents: 17016
diff changeset
1471 }
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1472 DEC_BOTH (pos, pos_byte);
17136
424932eba3e8 (compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents: 17016
diff changeset
1473 /* We have skipped the invis text, but not the
424932eba3e8 (compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents: 17016
diff changeset
1474 newline after. */
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1475 }
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1476 }
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1477 else
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1478 {
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1479 /* A visible line. */
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1480 vpos++;
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1481 hpos = 0;
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1482 hpos -= hscroll;
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1483 /* Count the truncation glyph on column 0 */
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1484 if (hscroll > 0)
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1485 hpos++;
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1486 tab_offset = 0;
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1487 }
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1488 contin_hpos = 0;
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1489 }
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1490 else if (c == CR && selective < 0)
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1491 {
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1492 /* In selective display mode,
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1493 everything from a ^M to the end of the line is invisible.
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1494 Stop *before* the real newline. */
17136
424932eba3e8 (compute_motion): When POS >= TO, don't call
Kenichi Handa <handa@m17n.org>
parents: 17016
diff changeset
1495 if (pos < to)
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1496 {
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1497 pos = find_before_next_newline (pos, to, 1);
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1498 pos_byte = CHAR_TO_BYTE (pos);
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1499 }
13453
ea373c55ed95 (Fmove_to_column): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 13363
diff changeset
1500 /* If we just skipped next_boundary,
ea373c55ed95 (Fmove_to_column): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 13363
diff changeset
1501 loop around in the main while
ea373c55ed95 (Fmove_to_column): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 13363
diff changeset
1502 and handle it. */
ea373c55ed95 (Fmove_to_column): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 13363
diff changeset
1503 if (pos > next_boundary)
ea373c55ed95 (Fmove_to_column): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 13363
diff changeset
1504 next_boundary = pos;
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1505 /* Allow for the " ..." that is displayed for them. */
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1506 if (selective_rlen)
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1507 {
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1508 hpos += selective_rlen;
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1509 if (hpos >= width)
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1510 hpos = width;
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1511 }
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1512 }
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1513 else if (multibyte && BASE_LEADING_CODE_P (c))
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1514 {
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1515 /* Start of multi-byte form. */
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1516 unsigned char *ptr;
20938
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
1517 int bytes, width, wide_column;
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1518
20938
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
1519 pos_byte--; /* rewind POS_BYTE */
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
1520 ptr = BYTE_POS_ADDR (pos_byte);
25510
d584d75fc3a7 (MULTIBYTE_BYTES_WIDTH): Delete the 2nd arg C. Use the
Kenichi Handa <handa@m17n.org>
parents: 25351
diff changeset
1521 MULTIBYTE_BYTES_WIDTH (ptr, dp);
20938
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
1522 pos_byte += bytes;
21283
c431691cbff1 (compute_motion): Call strwidth only when necessary.
Kenichi Handa <handa@m17n.org>
parents: 21275
diff changeset
1523 if (wide_column)
c431691cbff1 (compute_motion): Call strwidth only when necessary.
Kenichi Handa <handa@m17n.org>
parents: 21275
diff changeset
1524 wide_column_end_hpos = hpos + wide_column;
20938
12e635300b44 (MULTIBYTE_BYTES_WIDTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20876
diff changeset
1525 hpos += width;
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1526 }
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1527 else
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1528 hpos += (ctl_arrow && c < 0200) ? 2 : 4;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1529 }
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1530 }
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1531
17966
aaa25a87ae3d (compute_motion): Return correctly if skip_invisible
Richard M. Stallman <rms@gnu.org>
parents: 17136
diff changeset
1532 after_loop:
aaa25a87ae3d (compute_motion): Return correctly if skip_invisible
Richard M. Stallman <rms@gnu.org>
parents: 17136
diff changeset
1533
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1534 /* Remember any final width run in the cache. */
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1535 if (current_buffer->width_run_cache
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1536 && width_run_width == 1
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1537 && width_run_start < width_run_end)
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1538 know_region_cache (current_buffer, current_buffer->width_run_cache,
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1539 width_run_start, width_run_end);
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1540
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1541 val_compute_motion.bufpos = pos;
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1542 val_compute_motion.bytepos = pos_byte;
526
a41500eed1c5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 488
diff changeset
1543 val_compute_motion.hpos = hpos;
a41500eed1c5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 488
diff changeset
1544 val_compute_motion.vpos = vpos;
20985
020b0eade8c5 (compute_motion): If we just moved over a continuation
Andreas Schwab <schwab@suse.de>
parents: 20938
diff changeset
1545 if (contin_hpos && prev_hpos == 0)
020b0eade8c5 (compute_motion): If we just moved over a continuation
Andreas Schwab <schwab@suse.de>
parents: 20938
diff changeset
1546 val_compute_motion.prevhpos = contin_hpos;
020b0eade8c5 (compute_motion): If we just moved over a continuation
Andreas Schwab <schwab@suse.de>
parents: 20938
diff changeset
1547 else
020b0eade8c5 (compute_motion): If we just moved over a continuation
Andreas Schwab <schwab@suse.de>
parents: 20938
diff changeset
1548 val_compute_motion.prevhpos = prev_hpos;
16395
c6b901f809da (vmotion, compute_motion): Fill in ovstring_chars_done in the return value.
Richard M. Stallman <rms@gnu.org>
parents: 16257
diff changeset
1549 /* We alalways handle all of them here; none of them remain to do. */
c6b901f809da (vmotion, compute_motion): Fill in ovstring_chars_done in the return value.
Richard M. Stallman <rms@gnu.org>
parents: 16257
diff changeset
1550 val_compute_motion.ovstring_chars_done = 0;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1551
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1552 /* Nonzero if have just continued a line */
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1553 val_compute_motion.contin = (contin_hpos && prev_hpos == 0);
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1554
28537
862f955dfe92 (compute_motion): Set immediate_quit.
Gerd Moellmann <gerd@gnu.org>
parents: 28293
diff changeset
1555 immediate_quit = 0;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1556 return &val_compute_motion;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1557 }
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1558
25028
ab513f624bc6 (Fvertical_motion): Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 24828
diff changeset
1559
6587
168667ab5085 (Fcompute_motion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 6586
diff changeset
1560 #if 0 /* The doc string is too long for some compilers,
168667ab5085 (Fcompute_motion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 6586
diff changeset
1561 but make-docfile can find it in this comment. */
6691
3b56d4742266 (compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents: 6588
diff changeset
1562 DEFUN ("compute-motion", Ffoo, Sfoo, 7, 7, 0,
6296
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1563 "Scan through the current buffer, calculating screen position.\n\
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1564 Scan the current buffer forward from offset FROM,\n\
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1565 assuming it is at position FROMPOS--a cons of the form (HPOS . VPOS)--\n\
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1566 to position TO or position TOPOS--another cons of the form (HPOS . VPOS)--\n\
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1567 and return the ending buffer position and screen location.\n\
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1568 \n\
6691
3b56d4742266 (compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents: 6588
diff changeset
1569 There are three additional arguments:\n\
6296
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1570 \n\
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1571 WIDTH is the number of columns available to display text;\n\
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1572 this affects handling of continuation lines.\n\
6587
168667ab5085 (Fcompute_motion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 6586
diff changeset
1573 This is usually the value returned by `window-width', less one (to allow\n\
168667ab5085 (Fcompute_motion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 6586
diff changeset
1574 for the continuation glyph).\n\
6296
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1575 \n\
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1576 OFFSETS is either nil or a cons cell (HSCROLL . TAB-OFFSET).\n\
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1577 HSCROLL is the number of columns not being displayed at the left\n\
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1578 margin; this is usually taken from a window's hscroll member.\n\
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1579 TAB-OFFSET is the number of columns of the first tab that aren't\n\
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1580 being displayed, perhaps because the line was continued within it.\n\
6585
0e26a2431fa2 (Fcompute_motion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 6573
diff changeset
1581 If OFFSETS is nil, HSCROLL and TAB-OFFSET are assumed to be zero.\n\
6846
a6803ff29cca (compute_motion): Do not abort if window shows some other buffer.
Richard M. Stallman <rms@gnu.org>
parents: 6811
diff changeset
1582 \n\
15278
dc5e711a109e (compute_motion): When calling Fget_char_property,
Karl Heuer <kwzh@gnu.org>
parents: 15059
diff changeset
1583 WINDOW is the window to operate on. It is used to choose the display table;\n\
dc5e711a109e (compute_motion): When calling Fget_char_property,
Karl Heuer <kwzh@gnu.org>
parents: 15059
diff changeset
1584 if it is showing the current buffer, it is used also for\n\
dc5e711a109e (compute_motion): When calling Fget_char_property,
Karl Heuer <kwzh@gnu.org>
parents: 15059
diff changeset
1585 deciding which overlay properties apply.\n\
dc5e711a109e (compute_motion): When calling Fget_char_property,
Karl Heuer <kwzh@gnu.org>
parents: 15059
diff changeset
1586 Note that `compute-motion' always operates on the current buffer.\n\
6296
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1587 \n\
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1588 The value is a list of five elements:\n\
6586
de99006a8b38 (Fcompute_motion): Don't use XFASTINT on possibly-negative coords.
Karl Heuer <kwzh@gnu.org>
parents: 6585
diff changeset
1589 (POS HPOS VPOS PREVHPOS CONTIN)\n\
6296
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1590 POS is the buffer position where the scan stopped.\n\
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1591 VPOS is the vertical position where the scan stopped.\n\
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1592 HPOS is the horizontal position where the scan stopped.\n\
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1593 \n\
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1594 PREVHPOS is the horizontal position one character back from POS.\n\
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1595 CONTIN is t if a line was continued after (or within) the previous character.\n\
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1596 \n\
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1597 For example, to find the buffer position of column COL of line LINE\n\
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1598 of a certain window, pass the window's starting location as FROM\n\
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1599 and the window's upper-left coordinates as FROMPOS.\n\
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1600 Pass the buffer's (point-max) as TO, to limit the scan to the end of the\n\
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1601 visible section of the buffer, and pass LINE and COL as TOPOS.")
7566
8a0a7fb9f7d4 Add "args" to dummy definition of compute-motion.
Richard M. Stallman <rms@gnu.org>
parents: 7307
diff changeset
1602 (from, frompos, to, topos, width, offsets, window)
6587
168667ab5085 (Fcompute_motion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 6586
diff changeset
1603 #endif
168667ab5085 (Fcompute_motion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 6586
diff changeset
1604
6691
3b56d4742266 (compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents: 6588
diff changeset
1605 DEFUN ("compute-motion", Fcompute_motion, Scompute_motion, 7, 7, 0,
6587
168667ab5085 (Fcompute_motion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 6586
diff changeset
1606 0)
6691
3b56d4742266 (compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents: 6588
diff changeset
1607 (from, frompos, to, topos, width, offsets, window)
6296
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1608 Lisp_Object from, frompos, to, topos;
6691
3b56d4742266 (compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents: 6588
diff changeset
1609 Lisp_Object width, offsets, window;
6296
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1610 {
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1611 Lisp_Object bufpos, hpos, vpos, prevhpos, contin;
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1612 struct position *pos;
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1613 int hscroll, tab_offset;
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1614
6573
33ae9314b443 Fix glitches in previous change.
Karl Heuer <kwzh@gnu.org>
parents: 6572
diff changeset
1615 CHECK_NUMBER_COERCE_MARKER (from, 0);
6296
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1616 CHECK_CONS (frompos, 0);
25645
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25510
diff changeset
1617 CHECK_NUMBER (XCAR (frompos), 0);
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25510
diff changeset
1618 CHECK_NUMBER (XCDR (frompos), 0);
6573
33ae9314b443 Fix glitches in previous change.
Karl Heuer <kwzh@gnu.org>
parents: 6572
diff changeset
1619 CHECK_NUMBER_COERCE_MARKER (to, 0);
6296
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1620 CHECK_CONS (topos, 0);
25645
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25510
diff changeset
1621 CHECK_NUMBER (XCAR (topos), 0);
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25510
diff changeset
1622 CHECK_NUMBER (XCDR (topos), 0);
6573
33ae9314b443 Fix glitches in previous change.
Karl Heuer <kwzh@gnu.org>
parents: 6572
diff changeset
1623 CHECK_NUMBER (width, 0);
6296
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1624 if (!NILP (offsets))
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1625 {
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1626 CHECK_CONS (offsets, 0);
25645
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25510
diff changeset
1627 CHECK_NUMBER (XCAR (offsets), 0);
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25510
diff changeset
1628 CHECK_NUMBER (XCDR (offsets), 0);
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25510
diff changeset
1629 hscroll = XINT (XCAR (offsets));
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25510
diff changeset
1630 tab_offset = XINT (XCDR (offsets));
6296
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1631 }
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1632 else
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1633 hscroll = tab_offset = 0;
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1634
6691
3b56d4742266 (compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents: 6588
diff changeset
1635 if (NILP (window))
3b56d4742266 (compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents: 6588
diff changeset
1636 window = Fselected_window ();
3b56d4742266 (compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents: 6588
diff changeset
1637 else
3b56d4742266 (compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents: 6588
diff changeset
1638 CHECK_LIVE_WINDOW (window, 0);
3b56d4742266 (compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents: 6588
diff changeset
1639
21496
6ec5e85328a9 (Fcompute_motion): Check that TO and FROM are in range.
Karl Heuer <kwzh@gnu.org>
parents: 21283
diff changeset
1640 if (XINT (from) < BEGV || XINT (from) > ZV)
6ec5e85328a9 (Fcompute_motion): Check that TO and FROM are in range.
Karl Heuer <kwzh@gnu.org>
parents: 21283
diff changeset
1641 args_out_of_range_3 (from, make_number (BEGV), make_number (ZV));
6ec5e85328a9 (Fcompute_motion): Check that TO and FROM are in range.
Karl Heuer <kwzh@gnu.org>
parents: 21283
diff changeset
1642 if (XINT (to) < BEGV || XINT (to) > ZV)
6ec5e85328a9 (Fcompute_motion): Check that TO and FROM are in range.
Karl Heuer <kwzh@gnu.org>
parents: 21283
diff changeset
1643 args_out_of_range_3 (to, make_number (BEGV), make_number (ZV));
6ec5e85328a9 (Fcompute_motion): Check that TO and FROM are in range.
Karl Heuer <kwzh@gnu.org>
parents: 21283
diff changeset
1644
25645
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25510
diff changeset
1645 pos = compute_motion (XINT (from), XINT (XCDR (frompos)),
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25510
diff changeset
1646 XINT (XCAR (frompos)), 0,
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25510
diff changeset
1647 XINT (to), XINT (XCDR (topos)),
a14111a2a100 Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25510
diff changeset
1648 XINT (XCAR (topos)),
6691
3b56d4742266 (compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents: 6588
diff changeset
1649 XINT (width), hscroll, tab_offset,
3b56d4742266 (compute_motion): Add window argument.
Karl Heuer <kwzh@gnu.org>
parents: 6588
diff changeset
1650 XWINDOW (window));
6296
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1651
9310
1dfd9def3467 (Fcurrent_column, Findent_to, Fcurrent_indentation, Fmove_to_column,
Karl Heuer <kwzh@gnu.org>
parents: 9269
diff changeset
1652 XSETFASTINT (bufpos, pos->bufpos);
9269
0f29bb3f784f (Fcompute_motion): Use new accessor macros instead of calling XSET directly.
Karl Heuer <kwzh@gnu.org>
parents: 9126
diff changeset
1653 XSETINT (hpos, pos->hpos);
0f29bb3f784f (Fcompute_motion): Use new accessor macros instead of calling XSET directly.
Karl Heuer <kwzh@gnu.org>
parents: 9126
diff changeset
1654 XSETINT (vpos, pos->vpos);
0f29bb3f784f (Fcompute_motion): Use new accessor macros instead of calling XSET directly.
Karl Heuer <kwzh@gnu.org>
parents: 9126
diff changeset
1655 XSETINT (prevhpos, pos->prevhpos);
6296
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1656
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1657 return Fcons (bufpos,
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1658 Fcons (hpos,
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1659 Fcons (vpos,
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1660 Fcons (prevhpos,
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1661 Fcons (pos->contin ? Qt : Qnil, Qnil)))));
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1662
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1663 }
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1664
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1665 /* Fvertical_motion and vmotion */
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1666 struct position val_vmotion;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1667
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1668 struct position *
11811
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1669 vmotion (from, vtarget, w)
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1670 register int from, vtarget;
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1671 struct window *w;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1672 {
11811
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1673 int width = window_internal_width (w) - 1;
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1674 int hscroll = XINT (w->hscroll);
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1675 struct position pos;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1676 /* vpos is cumulative vertical position, changed as from is changed */
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1677 register int vpos = 0;
8905
2ef3da79aabb (vmotion, Fvertical_motion): Fix Lisp_Object vs. int problems.
Karl Heuer <kwzh@gnu.org>
parents: 8648
diff changeset
1678 Lisp_Object prevline;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1679 register int first;
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1680 int from_byte;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1681 int lmargin = hscroll > 0 ? 1 - hscroll : 0;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1682 int selective
9126
e475f8108156 (buffer_display_table, current_column, Fmove_to_column, compute_motion,
Karl Heuer <kwzh@gnu.org>
parents: 8946
diff changeset
1683 = (INTEGERP (current_buffer->selective_display)
e475f8108156 (buffer_display_table, current_column, Fmove_to_column, compute_motion,
Karl Heuer <kwzh@gnu.org>
parents: 8946
diff changeset
1684 ? XINT (current_buffer->selective_display)
e475f8108156 (buffer_display_table, current_column, Fmove_to_column, compute_motion,
Karl Heuer <kwzh@gnu.org>
parents: 8946
diff changeset
1685 : !NILP (current_buffer->selective_display) ? -1 : 0);
11811
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1686 Lisp_Object window;
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1687 int start_hpos = 0;
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1688 int did_motion;
23039
f4262c9a21dd (vmotion): Don't use WINDOW for Fget_char_property
Richard M. Stallman <rms@gnu.org>
parents: 22560
diff changeset
1689 /* This is the object we use for fetching character properties. */
f4262c9a21dd (vmotion): Don't use WINDOW for Fget_char_property
Richard M. Stallman <rms@gnu.org>
parents: 22560
diff changeset
1690 Lisp_Object text_prop_object;
11811
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1691
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1692 XSETWINDOW (window, w);
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1693
23039
f4262c9a21dd (vmotion): Don't use WINDOW for Fget_char_property
Richard M. Stallman <rms@gnu.org>
parents: 22560
diff changeset
1694 /* If the window contains this buffer, use it for getting text properties.
f4262c9a21dd (vmotion): Don't use WINDOW for Fget_char_property
Richard M. Stallman <rms@gnu.org>
parents: 22560
diff changeset
1695 Otherwise use the current buffer as arg for doing that. */
f4262c9a21dd (vmotion): Don't use WINDOW for Fget_char_property
Richard M. Stallman <rms@gnu.org>
parents: 22560
diff changeset
1696 if (EQ (w->buffer, Fcurrent_buffer ()))
f4262c9a21dd (vmotion): Don't use WINDOW for Fget_char_property
Richard M. Stallman <rms@gnu.org>
parents: 22560
diff changeset
1697 text_prop_object = window;
f4262c9a21dd (vmotion): Don't use WINDOW for Fget_char_property
Richard M. Stallman <rms@gnu.org>
parents: 22560
diff changeset
1698 else
f4262c9a21dd (vmotion): Don't use WINDOW for Fget_char_property
Richard M. Stallman <rms@gnu.org>
parents: 22560
diff changeset
1699 text_prop_object = Fcurrent_buffer ();
f4262c9a21dd (vmotion): Don't use WINDOW for Fget_char_property
Richard M. Stallman <rms@gnu.org>
parents: 22560
diff changeset
1700
11811
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1701 if (vpos >= vtarget)
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1702 {
11811
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1703 /* To move upward, go a line at a time until
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1704 we have gone at least far enough. */
11811
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1705
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1706 first = 1;
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1707
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1708 while ((vpos > vtarget || first) && from > BEGV)
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1709 {
10964
474b6b03a71f (compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents: 10538
diff changeset
1710 Lisp_Object propval;
474b6b03a71f (compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents: 10538
diff changeset
1711
11811
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1712 XSETFASTINT (prevline, find_next_newline_no_quit (from - 1, -1));
8905
2ef3da79aabb (vmotion, Fvertical_motion): Fix Lisp_Object vs. int problems.
Karl Heuer <kwzh@gnu.org>
parents: 8648
diff changeset
1713 while (XFASTINT (prevline) > BEGV
4385
edffa4f0c5d9 (compute_motion): Compute correctly for invisible text.
Richard M. Stallman <rms@gnu.org>
parents: 2961
diff changeset
1714 && ((selective > 0
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1715 && indented_beyond_p (XFASTINT (prevline),
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1716 CHAR_TO_BYTE (XFASTINT (prevline)),
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1717 selective))
4385
edffa4f0c5d9 (compute_motion): Compute correctly for invisible text.
Richard M. Stallman <rms@gnu.org>
parents: 2961
diff changeset
1718 /* watch out for newlines with `invisible' property */
10964
474b6b03a71f (compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents: 10538
diff changeset
1719 || (propval = Fget_char_property (prevline,
474b6b03a71f (compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents: 10538
diff changeset
1720 Qinvisible,
23039
f4262c9a21dd (vmotion): Don't use WINDOW for Fget_char_property
Richard M. Stallman <rms@gnu.org>
parents: 22560
diff changeset
1721 text_prop_object),
26404
c3c9cc1c2379 Remove USE_TEXT_PROPERTIES.
Gerd Moellmann <gerd@gnu.org>
parents: 25645
diff changeset
1722 TEXT_PROP_MEANS_INVISIBLE (propval))))
9310
1dfd9def3467 (Fcurrent_column, Findent_to, Fcurrent_indentation, Fmove_to_column,
Karl Heuer <kwzh@gnu.org>
parents: 9269
diff changeset
1723 XSETFASTINT (prevline,
1dfd9def3467 (Fcurrent_column, Findent_to, Fcurrent_indentation, Fmove_to_column,
Karl Heuer <kwzh@gnu.org>
parents: 9269
diff changeset
1724 find_next_newline_no_quit (XFASTINT (prevline) - 1,
1dfd9def3467 (Fcurrent_column, Findent_to, Fcurrent_indentation, Fmove_to_column,
Karl Heuer <kwzh@gnu.org>
parents: 9269
diff changeset
1725 -1));
8905
2ef3da79aabb (vmotion, Fvertical_motion): Fix Lisp_Object vs. int problems.
Karl Heuer <kwzh@gnu.org>
parents: 8648
diff changeset
1726 pos = *compute_motion (XFASTINT (prevline), 0,
11811
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1727 lmargin + (XFASTINT (prevline) == BEG
8905
2ef3da79aabb (vmotion, Fvertical_motion): Fix Lisp_Object vs. int problems.
Karl Heuer <kwzh@gnu.org>
parents: 8648
diff changeset
1728 ? start_hpos : 0),
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1729 0,
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1730 from,
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1731 /* Don't care for VPOS... */
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1732 1 << (BITS_PER_SHORT - 1),
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1733 /* ... nor HPOS. */
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1734 1 << (BITS_PER_SHORT - 1),
16926
3baea3418dec (pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents: 16395
diff changeset
1735 width, hscroll,
3baea3418dec (pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents: 16395
diff changeset
1736 /* This compensates for start_hpos
3baea3418dec (pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents: 16395
diff changeset
1737 so that a tab as first character
3baea3418dec (pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents: 16395
diff changeset
1738 still occupies 8 columns. */
3baea3418dec (pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents: 16395
diff changeset
1739 (XFASTINT (prevline) == BEG
3baea3418dec (pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents: 16395
diff changeset
1740 ? -start_hpos : 0),
3baea3418dec (pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents: 16395
diff changeset
1741 w);
11811
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1742 vpos -= pos.vpos;
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1743 first = 0;
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1744 from = XFASTINT (prevline);
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1745 }
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1746
11811
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1747 /* If we made exactly the desired vertical distance,
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1748 or if we hit beginning of buffer,
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1749 return point found */
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1750 if (vpos >= vtarget)
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1751 {
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1752 val_vmotion.bufpos = from;
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1753 val_vmotion.bytepos = CHAR_TO_BYTE (from);
11811
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1754 val_vmotion.vpos = vpos;
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1755 val_vmotion.hpos = lmargin;
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1756 val_vmotion.contin = 0;
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1757 val_vmotion.prevhpos = 0;
16395
c6b901f809da (vmotion, compute_motion): Fill in ovstring_chars_done in the return value.
Richard M. Stallman <rms@gnu.org>
parents: 16257
diff changeset
1758 val_vmotion.ovstring_chars_done = 0;
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1759 val_vmotion.tab_offset = 0; /* For accumulating tab offset. */
11811
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1760 return &val_vmotion;
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1761 }
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1762
11811
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1763 /* Otherwise find the correct spot by moving down */
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1764 }
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1765 /* Moving downward is simple, but must calculate from beg of line
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1766 to determine hpos of starting point */
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1767 from_byte = CHAR_TO_BYTE (from);
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1768 if (from > BEGV && FETCH_BYTE (from_byte - 1) != '\n')
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1769 {
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1770 Lisp_Object propval;
10964
474b6b03a71f (compute_motion): Call recenter_overlay_lists sooner.
Richard M. Stallman <rms@gnu.org>
parents: 10538
diff changeset
1771
11811
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1772 XSETFASTINT (prevline, find_next_newline_no_quit (from, -1));
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1773 while (XFASTINT (prevline) > BEGV
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1774 && ((selective > 0
20571
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1775 && indented_beyond_p (XFASTINT (prevline),
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1776 CHAR_TO_BYTE (XFASTINT (prevline)),
3e0e568163f5 (current_column_1, Fmove_to_column):
Richard M. Stallman <rms@gnu.org>
parents: 20371
diff changeset
1777 selective))
11811
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1778 /* watch out for newlines with `invisible' property */
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1779 || (propval = Fget_char_property (prevline, Qinvisible,
23039
f4262c9a21dd (vmotion): Don't use WINDOW for Fget_char_property
Richard M. Stallman <rms@gnu.org>
parents: 22560
diff changeset
1780 text_prop_object),
26404
c3c9cc1c2379 Remove USE_TEXT_PROPERTIES.
Gerd Moellmann <gerd@gnu.org>
parents: 25645
diff changeset
1781 TEXT_PROP_MEANS_INVISIBLE (propval))))
11811
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1782 XSETFASTINT (prevline,
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1783 find_next_newline_no_quit (XFASTINT (prevline) - 1,
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1784 -1));
8905
2ef3da79aabb (vmotion, Fvertical_motion): Fix Lisp_Object vs. int problems.
Karl Heuer <kwzh@gnu.org>
parents: 8648
diff changeset
1785 pos = *compute_motion (XFASTINT (prevline), 0,
11811
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1786 lmargin + (XFASTINT (prevline) == BEG
8905
2ef3da79aabb (vmotion, Fvertical_motion): Fix Lisp_Object vs. int problems.
Karl Heuer <kwzh@gnu.org>
parents: 8648
diff changeset
1787 ? start_hpos : 0),
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1788 0,
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1789 from,
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1790 /* Don't care for VPOS... */
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1791 1 << (BITS_PER_SHORT - 1),
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1792 /* ... nor HPOS. */
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1793 1 << (BITS_PER_SHORT - 1),
16926
3baea3418dec (pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents: 16395
diff changeset
1794 width, hscroll,
3baea3418dec (pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents: 16395
diff changeset
1795 (XFASTINT (prevline) == BEG ? -start_hpos : 0),
3baea3418dec (pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents: 16395
diff changeset
1796 w);
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1797 did_motion = 1;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1798 }
11811
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1799 else
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1800 {
11811
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1801 pos.hpos = lmargin + (from == BEG ? start_hpos : 0);
a0db528dfa1c (vmotion): Simplify. Replace last three args with a single
Karl Heuer <kwzh@gnu.org>
parents: 11704
diff changeset
1802 pos.vpos = 0;
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1803 pos.tab_offset = 0;
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1804 did_motion = 0;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1805 }
11853
6578a356c540 (compute_motion): Handle overlay strings.
Karl Heuer <kwzh@gnu.org>
parents: 11813
diff changeset
1806 return compute_motion (from, vpos, pos.hpos, did_motion,
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1807 ZV, vtarget, - (1 << (BITS_PER_SHORT - 1)),
16926
3baea3418dec (pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents: 16395
diff changeset
1808 width, hscroll,
17016
ded89d7e1575 (current_column_bol_cache): New variable. This makes
Karl Heuer <kwzh@gnu.org>
parents: 16926
diff changeset
1809 pos.tab_offset - (from == BEG ? start_hpos : 0),
16926
3baea3418dec (pos_tab_offset): Take the width of the minibuffer prompt into account.
Richard M. Stallman <rms@gnu.org>
parents: 16395
diff changeset
1810 w);
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1811 }
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1812
6327
d93a087868cb (Fvertical_motion): New optional arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents: 6296
diff changeset
1813 DEFUN ("vertical-motion", Fvertical_motion, Svertical_motion, 1, 2, 0,
15659
6e4665e4f807 (Fvertical_motion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 15609
diff changeset
1814 "Move point to start of the screen line LINES lines down.\n\
6e4665e4f807 (Fvertical_motion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 15609
diff changeset
1815 If LINES is negative, this means moving up.\n\
6e4665e4f807 (Fvertical_motion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 15609
diff changeset
1816 \n\
6e4665e4f807 (Fvertical_motion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 15609
diff changeset
1817 This function is an ordinary cursor motion function\n\
6e4665e4f807 (Fvertical_motion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 15609
diff changeset
1818 which calculates the new position based on how text would be displayed.\n\
6e4665e4f807 (Fvertical_motion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 15609
diff changeset
1819 The new position may be the start of a line,\n\
6e4665e4f807 (Fvertical_motion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 15609
diff changeset
1820 or just the start of a continuation line.\n\
6e4665e4f807 (Fvertical_motion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 15609
diff changeset
1821 The function returns number of screen lines moved over;\n\
6e4665e4f807 (Fvertical_motion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 15609
diff changeset
1822 that usually equals LINES, but may be closer to zero\n\
6e4665e4f807 (Fvertical_motion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 15609
diff changeset
1823 if beginning or end of buffer was reached.\n\
6846
a6803ff29cca (compute_motion): Do not abort if window shows some other buffer.
Richard M. Stallman <rms@gnu.org>
parents: 6811
diff changeset
1824 \n\
a6803ff29cca (compute_motion): Do not abort if window shows some other buffer.
Richard M. Stallman <rms@gnu.org>
parents: 6811
diff changeset
1825 The optional second argument WINDOW specifies the window to use for\n\
a6803ff29cca (compute_motion): Do not abort if window shows some other buffer.
Richard M. Stallman <rms@gnu.org>
parents: 6811
diff changeset
1826 parameters such as width, horizontal scrolling, and so on.\n\
15659
6e4665e4f807 (Fvertical_motion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 15609
diff changeset
1827 The default is to use the selected window's parameters.\n\
6846
a6803ff29cca (compute_motion): Do not abort if window shows some other buffer.
Richard M. Stallman <rms@gnu.org>
parents: 6811
diff changeset
1828 \n\
15659
6e4665e4f807 (Fvertical_motion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 15609
diff changeset
1829 `vertical-motion' always uses the current buffer,\n\
6e4665e4f807 (Fvertical_motion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 15609
diff changeset
1830 regardless of which buffer is displayed in WINDOW.\n\
6e4665e4f807 (Fvertical_motion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 15609
diff changeset
1831 This is consistent with other cursor motion functions\n\
6e4665e4f807 (Fvertical_motion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 15609
diff changeset
1832 and makes it possible to use `vertical-motion' in any buffer,\n\
6e4665e4f807 (Fvertical_motion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 15609
diff changeset
1833 whether or not it is currently displayed in some window.")
6327
d93a087868cb (Fvertical_motion): New optional arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents: 6296
diff changeset
1834 (lines, window)
d93a087868cb (Fvertical_motion): New optional arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents: 6296
diff changeset
1835 Lisp_Object lines, window;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1836 {
25028
ab513f624bc6 (Fvertical_motion): Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 24828
diff changeset
1837 struct it it;
ab513f624bc6 (Fvertical_motion): Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 24828
diff changeset
1838 struct text_pos pt;
ab513f624bc6 (Fvertical_motion): Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 24828
diff changeset
1839 struct window *w;
28293
14eccbd25cae (Fvertical_motion): Always use the current buffer.
Gerd Moellmann <gerd@gnu.org>
parents: 26859
diff changeset
1840 Lisp_Object old_buffer;
14eccbd25cae (Fvertical_motion): Always use the current buffer.
Gerd Moellmann <gerd@gnu.org>
parents: 26859
diff changeset
1841 struct gcpro gcpro1;
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1842
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1843 CHECK_NUMBER (lines, 0);
6327
d93a087868cb (Fvertical_motion): New optional arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents: 6296
diff changeset
1844 if (! NILP (window))
d93a087868cb (Fvertical_motion): New optional arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents: 6296
diff changeset
1845 CHECK_WINDOW (window, 0);
d93a087868cb (Fvertical_motion): New optional arg WINDOW.
Richard M. Stallman <rms@gnu.org>
parents: 6296
diff changeset
1846 else
8905
2ef3da79aabb (vmotion, Fvertical_motion): Fix Lisp_Object vs. int problems.
Karl Heuer <kwzh@gnu.org>
parents: 8648
diff changeset
1847 window = selected_window;
28293
14eccbd25cae (Fvertical_motion): Always use the current buffer.
Gerd Moellmann <gerd@gnu.org>
parents: 26859
diff changeset
1848 w = XWINDOW (window);
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1849
28293
14eccbd25cae (Fvertical_motion): Always use the current buffer.
Gerd Moellmann <gerd@gnu.org>
parents: 26859
diff changeset
1850 old_buffer = Qnil;
14eccbd25cae (Fvertical_motion): Always use the current buffer.
Gerd Moellmann <gerd@gnu.org>
parents: 26859
diff changeset
1851 GCPRO1 (old_buffer);
14eccbd25cae (Fvertical_motion): Always use the current buffer.
Gerd Moellmann <gerd@gnu.org>
parents: 26859
diff changeset
1852 if (XBUFFER (w->buffer) != current_buffer)
25028
ab513f624bc6 (Fvertical_motion): Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 24828
diff changeset
1853 {
28293
14eccbd25cae (Fvertical_motion): Always use the current buffer.
Gerd Moellmann <gerd@gnu.org>
parents: 26859
diff changeset
1854 /* Set the window's buffer temporarily to the current buffer. */
14eccbd25cae (Fvertical_motion): Always use the current buffer.
Gerd Moellmann <gerd@gnu.org>
parents: 26859
diff changeset
1855 old_buffer = w->buffer;
14eccbd25cae (Fvertical_motion): Always use the current buffer.
Gerd Moellmann <gerd@gnu.org>
parents: 26859
diff changeset
1856 XSETBUFFER (w->buffer, current_buffer);
25028
ab513f624bc6 (Fvertical_motion): Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 24828
diff changeset
1857 }
ab513f624bc6 (Fvertical_motion): Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 24828
diff changeset
1858
ab513f624bc6 (Fvertical_motion): Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 24828
diff changeset
1859 SET_TEXT_POS (pt, PT, PT_BYTE);
ab513f624bc6 (Fvertical_motion): Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 24828
diff changeset
1860 start_display (&it, w, pt);
ab513f624bc6 (Fvertical_motion): Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 24828
diff changeset
1861 move_it_by_lines (&it, XINT (lines), 0);
ab513f624bc6 (Fvertical_motion): Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 24828
diff changeset
1862 SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1863
28293
14eccbd25cae (Fvertical_motion): Always use the current buffer.
Gerd Moellmann <gerd@gnu.org>
parents: 26859
diff changeset
1864 if (BUFFERP (old_buffer))
14eccbd25cae (Fvertical_motion): Always use the current buffer.
Gerd Moellmann <gerd@gnu.org>
parents: 26859
diff changeset
1865 w->buffer = old_buffer;
25028
ab513f624bc6 (Fvertical_motion): Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 24828
diff changeset
1866
28293
14eccbd25cae (Fvertical_motion): Always use the current buffer.
Gerd Moellmann <gerd@gnu.org>
parents: 26859
diff changeset
1867 RETURN_UNGCPRO (make_number (it.vpos));
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1868 }
25028
ab513f624bc6 (Fvertical_motion): Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 24828
diff changeset
1869
ab513f624bc6 (Fvertical_motion): Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 24828
diff changeset
1870
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1871
9407
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1872 /* file's initialization. */
4dcc0221b449 * indent.c: #include "region-cache.h".
Jim Blandy <jimb@redhat.com>
parents: 9310
diff changeset
1873
21514
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21496
diff changeset
1874 void
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1875 syms_of_indent ()
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1876 {
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1877 DEFVAR_BOOL ("indent-tabs-mode", &indent_tabs_mode,
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1878 "*Indentation can insert tabs if this is non-nil.\n\
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1879 Setting this variable automatically makes it local to the current buffer.");
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1880 indent_tabs_mode = 1;
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1881
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1882 defsubr (&Scurrent_indentation);
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1883 defsubr (&Sindent_to);
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1884 defsubr (&Scurrent_column);
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1885 defsubr (&Smove_to_column);
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1886 defsubr (&Svertical_motion);
6296
a1b438e4754b (compute_motion): Initialize prev_hpos.
Richard M. Stallman <rms@gnu.org>
parents: 6092
diff changeset
1887 defsubr (&Scompute_motion);
165
ee44492a4419 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1888 }