emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: line-move-partial too costly ?


From: Michaël Cadilhac
Subject: Re: line-move-partial too costly ?
Date: Tue, 19 Sep 2006 10:19:47 +0200
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.50 (gnu/linux)

address@hidden (Kim F. Storm) writes:

> address@hidden (Michaël Cadilhac) writes:
>
>> address@hidden (Kim F. Storm) writes:
>>
>>> address@hidden (Michaël Cadilhac) writes:
>>>
>>>> Since the creation of line-move-partial, going to the next few lines
>>>> has become a P*TA.
>>>
>>>> Is there any solution ?
>>>
>>> I installed a small optimization -- pls try again.
>>>
>> AFAICT, it doesn't fix my problem.
>
> I have installed an more elaborate change to line-move-partial
> (involving a new primitive `window-line-visibility').

(* Sorry for the delay *)

It makes the job ! I'm no longer stuck at the first line when going to
the next few lines.

To me, it's OK, but I have a minor issue (I don't know if it needs
attention).

After scrolling a couple of screens with C-n, the cursor stops, like
previously (it doesn't happen with auto-window-vscroll to nil), and
the display is buggy for the time I'm stuck (which could be quite
long [1]). The cursor stop happens on a screen change, and appears like
that :

http://www.lrde.org/~cadilh_m/freeze.png

As you can see, the first half of the screen is correct whilst the
other one hasn't been redrawn. Like if the redisplay was made before
the scroll change, and not after.

Voilà, FWIW :-)

Footnotes: 
[1]  I tried to make a fix for this one. The principle was : if
there's unread C-n when entering next-line, just buffer its arg.

The (dirty) patch, that moreover doesn't work, looks like that :

Index: simple.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/simple.el,v
retrieving revision 1.820
diff -b -u -w -r1.820 simple.el
@@ -3379,6 +3381,26 @@
   :version "21.1"
   :group 'editing-basics)
 
+(defvar next-or-previous-line-count 0
+  "Buffer for line moves.
+If `next-line' or `previous-line' are used repeatedly, the amount
+of line to scroll is stored to avoid freezing.")
+
+(defun update-next-or-previous-line-count (arg)
+  "Update `next-or-previous-line-count' by adding ARG to it if necessary."
+  (let ((unread (append unread-command-events
+                       unread-post-input-method-events
+                       unread-input-method-events
+                       (if (> unread-command-char 0)
+                           (list unread-command-char)
+                         nil))))
+    (when (progn (while (and unread (not (memq (key-binding (car unread))
+                                              '(next-line previous-line))))
+                  (setq unread (cdr unread)))
+                unread)
+      (setq next-or-previous-line-count (+ next-or-previous-line-count arg)))))
+
+
 (defun next-line (&optional arg try-vscroll)
   "Move cursor vertically down ARG lines.
 Interactively, vscroll tall lines if `auto-window-vscroll' is enabled.
@@ -3402,6 +3424,9 @@
 and more reliable (no dependence on goal column, etc.)."
   (interactive "p\np")
   (or arg (setq arg 1))
+  (when (not (update-next-or-previous-line-count arg))
+    (setq arg (+ arg next-or-previous-line-count)
+         next-or-previous-line-count 0)
   (if (and next-line-add-newlines (= arg 1))
       (if (save-excursion (end-of-line) (eobp))
          ;; When adding a newline, don't expand an abbrev.
@@ -3436,9 +3461,12 @@
   (interactive "p\np")
   (or arg (setq arg 1))
   (if (interactive-p)
+      (when (not (update-next-or-previous-line-count arg))
+       (setq arg (+ arg next-or-previous-line-count)
+             next-or-previous-line-count 0)
       (condition-case nil
          (line-move (- arg) nil nil try-vscroll)
        ((beginning-of-buffer end-of-buffer) (ding)))
     (line-move (- arg) nil nil try-vscroll))
   nil)
 


-- 
/!\ My mail address changed, please update your files accordingly.
 |      Michaël `Micha' Cadilhac   |  Un certain Blaise Pascal              |
 |         Epita/LRDE Promo 2007   |    etc... etc...                       |
 |  http://michael.cadilhac.name   |  -- Prévert (Les paris stupides)       |
 `--  -   JID: address@hidden --'                                   -  --'

Attachment: pgpH0gPaw_eDr.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]