Last active
September 25, 2019 02:35
-
-
Save tsuu32/7e299677da3ddd6896fb51460ebeff9c to your computer and use it in GitHub Desktop.
https://gist.github.com/tsuu32/abbe09a7aea09bcfff397c5bb313854b をglobalなmodeにしました
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 sushi-bar--old-format mode-line-format) | |
(defvar sushi-bar--conveyor-belt "") | |
(defvar sushi-bar--update-timer nil) | |
(defun sushi-bar--sushi-is-ready-p () | |
(eq (random 15) 1)) | |
(defun sushi-bar--conveyor-update () | |
(when (and sushi-bar-mode (null (window-minibuffer-p))) | |
(let* ((current-belt | |
(substring-no-properties sushi-bar--conveyor-belt | |
1)) ;; Conveyor moved to left | |
(padding-right (- (window-width) | |
(length current-belt)))) | |
(setq current-belt | |
(cond | |
((> padding-right 1) | |
(concat current-belt (make-string (1- padding-right) ? ))) | |
((< padding-right 1) | |
(substring-no-properties current-belt 0 (1- padding-right))) | |
(t current-belt))) | |
(setq-local sushi-bar--conveyor-belt | |
(concat current-belt | |
(if (sushi-bar--sushi-is-ready-p) "🍣" " ")))) | |
(force-mode-line-update))) | |
(defun sushi-bar--mode-enable () | |
(setq sushi-bar--update-timer | |
(run-at-time t 0.045 'sushi-bar--conveyor-update)) | |
(setq-default sushi-bar--conveyor-belt (make-string (window-width) ? )) | |
(setq-default mode-line-format '(:eval sushi-bar--conveyor-belt))) | |
(defun sushi-bar--mode-disable () | |
(setq-default sushi-bar--conveyor-belt "") | |
(setq-default mode-line-format sushi-bar--old-format)) | |
(define-minor-mode sushi-bar-mode () | |
:global t | |
(and sushi-bar--update-timer (cancel-timer sushi-bar--update-timer)) | |
(setq sushi-bar--update-timer nil) | |
(if sushi-bar-mode | |
(sushi-bar--mode-enable) | |
(sushi-bar--mode-disable))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
簡単な説明
https://gist.github.com/tsuu32/abbe09a7aea09bcfff397c5bb313854b では、
M-x sushi-bar-mode
を実行した各バッファでsushi-barになるものだった。こっちはglobalなminor modeであり、
M-x sushi-bar-mode
すると全バッファでsushi-barになる。