I think you should separate out the clear and redisplay functionality as well,
like force-redisplay, and then move recenter into Lisp. Come to think of it, the
various functions that cause redisplay to happen (such as force-redisplay and
redraw-frame) have too much overlapping functionality and need to be thought out
more clearly.
Hrvoje Niksic wrote:
I don't know how about you, but for me it's terribly annoying
that C-l
redisplays the frame (I often use C-l to recenter the point). After
thinking about it for a while, I realized that under X I've *never*
really needed the "redisplay" side-effect of C-l.
This patch creates a new function `center-to-window-line' (analogous
to `move-to-window-line'), and makes `recenter' use that internally.
The advantage is that you can, if you desire, bind C-l to this new
function and avoid the redisplay flicker.
1998-04-30 Hrvoje Niksic <hniksic(a)srce.hr>
* window.c (Fcenter_to_window_line): New function.
(Frecenter): Use it.
--- etc/NEWS.orig Thu Apr 30 04:38:19 1998
+++ etc/NEWS Thu Apr 30 04:39:50 1998
@@ -50,6 +50,9 @@
(setq echo-keystrokes 0.1)
+** The new command `center-to-window-line' works like `recenter'
+(bound to `C-l'), only it does not redisplay the whole display area.
+
** The `M-.' command will now first search through exact tags matches,
and then through inexact matches, as one would expect.
--- src/window.c.orig Thu Apr 30 04:03:19 1998
+++ src/window.c Thu Apr 30 04:52:48 1998
@@ -1371,9 +1371,8 @@
*/
(window))
{
- struct window *w;
+ struct window *w = decode_window (window);
- w = decode_window (window);
return (WINDOW_HAS_MODELINE_P (w)) ? make_int (w->modeline_hscroll) : Qnil;
}
@@ -1384,12 +1383,11 @@
*/
(window, ncol))
{
- struct window *w;
- int ncols;
+ struct window *w = decode_window (window);
- w = decode_window (window);
if (WINDOW_HAS_MODELINE_P (w))
{
+ int ncols;
CHECK_INT (ncol);
ncols = XINT (ncol);
if (ncols < 0) ncols = 0;
@@ -4188,47 +4186,24 @@
return Fset_window_hscroll (window, make_int (w->hscroll - XINT (arg)));
}
-DEFUN ("recenter", Frecenter, 0, 2, "_P", /*
-Center point in WINDOW and redisplay frame. With N, put point on line N.
+DEFUN ("center-to-window-line", Fcenter_to_window_line, 0, 2, "_P",
/*
+Center point in WINDOW. With N, put point on line N.
The desired position of point is always relative to the window.
-Just C-u as prefix means put point in the center of the window.
-No N (i.e., it is nil) erases the entire frame and then
-redraws with point in the center of the window.
If WINDOW is nil, the selected window is used.
*/
(n, window))
{
- struct window *w;
- struct buffer *b;
+ struct window *w = decode_window (window);
+ struct buffer *b = XBUFFER (w->buffer);
+ Bufpos opoint = BUF_PT (b);
Bufpos startp;
- Bufpos opoint;
- if (NILP (window))
- window = Fselected_window (Qnil);
- else
- CHECK_WINDOW (window);
- w = XWINDOW (window);
- b = XBUFFER (w->buffer);
-
- opoint = BUF_PT (b);
-
- if (LISTP (n))
- {
- struct frame *f = XFRAME (w->frame);
-
- if (NILP (n))
- {
- MARK_FRAME_CHANGED (f);
- SET_FRAME_CLEAR (f);
- }
-
- startp = start_with_line_at_pixpos (w, opoint, window_half_pixpos (w));
- }
+ if (NILP (n))
+ startp = start_with_line_at_pixpos (w, opoint, window_half_pixpos (w));
else
{
n = Fprefix_numeric_value (n);
CHECK_INT (n);
-
startp = start_with_point_on_display_line (w, opoint, XINT (n));
}
@@ -4239,6 +4214,29 @@
MARK_WINDOWS_CHANGED (w);
return Qnil;
}
+
+DEFUN ("recenter", Frecenter, 0, 2, "_P", /*
+Center point in WINDOW and redisplay frame. With N, put point on line N.
+The desired position of point is always relative to the window.
+Just C-u as prefix means put point in the center of the window.
+No N (i.e., it is nil) erases the entire frame and then
+redraws with point in the center of the window.
+If WINDOW is nil, the selected window is used.
+*/
+ (n, window))
+{
+ if (NILP (n))
+ {
+ struct frame *f = XFRAME (decode_window (window)->frame);
+ MARK_FRAME_CHANGED (f);
+ SET_FRAME_CLEAR (f);
+ }
+ else if (CONSP (n))
+ n = Qnil;
+ Fcenter_to_window_line (n, window);
+ return Qnil;
+}
+
DEFUN ("move-to-window-line", Fmove_to_window_line, 1, 2, "_P", /*
Position point relative to WINDOW.
@@ -4255,6 +4253,8 @@
Bufpos start, new_point;
int selected;
+ /* Don't use decode_window() because we need the new value of
+ WINDOW. */
if (NILP (window))
window = Fselected_window (Qnil);
else
@@ -5568,6 +5568,7 @@
DEFSUBR (Fscroll_right);
DEFSUBR (Fother_window_for_scrolling);
DEFSUBR (Fscroll_other_window);
+ DEFSUBR (Fcenter_to_window_line);
DEFSUBR (Frecenter);
DEFSUBR (Fmove_to_window_line);
#ifdef MEMORY_USAGE_STATS
--
Hrvoje Niksic <hniksic(a)srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
A radioactive cat has eighteen half-lives.
--
This message composed using voice recognition software and foot pedals.
(No keyboards were harmed while composing this message.)