2011-01-13 15 views
12

Temelde yeni bir mesaj geldiğinde *Mesajlar* tampon daima altına gidin istiyorum.Emacs'de, * Mesajlar * arabelleğinin kuyruklarını oluşturacak şekilde ayarlayabilir miyim?

Bunu yapabilir miyim?

auto-revert-tail-mode bulunamadı, ancak bu dosyaları ziyaret eden arabellekleri için çalışır. Ben Mesajlar tamponu içinde güvenilir o zaman , bu bir hata attı:
auto-revert-tail-mode: This buffer is not visiting a file

+2

üzerinde bir değişiklik var. Onu almam yeterli değil mi? –

+4

Evet, en azından Emacs 23.2.1'de, EOF'tan el ile noktayı el ile taşımadığınız sürece, varsayılan olarak \ * Mesajlar \ * işaretlenir (ve geri alma işlemi, geri yükleme davranışını yeniden başlatır). 'auto-revert-tail-mode' açıkça farklı bir şey yapmak için görünmüyor. – phils

cevap

8

çerçeveler muhtemelen istiyorum:

(defadvice message (after message-tail activate) 
    "goto point max after a message" 
    (with-current-buffer "*Messages*" 
    (goto-char (point-max)) 
    (walk-windows (lambda (window) 
        (if (string-equal (buffer-name (window-buffer window)) "*Messages*") 
         (set-window-point window (point-max)))) 
        nil 
        t))) 
+0

Güzel, ama muhtemelen walk-buffer + filter yerine 'buffer-window-list' kullanmalısınız. –

1

Bu kod biraz overkill gibi görünüyor, ama basit (goto-char (point-max)) benim için çalışma değildi: çoklu İçin

(defadvice message (after message-tail activate) 
    "goto point max after a message" 
    (with-current-buffer "*Messages*" 
    (goto-char (point-max)) 
    (let ((windows (get-buffer-window-list (current-buffer) nil t))) 
     (while windows 
     (set-window-point (car windows) (point-max)) 
     (setq windows (cdr windows)))))) 
+1

çok üretkensiniz Bay Jackson. – Cheeso

+0

Yukarıdaki pencereler, walk-windows'u kullanmak bana göre daha zarif görünüyor. –

+0

@ Nordlöw: en azından, (pencereler ...) 'burada' walk-windows' sürümünde daha iyi yazılır: '(mapc (lambda (w) (set-window-point w (point-max)))) pencereler). – ntc2

0

i 23.3 çalıştırın ve yol çok sayıda günler hala nerede yerleşik 'çözüm' ve mesaj işlevi jus orjinal defadvice t onu kesmedi, bu yüzden bir liste/geçiş/zamanlayıcıda bu kodu sardım ve güzel çalışıyor - hata ayıklama yaparken artık bir hayal kırıklığı!

o

(toggle-buffer-tail "*Messages*" "on") 

Birisine yararlıdır ..hope .., bildik! Ben sadece gerçekten için kullanmak her ne kadar bu yüzden, herhangi bir tampon üzerinde çalışır.

;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))))) 

düzenleme: değişmiş işlevselliği Sadece tampon M-> sonunda nokta koymak pencerenin

+0

Bunun için teşekkürler, tam olarak aradığım şey buydu :) –

+0

github'u buraya koydu (sadece kendi rahatlığım için) http://github.com/mbriggs/buffer-tail.el –

2

altındaki kuyruk görüntülemek için. Eğer elle hareket ettirmezseniz orada kalacak - IOW, her zaman kuyruğu göreceksiniz.

+2

Oldukça emin bu isn ' t true ... kesinlikle etrafımdaki emacların hiçbirinde işe yaramıyor. –

+1

@nicferrier Evet, işe yarıyor. Ne anlama geldiği hakkında daha fazla ayrıntı için soru altındaki diğer yorumları görün. 'Point-max' noktasını almak için' M-> 've diğer imleç hareketlerini kullanmadığınızdan emin olun. – Drew

1

İşte imleç o tampon sonunda olduğunda, yeni iletiler geldiğinde bile orada kalır Peter 's/Trey' ın ​​çözümleri

(defun modi/messages-auto-tail (&rest _) 
    "Make *Messages* buffer auto-scroll to the end after each message." 
    (let* ((buf-name "*Messages*") 
     ;; Create *Messages* buffer if it does not exist 
     (buf (get-buffer-create buf-name))) 
    ;; Activate this advice only if the point is _not_ in the *Messages* buffer 
    ;; to begin with. This condition is required; otherwise you will not be 
    ;; able to use `isearch' and other stuff within the *Messages* buffer as 
    ;; the point will keep moving to the end of buffer :P 
    (when (not (string= buf-name (buffer-name))) 
     ;; Go to the end of buffer in all *Messages* buffer windows that are 
     ;; *live* (`get-buffer-window-list' returns a list of only live windows). 
     (dolist (win (get-buffer-window-list buf-name nil :all-frames)) 
     (with-selected-window win 
      (goto-char (point-max)))) 
     ;; Go to the end of the *Messages* buffer even if it is not in one of 
     ;; the live windows. 
     (with-current-buffer buf 
     (goto-char (point-max)))))) 
(advice-add 'message :after #'modi/messages-auto-tail) 
İlgili konular