Skip to content

Latest commit

 

History

History
56 lines (38 loc) · 1.84 KB

crouton-emacs-middle-click.md

File metadata and controls

56 lines (38 loc) · 1.84 KB

Simulate middle mouse click in emacs on crouton

// crouton emacs ubuntu chromebook chrome os

Crouton is a nice set of scripts for running Ubuntu on a Chromebook. These notebooks have no middle mouse button. If you also run emacs in crouton, this is for you.

This article describes how to simulate a middle mouse click in emacs in order to paste the primary clipboard.

Map alt + click to middle button in crouton

This official wiki page describes how alt + click can be mapped to the middle button in crouton:

  1. Install xdotool in your chroot:
# apt-get install xdotool
  1. Create in your chroot ~/.xbindkeysrc.scm containing:
; Map Alt+click to middle button
; Map on Release so that it does not appear both buttons are pressed
(xbindkey '(release alt "b:1") "xdotool click --clearmodifiers 2")
  1. Restart your chroot.

Explanation

In each chroot, crouton starts for you Xbindkeys

$ ps aux | grep xbind
/usr/bin/xbindkeys -f /home/lourot/.xbindkeysrc.scm

and you've just told it to use xdotool to simulate another key when releasing alt + click.

Configure emacs

Unfortunately with the previous trick, emacs hears alt + middle-click instead of just middle-click. Therefore we need to make alt + middle-click paste the primary clipboard in emacs. To do so, add the following line to your emacs configuration and restart it:

(global-set-key (kbd "<M-mouse-2>") 'mouse-yank-primary)

For other emacs configuration tips for crouton, see crouton-emacs-conf.