0

I've set up activate-mark-hook and deactivate-mark-hook, but they work only when selecting text by dragging mouse, not by using shift-selection. How do I hook into shift selection?

I'm using Aquamacs 24 on Mac OS X 10.6.6.

myfreeweb
  • 971
  • 1
  • 13
  • 19
  • You should probably post here, not SO: http://superuser.com/ – Josh Feb 25 '11 at 18:03
  • 1
    @Josh: That *really* depends on what he want to do with those hooks (which are after all usually provided for future *programming* needs) @myfreeweb: you should clarify *why* you want this. – dmckee --- ex-moderator kitten Feb 25 '11 at 18:05
  • Does it really matter? I want to turn off hl-line-mode on activating the mark and vice versa because I want to have the same color for highlighted line and the region. Just like TextMate does it out of the box. – myfreeweb Feb 25 '11 at 18:11
  • It matters because [site selection for emacs related questions is tricky and somewhat controversial](http://meta.stackexchange.com/questions/79659/can-we-please-have-a-ruling-about-emacs-questions-on-so/79725#79725), but if you can show explicitly that this is a *programming* question, then there is no need to argue. – dmckee --- ex-moderator kitten Feb 25 '11 at 18:52

1 Answers1

1

Just peeked into the Emacs source to see what happens, this is what I found:

For every command that has been shift-translated, the function "handle-shift-selection" is called. This function will activate or deactivate the selection by using the "transient-mark-mode" variable, and by calling "push-mark" and "deactivate-mark", respectively. If I do the math correctly, this means that your deactivate hook will be called, but not you activation hook.

One way to solve this is to add your own code to "push-mark" using "defadvice".

Lindydancer
  • 25,428
  • 4
  • 49
  • 68