LoginSignup
4
2

More than 5 years have passed since last update.

evilの/?nNでmigemo検索

Posted at

evilの/?でmigemo検索をしたいので調べました。

(setq evil-regexp-search nil)

でいけるかと思ったのですが、n/Nコマンドでの再検索がうまくいきませんでした。

いろいろ試行錯誤した結果、結局関数を再定義しました。

(defun evil-search-function (&optional forward regexp-p wrap)
  "Return a search function.
If FORWARD is nil, search backward, otherwise forward.
If REGEXP-P is non-nil, the input is a regular expression.
If WRAP is non-nil, the search wraps around the top or bottom
of the buffer."
  `(lambda (string &optional bound noerror count)
     (let ((start (point))
           (search-fun ',(if regexp-p
                             (if forward
                                 're-search-forward
                               're-search-backward)
                           (if forward
                               'migemo-forward
                             'migemo-backward)))
           result)
       (setq result (funcall search-fun string bound
                             ,(if wrap t 'noerror) count))
       (when (and ,wrap (null result))
         (goto-char ,(if forward '(point-min) '(point-max)))
         (unwind-protect
             (setq result (funcall search-fun string bound noerror count))
           (unless result
             (goto-char start))))
       result)))

search-forward/search-backwardをmigemo-forward/migemo-backwardにしただけです。
何かもっと良い方法があればと思うのですが、なかなか難しいです。

4
2
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
4
2