0

i am trying to use the mouse for search as in VIM "super *"\ shift-mouse1 search.

used the highlight-symbol mode to get (almost) the desired behavior for the keyboard search, but I can't find a way to do the same for the mouse. I tried:

(require 'highlight-symbol)
(global-set-key [(control f3)] 'highlight-symbol-at-point)// <- works for the keyboard
(global-set-key [(control shift mouse1)] 'highlight-symbol-at-point)

but when i'm trying Ctrl-Shift-Mouse1 it doesn't search for the mouse current location, but the cursor's current location. is there a way for me to get teh mouse current position for function use? the highlight-symbol uses things-at-point, but i couldn't find a similar package for the mouse.

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

1 Answers1

0

This piece of code may do what you are looking for. Note that you need to capture the event, hence the (interactive "e"):

(global-set-key [(control shift mouse-1)]
                (lambda (event)
                  (interactive "e")
                  (save-excursion
                    (goto-char (posn-point (event-start event)))
                    (highlight-symbol-at-point))))

Also, I had to use mouse-1 instead of mouse1... ymmv.

juanleon
  • 9,220
  • 30
  • 41
  • that's odd, but you're right - the aliasing stopped working with mouse1 when i attached it to the function you made. it did work before... in any case, your solution is working well. tnx. – user2141046 Jul 03 '13 at 06:19
  • however, this is quite retarded because it marks the words according the mouse click but won't search between highlighted items because they are not under the cursor... need to improve the alias to also position the cursor at the point. – user2141046 Jul 03 '13 at 06:34
  • 2
    If you want to position the cursor at the point, just remove the `save-excursion`. – juanleon Jul 03 '13 at 06:43