Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 3 down vote accepted

Use the env command:


and you can alias this as before:

alias emacs="env GDK_NATIVE_WINDOWS=1 emacs"
share|improve this answer

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.

share|improve this answer
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 posting your answer, you agree to the privacy policy and terms of service.

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