Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get mouse selection to work in emacs and iTerm2 on Mac?

Tags:

emacs

macos

iterm

after turning on xterm-mouse-mode, any click on the in the screen returns "mouse-1 is undefined". What should I be defining "mouse-1" as? Is there some reason my mouse clicks are returning this event, and not others its suspecting?

like image 779
Chris Avatar asked Apr 19 '11 00:04

Chris


People also ask

How do I use mouse in Emacs?

Mouse-1 is the left button, Mouse-2 is the middle button, and Mouse-3 is the right button. If you mouse only has two buttons and no scroll wheel, you can simulate the middle button by pressing the left and right buttons simultaneously.

How do I get to iTerm2 preferences?

Select Session > Edit Session to modify properties of the current session. The preference window will open, and at the bottom of the General tab is a field where you can set a hotkey that opens iTerm2 to reveal that session.

How do I use iTerm2 on Mac?

How do I open iTerm2 on Mac? To open iTerm 2, you simply need to double-click its icon – the one that you downloaded. If you go through the process of setting up hotkeys for the app, you will also be able to open iTerm2 through a specified by you keyboard combination.

How do you use item 2?

The primary use of the mouse in iTerm2 is to select text, and (by default) text is copied to the clipboard immediately upon being selected. You can click and drag to perform a normal selection. Double-clicking selects a whole word. Triple-clicking selects an entire line.


1 Answers

For Emacs in iTerm 2, I've found that the following bit in my ~/.emacs file works very well, providing the ability to insert the character at an arbitrary location, mark a region, and use the scroll wheel:

;; Enable mouse support (unless window-system   (require 'mouse)   (xterm-mouse-mode t)   (global-set-key [mouse-4] (lambda ()                               (interactive)                               (scroll-down 1)))   (global-set-key [mouse-5] (lambda ()                               (interactive)                               (scroll-up 1)))   (defun track-mouse (e))   (setq mouse-sel-mode t) ) 
like image 62
bfroehle Avatar answered Oct 02 '22 20:10

bfroehle