停止emacs erc重定时

时间:2014-03-10 20:15:20

标签: emacs

Emacs erc继续重新定位。由于它,很难跟上小缓冲区中的对话。

我尝试了以下但似乎没有工作......

(erc-scrolltobottom-mode)

(require 'erc-goodies)

(setq erc-input-line-position -1)
(erc-add-scroll-to-bottom)

(add-hook 'erc-mode-hook 'erc-add-scroll-to-bottom)
(add-hook 'erc-insert-post-hook 'erc-scroll-to-bottom)

有没有办法让erc不被重新定位?

2 个答案:

答案 0 :(得分:3)

问题是Emacs(而不是erc)每次尝试重新进入屏幕,光标移出可见部分。请参阅scroll-conservatively的文档字符串( C-h v scroll-conservatively RET

  

向上滚动到这么多行,将点重新显示在屏幕上。如果点   在屏幕外移动,重新显示将向上滚动   `滚动保守'线条,以便几乎没有点   屏幕再次。如果无法做到,那么重新显示重新定位   像往常一样。

     

如果该值大于100,重新显示将永远不会重新点入,   但总会滚动足够的文字,甚至可以将视点带入视野   如果你走得很远。

     

如果零值移出屏幕,则值为零意味着始终重新定位点。

因此在scroll-conservatively中设置erc-mode-hook可能会解决问题

(add-to-list 'erc-mode-hook (lambda ()
                              (set (make-local-variable 'scroll-conservatively) 100)))

实际上有很多方法可以达到你想要的效果。查看Emacs手册的this section

答案 1 :(得分:1)

解决方案#1 :在以下链接中注释掉Github源代码的第101行 - 即注释掉如下所示的代码行:(recenter (or erc-input-line-position -1))

https://github.com/emacsmirror/erc/blob/master/erc-goodies.el

  
(defun erc-scroll-to-bottom (window display-start)
  "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)
      ;; 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))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LINE 101 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                ;; (recenter (or erc-input-line-position -1))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                (sit-for 0))))))))

解决方案#2 :在.emacs文件中,您可以创建一个新功能和defalias,如下所示:

  
(require 'erc-goodies)

(erc-scrolltobottom-mode)

(setq erc-input-line-position -1)

(erc-add-scroll-to-bottom)

(add-hook 'erc-mode-hook 'erc-add-scroll-to-bottom)

(add-hook 'erc-insert-post-hook 'erc-scroll-to-bottom)

(defun guimobob-erc-scroll-to-bottom (window display-start)
  "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)
      ;; 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))))))))

(defalias 'erc-scroll-to-bottom 'guimobob-erc-scroll-to-bottom)