Emacs mouse via xterm causing undefined key error - emacs

I am connecting to a RedHat Linux box via Xterm and running Emacs 24.4.1 and am trying to get the mouse to work properly.
I put the following in my .emacs file
(require 'mouse)
(xterm-mouse-mode t)
(mouse-wheel-mode t)
Mouse clicks now set the focus. I can use the mouse to select an area.
If I attempt to scroll with the mouse, the window scrolls properly, but I hear a beep and see an error:
M-[ m is undefined
Any idea what can be causing this and how to fix it?

Related

Emacs auto-complete-mode cycles focus through every window?

When I have autocomplete mode enabled:
(global-auto-complete-mode 1)
Once I get a few windows open, hitting any key in one window will quickly cycle focus through all the windows in the frame.
For example, to recreate:
Load auto-complete-mode
Open up 5 or 6 windows in one frame
Open up a frame editing a Python file (although this appears to happen with other file types too, like .c)
Mash the keyboard. Observe that focus is quickly cycled between the windows.
Here is a video showing the problem: http://gfycat.com/LeafyCleverCommongonolek — notice that I'm typing at a constant rate, but every few characters focus cycles between all the open windows.
If I set:
(global-auto-complete-mode nil)
Then the problem goes away.
What can I do to fix this?
This is happening with Carbon emacs 24.3.1 installed from Homebrew.

emacs won't repaint buffer (windows 7)

I am using GNU Emacs 24.2.1 on 64-bit Windows 7. Sometimes emacs window goes blank. This usually happens when switching focus back to emacs from another window. The only way to get the content back is to switch to another buffer and then back. No other programs behave like this. I do not have this problem on my home PC with similar hardware and OS.
I added the following code to my init.el so that when it happens to me (in 24.4), I just need to press F5:
(global-set-key (kbd "<f5>") #'redraw-display)

How can I configure emacs to switch to a particular buffer when I click the mouse in it?

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
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).

Emacs mouse support over terminal ssh

In my .vimrc file, I have this line:
set mouse=a
This enables the mouse to work with vim. You can move the point around by clicking, and it responds to the scroll wheel. It also works fine even in a vim instance accessed over a standard terminal emulator using SSH. Is there a way to enable the same functionality in Emacs?
Does xterm-mouse-mode do what you want? I found it by searching "emacs 'set mouse=a'"

How to disable cursor in emacs when emacs doesn't have focus?

I'm using emacs 22.3.3 over X on a Windows box.
When I've switched to another window, the cursor stays enabled (which means if it's blinking, it still blinks).
Every other program I've ever used disables the cursor when the window doesn't have focus. Since emacs is different, I keep accidentally typing input meant for emacs into other programs.
How can I programatically disable the cursor in my .emacs file when the window loses focus?
I know that emacs has a disabled cursor mode, because it switches the cursor to white with a black border when a particular buffer doesn't have the focus.
Update: My X client is Xming 6.9.0.31. I'm using X forwarding through putty.
Sounds like it's a window manager issue... the window manager is sending events to Emacs when (you believe) it shouldn't.
GNU Emacs doesn't have a window(frame) leave event hook (I've looked and can't find one (as of 23.1)), and the question: how to automatically save files on lose focus in emacs appears to bear that out.
Good luck...
The white with a black buffer is what I get when the Emacs window doesn't have focus. I'm using GNU Emacs 22.1.1 on XP. I haven't tried 22.3.3 yet, but I'd guess the issue might be that it is over X, rather than the version.
Some more info might be nice. What platform is the emacs itself running on? What version of X client are you using?