From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Antoine Levitt Newsgroups: gmane.emacs.bugs Subject: bug#9246: Scrolling bug with word-wrap in emacs -nw Date: Fri, 30 Dec 2011 15:01:26 +0100 Message-ID: <87mxaaupjd.fsf@gmail.com> References: <8762mb1jq1.fsf@gmail.com> <1312839728.2986.6.camel@kiwi-pc2> <83fwgaxkdu.fsf@gnu.org> <87ehvudqcs.fsf@gmail.com> <8362h6xc0q.fsf@gnu.org> <877h1m56ob.fsf@gmail.com> <8339cax74g.fsf@gnu.org> <87ty4p3nr0.fsf@gmail.com> <83wr9lx4u6.fsf@gnu.org> <87ipkzvvy2.fsf@gmail.com> <83y5tutnc0.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1325253737 22107 80.91.229.12 (30 Dec 2011 14:02:17 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 30 Dec 2011 14:02:17 +0000 (UTC) Cc: 9246@debbugs.gnu.org, riccardi.thomas@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Dec 30 15:02:12 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Rgd2B-0008An-Vv for geb-bug-gnu-emacs@m.gmane.org; Fri, 30 Dec 2011 15:02:12 +0100 Original-Received: from localhost ([::1]:40561 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rgd2B-0004HC-IZ for geb-bug-gnu-emacs@m.gmane.org; Fri, 30 Dec 2011 09:02:11 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:44046) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rgd27-0004H5-Rq for bug-gnu-emacs@gnu.org; Fri, 30 Dec 2011 09:02:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rgd26-0000jC-MJ for bug-gnu-emacs@gnu.org; Fri, 30 Dec 2011 09:02:07 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:58508) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rgd26-0000j8-G9 for bug-gnu-emacs@gnu.org; Fri, 30 Dec 2011 09:02:06 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1Rgd4w-0005MD-3f for bug-gnu-emacs@gnu.org; Fri, 30 Dec 2011 09:05:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <8762mb1jq1.fsf@gmail.com> Resent-From: Antoine Levitt Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 30 Dec 2011 14:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 9246 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 9246-submit@debbugs.gnu.org id=B9246.132525387620556 (code B ref 9246); Fri, 30 Dec 2011 14:05:02 +0000 Original-Received: (at 9246) by debbugs.gnu.org; 30 Dec 2011 14:04:36 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Rgd4W-0005LV-1T for submit@debbugs.gnu.org; Fri, 30 Dec 2011 09:04:36 -0500 Original-Received: from mail-we0-f172.google.com ([74.125.82.172]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Rgd4S-0005LL-Vq for 9246@debbugs.gnu.org; Fri, 30 Dec 2011 09:04:34 -0500 Original-Received: by werb14 with SMTP id b14so7007200wer.3 for <9246@debbugs.gnu.org>; Fri, 30 Dec 2011 06:01:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:message-id:user-agent :mime-version:content-type; bh=ttJ+dtf5FItubVhDvtwr/7I0Wv+v61L0gevhDq7bcXY=; b=veHN5JhSqjja3gqaA2W6SKz+qfjuNgQiXYUMb5S6t5rNZkYl+dWl/VsVQ/qhZanlqT ShRR2dxwlL/5cbvqbOI8cwJ9oPMwnR2oM+gpRDxGBtyW6nIlarqBkzGpO5UWhpFn5dRT gQAppgNWLBgup4M8Mu3r22K5R5qH54wa38drU= Original-Received: by 10.216.209.228 with SMTP id s78mr27676778weo.26.1325253696468; Fri, 30 Dec 2011 06:01:36 -0800 (PST) Original-Received: from lambda (i01v-213-44-207-121.d4.club-internet.fr. [213.44.207.121]) by mx.google.com with ESMTPS id dd4sm92561407wib.1.2011.12.30.06.01.31 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 30 Dec 2011 06:01:35 -0800 (PST) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Fri, 30 Dec 2011 09:05:02 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:55307 Archived-At: --=-=-= Content-Type: text/plain 30/12/11 10:34, Eli Zaretskii >> From: Antoine Levitt >> 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? --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=add-warning-to-window-scroll-functions.diff === 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 + + * xdisp.c (syms_of_xdisp): Add warning to the doc of + window-scroll-functions, not just its info file. + 2011-12-23 Eli Zaretskii * 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", --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=use-post-command-hook.diff === 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 + + * 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 (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 --=-=-=--