aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2023-07-31 11:11:23 -0400
committerEli Zaretskii2023-07-31 11:11:23 -0400
commit30bcd71476127fa20da37372501637b07cd53d6c (patch)
treebdb5c57ee12255ba0de15a57ba90f354e2c326dc /src
parent38bbfdee62d9cccaadd76135c396df1a2e5982fa (diff)
parent525d05c1b8ac54a4f7ad166b97f2fa913f80e73c (diff)
downloademacs-30bcd71476127fa20da37372501637b07cd53d6c.tar.gz
emacs-30bcd71476127fa20da37372501637b07cd53d6c.zip
Merge from origin/emacs-29
525d05c1b8a Merge branch 'emacs-29' of git.savannah.gnu.org:/srv/git/... 29ef2157116 ; * lisp/textmodes/paragraphs.el: Remove leftover comment. 80c9f491fc8 Update to Org 9.6.7-5-gd1d0c3 735f3700f65 ; * src/character.c (Fstring_width): Fix last change. bf83fdba9e3 ; * src/character.c (Fstring_width, Fchar_width): Doc fixes. 1198cdb5567 Merge branch 'emacs-29' of git.sv.gnu.org:/srv/git/emacs ... 2b8796eea19 Fix rx wrong-code bug: ranges starting with ^ ba60070b81c Backport: Fix some tree-sitter :match regexps 092a2ecb083 ; * admin/make-tarball.txt: Update based on latest experi... 7b9e83d3cf9 Fix bug#64923 0002d4f3166 Avoid spurious whitespace in the modeline of emacsclient ... 96d52f89444 Fix function help for advised aliases (bug#64797) 71419a60c37 Avoid crashes due to invalid 'mode-line-format' b2cb6e82160 ; Better documentation of HOME on MS-Windows 54e98b5f9bd ; Clarify documentation of 'server-after-make-frame-hook' d13029cdcde Avoid crashes under 'which-key-mode' cb1f7db2490 ; Minor documentation fixes 4a687bcc20d Bump Emacs version
Diffstat (limited to 'src')
-rw-r--r--src/character.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/src/character.c b/src/character.c
index 9389e1c0098..f4164360f21 100644
--- a/src/character.c
+++ b/src/character.c
@@ -260,8 +260,12 @@ char_width (int c, struct Lisp_Char_Table *dp)
260 260
261 261
262DEFUN ("char-width", Fchar_width, Schar_width, 1, 1, 0, 262DEFUN ("char-width", Fchar_width, Schar_width, 1, 1, 0,
263 doc: /* Return width of CHAR when displayed in the current buffer. 263 doc: /* Return width of CHAR in columns when displayed in the current buffer.
264The width is measured by how many columns it occupies on the screen. 264The width of CHAR is measured by how many columns it will occupy on the screen.
265This is based on data in `char-width-table', and ignores the actual
266metrics of the character's glyph as determined by its font.
267If the display table in effect replaces CHAR on display with
268something else, the function returns the width of the replacement.
265Tab is taken to occupy `tab-width' columns. 269Tab is taken to occupy `tab-width' columns.
266usage: (char-width CHAR) */) 270usage: (char-width CHAR) */)
267 (Lisp_Object ch) 271 (Lisp_Object ch)
@@ -457,20 +461,26 @@ lisp_string_width (Lisp_Object string, ptrdiff_t from, ptrdiff_t to,
457} 461}
458 462
459DEFUN ("string-width", Fstring_width, Sstring_width, 1, 3, 0, 463DEFUN ("string-width", Fstring_width, Sstring_width, 1, 3, 0,
460 doc: /* Return width of STRING when displayed in the current buffer. 464 doc: /* Return width of STRING in columns when displayed in the current buffer.
461Width is measured by how many columns it occupies on the screen. 465Width of STRING is measured by how many columns it will occupy on the screen.
466
462Optional arguments FROM and TO specify the substring of STRING to 467Optional arguments FROM and TO specify the substring of STRING to
463consider, and are interpreted as in `substring'. 468consider, and are interpreted as in `substring'.
464 469
465When calculating width of a multibyte character in STRING, 470Width of each character in STRING is generally taken according to
466only the base leading-code is considered; the validity of 471`char-width', but character compositions and the display table in
467the following bytes is not checked. Tabs in STRING are always 472effect are taken into consideration.
468taken to occupy `tab-width' columns. The effect of faces and fonts 473Tabs in STRING are always assumed to occupy `tab-width' columns,
469used for non-Latin and other unusual characters (such as emoji) is 474although they might take fewer columns depending on the column where
470ignored as well, as are display properties and invisible text. 475they begin on display.
471For these reasons, the results are not generally reliable; 476The effect of faces and fonts, including fonts used for non-Latin and
472for accurate dimensions of text as it will be displayed, 477other unusual characters, such as emoji, is ignored, as are display
473use `string-pixel-width' or `window-text-pixel-size' instead. 478properties and invisible text.
479
480For these reasons, the results are just an approximation, especially
481on GUI frames; for accurate dimensions of text as it will be
482displayed, use `string-pixel-width' or `window-text-pixel-size'
483instead.
474usage: (string-width STRING &optional FROM TO) */) 484usage: (string-width STRING &optional FROM TO) */)
475 (Lisp_Object str, Lisp_Object from, Lisp_Object to) 485 (Lisp_Object str, Lisp_Object from, Lisp_Object to)
476{ 486{