aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/buffer.h')
-rw-r--r--src/buffer.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/buffer.h b/src/buffer.h
index abb1294d038..9875b8a447b 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1523,6 +1523,45 @@ lowercasep (int c)
1523 return !uppercasep (c) && upcase (c) != c; 1523 return !uppercasep (c) && upcase (c) != c;
1524} 1524}
1525 1525
1526/* Return a non-outlandish value for the tab width. */
1527
1528INLINE int
1529sanitize_tab_width (Lisp_Object width)
1530{
1531 return (FIXNUMP (width) && 0 < XFIXNUM (width) && XFIXNUM (width) <= 1000
1532 ? XFIXNUM (width) : 8);
1533}
1534
1535INLINE int
1536SANE_TAB_WIDTH (struct buffer *buf)
1537{
1538 return sanitize_tab_width (BVAR (buf, tab_width));
1539}
1540
1541/* Return a non-outlandish value for a character width. */
1542
1543INLINE int
1544sanitize_char_width (EMACS_INT width)
1545{
1546 return 0 <= width && width <= 1000 ? width : 1000;
1547}
1548
1549/* Return the width of character C. The width is measured by how many
1550 columns C will occupy on the screen when displayed in the current
1551 buffer. The name CHARACTER_WIDTH avoids a collision with <limits.h>
1552 CHAR_WIDTH. */
1553
1554INLINE int
1555CHARACTER_WIDTH (int c)
1556{
1557 return (0x20 <= c && c < 0x7f ? 1
1558 : 0x7f < c ? (sanitize_char_width
1559 (XFIXNUM (CHAR_TABLE_REF (Vchar_width_table, c))))
1560 : c == '\t' ? SANE_TAB_WIDTH (current_buffer)
1561 : c == '\n' ? 0
1562 : !NILP (BVAR (current_buffer, ctl_arrow)) ? 2 : 4);
1563}
1564
1526INLINE_HEADER_END 1565INLINE_HEADER_END
1527 1566
1528#endif /* EMACS_BUFFER_H */ 1567#endif /* EMACS_BUFFER_H */