Emacsのひらいているバッファで適当な行へジャンプするものをつくった。
This file contains hidden or 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
(require 'cl) | |
(cl-defun y-goto-randam-line(&optional (cond (lambda(x) x))) | |
"バッファのランダムな行へ移動する" | |
(let ((max (save-excursion (end-of-buffer) | |
(line-number-at-pos)))) | |
(cl-random max (make-random-state)) | |
(while (not (let ((line (+ (cl-random max) 1))) | |
(when (funcall cond line) | |
(goto-line line))))))) |
引数は飛び先の行を判定する条件をコントロールするもの。
(y-goto-randam-line 'oddp)
これで奇数行だけにジャンプする(はず)。
——これが何の役に立つのか?
立たないかもしれない。