I'm trying to work around a known bug in Ubuntu 9.10, where using the scrollbar in emacs causes text to be highlighted, and the cursor to move. This page here shows that you can fix this by setting an environment variable before launching emacs:


So a lazy fix would be to alias "emacs" in my .bashrc:

alias emacs="GDK_NATIVE_WINDOWS=1 emacs"

This, however, has the drawback of setting this environment variable for all subsequent commands run from that shell. Is there any way to set GDK_NATIVE_WINDOWS=1 for just emacs, whenever I run emacs?


Use the env command:


and you can alias this as before:

alias emacs="env GDK_NATIVE_WINDOWS=1 emacs"

What you need to do is to clear the variable once emacs started. I am not sure how you can do this, however I am pretty sure it can be done.

  • So something like: alias emacs = "tmp=${GDK_NATIVE_WINDOWS} GDK_NATIVE_WINDOWS=1 emacs& GDK_NATIVE_WINDOWS=${tmp}" ? – SuperElectric Jan 29 '11 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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