I'm overriding double-mouse-1
to do additional stuff on top of its default behavior. To this end, I have a function that (1) does my additional stuff and then (2) calls another function, ora-mark-like-double-mouse-1
, which simulates normal double-mouse-1
behavior (copied from here).
(transient-mark-mode t)
(defun ora-mark-like-double-mouse-1 ()
(interactive)
(let ((bnd (mouse-start-end (point) (point) 1)))
(goto-char (car bnd))
(push-mark)
(set-mark (point))
(goto-char (cadr bnd))
; The addition of this line produces a different,
; but also wrong effect, in which the selection vanishes
; immediately after appearing.
(setq deactivate-mark t)
)
)
(global-set-key [(double-mouse-1)] 'ora-mark-like-double-mouse-1)
However, this function is slightly flawed. It selects the clicked-on word as the region, but afterwards, any non-shifted cursor movement I do with the arrow keys causes the existing region to be expanded, rather than deactivated. This is different from normal double-mouse-1
behavior. This happens even if I just bind this function directly to double-mouse-1
, as I do in the code above (in which I have temporarily removed my own extra functionality, and I have added a call to (setq deactivate-mark t)
, which causes the selection to vanish immediately after appearing -- which is not the correct behavior either).
Is there a way to set it so that, after calling this function, which selects a region, subsequent non-shifted cursor movement will cause the region to be deactivated?
Alternatively, if there some way to set up a hook to run after a double-click event, I wouldn't need to override and reimplement the default functionality at all. (It would also solve the problem that the linked-to function doesn't work when I double-click on the opening quote.)