Skip to content

Instantly share code, notes, and snippets.

@guehara
Created April 20, 2012 05:07
Show Gist options
  • Save guehara/2426152 to your computer and use it in GitHub Desktop.
Save guehara/2426152 to your computer and use it in GitHub Desktop.
isearch-forward-word が気に入らないので改良版
参考【EmacsWiki: Search At Point】 http://emacswiki.org/emacs/SearchAtPoint
(defvar isearch-initial-string nil)
(defun isearch-set-initial-string ()
(remove-hook 'isearch-mode-hook 'isearch-set-initial-string)
(setq isearch-string isearch-initial-string)
(isearch-search-and-update))
(defun isearch-forward-at-point (&optional regexp-p no-recursive-edit)
"Interactive search forward for the symbol at point."
(interactive "P\np")
(if regexp-p (isearch-forward regexp-p no-recursive-edit)
(let* ((end (progn (skip-syntax-forward "w_") (point)))
(begin (progn (skip-syntax-backward "w_") (point))))
(if (eq begin end)
(isearch-forward regexp-p no-recursive-edit)
(setq isearch-initial-string (buffer-substring begin end))
(add-hook 'isearch-mode-hook 'isearch-set-initial-string)
(isearch-forward regexp-p no-recursive-edit)))))
(define-key isearch-mode-map "\C-w" 'isearch-forward-at-point)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment