简体   繁体   English

扩展emacs搜索到其他缓冲区

[英]extending emacs search to other buffers

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. 我正在尝试改善emacs的搜索功能,并允许其在其他窗口中搜索(当多个窗口打开时),搜索我当前所在的词并单击鼠标。 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. 它不会环绕和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. 它也不会像isearch-forward那样标记候选人。

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 :( 至于使用鼠标作为搜索器(我想到了类似Alt-mouse的方法来选择一个单词并查找其所有实例-诸如GVIM shift-mouse1),我什至不知道如何分配鼠标点击:(

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 Cs? 所以我的问题是:如何改善我的功能以进行环绕式搜索并突出显示选择\\使isearch记住搜索,以便至少我可以继续使用Cs进行搜索? 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: 更新:highlight_symbol模式几乎是我想要使用鼠标作为搜索设备的方式:

 (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 :( 我仍然不能为其他窗口中的项目(可包装)搜索提供一个像样的功能:(

multi-isearch存在于misearch.el中,这可能是一个很好的起点,即使不能满足您的所有需求。

well, the solution might not be fancy and remarkable, but i simply made a macro: 好吧,解决方案可能并不花哨且引人注目,但我只是做了一个宏:

(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)

and get the desired behavior by Ctrl-=. 并通过Ctrl- =获得所需的行为。 it also saves the search in the isearch memory so continuous Cs will proceed the search. 它还将搜索保存在isearch内存中,因此连续的C将继续搜索。

a bit dull solution, but who said all solutions have to be remarkable and shinny... 有点沉闷的解决方案,但是谁说所有解决方案都必须出色而闪亮……

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM