unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r99831: Scrolling commands  which does not signal errors at top/bottom.
       [not found] <E1NywTs-00007U-Lf@internal.in.savannah.gnu.org>
@ 2010-04-06  0:51 ` Juanma Barranquero
  2010-04-06  0:59   ` Juri Linkov
  0 siblings, 1 reply; 22+ messages in thread
From: Juanma Barranquero @ 2010-04-06  0:51 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Emacs developers

On Tue, Apr 6, 2010 at 01:38, Juri Linkov <juri@jurta.org> wrote:

> +** New scrolling commands `scroll-up-command' and `scroll-down-command'
> +(bound to [next] and [prior]) does not signal errors at top/bottom
> +of buffer at first key-press (instead moves to top/bottom of buffer).

How do these commands interact with `scroll-preserve-screen-position'?

    Juanma




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r99831: Scrolling commands which does not signal errors at top/bottom.
  2010-04-06  0:51 ` [Emacs-diffs] /srv/bzr/emacs/trunk r99831: Scrolling commands which does not signal errors at top/bottom Juanma Barranquero
@ 2010-04-06  0:59   ` Juri Linkov
  2010-04-06  1:58     ` Juanma Barranquero
  0 siblings, 1 reply; 22+ messages in thread
From: Juri Linkov @ 2010-04-06  0:59 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: Emacs developers

> How do these commands interact with `scroll-preserve-screen-position'?

Exactly as documented in the docstring of `scroll-preserve-screen-position':

  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.

and in the Info manual:

     Some users like the full-screen scroll commands to keep point at the
  same screen position.  To enable this behavior, set the variable
  `scroll-preserve-screen-position' to a non-`nil' value.  Then, whenever
  a command scrolls the text around point offscreen (or within
                                          =========
  `scroll-margin' lines of the edge), Emacs moves point to keep it at the
  same vertical and horizontal position within the window.

i.e. this option doesn't apply when point stays on the same screen.

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r99831: Scrolling commands  which does not signal errors at top/bottom.
  2010-04-06  0:59   ` Juri Linkov
@ 2010-04-06  1:58     ` Juanma Barranquero
  2010-04-06 16:12       ` Juri Linkov
  0 siblings, 1 reply; 22+ messages in thread
From: Juanma Barranquero @ 2010-04-06  1:58 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Emacs developers

On Tue, Apr 6, 2010 at 02:59, Juri Linkov <juri@jurta.org> wrote:

> i.e. this option doesn't apply when point stays on the same screen.

Fine. I'm talking about the case when point does not stay in the same
screen. I mean, try

  emacs -Q --eval '(setq scroll-preserve-screen-position :always)'

with emacs-23 and trunk, by moving the cursor to the end of some line
in etc/NEWS and doing a few pg-up/pg-down, and I think you'll see the
difference.

    Juanma




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r99831: Scrolling commands which does not signal errors at top/bottom.
  2010-04-06  1:58     ` Juanma Barranquero
@ 2010-04-06 16:12       ` Juri Linkov
  2010-04-06 18:26         ` Juanma Barranquero
  0 siblings, 1 reply; 22+ messages in thread
From: Juri Linkov @ 2010-04-06 16:12 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: Emacs developers

> Fine. I'm talking about the case when point does not stay in the same
> screen. I mean, try
>
>   emacs -Q --eval '(setq scroll-preserve-screen-position :always)'
>
> with emacs-23 and trunk, by moving the cursor to the end of some line
> in etc/NEWS and doing a few pg-up/pg-down, and I think you'll see the
> difference.

This means a customizable option is still necessary:

=== modified file 'lisp/emulation/pc-select.el'
--- lisp/emulation/pc-select.el	2010-04-05 22:54:57 +0000
+++ lisp/emulation/pc-select.el	2010-04-06 16:12:36 +0000
@@ -93,6 +93,9 @@ (defcustom pc-select-override-scroll-err
 errors are suppressed."
   :type 'boolean
   :group 'pc-select)
+(define-obsolete-variable-alias 'pc-select-override-scroll-error
+                                'scroll-error-top-bottom
+                                "24.1")
 
 (defcustom pc-select-selection-keys-only nil
   "*Non-nil means only bind the basic selection keys when started.

=== modified file 'lisp/simple.el'
--- lisp/simple.el	2010-04-06 13:08:58 +0000
+++ lisp/simple.el	2010-04-06 16:12:02 +0000
@@ -4877,6 +4877,16 @@ (define-globalized-minor-mode global-vis
 ;;; of buffer at first key-press (instead moves to top/bottom
 ;;; of buffer).
 
+(defcustom scroll-error-top-bottom nil
+  "Move point to top/bottom of buffer before signalling a scrolling error.
+A value of nil means just signal an error if no more scrolling possible.
+A value of t means point moves to the beginning or the end of the buffer
+\(depending on scrolling direction) when no more scrolling possible.
+When point is already on that position, then signal an error."
+  :type 'boolean
+  :group 'scrolling
+  :version "24.1")
+
 (defun scroll-up-command (&optional arg)
   "Scroll text of selected window upward ARG lines; or near full screen if no ARG.
 If `scroll-up' cannot scroll window further, move cursor to the bottom line.
@@ -4886,6 +4896,8 @@ (defun scroll-up-command (&optional arg)
 If ARG is the atom `-', scroll downward by nearly full screen."
   (interactive "^P")
   (cond
+   ((null scroll-error-top-bottom)
+    (scroll-up arg))
    ((eq arg '-) (scroll-down-command nil))
    ((< (prefix-numeric-value arg) 0)
     (scroll-down-command (- (prefix-numeric-value arg))))
@@ -4914,11 +4926,13 @@ (defun scroll-down-command (&optional ar
 If ARG is the atom `-', scroll upward by nearly full screen."
   (interactive "^P")
   (cond
+   ((null scroll-error-top-bottom)
+    (scroll-down arg))
    ((eq arg '-) (scroll-up-command nil))
    ((< (prefix-numeric-value arg) 0)
     (scroll-up-command (- (prefix-numeric-value arg))))

=== modified file 'lisp/tutorial.el'
--- lisp/tutorial.el	2010-01-13 08:35:10 +0000
+++ lisp/tutorial.el	2010-04-06 16:10:38 +0000
@@ -218,8 +218,8 @@ (defconst tutorial--default-keys
              (save-buffers-kill-terminal [?\C-x ?\C-c])
 
              ;; * SUMMARY
-             (scroll-up [?\C-v])
-             (scroll-down [?\M-v])
+             (scroll-up-command [?\C-v])
+             (scroll-down-command [?\M-v])
              (recenter-top-bottom [?\C-l])
 
              ;; * BASIC CURSOR CONTROL

=== modified file 'src/window.c'
--- src/window.c	2010-04-05 22:54:57 +0000
+++ src/window.c	2010-04-06 16:09:50 +0000
@@ -7377,9 +7377,9 @@ (let ((edges (window-edges))) (- (nth 2 
   initial_define_key (control_x_map, '<', "scroll-left");
   initial_define_key (control_x_map, '>', "scroll-right");
 
-  initial_define_key (global_map, Ctl ('V'), "scroll-up");
+  initial_define_key (global_map, Ctl ('V'), "scroll-up-command");
   initial_define_key (meta_map, Ctl ('V'), "scroll-other-window");
-  initial_define_key (meta_map, 'v', "scroll-down");
+  initial_define_key (meta_map, 'v', "scroll-down-command");
 }
 
 /* arch-tag: 90a9c576-0590-48f1-a5f1-6c96a0452d9f

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r99831: Scrolling commands  which does not signal errors at top/bottom.
  2010-04-06 16:12       ` Juri Linkov
@ 2010-04-06 18:26         ` Juanma Barranquero
  2010-04-06 20:19           ` Juri Linkov
  0 siblings, 1 reply; 22+ messages in thread
From: Juanma Barranquero @ 2010-04-06 18:26 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Emacs developers

On Tue, Apr 6, 2010 at 18:12, Juri Linkov <juri@jurta.org> wrote:

> This means a customizable option is still necessary:

> +(defcustom scroll-error-top-bottom nil
> +  "Move point to top/bottom of buffer before signalling a scrolling error.
> +A value of nil means just signal an error if no more scrolling possible.
> +A value of t means point moves to the beginning or the end of the buffer
> +\(depending on scrolling direction) when no more scrolling possible.
> +When point is already on that position, then signal an error."
> +  :type 'boolean
> +  :group 'scrolling
> +  :version "24.1")

This fixes one problem, but not the other: scroll-(up|down)-command do
not preserve the column.

    Juanma




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r99831: Scrolling commands which does not signal errors at top/bottom.
  2010-04-06 18:26         ` Juanma Barranquero
@ 2010-04-06 20:19           ` Juri Linkov
  2010-04-06 20:49             ` Juanma Barranquero
  0 siblings, 1 reply; 22+ messages in thread
From: Juri Linkov @ 2010-04-06 20:19 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: Emacs developers

> This fixes one problem, but not the other: scroll-(up|down)-command do
> not preserve the column.

I see now what do you mean.  This patch takes care of that:

=== modified file 'lisp/simple.el'
--- lisp/simple.el	2010-04-05 19:08:58 +0000
+++ lisp/simple.el	2010-04-06 20:18:23 +0000
@@ -4877,6 +4877,16 @@ (define-globalized-minor-mode global-vis
 ;;; of buffer at first key-press (instead moves to top/bottom
 ;;; of buffer).
 
+(defcustom scroll-error-top-bottom nil
+  "Move point to top/bottom of buffer before signalling a scrolling error.
+A value of nil means just signal an error if no more scrolling possible.
+A value of t means point moves to the beginning or the end of the buffer
+\(depending on scrolling direction) when no more scrolling possible.
+When point is already on that position, then signal an error."
+  :type 'boolean
+  :group 'scrolling
+  :version "24.1")
+
 (defun scroll-up-command (&optional arg)
   "Scroll text of selected window upward ARG lines; or near full screen if no ARG.
 If `scroll-up' cannot scroll window further, move cursor to the bottom line.
@@ -4886,6 +4896,8 @@ (defun scroll-up-command (&optional arg)
 If ARG is the atom `-', scroll downward by nearly full screen."
   (interactive "^P")
   (cond
+   ((null scroll-error-top-bottom)
+    (scroll-up arg))
    ((eq arg '-) (scroll-down-command nil))
    ((< (prefix-numeric-value arg) 0)
     (scroll-down-command (- (prefix-numeric-value arg))))
@@ -4893,7 +4905,14 @@ (defun scroll-up-command (&optional arg)
     (scroll-up arg))  ; signal error
    (t
     (condition-case nil
-	(scroll-up arg)
+	(progn
+	  (when (and scroll-preserve-screen-position
+		     (not (eq scroll-preserve-screen-position t)))
+	    (setq temporary-goal-column
+		  (if (and track-eol (eolp) (not (bolp)))
+		      most-positive-fixnum
+		    (current-column))))
+	  (scroll-up arg))
       (end-of-buffer
        (if arg
 	   ;; When scrolling by ARG lines can't be done,
@@ -4901,7 +4920,10 @@ (defun scroll-up-command (&optional arg)
 	   (forward-line arg)
 	 ;; When ARG is nil for full-screen scrolling,
 	 ;; move to the bottom of the buffer.
-	 (goto-char (point-max))))))))
+	 (goto-char (point-max))
+	 (when (and scroll-preserve-screen-position
+		    (not (eq scroll-preserve-screen-position t)))
+	   (line-move-to-column (truncate temporary-goal-column)))))))))
 
 (put 'scroll-up-command 'isearch-scroll t)
 
@@ -4914,6 +4936,8 @@ (defun scroll-down-command (&optional ar
 If ARG is the atom `-', scroll upward by nearly full screen."
   (interactive "^P")
   (cond
+   ((null scroll-error-top-bottom)
+    (scroll-down arg))
    ((eq arg '-) (scroll-up-command nil))
    ((< (prefix-numeric-value arg) 0)
     (scroll-up-command (- (prefix-numeric-value arg))))
@@ -4921,7 +4945,14 @@ (defun scroll-down-command (&optional ar
     (scroll-down arg))  ; signal error
    (t
     (condition-case nil
-	(scroll-down arg)
+	(progn
+	  (when (and scroll-preserve-screen-position
+		     (not (eq scroll-preserve-screen-position t)))
+	    (setq temporary-goal-column
+		  (if (and track-eol (eolp) (not (bolp)))
+		      most-positive-fixnum
+		    (current-column))))
+	  (scroll-down arg))
       (beginning-of-buffer
        (if arg
 	   ;; When scrolling by ARG lines can't be done,
@@ -4929,7 +4960,10 @@ (defun scroll-down-command (&optional ar
 	   (forward-line (- arg))
 	 ;; When ARG is nil for full-screen scrolling,
 	 ;; move to the top of the buffer.
-	 (goto-char (point-min))))))))
+	 (goto-char (point-min))
+	 (when (and scroll-preserve-screen-position
+		    (not (eq scroll-preserve-screen-position t)))
+	   (line-move-to-column (truncate temporary-goal-column)))))))))
 
 (put 'scroll-down-command 'isearch-scroll t)
 

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r99831: Scrolling commands  which does not signal errors at top/bottom.
  2010-04-06 20:19           ` Juri Linkov
@ 2010-04-06 20:49             ` Juanma Barranquero
  2010-04-06 21:06               ` Juri Linkov
  0 siblings, 1 reply; 22+ messages in thread
From: Juanma Barranquero @ 2010-04-06 20:49 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Emacs developers

On Tue, Apr 6, 2010 at 22:19, Juri Linkov <juri@jurta.org> wrote:

> I see now what do you mean.  This patch takes care of that:

Not exactly. On emacs-23, go to a long line and do:

  C-e <next> <next> <next>  ...  ; until you reach a line shorter than
the original one
  ... <prior> <prior> <prior>         ; point is still at end of line

That does not happen with your patch, AFAICS.

    Juanma




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r99831: Scrolling commands which does not signal errors at top/bottom.
  2010-04-06 20:49             ` Juanma Barranquero
@ 2010-04-06 21:06               ` Juri Linkov
  2010-04-06 21:39                 ` Juanma Barranquero
  0 siblings, 1 reply; 22+ messages in thread
From: Juri Linkov @ 2010-04-06 21:06 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: Emacs developers

>> I see now what do you mean.  This patch takes care of that:
>
> Not exactly. On emacs-23, go to a long line and do:
>
>   C-e <next> <next> <next>  ...  ; until you reach a line shorter than
> the original one
>   ... <prior> <prior> <prior>         ; point is still at end of line
>
> That does not happen with your patch, AFAICS.

Then additionally you need this patch:

=== modified file 'src/window.c'
--- src/window.c	2010-04-05 22:54:57 +0000
+++ src/window.c	2010-04-06 21:05:45 +0000
@@ -54,7 +54,7 @@ (at your option) any later version.
 
 Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_configuration_p;
 Lisp_Object Qdisplay_buffer;
-Lisp_Object Qscroll_up, Qscroll_down;
+Lisp_Object Qscroll_up, Qscroll_down, Qscroll_up_command, Qscroll_down_command;
 Lisp_Object Qwindow_size_fixed;
 
 extern Lisp_Object Qleft_margin, Qright_margin;
@@ -4947,7 +4947,9 @@ (let ((edges (window-edges))) (- (nth 2 
 	 scrolling by one line.  */
       if (window_scroll_pixel_based_preserve_y < 0
 	  || (!EQ (current_kboard->Vlast_command, Qscroll_up)
-	      && !EQ (current_kboard->Vlast_command, Qscroll_down)))
+	      && !EQ (current_kboard->Vlast_command, Qscroll_down)
+	      && !EQ (current_kboard->Vlast_command, Qscroll_up_command)
+	      && !EQ (current_kboard->Vlast_command, Qscroll_down_command)))
 	{
 	  start_display (&it, w, start);
 	  move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS);
@@ -5208,7 +5210,9 @@ (let ((edges (window-edges))) (- (nth 2 
     {
       if (window_scroll_preserve_vpos <= 0
 	  || (!EQ (current_kboard->Vlast_command, Qscroll_up)
-	      && !EQ (current_kboard->Vlast_command, Qscroll_down)))
+	      && !EQ (current_kboard->Vlast_command, Qscroll_down)
+	      && !EQ (current_kboard->Vlast_command, Qscroll_up_command)
+	      && !EQ (current_kboard->Vlast_command, Qscroll_down_command)))
 	{
 	  struct position posit
 	    = *compute_motion (startpos, 0, 0, 0,
@@ -7176,6 +7180,12 @@ (let ((edges (window-edges))) (- (nth 2 
   Qscroll_down = intern_c_string ("scroll-down");
   staticpro (&Qscroll_down);
 
+  Qscroll_up_command = intern_c_string ("scroll-up-command");
+  staticpro (&Qscroll_up_command);
+
+  Qscroll_down_command = intern_c_string ("scroll-down-command");
+  staticpro (&Qscroll_down_command);
+
   Qwindow_size_fixed = intern_c_string ("window-size-fixed");
   staticpro (&Qwindow_size_fixed);
   Fset (Qwindow_size_fixed, Qnil);
@@ -7377,9 +7387,9 @@ (let ((edges (window-edges))) (- (nth 2 
   initial_define_key (control_x_map, '<', "scroll-left");
   initial_define_key (control_x_map, '>', "scroll-right");
 
-  initial_define_key (global_map, Ctl ('V'), "scroll-up");
+  initial_define_key (global_map, Ctl ('V'), "scroll-up-command");
   initial_define_key (meta_map, Ctl ('V'), "scroll-other-window");
-  initial_define_key (meta_map, 'v', "scroll-down");
+  initial_define_key (meta_map, 'v', "scroll-down-command");
 }
 
 /* arch-tag: 90a9c576-0590-48f1-a5f1-6c96a0452d9f

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r99831: Scrolling commands  which does not signal errors at top/bottom.
  2010-04-06 21:06               ` Juri Linkov
@ 2010-04-06 21:39                 ` Juanma Barranquero
  2010-04-06 21:47                   ` Juanma Barranquero
  0 siblings, 1 reply; 22+ messages in thread
From: Juanma Barranquero @ 2010-04-06 21:39 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Emacs developers

On Tue, Apr 6, 2010 at 23:06, Juri Linkov <juri@jurta.org> wrote:

> Then additionally you need this patch:

Yes, now it works as expected.  Thanks.

    Juanma




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r99831: Scrolling commands  which does not signal errors at top/bottom.
  2010-04-06 21:39                 ` Juanma Barranquero
@ 2010-04-06 21:47                   ` Juanma Barranquero
  2010-04-07 20:17                     ` Juri Linkov
  0 siblings, 1 reply; 22+ messages in thread
From: Juanma Barranquero @ 2010-04-06 21:47 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Emacs developers

> Yes, now it works as expected.

BTW, it's less important, but it would be nice if
scroll-(up|down)-line also obeyed `scroll-preserve-screen-position'.

    Juanma




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r99831: Scrolling commands which does not signal errors at top/bottom.
  2010-04-06 21:47                   ` Juanma Barranquero
@ 2010-04-07 20:17                     ` Juri Linkov
  2010-04-07 22:16                       ` Juanma Barranquero
  2010-04-09 15:29                       ` Stefan Monnier
  0 siblings, 2 replies; 22+ messages in thread
From: Juri Linkov @ 2010-04-07 20:17 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: Emacs developers

> BTW, it's less important, but it would be nice if
> scroll-(up|down)-line also obeyed `scroll-preserve-screen-position'.

`mwheel-scroll' disobeys `scroll-preserve-screen-position' too.  I think
it would be wrong to add all possible scrolling commands to this code:

          && !EQ (current_kboard->Vlast_command, Qscroll_up)))
          && !EQ (current_kboard->Vlast_command, Qscroll_down)
          && !EQ (current_kboard->Vlast_command, Qscroll_up_command)
          && !EQ (current_kboard->Vlast_command, Qscroll_down_command)))

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r99831: Scrolling commands  which does not signal errors at top/bottom.
  2010-04-07 20:17                     ` Juri Linkov
@ 2010-04-07 22:16                       ` Juanma Barranquero
  2010-04-07 23:19                         ` Juri Linkov
  2010-04-09 15:29                       ` Stefan Monnier
  1 sibling, 1 reply; 22+ messages in thread
From: Juanma Barranquero @ 2010-04-07 22:16 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Emacs developers

> `mwheel-scroll' disobeys `scroll-preserve-screen-position' too.

I would consider that a bug, too. The docstring for
`scroll-preserve-screen-position' does talk about "scroll commands".
The reason the option exists, I think, is because some of us find the
non-preserving behavior quite unbearable (I used Mikael Sjödin's
pager.el for years because I found the standard scroll-(up|down)
commands almost unusable).

> I think
> it would be wrong to add all possible scrolling commands to this code:

Why? Perhaps it should be implemented differently, but that's not the
same as being "wrong".

    Juanma




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r99831: Scrolling commands which does not signal errors at top/bottom.
  2010-04-07 22:16                       ` Juanma Barranquero
@ 2010-04-07 23:19                         ` Juri Linkov
  2010-04-07 23:35                           ` Juanma Barranquero
  0 siblings, 1 reply; 22+ messages in thread
From: Juri Linkov @ 2010-04-07 23:19 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: Emacs developers

>> `mwheel-scroll' disobeys `scroll-preserve-screen-position' too.
>
> I would consider that a bug, too. The docstring for
> `scroll-preserve-screen-position' does talk about "scroll commands".
> The reason the option exists, I think, is because some of us find the
> non-preserving behavior quite unbearable (I used Mikael Sjödin's
> pager.el for years because I found the standard scroll-(up|down)
> commands almost unusable).

I have a 1997-year copy of pager.el (not sure if later versions exist).
It contains the variable `pager-keep-column-commands' that defines
a list of scrolling commands that keep the current column.

Maybe `scroll-up-command' and `scroll-down-command' should use a similar
list.  And then `mwheel-scroll' and scroll-(up|down)-line should call
`scroll-(up|down)-command' instead of `scroll-(up|down)'.

>> I think
>> it would be wrong to add all possible scrolling commands to this code:
>
> Why? Perhaps it should be implemented differently, but that's not the
> same as being "wrong".

By "wrong" I meant that window.c is the wrong place to implement this.

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r99831: Scrolling commands  which does not signal errors at top/bottom.
  2010-04-07 23:19                         ` Juri Linkov
@ 2010-04-07 23:35                           ` Juanma Barranquero
  0 siblings, 0 replies; 22+ messages in thread
From: Juanma Barranquero @ 2010-04-07 23:35 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Emacs developers

On Thu, Apr 8, 2010 at 01:19, Juri Linkov <juri@jurta.org> wrote:

> I have a 1997-year copy of pager.el (not sure if later versions exist).

I think that release (2.0, 97-10-06) is the last.

> Maybe `scroll-up-command' and `scroll-down-command' should use a similar
> list.  And then `mwheel-scroll' and scroll-(up|down)-line should call
> `scroll-(up|down)-command' instead of `scroll-(up|down)'.

Seems like a good idea. And cua-scroll-(up|down) obeying s-p-s-p too
would be the icing on the cake.

> By "wrong" I meant that window.c is the wrong place to implement this.

Ah, OK. Agreed.

    Juanma




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r99831: Scrolling commands which does not signal errors at top/bottom.
  2010-04-07 20:17                     ` Juri Linkov
  2010-04-07 22:16                       ` Juanma Barranquero
@ 2010-04-09 15:29                       ` Stefan Monnier
  2010-04-09 22:46                         ` Juri Linkov
  1 sibling, 1 reply; 22+ messages in thread
From: Stefan Monnier @ 2010-04-09 15:29 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Juanma Barranquero, Emacs developers

> `mwheel-scroll' disobeys `scroll-preserve-screen-position' too.  I think
> it would be wrong to add all possible scrolling commands to this code:

>           && !EQ (current_kboard->Vlast_command, Qscroll_up)))
>           && !EQ (current_kboard->Vlast_command, Qscroll_down)
>           && !EQ (current_kboard->Vlast_command, Qscroll_up_command)
>           && !EQ (current_kboard->Vlast_command, Qscroll_down_command)))

Please add a new variable so we can do

            && NILP (Fmemq (current_kboard->Vlast_command, Vnewvariable))

and let Lisp packages add their commands to that variable.


        Stefan




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r99831: Scrolling commands which does not signal errors at top/bottom.
  2010-04-09 15:29                       ` Stefan Monnier
@ 2010-04-09 22:46                         ` Juri Linkov
  2010-04-10 14:51                           ` Stefan Monnier
  0 siblings, 1 reply; 22+ messages in thread
From: Juri Linkov @ 2010-04-09 22:46 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Juanma Barranquero, Emacs developers

[-- Attachment #1: Type: text/plain, Size: 261 bytes --]

> Please add a new variable so we can do
>
>             && NILP (Fmemq (current_kboard->Vlast_command, Vnewvariable))
>
> and let Lisp packages add their commands to that variable.

A new variable is added in this patch (that includes other changes as well):


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: scroll.patch --]
[-- Type: text/x-diff, Size: 9430 bytes --]

=== modified file 'src/window.c'
--- src/window.c	2010-03-31 02:08:05 +0000
+++ src/window.c	2010-04-09 22:42:06 +0000
@@ -168,6 +168,10 @@
 
 Lisp_Object Vscroll_preserve_screen_position;
 
+/* List of commands affected by `Vscroll_preserve_screen_position'.  */
+
+Lisp_Object Vscroll_preserve_screen_position_commands;
+
 /* Non-nil means that text is inserted before window's markers.  */
 
 Lisp_Object Vwindow_point_insertion_type;
@@ -4946,8 +4950,8 @@
 	 possibility of point becoming "stuck" on a tall line when
 	 scrolling by one line.  */
       if (window_scroll_pixel_based_preserve_y < 0
-	  || (!EQ (current_kboard->Vlast_command, Qscroll_up)
-	      && !EQ (current_kboard->Vlast_command, Qscroll_down)))
+	  || NILP (Fmemq (current_kboard->Vlast_command,
+			  Vscroll_preserve_screen_position_commands)))
 	{
 	  start_display (&it, w, start);
 	  move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS);
@@ -5207,8 +5211,8 @@
   if (!NILP (Vscroll_preserve_screen_position))
     {
       if (window_scroll_preserve_vpos <= 0
-	  || (!EQ (current_kboard->Vlast_command, Qscroll_up)
-	      && !EQ (current_kboard->Vlast_command, Qscroll_down)))
+	  || NILP (Fmemq (current_kboard->Vlast_command,
+			  Vscroll_preserve_screen_position_commands)))
 	{
 	  struct position posit
 	    = *compute_motion (startpos, 0, 0, 0,
@@ -7265,9 +7269,19 @@
 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.
-Any other value means point always keeps its screen position.  */);
+Any other value means point always keeps its screen position.
+Scroll commands are defined by the variable
+`scroll-preserve-screen-position-commands'.  */);
   Vscroll_preserve_screen_position = Qnil;
 
+  DEFVAR_LISP ("scroll-preserve-screen-position-commands",
+	       &Vscroll_preserve_screen_position_commands,
+	       doc: /* A list of commands whose scrolling should keep screen position unchanged.
+This list defines the names of scroll commands affected by the variable
+`scroll-preserve-screen-position'.  */);
+  Vscroll_preserve_screen_position_commands =
+    Fcons (Qscroll_down, Fcons (Qscroll_up, Qnil));
+
   DEFVAR_LISP ("window-point-insertion-type", &Vwindow_point_insertion_type,
 	       doc: /* Type of marker to use for `window-point'.  */);
   Vwindow_point_insertion_type = Qnil;
@@ -7377,9 +7391,9 @@
   initial_define_key (control_x_map, '<', "scroll-left");
   initial_define_key (control_x_map, '>', "scroll-right");
 
-  initial_define_key (global_map, Ctl ('V'), "scroll-up");
+  initial_define_key (global_map, Ctl ('V'), "scroll-up-command");
   initial_define_key (meta_map, Ctl ('V'), "scroll-other-window");
-  initial_define_key (meta_map, 'v', "scroll-down");
+  initial_define_key (meta_map, 'v', "scroll-down-command");
 }
 
 /* arch-tag: 90a9c576-0590-48f1-a5f1-6c96a0452d9f

=== modified file 'lisp/mwheel.el'
--- lisp/mwheel.el	2010-01-13 08:35:10 +0000
+++ lisp/mwheel.el	2010-04-09 22:30:53 +0000
@@ -246,6 +246,8 @@ (defun mwheel-scroll (event)
 	  (run-with-timer mouse-wheel-inhibit-click-time nil
 			  'mwheel-inhibit-click-timeout))))
 
+(add-to-list 'scroll-preserve-screen-position-commands 'mwheel-scroll)
+
 (defvar mwheel-installed-bindings nil)
 
 ;; preloaded ;;;###autoload

=== modified file 'lisp/simple.el'
--- lisp/simple.el	2010-04-05 23:44:24 +0000
+++ lisp/simple.el	2010-04-09 22:37:09 +0000
@@ -4744,6 +4877,16 @@ (define-globalized-minor-mode global-vis
 ;;; of buffer at first key-press (instead moves to top/bottom
 ;;; of buffer).
 
+(defcustom scroll-error-top-bottom nil
+  "Move point to top/bottom of buffer before signalling a scrolling error.
+A value of nil means just signal an error if no more scrolling possible.
+A value of t means point moves to the beginning or the end of the buffer
+\(depending on scrolling direction) when no more scrolling possible.
+When point is already on that position, then signal an error."
+  :type 'boolean
+  :group 'scrolling
+  :version "24.1")
+
 (defun scroll-up-command (&optional arg)
   "Scroll text of selected window upward ARG lines; or near full screen if no ARG.
 If `scroll-up' cannot scroll window further, move cursor to the bottom line.
@@ -4753,6 +4896,8 @@ (defun scroll-up-command (&optional arg)
 If ARG is the atom `-', scroll downward by nearly full screen."
   (interactive "^P")
   (cond
+   ((null scroll-error-top-bottom)
+    (scroll-up arg))
    ((eq arg '-) (scroll-down-command nil))
    ((< (prefix-numeric-value arg) 0)
     (scroll-down-command (- (prefix-numeric-value arg))))
@@ -4771,6 +4916,7 @@ (defun scroll-up-command (&optional arg)
 	 (goto-char (point-max))))))))
 
 (put 'scroll-up-command 'isearch-scroll t)
+(add-to-list 'scroll-preserve-screen-position-commands 'scroll-up-command)
 
 (defun scroll-down-command (&optional arg)
   "Scroll text of selected window down ARG lines; or near full screen if no ARG.
@@ -4781,6 +4927,8 @@ (defun scroll-down-command (&optional ar
 If ARG is the atom `-', scroll upward by nearly full screen."
   (interactive "^P")
   (cond
+   ((null scroll-error-top-bottom)
+    (scroll-down arg))
    ((eq arg '-) (scroll-up-command nil))
    ((< (prefix-numeric-value arg) 0)
     (scroll-up-command (- (prefix-numeric-value arg))))
@@ -4799,6 +4947,7 @@ (defun scroll-down-command (&optional ar
 	 (goto-char (point-min))))))))
 
 (put 'scroll-down-command 'isearch-scroll t)
+(add-to-list 'scroll-preserve-screen-position-commands 'scroll-down-command)
 
 ;;; Scrolling commands which scroll a line instead of full screen.
 
@@ -4810,6 +4959,7 @@ (defun scroll-up-line (&optional arg)
   (scroll-up (or arg 1)))
 
 (put 'scroll-up-line 'isearch-scroll t)
+(add-to-list 'scroll-preserve-screen-position-commands 'scroll-up-line)
 
 (defun scroll-down-line (&optional arg)
   "Scroll text of selected window down ARG lines; or one line if no ARG.
@@ -4819,6 +4969,7 @@ (defun scroll-down-line (&optional arg)
   (scroll-down (or arg 1)))
 
 (put 'scroll-down-line 'isearch-scroll t)
+(add-to-list 'scroll-preserve-screen-position-commands 'scroll-down-line)
 
 \f
 (defun scroll-other-window-down (lines)

=== modified file 'lisp/emulation/pc-select.el'
--- lisp/emulation/pc-select.el	2010-03-12 17:47:22 +0000
+++ lisp/emulation/pc-select.el	2010-04-06 23:17:36 +0000
@@ -93,6 +93,9 @@ (defcustom pc-select-override-scroll-err
 errors are suppressed."
   :type 'boolean
   :group 'pc-select)
+(define-obsolete-variable-alias 'pc-select-override-scroll-error
+                                'scroll-error-top-bottom
+                                "24.1")
 
 (defcustom pc-select-selection-keys-only nil
   "*Non-nil means only bind the basic selection keys when started.

=== modified file 'lisp/tutorial.el'
--- lisp/tutorial.el	2010-01-13 08:35:10 +0000
+++ lisp/tutorial.el	2010-04-06 23:10:38 +0000
@@ -218,8 +218,8 @@ (defconst tutorial--default-keys
              (save-buffers-kill-terminal [?\C-x ?\C-c])
 
              ;; * SUMMARY
-             (scroll-up [?\C-v])
-             (scroll-down [?\M-v])
+             (scroll-up-command [?\C-v])
+             (scroll-down-command [?\M-v])
              (recenter-top-bottom [?\C-l])
 
              ;; * BASIC CURSOR CONTROL

=== modified file 'lisp/image-mode.el'
--- lisp/image-mode.el	2010-03-10 14:01:48 +0000
+++ lisp/image-mode.el	2010-04-09 22:31:42 +0000
@@ -302,6 +302,8 @@ (defvar image-mode-map
     (define-key map [remap next-line] 'image-next-line)
     (define-key map [remap scroll-up] 'image-scroll-up)
     (define-key map [remap scroll-down] 'image-scroll-down)
+    (define-key map [remap scroll-up-command] 'image-scroll-up)
+    (define-key map [remap scroll-down-command] 'image-scroll-down)
     (define-key map [remap move-beginning-of-line] 'image-bol)
     (define-key map [remap move-end-of-line] 'image-eol)
     (define-key map [remap beginning-of-buffer] 'image-bob)

=== modified file 'lisp/emulation/cua-rect.el'
--- lisp/emulation/cua-rect.el	2010-01-13 08:35:10 +0000
+++ lisp/emulation/cua-rect.el	2010-04-09 22:30:27 +0000
@@ -1432,6 +1432,8 @@ (defun cua--init-rectangles ()
   (define-key cua--rectangle-keymap [remap beginning-of-buffer] 'cua-resize-rectangle-top)
   (define-key cua--rectangle-keymap [remap scroll-down]         'cua-resize-rectangle-page-up)
   (define-key cua--rectangle-keymap [remap scroll-up]           'cua-resize-rectangle-page-down)
+  (define-key cua--rectangle-keymap [remap scroll-down-command] 'cua-resize-rectangle-page-up)
+  (define-key cua--rectangle-keymap [remap scroll-up-command]   'cua-resize-rectangle-page-down)
 
   (define-key cua--rectangle-keymap [remap delete-backward-char] 'cua-delete-char-rectangle)
   (define-key cua--rectangle-keymap [remap backward-delete-char] 'cua-delete-char-rectangle)

=== modified file 'lisp/forms.el'
--- lisp/forms.el	2010-01-13 08:35:10 +0000
+++ lisp/forms.el	2010-04-09 22:31:08 +0000
@@ -1407,7 +1407,9 @@ (defun forms--change-commands ()
   (if forms-forms-scroll
       (progn
 	(local-set-key [remap scroll-up] 'forms-next-record)
-	(local-set-key [remap scroll-down] 'forms-prev-record)))
+	(local-set-key [remap scroll-down] 'forms-prev-record)
+	(local-set-key [remap scroll-up-command] 'forms-next-record)
+	(local-set-key [remap scroll-down-command] 'forms-prev-record)))
   ;;
   ;; beginning-of-buffer -> forms-first-record
   ;; end-of-buffer -> forms-end-record

[-- Attachment #3: Type: text/plain, Size: 45 bytes --]


-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r99831: Scrolling commands which does not signal errors at top/bottom.
  2010-04-09 22:46                         ` Juri Linkov
@ 2010-04-10 14:51                           ` Stefan Monnier
  2010-04-14 16:49                             ` Juri Linkov
  0 siblings, 1 reply; 22+ messages in thread
From: Stefan Monnier @ 2010-04-10 14:51 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Juanma Barranquero, Emacs developers

>> Please add a new variable so we can do
>> && NILP (Fmemq (current_kboard->Vlast_command, Vnewvariable))
>> and let Lisp packages add their commands to that variable.

> A new variable is added in this patch (that includes other changes as well):

Looks good, thank you,


        Stefan




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r99831: Scrolling commands which does not signal errors at top/bottom.
  2010-04-10 14:51                           ` Stefan Monnier
@ 2010-04-14 16:49                             ` Juri Linkov
  2010-04-15  4:41                               ` Stefan Monnier
  0 siblings, 1 reply; 22+ messages in thread
From: Juri Linkov @ 2010-04-14 16:49 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Juanma Barranquero, Emacs developers

>>> Please add a new variable so we can do
>>> && NILP (Fmemq (current_kboard->Vlast_command, Vnewvariable))
>>> and let Lisp packages add their commands to that variable.
>
>> A new variable is added in this patch (that includes other changes as well):
>
> Looks good, thank you,

Looking now at such lines:

  (put 'scroll-up-command 'isearch-scroll t)
  (add-to-list 'scroll-preserve-screen-position-commands 'scroll-up-command)

suggests that something is wrong here.

Even though pager.el uses a list variable to define scrolling commands,
we already use symbol properties to define scrolling commands for isearch.

So now it looks too ugly to use different methods to do the same thing.

Wouldn't it better to define scrolling commands for scroll-preserve-screen-position
the same way with symbol properties?

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r99831: Scrolling commands which does not signal errors at top/bottom.
  2010-04-14 16:49                             ` Juri Linkov
@ 2010-04-15  4:41                               ` Stefan Monnier
  2010-04-15 23:56                                 ` Juri Linkov
  0 siblings, 1 reply; 22+ messages in thread
From: Stefan Monnier @ 2010-04-15  4:41 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Juanma Barranquero, Emacs developers

> Wouldn't it better to define scrolling commands for
> scroll-preserve-screen-position the same way with symbol properties?

Fine by me.  Especially if we can reduce the number of symbol properties
by merging them into just one `scroll-command' property which isearch
and scroll-preserve-screen-position can share.


        Stefan




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r99831: Scrolling commands which does not signal errors at top/bottom.
  2010-04-15  4:41                               ` Stefan Monnier
@ 2010-04-15 23:56                                 ` Juri Linkov
  2010-04-16  0:41                                   ` Stefan Monnier
  0 siblings, 1 reply; 22+ messages in thread
From: Juri Linkov @ 2010-04-15 23:56 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Juanma Barranquero, Emacs developers

>> Wouldn't it better to define scrolling commands for
>> scroll-preserve-screen-position the same way with symbol properties?
>
> Fine by me.

Done with the `scroll-command' property.

> Especially if we can reduce the number of symbol properties
> by merging them into just one `scroll-command' property
> which isearch and scroll-preserve-screen-position can share.

Unfortunately, the definition of a scroll command used
by `isearch-allow-scroll' is too broad: it can be a command
that scrolls the window, acts on the other window or changes
the window layout.  I'm not sure if it would be good for
`scroll-preserve-screen-position' to put the `scroll-command' property
on all these commands that currently have the `isearch-scroll' property,
or whether some users might want to remove the `isearch-scroll' property
from some real scroll commands.

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r99831: Scrolling commands which does not signal errors at top/bottom.
  2010-04-15 23:56                                 ` Juri Linkov
@ 2010-04-16  0:41                                   ` Stefan Monnier
  2010-04-16  1:27                                     ` Juri Linkov
  0 siblings, 1 reply; 22+ messages in thread
From: Stefan Monnier @ 2010-04-16  0:41 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Juanma Barranquero, Emacs developers

> Unfortunately, the definition of a scroll command used
> by `isearch-allow-scroll' is too broad: it can be a command
> that scrolls the window, acts on the other window or changes
> the window layout.  I'm not sure if it would be good for
> `scroll-preserve-screen-position' to put the `scroll-command' property
> on all these commands that currently have the `isearch-scroll' property,
> or whether some users might want to remove the `isearch-scroll' property
> from some real scroll commands.

How 'bout having isearch check both isearch-scroll and
scroll-command, then?  At least this way, we don't have to label all the
scroll-commands as being also isearch-scroll.


        Stefan




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r99831: Scrolling commands which does not signal errors at top/bottom.
  2010-04-16  0:41                                   ` Stefan Monnier
@ 2010-04-16  1:27                                     ` Juri Linkov
  0 siblings, 0 replies; 22+ messages in thread
From: Juri Linkov @ 2010-04-16  1:27 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Juanma Barranquero, Emacs developers

> How 'bout having isearch check both isearch-scroll and
> scroll-command, then?  At least this way, we don't have to label all the
> scroll-commands as being also isearch-scroll.

Done.

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2010-04-16  1:27 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <E1NywTs-00007U-Lf@internal.in.savannah.gnu.org>
2010-04-06  0:51 ` [Emacs-diffs] /srv/bzr/emacs/trunk r99831: Scrolling commands which does not signal errors at top/bottom Juanma Barranquero
2010-04-06  0:59   ` Juri Linkov
2010-04-06  1:58     ` Juanma Barranquero
2010-04-06 16:12       ` Juri Linkov
2010-04-06 18:26         ` Juanma Barranquero
2010-04-06 20:19           ` Juri Linkov
2010-04-06 20:49             ` Juanma Barranquero
2010-04-06 21:06               ` Juri Linkov
2010-04-06 21:39                 ` Juanma Barranquero
2010-04-06 21:47                   ` Juanma Barranquero
2010-04-07 20:17                     ` Juri Linkov
2010-04-07 22:16                       ` Juanma Barranquero
2010-04-07 23:19                         ` Juri Linkov
2010-04-07 23:35                           ` Juanma Barranquero
2010-04-09 15:29                       ` Stefan Monnier
2010-04-09 22:46                         ` Juri Linkov
2010-04-10 14:51                           ` Stefan Monnier
2010-04-14 16:49                             ` Juri Linkov
2010-04-15  4:41                               ` Stefan Monnier
2010-04-15 23:56                                 ` Juri Linkov
2010-04-16  0:41                                   ` Stefan Monnier
2010-04-16  1:27                                     ` Juri Linkov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).