2

I'm using iTerm2 on my mac to ssh into a Linux box and run emacs in the terminal. On a big monitor, I like to split the window to see multiple buffers side-by-side. I'd like to be able to switch to a particular buffer by clicking the mouse in it (rather than doing C-x o).

What seems to be happening is that if I click the mouse anywhere outside the currently active buffer e.g. in the next buffer, on the mode line etc., the click is being interpreted as which is bound to (tmm-menubar-mouse EVENT).

I have disabled the menubar by doing the following in my .emacs_d/init.el: (menu-bar-mode -1)

This seems to disable the visible display of the menu bar at the top of the window, but the mouse click behavior I described is still happening.

I think what I need is to have the click interpreted as something other than and then bind that to some function that detects which buffer the click happened in and switch to it. But, I don't know how to do that and the searching I've done hasn't yielded any clear answer. Can anyone help?

Alternatively, I looked into using windmove to enable switching between buffers with SHIFT and the arrow keys. I did (windmove-default-keybindings) but emacs then seems to respond to SHIFT left-arrow by inserting "2C" into the buffer and SHIFT-right-arrow by inserting "2D". If anyone has any tips on making this work too, I'd love to hear them.

Thanks

triangle_man
  • 1,072
  • 6
  • 10
  • Re: your windmove issue, Gilles has a couple of good answers on using input-decode-map to get terminals and Emacs speaking the same language. See http://stackoverflow.com/questions/3518846/shift-tab-produces-cryptic-error-in-emacs/3520543#3520543 and http://stackoverflow.com/questions/4351044/binding-m-up-m-down-in-emacs-23-1-1/4360658#4360658 – phils Sep 29 '11 at 20:54
  • Thanks. I looked at that but mysteriously, when I did the fix below that Asher L. suggested for my mouse issues, the windmove stuff started working. Not sure if it's coincidence or not, but I'm back in business. – triangle_man Sep 30 '11 at 16:57

1 Answers1

1

I ran into this problem a while ago, where clicking on column > 95 was interpreted as <menu-bar> <mouse-1>, which invokes tmm-menubar-mouse. It turned out to be a bug:

http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6594

There hasn't been a formal release since this bug was fixed, but you can get the patch here:

http://bzr.savannah.gnu.org/lh/emacs/emacs-23/revision/100618

If I recall correctly, you should be able to just drop the modified file into your existing emacs installation and byte-compile it (assuming you're running the 23.3.1, the latest release).

Asher L.
  • 1,297
  • 11
  • 10
  • After a day of using emacs with the fix you suggested in place, things are working much better, but I'm occasionally seeing another related problem. Sometimes when I click the mouse in a buffer, the click doesn't seem to "take" and the following shows up in the *Messages* buffer: xterm-mouse-event: Wrong type argument: wholenump, -6. Any ideas on this? I found [link](http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6594) when searching on this, which seems to suggest a similar, but different fix than the one in the patch you described earlier. Any ideas on what I should do? Thanks again! – triangle_man Sep 30 '11 at 23:00
  • Does that happen only at one specific column? There may be a boundary condition that isn't handled properly. The patch in your link is probably mine; I submitted a hack that seemed to work (though I'm not an emacs/elisp guru), and Andreas Schwab committed a different patch that appeared to be a bit nicer. I didn't carefully study his patch, and I don't usually run in console mode, but it worked for me. If you can reproduce this with the latest version of either the 23.3 or the 24 branch, you could reopen issue 6594. Also, I'll see if I can reproduce on my machine. – Asher L. Sep 30 '11 at 23:16