19
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

GetWild駆動開発の生産性を8倍に高めるget-wild.el

Last updated at Posted at 2016-12-18

GetWild Advent Calendar 2016の14日目の記事です。投稿が遅れてごめんなさい :pray:

GetWild駆動開発の弱点

こんにちは。皆さんは良いGetWildしていますか? 業務中にGetWildを聴きながら開発を行うことで、ゾーンに入るための時間が短縮されることは研究の結果[要出典]確定的に明らかです。

が、そんなGetWild駆動開発には致命的な弱点があることがだんだん分かってきました。それはGetWildの素晴らしすぎるサウンドのあまり、聴き入ってしまい手が止まってしまうことです。そこで、この問題を解決すべく発想の転換を行い、手を動かさなければGetWildが聴けなくなってしまうEmacs Pluginを開発しました。GetWild依存度の強い人ほど生産性の向上に寄与してくれることでしょう。

get-wild.el

daichirata/emacs-get-wild

動作としては、キー入力があるとGetWildが流れます。キー入力を止めて一定時間立つとGetWildが止まります。

mplayerをslaveモードで起動しpauseコマンドで再生を制御しているので、mplayerを別途インストールしておいてください。

(defcustom get-wild-path ""
  "Path to sound source file"
  :type 'string
  :group 'get-wild)

(defcustom get-wild-timeout-seconds 1
  "Timeout seconds for `run-with-idle-timer'"
  :type 'integer
  :group 'get-wild)

(defcustom get-wild-cheap-thrills nil
  "To give oneself to cheap thrills"
  :type 'boolean
  :group 'get-wild)

(defvar get-wild-buffer "*get-wild*")
(defvar get-wild-player-status nil)
(defvar get-wild-process nil)

(defun get-wild-ensure-process ()
  (unless (process-live-p get-wild-process)
    (setq get-wild-process (start-process-shell-command "get-wild" get-wild-buffer (concat "mplayer -loop 0 -slave" get-wild-path)))
    (get-wild-player-send-pause)))

(defun get-wild-remove-process ()
  (when (process-live-p get-wild-process)
    (delete-process get-wild-process)))

(defun get-wild-player-send-pause ()
  (process-send-string get-wild-process "pause\n"))

(defun get-wild-player-stop ()
  (when get-wild-player-status
    (setq get-wild-player-status nil)
    (get-wild-player-send-pause)))

(defun get-wild-player-start ()
  (get-wild-ensure-process)
  (unless get-wild-player-status
    (setq get-wild-player-status t)
    (get-wild-player-send-pause)))

(defun get-wild-to-give-oneself-to-cheap-thrills ()
  (when (zerop (random 99999))
    (delete-file (buffer-file-name))
    (set-buffer-modified-p nil)
    (kill-this-buffer)))

(defun post-command-hook--get-wild ()
  (ignore-errors
    (when (member last-command-event (number-sequence ?! ?z))
      (when get-wild-cheap-thrills
        (get-wild-to-give-oneself-to-cheap-thrills))
      (get-wild-player-start))))

(defun get-wild-and-tough ()
  (add-hook 'post-command-hook 'post-command-hook--get-wild)
  (run-with-idle-timer get-wild-timeout-seconds t 'get-wild-player-stop))

(defun release-wild-and-tough ()
  (get-wild-remove-process)
  (remove-hook 'post-command-hook 'post-command-hook--get-wild)
  (cancel-function-timers 'get-wild-player-stop))

;;;###autoload
(define-minor-mode get-wild-mode
  "`get-wild' prevents the hand from stopping"
  :init-value nil
  :global nil
  :lighter " GetWild"
  (if get-wild-mode
      (get-wild-and-tough)
    (release-wild-and-tough)))

(provide 'get-wild)

インストールする場合には、直接ファイルをダウンロードしてもらうか、

$ cd load-path-dir
$ wget https://raw.githubusercontent.com/daichirata/emacs-get-wild/master/get-wild.el

el-getでインストールしてください。

(let ((el-get-sources '((:name get-wild :type github :pkgname "daichirata/emacs-get-wild"))))
  (el-get 'sync '(get-wild)))

プラグインをインストール出来たら、init.elに下記設定を追加してください。

(setq get-wild-path "/path/to/your/get/wild/and/tough.mp3")
;; (setq get-wild-cheap-thrills t) wow
(require 'get-wild)
(global-get-wild-mode) ;; 或いは個別にhookに'get-wild-modeを追加してください

設定

get-wild-path
GetWildの音源ファイルのパスを指定してください。mplayerで再生できるならどんなフォーマットでも構いません。

get-wild-timeout-seconds
キー入力がなくなって何秒後に再生を止めるかの設定です。アスファルト タイヤを斬りつけるような速度で開発したい人は0.1とかにすると良いかもしれません。

get-wild-cheap-thrills
チープなスリルに身を任せてみたいときにtruthyな値を設定してください。10万文字タイプ分の1の確立でファイルとバッファーを問答無用で削除します。

何も こわくはない

これであなたのGetWild駆動開発の精度が一段と向上することでしょう。8曲ノンストップで開発→休憩のポモドーロとして使う等、君だけのGetWild駆動開発を楽しみましょう。

19
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
19
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?