2

I am trying to improve the searching features of my emacs and allow it to search in other window (when multiple windows open), search the word i'm currently on and search on mouse click. I used this unit-at-cursor to create the following functions:

(defun seek-other-tab ()
  (interactive)
   (setq unit (elt (unit-at-cursor 'word) 0) // gets the word at which the cursor is
   (other-window 1) // get to the next window
   (search-forward unit nil nil)))  // search...

and

(defun seek-buffer ()
 (interactive)
 (search-forward (elt (unit-at-cursor 'word) 0))

however, this is weaker than manually searching the other buffer because a. it doesn't wrap around and b. it doesn't remember the search so basically i need to use the both of the functions for searching effectively. it also doesn't mark the candidates as isearch-forward does.

as to the use of mouse as searcher (i thought of something like Alt-mouse to select a word and look for all its instances - like the GVIM shift-mouse1), i don't even know how to assign the mouse click :(

so my questions are : How can i improve my functions to have a wraparound search and to highlight selection\ make the isearch remember the search so at least i will be able to continue searching with C-s? How can i make the third function, that selects the word touched by the mouse and search for the instances (preferably, also highlighting)

update: the highlight_symbol mode is almost what i wanted for using the mouse as search device:

 (global-set-key [(control shift mouse1)] 'highlight-symbol-at-point)

however, the function still only looks under the cursor instead of the mouse position. will ask it in a different thread. i still can't make a decent function for the (wrapable) searching of items in the other window :(

4

2 回答 2

1

好吧,这个解决方案可能并不花哨和非凡,但我只是做了一个宏:

(defalias 'search-other-window (read-kbd-macro "M-b C-s C-w C-x o C-s C-s"))
(global-set-key (kbd "C-=") 'search-other-window)

并通过 Ctrl-= 获得所需的行为。它还将搜索保存在 isearch 内存中,因此连续的 Cs 将继续搜索。

有点沉闷的解决方案,但谁说所有解决方案都必须出色而闪亮......

于 2013-07-03T13:53:36.473 回答
1

存在multi-isearch于 misearch.el 中,如果不能提供您正在寻找的所有内容,它可能会提供一个很好的起点。

于 2013-07-01T13:11:37.490 回答