bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#9246: Scrolling bug with word-wrap in emacs -nw


From: Antoine Levitt
Subject: bug#9246: Scrolling bug with word-wrap in emacs -nw
Date: Fri, 30 Dec 2011 15:01:26 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

30/12/11 10:34, Eli Zaretskii
>> From: Antoine Levitt <antoine.levitt@gmail.com>
>> Cc: riccardi.thomas@gmail.com,  9246@debbugs.gnu.org
>> Date: Thu, 29 Dec 2011 23:45:25 +0100
>> 
>> >> So, should erc-scrollbottom be changed?
>> >
>> > Definitely.  It shouldn't use window-scroll-functions.
>> 
>> So is there a hook it could use?
>
> How about post-command-hook?
>
>> Incidentally, this warning doesn't get displayed on C-h v, it might be a
>> good idea to move it.
>
> Patches are welcome.

Here's two patches. The first adds the warning from the info file into
the variable definition. The second fixes erc-scrollbottom by using
post-command-hook instead of window-scroll-functions.

Can you merge them?

>
>> >> Actually, this is a behavior I'd like for emacs as a whole, to make it
>> >> behave more like other editors that never display anything past the end
>> >> of text. Is there any way to do it, some other variable one could set in
>> >> addition to scroll-conservatively?
>> >
>> > Maybe, I don't know.
>> 
>> If you don't know, it probably means there isn't ;)
>
> Don't count on that ;-)
>
>> I tried to hack something together, but I couldn't make it work, because
>> I couldn't find an appropriate way to express "if the window is
>> displaying stuff past the end of buffer" (using window-end and
>> buffer-end does not work, because window-end can never be past
>> buffer-end).
>
> How about this strategy:
>
>   go to window-end
>   call posn-at-point
>   compare the row returned by posn-at-point with window-height

That works pretty well! (when hooked into post-command-hook) Except that
sometimes posn-at-point is nil, presumably because redisplay hasn't
taken place yet. It works when I force redisplay, except that of course
it's wrong to do that. I couldn't find a post-redisplay-hook, which
might be more appropriate. Is there one?

=== modified file 'src/ChangeLog'
--- src/ChangeLog       2011-12-23 14:51:51 +0000
+++ src/ChangeLog       2011-12-30 12:10:36 +0000
@@ -1,3 +1,8 @@
+2011-12-30  Antoine Levitt  <antoine.levitt@gmail.com>
+
+       * xdisp.c (syms_of_xdisp): Add warning to the doc of
+       window-scroll-functions, not just its info file.
+
 2011-12-23  Eli Zaretskii  <eliz@gnu.org>
 
        * xdisp.c (handle_invisible_prop): Handle correctly an invisible

=== modified file 'src/xdisp.c'
--- src/xdisp.c 2011-12-23 14:51:51 +0000
+++ src/xdisp.c 2011-12-30 10:41:12 +0000
@@ -28325,7 +28325,11 @@
 Each function is called with two arguments, the window and its new
 display-start position.  Note that these functions are also called by
 `set-window-buffer'.  Also note that the value of `window-end' is not
-valid when these functions are called.  */);
+valid when these functions are called.
+
+Warning: don't use this feature to alter the way the window
+is scrolled.  It's not designed for that, and such use probably won't
+work.  */);
   Vwindow_scroll_functions = Qnil;
 
   DEFVAR_LISP ("window-text-change-functions",
=== modified file 'lisp/erc/ChangeLog'
--- lisp/erc/ChangeLog  2011-11-28 09:24:08 +0000
+++ lisp/erc/ChangeLog  2011-12-30 12:26:11 +0000
@@ -1,3 +1,9 @@
+2011-12-30  Antoine Levitt  <antoine.levitt@gmail.com>
+
+       * erc-goodies.el (erc-scroll-to-bottom): Use post-command-hook
+       rather than window-scroll-functions. Fixes a bug with word-wrap on
+       a tty.
+
 2011-11-28  Mike Kazantsev  <mk.fraggod@gmail.com>  (tiny change)
 
        * erc-dcc.el (erc-dcc-ctcp-query-send-regexp): Updated regexp to

=== modified file 'lisp/erc/erc-goodies.el'
--- lisp/erc/erc-goodies.el     2011-01-26 08:36:39 +0000
+++ lisp/erc/erc-goodies.el     2011-12-30 13:59:12 +0000
@@ -60,7 +60,7 @@
   ((remove-hook 'erc-mode-hook 'erc-add-scroll-to-bottom)
    (dolist (buffer (erc-buffer-list))
      (with-current-buffer buffer
-       (remove-hook 'window-scroll-functions 'erc-scroll-to-bottom t)))))
+       (remove-hook 'post-command-hook 'erc-scroll-to-bottom t)))))
 
 (defun erc-add-scroll-to-bottom ()
   "A hook function for `erc-mode-hook' to recenter output at bottom of window.
@@ -70,35 +70,29 @@
 
 This works whenever scrolling happens, so it's added to
 `window-scroll-functions' rather than `erc-insert-post-hook'."
-  ;;(make-local-hook 'window-scroll-functions)
-  (add-hook 'window-scroll-functions 'erc-scroll-to-bottom nil t))
+  (add-hook 'post-command-hook 'erc-scroll-to-bottom nil t))
 
-(defun erc-scroll-to-bottom (window display-start)
+(defun erc-scroll-to-bottom ()
   "Recenter WINDOW so that `point' is on the last line.
 
 This is added to `window-scroll-functions' by `erc-add-scroll-to-bottom'.
 
 You can control which line is recentered to by customizing the
-variable `erc-input-line-position'.
-
-DISPLAY-START is ignored."
-  (if (window-live-p window)
+variable `erc-input-line-position'."
       ;; Temporarily bind resize-mini-windows to nil so that users who have it
       ;; set to a non-nil value will not suffer from premature minibuffer
       ;; shrinkage due to the below recenter call.  I have no idea why this
       ;; works, but it solves the problem, and has no negative side effects.
       ;; (Fran Litterio, 2003/01/07)
-      (let ((resize-mini-windows nil))
-        (erc-with-selected-window window
-          (save-restriction
-            (widen)
-            (when (and erc-insert-marker
-                       ;; we're editing a line. Scroll.
-                       (> (point) erc-insert-marker))
-              (save-excursion
-                (goto-char (point-max))
-                (recenter (or erc-input-line-position -1))
-                (sit-for 0))))))))
+  (let ((resize-mini-windows nil))
+    (save-restriction
+      (widen)
+      (when (and erc-insert-marker
+                ;; we're editing a line. Scroll.
+                (> (point) erc-insert-marker))
+       (save-excursion
+         (goto-char (point-max))
+         (recenter (or erc-input-line-position -1)))))))
 
 ;;; Make read only
 (define-erc-module readonly nil


reply via email to

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