From: Deniz Dogan <deniz@dogan.se>
To: Brian Fransioli <assem@terranpro.org>
Cc: 11697@debbugs.gnu.org
Subject: bug#11697: 24.1.50; ERC scroll-to-bottom functionality 'broken' in emacs 24.1.x
Date: Wed, 13 Jun 2012 22:03:00 +0200 [thread overview]
Message-ID: <4FD8F1F4.6080809@dogan.se> (raw)
In-Reply-To: <87ipevji6m.fsf@pringles.terranpro.org>
[-- Attachment #1: Type: text/plain, Size: 1913 bytes --]
On 2012-06-13 18:22,, Brian Fransioli wrote:
>
> After updating to emacs 24.1.x I noticed ERC scroll functionality
> changed. Originally, it would recenter to force the prompt to be near
> the bottom of the screen (according to `erc-input-line-position'). Now,
> this recentering only happens when I enter text, or perform a mouse
> event. Channel joins/parts and new messages hit the bottom of the
> screen, and recentering moves the bottom line to the center of the
> buffer.
>
> The overall effect is input by the user moves the screen to the bottom,
> while channel/server inputs bounce around from middle to bottom and back
> again.
>
> Looking in erc-goodies.el at `erc-add-scroll-bottom', it's easy to see
> the documentation is also out of date. It states it uses
> `window-scroll-functions' but instead adds the hook to
> `post-command-hook'.
>
> Examining commits, I found the culprit:
>
> commit:
> a1d63e03c3eda51dcec158d6027adf9dbdcfd8dd
>
> view changes via git emacs web:
> http://git.savannah.gnu.org/cgit/emacs.git/commit/lisp/erc/erc-goodies.el?id=a1d63e03c3eda51dcec158d6027adf9dbdcfd8dd
>
>
> I see that the changes were reported to fix a bug on tty's, but the
> results are severe motion sickness for even moderately chatty channels.
>
> Reproduce by:
> (erc-scrolltobottom-mode)
> (setq erc-input-line-position -2)
>
> Regards,
> Brian
>
Firstly, I agree with you completely that scrolltobottom needs
improvements. I can't be sure why they changed the behavior, since the
new method is clearly inferior, but I believe it's because
window-scroll-functions is never meant to change "the way the window is
scrolled".
I've monkey-patched ERC myself to handle the whole thing better. I've
attached the Lisp. Just evaluate all the code and you'll be all set.
(I know it's not production-quality code, but it does the job and
relieves you from ever thinking about it again.)
Deniz
[-- Attachment #2: erc-better-scroll.el --]
[-- Type: text/plain, Size: 2880 bytes --]
(defun erc-display-line-1 (string buffer)
"Display STRING in `erc-mode' BUFFER.
Auxiliary function used in `erc-display-line'. The line gets filtered to
interpret the control characters. Then, `erc-insert-pre-hook' gets called.
If `erc-insert-this' is still t, STRING gets inserted into the buffer.
Afterwards, `erc-insert-modify' and `erc-insert-post-hook' get called.
If STRING is nil, the function does nothing."
(when string
(with-current-buffer (or buffer (process-buffer erc-server-process))
(let ((insert-position (or (marker-position erc-insert-marker)
(point-max))))
(let ((string string) ;; FIXME! Can this be removed?
(buffer-undo-list t)
(inhibit-read-only t))
(unless (string-match "\n$" string)
(setq string (concat string "\n"))
(when (erc-string-invisible-p string)
(erc-put-text-properties 0 (length string)
'(invisible intangible) string)))
(erc-log (concat "erc-display-line: " string
(format "(%S)" string) " in buffer "
(format "%s" buffer)))
(setq erc-insert-this t)
(run-hook-with-args 'erc-insert-pre-hook string)
(if (null erc-insert-this)
;; Leave erc-insert-this set to t as much as possible. Fran
;; Litterio <franl> has seen erc-insert-this set to nil while
;; erc-send-pre-hook is running, which should never happen. This
;; may cure it.
(setq erc-insert-this t)
(save-excursion ;; to restore point in the new buffer
(save-restriction
(widen)
(goto-char insert-position)
(insert-before-markers string)
;; run insertion hook, with point at restored location
(save-restriction
(narrow-to-region insert-position (point))
(run-hooks 'erc-insert-modify-hook)
(run-hooks 'erc-insert-post-hook)
(when erc-remove-parsed-property
(remove-text-properties (point-min) (point-max)
'(erc-parsed nil))))))))
(erc-update-undo-list (- (or (marker-position erc-insert-marker)
(point-max))
insert-position)))
(run-hooks 'erc-display-post-hook)))) ;;; this line and only this line was added
(defvar erc-display-post-hook nil
"New hook!")
(defun damd-erc-display-post-hook ()
(let ((windows (get-buffer-window-list (current-buffer) nil 'visible)))
(dolist (w windows)
(when (>= (point) erc-input-marker)
(with-selected-window w
(recenter -1))))))
(add-hook 'erc-display-post-hook 'damd-erc-display-post-hook)
(defun damd-erc-send-post-hook ()
(when (>= (point) erc-input-marker)
(goto-char (point-max))
(widen)
(recenter -1)))
(add-hook 'erc-send-post-hook 'damd-erc-send-post-hook)
(defun damd-window-configuration-change-hook ()
(when (and (eq major-mode 'erc-mode)
(>= (point) erc-input-marker))
(recenter -1)))
(add-hook 'window-configuration-change-hook 'damd-window-configuration-change-hook)
next prev parent reply other threads:[~2012-06-13 20:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-13 16:22 bug#11697: 24.1.50; ERC scroll-to-bottom functionality 'broken' in emacs 24.1.x Brian Fransioli
2012-06-13 20:03 ` Deniz Dogan [this message]
2012-06-14 7:35 ` Kevin Rodgers
2012-06-14 9:49 ` Antoine Levitt
2012-06-14 20:51 ` Deniz Dogan
2012-06-14 21:03 ` Antoine Levitt
2012-06-14 21:10 ` Deniz Dogan
2012-06-15 2:00 ` Stefan Monnier
2012-06-15 6:49 ` Antoine Levitt
[not found] ` <mailman.2844.1339743011.855.bug-gnu-emacs@gnu.org>
2013-02-08 5:06 ` maden.ldm
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=4FD8F1F4.6080809@dogan.se \
--to=deniz@dogan.se \
--cc=11697@debbugs.gnu.org \
--cc=assem@terranpro.org \
/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.