characters immediately following, then *NEXT_BOUNDARY_P
will equal the return value. */
-static int
+int
skip_invisible (pos, next_boundary_p, to, window)
int pos;
int *next_boundary_p;
\f
/* Set variables WIDTH and BYTES for a multibyte sequence starting at P.
- C is *P which should satisfy `BASE_LEADING_CODE_P (c)'.
-
DP is a display table or NULL.
This macro is used in current_column_1, Fmove_to_column, and
compute_motion. */
-#define MULTIBYTE_BYTES_WIDTH(p, c, dp) \
- do { \
- unsigned char *pend = p + 1; \
- \
- wide_column = 0; \
- while (! CHAR_HEAD_P (*pend)) pend++; \
- \
- if (c == LEADING_CODE_COMPOSITION) \
- { \
- int id = str_cmpchar_id (p, pend - p); \
- int ch = MAKE_COMPOSITE_CHAR (id); \
- \
- if (id >= 0) \
- { \
- bytes = cmpchar_table[id]->len; \
- if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, ch))) \
- width = XVECTOR (DISP_CHAR_VECTOR (dp, ch))->size; \
- else \
- width = cmpchar_table[id]->width; \
- if (width > 1) \
- wide_column = width; \
- } \
- else \
- { \
- bytes = 1; \
- width = 4; \
- } \
- } \
- else \
- { \
- bytes = BYTES_BY_CHAR_HEAD (c); \
- if (bytes >= 2 && bytes <= pend - p) \
- { \
- int ch = STRING_CHAR (p, bytes); \
- \
- if (CHAR_VALID_P (ch, 0)) \
- { \
- if (dp && VECTORP (DISP_CHAR_VECTOR (dp, ch))) \
- width = XVECTOR (DISP_CHAR_VECTOR (dp, ch))->size; \
- else \
- width = WIDTH_BY_CHAR_HEAD (c); \
- } \
- else \
- width = bytes * 4; \
- if (width > 1) \
- wide_column = width; \
- } \
- else \
- { \
- bytes = 1; \
- width = 4; \
- } \
- } \
- if (p + bytes < pend) \
- { \
- width += 4 * (pend - (p + bytes)); \
- bytes = pend - p; \
- } \
+#define MULTIBYTE_BYTES_WIDTH(p, dp) \
+ do { \
+ int c; \
+ \
+ wide_column = 0; \
+ c = STRING_CHAR_AND_LENGTH (p, MAX_LENGTH_OF_MULTI_BYTE_FORM, bytes); \
+ if (BYTES_BY_CHAR_HEAD (*p) != bytes) \
+ width = bytes * 4; \
+ else \
+ { \
+ if (dp != 0 && VECTORP (DISP_CHAR_VECTOR (dp, c))) \
+ width = XVECTOR (DISP_CHAR_VECTOR (dp, c))->size; \
+ else \
+ width = WIDTH_BY_CHAR_HEAD (*p); \
+ if (width > 1) \
+ wide_column = width; \
+ } \
} while (0)
DEFUN ("current-column", Fcurrent_column, Scurrent_column, 0, 0, 0,
scan_byte--;
ptr = BYTE_POS_ADDR (scan_byte);
- MULTIBYTE_BYTES_WIDTH (ptr, c, dp);
+ MULTIBYTE_BYTES_WIDTH (ptr, dp);
scan_byte += bytes;
col += width;
}
\n\
If specified column is within a character, point goes after that character.\n\
If it's past end of line, point goes to end of line.\n\n\
-A non-nil second (optional) argument FORCE means, if the line\n\
-is too short to reach column COLUMN then add spaces/tabs to get there,\n\
-and if COLUMN is in the middle of a tab character, change it to spaces.\n\
+A non-nil second (optional) argument FORCE means,\n\
+if COLUMN is in the middle of a tab character, change it to spaces.\n\
+In addition, if FORCE is t, and the line is too short\n\
+to reach column COLUMN, add spaces/tabs to get there.\n\
\n\
The return value is the current column.")
(column, force)
pos_byte--;
ptr = BYTE_POS_ADDR (pos_byte);
- MULTIBYTE_BYTES_WIDTH (ptr, c, dp);
+ MULTIBYTE_BYTES_WIDTH (ptr, dp);
pos_byte += bytes;
col += width;
}
}
/* If line ends prematurely, add space to the end. */
- if (col < goal && !NILP (force))
+ if (col < goal && EQ (force, Qt))
Findent_to (make_number (col = goal), Qnil);
last_known_column = col;
pos_byte--; /* rewind POS_BYTE */
ptr = BYTE_POS_ADDR (pos_byte);
- MULTIBYTE_BYTES_WIDTH (ptr, c, dp);
+ MULTIBYTE_BYTES_WIDTH (ptr, dp);
pos_byte += bytes;
if (wide_column)
wide_column_end_hpos = hpos + wide_column;
return &val_compute_motion;
}
+
#if 0 /* The doc string is too long for some compilers,
but make-docfile can find it in this comment. */
DEFUN ("compute-motion", Ffoo, Sfoo, 7, 7, 0,
CHECK_NUMBER_COERCE_MARKER (from, 0);
CHECK_CONS (frompos, 0);
- CHECK_NUMBER (XCONS (frompos)->car, 0);
- CHECK_NUMBER (XCONS (frompos)->cdr, 0);
+ CHECK_NUMBER (XCAR (frompos), 0);
+ CHECK_NUMBER (XCDR (frompos), 0);
CHECK_NUMBER_COERCE_MARKER (to, 0);
CHECK_CONS (topos, 0);
- CHECK_NUMBER (XCONS (topos)->car, 0);
- CHECK_NUMBER (XCONS (topos)->cdr, 0);
+ CHECK_NUMBER (XCAR (topos), 0);
+ CHECK_NUMBER (XCDR (topos), 0);
CHECK_NUMBER (width, 0);
if (!NILP (offsets))
{
CHECK_CONS (offsets, 0);
- CHECK_NUMBER (XCONS (offsets)->car, 0);
- CHECK_NUMBER (XCONS (offsets)->cdr, 0);
- hscroll = XINT (XCONS (offsets)->car);
- tab_offset = XINT (XCONS (offsets)->cdr);
+ CHECK_NUMBER (XCAR (offsets), 0);
+ CHECK_NUMBER (XCDR (offsets), 0);
+ hscroll = XINT (XCAR (offsets));
+ tab_offset = XINT (XCDR (offsets));
}
else
hscroll = tab_offset = 0;
if (XINT (to) < BEGV || XINT (to) > ZV)
args_out_of_range_3 (to, make_number (BEGV), make_number (ZV));
- pos = compute_motion (XINT (from), XINT (XCONS (frompos)->cdr),
- XINT (XCONS (frompos)->car), 0,
- XINT (to), XINT (XCONS (topos)->cdr),
- XINT (XCONS (topos)->car),
+ pos = compute_motion (XINT (from), XINT (XCDR (frompos)),
+ XINT (XCAR (frompos)), 0,
+ XINT (to), XINT (XCDR (topos)),
+ XINT (XCAR (topos)),
XINT (width), hscroll, tab_offset,
XWINDOW (window));
XSETWINDOW (window, w);
- /* The omission of the clause
- && marker_position (w->start) == BEG
- here is deliberate; I think we want to measure from the prompt
- position even if the minibuffer window has scrolled. */
- if (EQ (window, minibuf_window))
- {
- if (minibuf_prompt_width == 0 && STRINGP (minibuf_prompt))
- minibuf_prompt_width
- = string_display_width (minibuf_prompt, Qnil, Qnil);
-
- start_hpos = minibuf_prompt_width;
- }
-
/* If the window contains this buffer, use it for getting text properties.
Otherwise use the current buffer as arg for doing that. */
if (EQ (w->buffer, Fcurrent_buffer ()))
(lines, window)
Lisp_Object lines, window;
{
- struct position pos;
+ struct it it;
+ struct text_pos pt;
+ struct buffer *old, *b;
+ struct window *w;
CHECK_NUMBER (lines, 0);
if (! NILP (window))
else
window = selected_window;
- pos = *vmotion (PT, (int) XINT (lines), XWINDOW (window));
-
- SET_PT (pos.bufpos);
- return make_number (pos.vpos);
+ w = XWINDOW (window);
+ b = XBUFFER (w->buffer);
+ if (b != current_buffer)
+ {
+ old = current_buffer;
+ set_buffer_internal_1 (b);
+ }
+ else
+ old = NULL;
+
+ SET_TEXT_POS (pt, PT, PT_BYTE);
+ start_display (&it, w, pt);
+ move_it_by_lines (&it, XINT (lines), 0);
+ SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));
+
+ if (old)
+ set_buffer_internal_1 (old);
+
+ return make_number (it.vpos);
}
+
+
\f
/* file's initialization. */