i chạy 23.3 và vẫn còn quá nhiều lần khi tích hợp 'giải pháp' và nhược điểm ban đầu trên chức năng tin nhắn t đã không cắt nó, vì vậy tôi bọc mã trong một danh sách/chuyển đổi/hẹn giờ thiết lập và nó làm việc đẹp - không có nhiều thất vọng khi gỡ lỗi!
nó chung chung, do hoạt động trên bất kỳ đệm, mặc dù tôi chỉ thực sự sử dụng nó cho ..
(toggle-buffer-tail "*Messages*" "on")
..hope nó là hữu ích để một ai đó.
;alist of 'buffer-name/timer' items
(defvar buffer-tail-alist nil)
(defun buffer-tail (name)
"follow buffer tails"
(cond ((or (equal (buffer-name (current-buffer)) name)
(string-match "^ \\*Minibuf.*?\\*$" (buffer-name (current-buffer)))))
((get-buffer name)
(with-current-buffer (get-buffer name)
(goto-char (point-max))
(let ((windows (get-buffer-window-list (current-buffer) nil t)))
(while windows (set-window-point (car windows) (point-max))
(with-selected-window (car windows) (recenter -3)) (setq windows (cdr windows))))))))
(defun toggle-buffer-tail (name &optional force)
"toggle tailing of buffer NAME. when called non-interactively, a FORCE arg of 'on' or 'off' can be used to to ensure a given state for buffer NAME"
(interactive (list (cond ((if name name) (read-from-minibuffer
(concat "buffer name to tail"
(if buffer-tail-alist (concat " (" (caar buffer-tail-alist) ")") "") ": ")
(if buffer-tail-alist (caar buffer-tail-alist)) nil nil
(mapcar '(lambda (x) (car x)) buffer-tail-alist)
(if buffer-tail-alist (caar buffer-tail-alist)))) nil)))
(let ((toggle (cond (force force) ((assoc name buffer-tail-alist) "off") (t "on"))))
(if (not (or (equal toggle "on") (equal toggle "off")))
(error "invalid 'force' arg. required 'on'/'off'")
(progn
(while (assoc name buffer-tail-alist)
(cancel-timer (cdr (assoc name buffer-tail-alist)))
(setq buffer-tail-alist (remove* name buffer-tail-alist :key 'car :test 'equal)))
(if (equal toggle "on")
(add-to-list 'buffer-tail-alist (cons name (run-at-time t 1 'buffer-tail name))))
(message "toggled 'tail buffer' for '%s' %s" name toggle)))))
chỉnh sửa: thay đổi chức năng để hiển thị đuôi ở dưới cùng của cửa sổ
Khi con trỏ là ở phần cuối của bộ đệm đó, nó sẽ nằm ở đó ngay cả khi có thư mới. Tôi lấy nó không đủ cho bạn? –
Có, trong Emacs 23.2.1 ít nhất, \ * Tin nhắn \ * đuôi theo mặc định, trừ khi bạn di chuyển điểm thủ công từ EOF (và di chuyển nó trở lại một lần nữa tiếp tục hành vi tailing). 'auto-revert-tail-mode' dường như không làm bất cứ điều gì rõ ràng là khác nhau. – phils