新手求助 ACME编辑器中一个我个人觉得非常好的功能就是右键单击当前字符会自动查询并定位下一个匹配字符,现这几天折腾EMACS,想实现这个功能,照搬前辈了代码,但有问题,请求帮助
(defun my-search ()
(interactive)
(let ( $p1 $p2 )
(if (use-region-p)
(progn
(setq $p1 (region-beginning))
(setq $p2 (region-end)))
(save-excursion
(skip-chars-backward "-_A-Za-z0-9")
(setq $p1 (point))
(right-char)
(skip-chars-forward "-_A-Za-z0-9")
(setq $p2 (point))))
(setq mark-active nil)
(when (< $p1 (point))
(goto-char $p1))
(isearch-mode t)
(isearch-yank-string (buffer-substring-no-properties $p1 $p2))))
(global-set-key [(mouse-3)]
'my-search)
这是我照搬的代码,可以高度显示出匹配字符,但光标不会定位到下一个