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

Drew
  • 29,895
  • 7
  • 74
  • 104
user2141046
  • 862
  • 2
  • 7
  • 21

2 Answers2

1

Exists multi-isearch in misearch.el, which probably delivers a good starting point, if not delivering all you are looking for.

Andreas Röhler
  • 4,804
  • 14
  • 18
  • not really, it doesn't give me what i need - the misearch go to next buffer only if it fails to find in the current buffer, it is not what i need. managed to find `highlight-symbol` mode, but it also a bit inferior to the gvim functionality because it is alien to the default isearch. – user2141046 Jul 02 '13 at 06:35
  • I think it delivers exactly what you want - check `M-x multi-isearch-buffers` and see `ibuffer-do-isearch` for an example of invocation directly from lisp. – assem Jul 04 '13 at 11:32
  • BTW, IBuffer has lots of great functionality, you can mark all buffers of a specific mode or regexp, then run isearch, replace-regexp, occur, and more on them. I recommend `(defalias 'list-buffers 'ibuffer)` and then invoke w/ `C-x C-b` – assem Jul 04 '13 at 11:38
1

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-=. it also saves the search in the isearch memory so continuous C-s will proceed the search.

a bit dull solution, but who said all solutions have to be remarkable and shinny...

user2141046
  • 862
  • 2
  • 7
  • 21