diff options
| author | Eli Zaretskii | 2019-04-06 11:22:13 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2019-04-06 11:22:13 +0300 |
| commit | a30a6c3019ac09ede1cc47671083b2e9ecdbffdf (patch) | |
| tree | 7ea60b51caf504fc472e4b83b3766935d5ed1535 | |
| parent | 92ce2dd48bd3f31b848f0258ad79af01a7197b44 (diff) | |
| download | emacs-a30a6c3019ac09ede1cc47671083b2e9ecdbffdf.tar.gz emacs-a30a6c3019ac09ede1cc47671083b2e9ecdbffdf.zip | |
Improve documentation of set-window-start
* doc/lispref/windows.texi (Window Start and End):
* src/window.c (Fset_window_start): Document that reliable
setting of a window start position requires to adjust point to
be visible. (Bug#34038)
| -rw-r--r-- | doc/lispref/windows.texi | 22 | ||||
| -rw-r--r-- | src/window.c | 7 |
2 files changed, 21 insertions, 8 deletions
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi index 27940e12c79..f4395c12d26 100644 --- a/doc/lispref/windows.texi +++ b/doc/lispref/windows.texi | |||
| @@ -4625,13 +4625,14 @@ This function sets the display-start position of @var{window} to | |||
| 4625 | @var{position} in @var{window}'s buffer. It returns @var{position}. | 4625 | @var{position} in @var{window}'s buffer. It returns @var{position}. |
| 4626 | 4626 | ||
| 4627 | The display routines insist that the position of point be visible when a | 4627 | The display routines insist that the position of point be visible when a |
| 4628 | buffer is displayed. Normally, they change the display-start position | 4628 | buffer is displayed. Normally, they select the display-start position |
| 4629 | (that is, scroll the window) whenever necessary to make point visible. | 4629 | according to their internal logic (and scroll the window if necessary) |
| 4630 | However, if you specify the start position with this function using | 4630 | to make point visible. However, if you specify the start position |
| 4631 | @code{nil} for @var{noforce}, it means you want display to start at | 4631 | with this function using @code{nil} for @var{noforce}, it means you |
| 4632 | @var{position} even if that would put the location of point off the | 4632 | want display to start at @var{position} even if that would put the |
| 4633 | screen. If this does place point off screen, the display routines move | 4633 | location of point off the screen. If this does place point off |
| 4634 | point to the left margin on the middle line in the window. | 4634 | screen, the display routines attempt to move point to the left margin |
| 4635 | on the middle line in the window. | ||
| 4635 | 4636 | ||
| 4636 | For example, if point @w{is 1} and you set the start of the window | 4637 | For example, if point @w{is 1} and you set the start of the window |
| 4637 | @w{to 37}, the start of the next line, point will be above the top | 4638 | @w{to 37}, the start of the next line, point will be above the top |
| @@ -4678,6 +4679,13 @@ it is still 1 when redisplay occurs. Here is an example: | |||
| 4678 | @end group | 4679 | @end group |
| 4679 | @end example | 4680 | @end example |
| 4680 | 4681 | ||
| 4682 | If the attempt to make point visible (i.e., in a fully-visible screen | ||
| 4683 | line) fails, the display routines will disregard the requested | ||
| 4684 | window-start position and compute a new one anyway. Thus, for | ||
| 4685 | reliable results Lisp programs that call this function should always | ||
| 4686 | move point to be inside the window whose display starts at | ||
| 4687 | @var{position}. | ||
| 4688 | |||
| 4681 | If @var{noforce} is non-@code{nil}, and @var{position} would place point | 4689 | If @var{noforce} is non-@code{nil}, and @var{position} would place point |
| 4682 | off screen at the next redisplay, then redisplay computes a new window-start | 4690 | off screen at the next redisplay, then redisplay computes a new window-start |
| 4683 | position that works well with point, and thus @var{position} is not used. | 4691 | position that works well with point, and thus @var{position} is not used. |
diff --git a/src/window.c b/src/window.c index 04183abb7c5..dfac3b5b879 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -1704,7 +1704,12 @@ DEFUN ("set-window-start", Fset_window_start, Sset_window_start, 2, 3, 0, | |||
| 1704 | doc: /* Make display in WINDOW start at position POS in WINDOW's buffer. | 1704 | doc: /* Make display in WINDOW start at position POS in WINDOW's buffer. |
| 1705 | WINDOW must be a live window and defaults to the selected one. Return | 1705 | WINDOW must be a live window and defaults to the selected one. Return |
| 1706 | POS. Optional third arg NOFORCE non-nil inhibits next redisplay from | 1706 | POS. Optional third arg NOFORCE non-nil inhibits next redisplay from |
| 1707 | overriding motion of point in order to display at this exact start. */) | 1707 | overriding motion of point in order to display at this exact start. |
| 1708 | |||
| 1709 | For reliable setting of WINDOW start position, make sure point is | ||
| 1710 | at a position that will be visible when that start is in effect, | ||
| 1711 | otherwise there's a chance POS will be disregarded, e.g., if point | ||
| 1712 | winds up in a partially-visible line. */) | ||
| 1708 | (Lisp_Object window, Lisp_Object pos, Lisp_Object noforce) | 1713 | (Lisp_Object window, Lisp_Object pos, Lisp_Object noforce) |
| 1709 | { | 1714 | { |
| 1710 | register struct window *w = decode_live_window (window); | 1715 | register struct window *w = decode_live_window (window); |