(defvar minibuf-expand-migemo-original nil) (defvar minibuf-expand-migemo-migemo nil) (defun minibuf-expand-migemo () (interactive) (when (featurep 'migemo) (remove-hook 'minibuffer-exit-hook 'minibuf-expand-migemo-delete-history) (let* ((again (eq last-command this-command)) (beg (if (fboundp 'field-beginning) (field-beginning) (point-min))) (end (if (fboundp 'field-end) (field-end) (point-max))) (string (buffer-substring-no-properties beg end))) (if (and again minibuf-expand-migemo-original) (setq string minibuf-expand-migemo-original minibuf-expand-migemo-original nil) (setq minibuf-expand-migemo-original string) (setq string (migemo-get-pattern string)) (setq minibuf-expand-migemo-migemo string) (add-hook 'minibuffer-exit-hook 'minibuf-expand-migemo-delete-history)) (delete-region beg end) (insert string)))) (defun minibuf-expand-migemo-setup () (when (featurep 'migemo) (setq minibuf-expand-migemo-original nil) (setq minibuf-expand-migemo-migemo nil) (remove-hook 'minibuffer-exit-hook 'minibuf-expand-migemo-delete-history))) (defun minibuf-expand-migemo-delete-history () (when (and minibuf-expand-migemo-migemo (string= minibuf-expand-migemo-migemo (car (symbol-value minibuffer-history-variable)))) (set minibuffer-history-variable (cdr (symbol-value minibuffer-history-variable))) (when minibuf-expand-migemo-original (set minibuffer-history-variable (cons minibuf-expand-migemo-original (symbol-value minibuffer-history-variable))))) (minibuf-expand-migemo-setup)) (unless (featurep 'xemacs) (add-hook 'minibuffer-setup-hook 'minibuf-expand-migemo-setup) (mapcar (lambda (map) (define-key map "\M-\C-m" 'minibuf-expand-migemo)) (delq nil (list (and (boundp 'minibuffer-local-map) minibuffer-local-map) (and (boundp 'minibuffer-local-ns-map) minibuffer-local-ns-map) (and (boundp 'minibuffer-local-completion-map) minibuffer-local-completion-map) (and (boundp 'minibuffer-local-must-match-map) minibuffer-local-must-match-map)))))
本業のリリースは失敗するし、不用意に書いたメールで叱られるし。。。