summaryrefslogtreecommitdiff
path: root/src/window.c
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2022-04-27 18:14:56 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2022-04-27 18:15:34 -0400
commitafd3619b86ddf42c0591d394d95a7510758eaffb (patch)
tree07e8a3c63809ad352ebb435c072ecefcd2055c04 /src/window.c
parent134f4ff38b323af8892520200307e9d54ae90200 (diff)
downloademacs-afd3619b86ddf42c0591d394d95a7510758eaffb.tar.gz
src/xdisp.c: Use same test in `redisplay_window` and `prepare_menu_bars`
This consolidates the test made in those two functions so as to make sure they agree whether a window needs to be redisplayed. At the same time, change this test so it uses the window's point rather than the buffer's point when comparing to `w->last_point`. * src/xdisp.c (needs_no_redisplay): New function, extracted from `redisplay_window`. (redisplay_window, prepare_menu_bars): Use it. * src/window.c (window_point): New function, extracted from `Fwindow_point`. (Fwindow_point): Use it. * src/window.h (window_point): Declare it.
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/window.c b/src/window.c
index 4cca60e23d9..48da7839314 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1692,6 +1692,14 @@ column 0. */)
0, false, false);
}
+ptrdiff_t
+window_point (struct window *w)
+{
+ return (w == XWINDOW (selected_window)
+ ? BUF_PT (XBUFFER (w->contents))
+ : XMARKER (w->pointm)->charpos);
+}
+
DEFUN ("window-point", Fwindow_point, Swindow_point, 0, 1, 0,
doc: /* Return current value of point in WINDOW.
WINDOW must be a live window and defaults to the selected one.
@@ -1705,12 +1713,7 @@ correct to return the top-level value of `point', outside of any
`save-excursion' forms. But that is hard to define. */)
(Lisp_Object window)
{
- register struct window *w = decode_live_window (window);
-
- if (w == XWINDOW (selected_window))
- return make_fixnum (BUF_PT (XBUFFER (w->contents)));
- else
- return Fmarker_position (w->pointm);
+ return make_fixnum (window_point (decode_live_window (window)));
}
DEFUN ("window-old-point", Fwindow_old_point, Swindow_old_point, 0, 1, 0,