もしあれば、アクティブな領域を検索するようにisearchに指示する方法はありますか?それ以外の場合は、定期的に文字列の入力を求めます。
編集:27.10.12
私はこれらの関数を使用することになりました:
(defun er/isearch-word-at-point ()
(interactive)
(call-interactively 'isearch-forward-regexp))
(defun er/isearch-yank-word-hook ()
(when (equal this-command 'er/isearch-word-at-point)
(let ((string (concat "\\<"
(buffer-substring-no-properties
(progn (skip-syntax-backward "w_") (point))
(progn (skip-syntax-forward "w_") (point)))
"\\>")))
(if (and isearch-case-fold-search
(eq 'not-yanks search-upper-case))
(setq string (downcase string)))
(setq isearch-string string
isearch-message
(concat isearch-message
(mapconcat 'isearch-text-char-description
string ""))
isearch-yank-flag t)
(isearch-search-and-update))))
(defun er/isearch-yank-region ()
(interactive)
(isearch-yank-internal (lambda () (mark))))
(define-key isearch-mode-map (kbd "C-r") 'er/isearch-yank-region)
(define-key isearch-mode-map (kbd "C-t") 'er/isearch-word-at-point)
1つ目は、ウェブのどこかで見つけた関数で、カーソルの下の単語を検索語としてマークし(vimの*と#に似ています)、次の出現に直接ジャンプします。2つ目は、@OlegPavlivの答えです。
編集#2
実は、両方を組み合わせて超甘さを出してみませんか?わかった!
(defun er/isearch-word-or-region-at-point ()
(interactive)
(if (region-active-p)
(isearch-yank-internal (lambda () (mark)))
(call-interactively 'isearch-forward-regexp)))
(defun er/isearch-yank-word-hook ()
(when (equal this-command 'er/isearch-word-or-region-at-point)
(let ((string (concat "\\<"
(buffer-substring-no-properties
(progn (skip-syntax-backward "w_") (point))
(progn (skip-syntax-forward "w_") (point)))
"\\>")))
(if (and isearch-case-fold-search
(eq 'not-yanks search-upper-case))
(setq string (downcase string)))
(setq isearch-string string
isearch-message
(concat isearch-message
(mapconcat 'isearch-text-char-description
string ""))
isearch-yank-flag t)
(isearch-search-and-update))))
(add-hook 'isearch-mode-hook 'er/isearch-yank-word-hook)
(define-key isearch-mode-map (kbd "C-r") 'er/isearch-word-or-region-at-point)