diff options
| author | Eli Zaretskii | 2024-09-09 14:28:12 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2024-09-09 14:28:12 +0300 |
| commit | 03e56981675c9533f844257bc7f0bc5603bb58fa (patch) | |
| tree | e42dbe05d4f7494aadf7884fbf6197c2128af93a | |
| parent | 9f0603207b17084563c73f271c397c0c469bf3e9 (diff) | |
| download | emacs-03e56981675c9533f844257bc7f0bc5603bb58fa.tar.gz emacs-03e56981675c9533f844257bc7f0bc5603bb58fa.zip | |
Clarify the semantics of 'string-pixel-width'
* doc/lispref/display.texi (Size of Displayed Text):
* lisp/emacs-lisp/subr-x.el (string-pixel-width):
* src/xdisp.c (Fwindow_text_pixel_size, Fbuffer_text_pixel_size):
Doc fixes. (Bug#73129)
| -rw-r--r-- | doc/lispref/display.texi | 8 | ||||
| -rw-r--r-- | lisp/emacs-lisp/subr-x.el | 6 | ||||
| -rw-r--r-- | src/xdisp.c | 4 |
3 files changed, 13 insertions, 5 deletions
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index 9a43ad0568a..c0fbde5d96a 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi | |||
| @@ -2238,7 +2238,7 @@ displayed in a given window. This function is used by | |||
| 2238 | it contains. | 2238 | it contains. |
| 2239 | 2239 | ||
| 2240 | @defun window-text-pixel-size &optional window from to x-limit y-limit mode-lines ignore-line-at-end | 2240 | @defun window-text-pixel-size &optional window from to x-limit y-limit mode-lines ignore-line-at-end |
| 2241 | This function returns the size of the text of @var{window}'s buffer in | 2241 | This function returns the dimensions of the text of @var{window}'s buffer in |
| 2242 | pixels. @var{window} must be a live window and defaults to the | 2242 | pixels. @var{window} must be a live window and defaults to the |
| 2243 | selected one. The return value is a cons of the maximum pixel-width | 2243 | selected one. The return value is a cons of the maximum pixel-width |
| 2244 | of any text line and the maximum pixel-height of all text lines. This | 2244 | of any text line and the maximum pixel-height of all text lines. This |
| @@ -2387,7 +2387,11 @@ meaning as with @code{window-text-pixel-size}. | |||
| 2387 | 2387 | ||
| 2388 | @defun string-pixel-width string | 2388 | @defun string-pixel-width string |
| 2389 | This is a convenience function that uses @code{window-text-pixel-size} | 2389 | This is a convenience function that uses @code{window-text-pixel-size} |
| 2390 | to compute the width of @var{string} (in pixels). | 2390 | to compute the width of @var{string} (in pixels). Caveat: if you call |
| 2391 | this function to measure the width of a string with embedded newlines, | ||
| 2392 | it will then return the width of the widest substring that does not | ||
| 2393 | include newlines. The meaning of this result is the widest line taken | ||
| 2394 | by the string if inserted into a buffer. | ||
| 2391 | @end defun | 2395 | @end defun |
| 2392 | 2396 | ||
| 2393 | @defun line-pixel-height | 2397 | @defun line-pixel-height |
diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el index e725c490aba..d5ed934f805 100644 --- a/lisp/emacs-lisp/subr-x.el +++ b/lisp/emacs-lisp/subr-x.el | |||
| @@ -338,7 +338,11 @@ This construct can only be used with lexical binding." | |||
| 338 | 338 | ||
| 339 | ;;;###autoload | 339 | ;;;###autoload |
| 340 | (defun string-pixel-width (string) | 340 | (defun string-pixel-width (string) |
| 341 | "Return the width of STRING in pixels." | 341 | "Return the width of STRING in pixels. |
| 342 | |||
| 343 | If you call this function to measure pixel width of a string | ||
| 344 | with embedded newlines, it returns the width of the widest | ||
| 345 | substring that does not include newlines." | ||
| 342 | (declare (important-return-value t)) | 346 | (declare (important-return-value t)) |
| 343 | (if (zerop (length string)) | 347 | (if (zerop (length string)) |
| 344 | 0 | 348 | 0 |
diff --git a/src/xdisp.c b/src/xdisp.c index 5add42ef11b..bf7d84cdcb7 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -11774,7 +11774,7 @@ window_text_pixel_size (Lisp_Object window, Lisp_Object from, Lisp_Object to, | |||
| 11774 | } | 11774 | } |
| 11775 | 11775 | ||
| 11776 | DEFUN ("window-text-pixel-size", Fwindow_text_pixel_size, Swindow_text_pixel_size, 0, 7, 0, | 11776 | DEFUN ("window-text-pixel-size", Fwindow_text_pixel_size, Swindow_text_pixel_size, 0, 7, 0, |
| 11777 | doc: /* Return the size of the text of WINDOW's buffer in pixels. | 11777 | doc: /* Return the dimensions of the text of WINDOW's buffer in pixels. |
| 11778 | WINDOW must be a live window and defaults to the selected one. The | 11778 | WINDOW must be a live window and defaults to the selected one. The |
| 11779 | return value is a cons of the maximum pixel-width of any text line and | 11779 | return value is a cons of the maximum pixel-width of any text line and |
| 11780 | the pixel-height of all the text lines in the accessible portion of | 11780 | the pixel-height of all the text lines in the accessible portion of |
| @@ -11854,7 +11854,7 @@ screen line that includes TO to the returned height of the text. */) | |||
| 11854 | } | 11854 | } |
| 11855 | 11855 | ||
| 11856 | DEFUN ("buffer-text-pixel-size", Fbuffer_text_pixel_size, Sbuffer_text_pixel_size, 0, 4, 0, | 11856 | DEFUN ("buffer-text-pixel-size", Fbuffer_text_pixel_size, Sbuffer_text_pixel_size, 0, 4, 0, |
| 11857 | doc: /* Return size of whole text of BUFFER-OR-NAME in WINDOW. | 11857 | doc: /* Return the dimensions of whole text of BUFFER-OR-NAME in WINDOW. |
| 11858 | BUFFER-OR-NAME must specify a live buffer or the name of a live buffer | 11858 | BUFFER-OR-NAME must specify a live buffer or the name of a live buffer |
| 11859 | and defaults to the current buffer. WINDOW must be a live window and | 11859 | and defaults to the current buffer. WINDOW must be a live window and |
| 11860 | defaults to the selected one. The return value is a cons of the maximum | 11860 | defaults to the selected one. The return value is a cons of the maximum |