@peccul is peccu

(love peccu '(emacs lisp cat outdoor bicycle mac linux coffee))

twit.elで前後のつぶやきに移動する時に視線の移動をなくす

twit.elで*Twit-recent*バッファにいるときはn,pキーで前後のつぶやきに移動してる.

でも普通のカーソルと一緒で視線の移動が大きかった.

これをgoogle readerのn,pキーの挙動と同じように,今選択されているつぶやきをウィンドウの一番上に表示すれば視線の移動が減ってみやすくなるんじゃないかと考えた.

line-to-top-of-windowって関数は昔別の用途で作ってC-;に割り当てていた関数.
標準ではないから,functionpでこの関数がなければdefunするようにした

.emacsに書いとけばいい

;;; interface like google reader
;; line-to-top-of-window
(when (not (functionp 'line-to-top-of-window))
  (defun line-to-top-of-window ()
  "Move the line point is on to top of window."
  (interactive)
  (recenter 0)))

;;* interactive nav
(defadvice twit-next-tweet (around around-twit-next-tweet)
  (interactive "p")
  (mapc (lambda (n)
          (goto-char (next-single-char-property-change (point) 'twit-id nil
                                                       (point-max)))
                  (line-to-top-of-window))
        (number-sequence 1 (or arg 1))))
(ad-activate 'twit-next-tweet)

;;* interactive nav
(defadvice twit-previous-tweet (around around-twit-previous-tweet)
  (interactive "p")
  (mapc (lambda (n)
          (goto-char (previous-single-char-property-change (point) 'twit-id nil
                                                           (point-min)))
                  (line-to-top-of-window))
        (number-sequence 1 (or arg 1))))
(ad-activate 'twit-previous-tweet)