Created
December 3, 2013 18:07
-
-
Save sanryuu/7774326 to your computer and use it in GitHub Desktop.
Emacsのミニバッファで新幹線の電光掲示板っぽく表示します。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defvar ebb:display-taget "" | |
"ebbで表示する文字を設定") | |
(defcustom ebb:display-limit 7 | |
"表示する文字数を設定" | |
:type 'integer | |
:group 'ebb) | |
(defcustom ebb:display-interval 0.5 | |
"表示を送る感覚を設定" | |
:type 'integer | |
:group 'ebb) | |
(defvar ebb:point-display-begin 0) | |
(defvar ebb:point-display-end ebb:display-limit) | |
(defvar ebb:process nil) | |
(defvar ebb:lap-hooks '()) | |
(defun ebb:point-display-init () | |
"point-displayを初期化する" | |
(setq ebb:point-display-begin 0) | |
(setq ebb:point-display-end ebb:display-limit)) | |
(defun ebb:point-display-increment () | |
"point-displayをインクリメントする | |
表示上限に逹っしたときは、一周させる。" | |
(let ((len (length ebb:display-taget))) | |
(setq ebb:point-display-begin (+ ebb:point-display-begin 1)) | |
(when (= ebb:point-display-begin len) | |
(ebb:point-display-init) | |
(run-hooks 'ebb:lap-hooks)) | |
(setq ebb:point-display-end (+ ebb:point-display-begin ebb:display-limit)) | |
(when (> ebb:point-display-end len) | |
(setq ebb:point-display-end len)))) | |
(defun ebb:display () | |
"ebb:display-tagetを設定表示数分表示して、 | |
表示箇所を1文字分ずらす" | |
(interactive) | |
(message | |
(substring ebb:display-taget ebb:point-display-begin ebb:point-display-end)) | |
(ebb:point-display-increment)) | |
(defun ebb:toggle-display() | |
"ebbの定期表示をトグルさせる" | |
(interactive) | |
(if ebb:process | |
(progn | |
(cancel-timer ebb:process) | |
(setq ebb:process nil)) | |
(setq ebb:process (run-with-timer t ebb:display-interval 'ebb:display)))) | |
(defun ebb:set-display-taget (taget) | |
"ebbの表示対象を設定する | |
表示位置の初期化をし、 | |
先頭の1文字目から見えるようにするために、 | |
先頭を' 'で埋める。" | |
(ebb:point-display-init) | |
(let ((count 0)) | |
(setq ebb:display-taget "") | |
(while (< count ebb:display-limit) | |
(setq ebb:display-taget | |
(concat ebb:display-taget " ")) | |
(setq count (+ count 1))) | |
(setq ebb:display-taget | |
(concat ebb:display-taget taget)))) | |
(provide 'ebb) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment