* Richard M. Stallman (2005-06-27) writes: > If you only wanted it in read-only buffers, we could perhaps turn it > on by default in those buffers. If you want it to be available in any > buffer, we'd have to make it a minor mode, and you'd get it only when > you explicitly ask.
I think it would be nice to have a user option or another convenient way (e.g. a hook) for enabling the mode automatically in read-only buffers. But the criterion "read-only" is probably too wide to trigger the mode in all cases, so it might be better to simply activate the mode via the mode hooks of modes in which scroll locking should be enabled, e.g. Info mode or Woman mode. > 1) Using a special symbol for `scroll-preserve-screen-position'. > Setting it e.g. to 'always would preserve screen position of point > for any scroll command, even those which would not move point out > of the visible portion of the buffer. The behavior you get when > setting the variable to t would stay as is. > > That would be ok with me. Attached you can find a patch for window.c and an updated scroll-lock.el file corresponding to the changes in window.c. Here is a ChangeLog entry for the window.c changes: 2005-06-29 Ralf Angeli <[EMAIL PROTECTED]> * window.c (Qalways): New variable. (syms_of_window): Initialize it. (window_scroll_pixel_based, window_scroll_line_based): Preserve screen position of point if `scroll-preserve-screen-position' is set to 'always. (scroll-preserve-screen-position): Document 'always value. An open issue is the key binding for toggling the mode. If the minor mode should be able to be activated in some major modes but not in others, it doesn't make much sense to bind this to the Scroll Lock key which in my understanding means to enable or disable it globally (not just for Emacs but for other applications aware of it as well). So my idea was to make Scroll Lock minor mode a local mode and add e.g. `C-x %' as a key binding for toggling it. The binding seems not be used throughout the Emacs code base (according to some grepping I did in the lisp/ directory). And the % character looks a little bit like scrolls in a shelf. In addition it could be an option to give the mode a different name in order to avoid confusion about the mode not being accessible via the Scroll Lock key. -- Ralf
--- window.c 21 Jun 2005 11:29:47 -0000 1.505 +++ window.c 29 Jun 2005 10:50:21 -0000 @@ -51,6 +51,7 @@ Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_configuration_p; Lisp_Object Qwindow_size_fixed; +Lisp_Object Qalways; extern Lisp_Object Qleft_margin, Qright_margin; static int displayed_window_lines P_ ((struct window *)); @@ -4783,7 +4784,8 @@ /* We moved the window start towards ZV, so PT may be now in the scroll margin at the top. */ move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS); - if (IT_CHARPOS (it) == PT && it.current_y >= this_scroll_margin) + if (IT_CHARPOS (it) == PT && it.current_y >= this_scroll_margin + && !EQ (Vscroll_preserve_screen_position, Qalways)) /* We found PT at a legitimate height. Leave it alone. */ ; else if (preserve_y >= 0) @@ -4836,7 +4838,8 @@ partial_p = it.current_y > it.last_visible_y; } - if (charpos == PT && !partial_p) + if (charpos == PT && !partial_p + && !EQ (Vscroll_preserve_screen_position, Qalways)) /* We found PT before we found the display margin, so PT is ok. */ ; else if (preserve_y >= 0) @@ -4951,7 +4954,8 @@ the window-scroll-functions. */ w->force_start = Qt; - if (whole && !NILP (Vscroll_preserve_screen_position)) + if ((whole && !NILP (Vscroll_preserve_screen_position)) + || EQ (Vscroll_preserve_screen_position, Qalways)) { SET_PT_BOTH (pos, pos_byte); Fvertical_motion (make_number (original_vpos), window); @@ -6738,6 +6742,9 @@ minibuf_selected_window = Qnil; staticpro (&minibuf_selected_window); + Qalways = intern ("always"); + staticpro (&Qalways); + DEFVAR_LISP ("temp-buffer-show-function", &Vtemp_buffer_show_function, doc: /* Non-nil means call as function to display a help buffer. The function is called with one argument, the buffer to be displayed. @@ -6914,9 +6921,13 @@ DEFVAR_LISP ("scroll-preserve-screen-position", &Vscroll_preserve_screen_position, - doc: /* *Non-nil means scroll commands move point to keep its screen line unchanged. -This is only when it is impossible to keep point fixed and still -scroll as specified. */); + doc: /* *Controls if scroll commands move point to keep its screen line unchanged. +A value of nil means point does not keep its screen position except +at the scroll margin or window boundary respectively. +A value of t means point keeps its screen position if the scroll +command moved it vertically out of the window, e.g. when scrolling +by full screens. +A value of `always' means point always keeps its screen position. */); Vscroll_preserve_screen_position = Qnil; DEFVAR_LISP ("window-configuration-change-hook",
scroll-lock.el
Description: application/emacs-lisp
_______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel