Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Suppose I want to select some text (mark a region) using my mouse, but without dragging. What I normally do (in most apps but emacs) is:

  1. click with the left button of my mouse (down-mouse-1);
  2. release my mouse, in to leave the cursor where I want the selection to begin;
  3. press and hold the shift key;
  4. and finally click (down-mouse-1) again in the place of the text where I want the selection to end.

However, I cannot do this with emacs, because in step 4 a context menu pops up (Change default buffer face), and my selection gets lost.

I've tried remapping <S-down-mouse-1> to several other commands, with no success.

Does someone know how to accomplish this feat in emacs?

(I'm using emacs 24.2 on Xubuntu 12.04 and also on Mac Os X 10.8 (Cocoa Emacs); I'm using transient-mode and cua-mode.)


Update:

I have just tried this code, as suggested here, but also with no success.

  ;; shift + click select region
  (define-key global-map (kbd "<S-down-mouse-1>") 'ignore) ; turn off font dialog
  (define-key global-map (kbd "<S-mouse-1>") 'mouse-set-point)
  (put 'mouse-set-point 'CUA 'move)
share|improve this question
    
If you press C-h c, hold the shift key, and then click somewhere in the text, what do you get in the echo area? My Emacs says <S-mouse-1> (translated from <S-down-mouse-1> <S-mouse-1>) at that spot runs the command mouse-save-then-kill and behaves the way you want yours to behave. I'm also on 24.2 on OS X, using transient-mode but not cua-mode. –  legoscia Dec 20 '12 at 14:07
    
@legoscia I added this to my init file, as you suggested, and it worked!!! (define-key global-map (kbd "<S-down-mouse-1>") 'mouse-save-then-kill). (Please add it as an answer and I will acknowledge it.) –  NVaughan Dec 20 '12 at 14:52

2 Answers 2

up vote 2 down vote accepted

Not sure why you don't have this binding already, but this seems to have fixed your problem, as per your comment:

(define-key global-map (kbd "<S-down-mouse-1>") 'mouse-save-then-kill)
share|improve this answer

Have you tried using Cocoa emacs? I'm fairly certain the behavior you want works out of the box.

share|improve this answer
    
Well, I'm using it right now with no sucess. –  NVaughan Dec 18 '12 at 20:31
    
Just tried running emacs with emacs -q, to see if something in my init files was messing up with the mouse's behavior, but nothing changed. –  NVaughan Dec 18 '12 at 20:36
    
Have you tried it with no configuration? (i.e. temporarily rename your .emacs so it won't be found). Perhaps there's something in there causing the problem. I have the exact same emacs and OSX versions as you and it works without a .emacs. –  James Porter Dec 18 '12 at 20:38
    
wow, that's bizarre. I can think of no remaining difference between our setups. –  James Porter Dec 18 '12 at 20:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.