リアルタイムっぽい感じに動作するoccur
anything-occurがあれば用無しだけど…
read-from-minibufferにkey-mapを渡せることを知りませんでした。
(require 'cl) (defvar ort-running-timer nil) (defvar ort-current-input "") (defvar ort-current-buffer nil) (defvar ort-current-window nil) (defun ort-update-check () (with-selected-window (minibuffer-window) (let ((input (minibuffer-contents))) (unless (string-equal ort-current-input input) (setq ort-current-input input) (ort-update))))) (defun ort-update () (with-current-buffer ort-current-buffer (flet ((message (&rest x) nil)) ;;for silencing annoying message (when (occur ort-current-input) ;;matched line is not found then (display-buffer (get-buffer-create "*Occur*")))))) (defmacro ort-current-buffer-with (ac) `(lambda () (interactive) (with-selected-window ort-current-window ,ac))) (defvar ort-kmap (let ((kmap (copy-keymap minibuffer-local-map))) (define-key kmap "\C-n" (ort-current-buffer-with (next-line))) (define-key kmap "\C-p" (ort-current-buffer-with (previous-line))) (define-key kmap "\C-l" (ort-current-buffer-with (recenter-top-bottom))) (define-key kmap "\C-v" (ort-current-buffer-with (scroll-up))) (define-key kmap "\M-v" (ort-current-buffer-with (scroll-down))) kmap)) (defun ort-prepare () (when ort-running-timer (cancel-timer ort-running-timer)) (setq ort-current-buffer (current-buffer)) (setq ort-current-window (selected-window))) (defun occur-real-time () (interactive) (unwind-protect (progn (ort-prepare) (setq ort-running-timer (run-with-idle-timer 0.5 t 'ort-update-check)) (occur (read-from-minibuffer "occur:" nil ort-kmap))) (cancel-timer ort-running-timer)))