From: Antoine Levitt <antoine.levitt@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 9246@debbugs.gnu.org, riccardi.thomas@gmail.com
Subject: bug#9246: Scrolling bug with word-wrap in emacs -nw
Date: Fri, 30 Dec 2011 15:01:26 +0100 [thread overview]
Message-ID: <87mxaaupjd.fsf@gmail.com> (raw)
In-Reply-To: <8762mb1jq1.fsf@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1862 bytes --]
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?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: add-warning-to-window-scroll-functions.diff --]
[-- Type: text/x-diff, Size: 1087 bytes --]
=== 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",
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: use-post-command-hook.diff --]
[-- Type: text/x-diff, Size: 2937 bytes --]
=== 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
next prev parent reply other threads:[~2011-12-30 14:01 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-06 0:12 bug#9246: Scrolling bug with word-wrap in emacs -nw Antoine Levitt
2011-08-06 7:08 ` Eli Zaretskii
2011-08-06 9:32 ` Antoine Levitt
2011-08-08 21:42 ` Thomas Riccardi
2011-12-24 11:46 ` Eli Zaretskii
2011-12-24 13:57 ` Antoine Levitt
2011-12-24 14:47 ` Eli Zaretskii
2011-12-24 15:29 ` Antoine Levitt
2011-12-24 16:32 ` Eli Zaretskii
2011-12-24 17:04 ` Antoine Levitt
2011-12-24 17:22 ` Eli Zaretskii
2011-12-29 22:45 ` Antoine Levitt
2011-12-30 9:34 ` Eli Zaretskii
2011-12-30 14:01 ` Antoine Levitt [this message]
2011-12-30 15:45 ` Eli Zaretskii
2011-12-30 17:10 ` Antoine Levitt
2011-12-30 18:13 ` Eli Zaretskii
2011-12-31 10:33 ` Stefan Monnier
2012-01-01 2:59 ` Richard Stallman
2011-12-31 8:29 ` Eli Zaretskii
2011-12-31 11:28 ` Antoine Levitt
2011-12-31 11:44 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mxaaupjd.fsf@gmail.com \
--to=antoine.levitt@gmail.com \
--cc=9246@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=riccardi.thomas@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.