10

^ is the key binding for moving to the parent directory in dired ("Up directory").

However, in Gnu Emacs on Windows 7 Professional 64-bit with my German keyboard layout, it is not sufficient to type "^" but I have to type space afterwards to make the key-binding work.

How can I redefine the key-binding to avoid having to press space and move upwards only with "^"?


C-h k ^<space> returns

^ runs the command dired-up-directory, which is an interactive compiled Lisp function in `dired+.el'.

It is bound to ^, .

(dired-up-directory &optional OTHER-WINDOW)

Run Dired on parent directory of current directory. Find the parent directory either in this buffer or another buffer. Creates a buffer if necessary.

6
  • 4
    This is an OS issue as this behaviour sounds like sticky keys and is built into certain keymaps, such as us-intl on Linux.
    – wasamasa
    Commented Jun 2, 2015 at 11:42
  • Sounds like wasamasa is right, in which case you should be asking how to bind the command to a different key. Commented Jun 2, 2015 at 13:23
  • @AndrewSwann: Maybe, maybe not. It's a good thing to check, yes. But Linux behavior should be irrelevant here, assuming the microsoft-windows tag is appropriate.
    – Drew
    Commented Jun 2, 2015 at 14:30
  • The simplest way of checking for this would be looking whether the same behaviour applies to other programs, such as by typing ^ into notepad.exe.
    – wasamasa
    Commented Jun 2, 2015 at 15:10
  • 3
    I think you have only a few options: (1) Use a different keyboard layout in which ^ is not a dead key – this is done at the OS level, not in emacs, or (2) Bind some other key to dired-up-directory and use it instead, or (3) Live with the problem, and type the space after ^. I am going with (3) myself, but I do find it irritating. Commented Jun 2, 2015 at 15:21

2 Answers 2

12

With your keyboard setup, the key ^ is most probably a "dead key". It is a key meant to be used in conjunction with another one, in order to produce another character. In this case, it is meant to produce accented characters : ^e will produce ê, ^a will produce â and so on.

It should not be specific to emacs though : I guess all your applications require you to hit ^ and to produce an actual ^ on the screen.

To solve this, you simply have to use another keyboard layout. In the case of your german layout in a windows environment, I'll simply refer to https://superuser.com/questions/280005/how-to-make-and-non-dead-keys-on-windows-7-with-german-keyboard-layout, hoping this is the right thing to do.

0

I guess you've confirmed the binding of ^ in Dired as being dired-up-directory, so which command is invoked is not the problem, unless you or something you load has advised that command. (Use C-h k ^, and let us know if the command is advised.)

You tagged this with microsoft-windows. Maybe mention which MS Windows version you use. I do not see this with Windows 7 64-bit.

Do you see the same behavior if you start Emacs by using runemacs -Q, i.e., with no init file? If so, please give a recipe here, starting from runemacs -Q. In that case, this could be an Emacs bug.

If you do not see the problem with emacs -Q then recursively bisect your init file until you narrow it down to find the culprit. You can use command comment-region to comment out the region of code (use C-u with it to uncomment the region).

Once you find the culprit code, you can investigate that more closely. Or you can report here what you've found, if you need further help. For the best help, be as specific as possible.

As for redefining the key: That's not a problem - just use (define-key dired-mode-map SOME-KEY 'dired-up-directory), where SOME-KEY is a key description. For example, to bind the command to C-o, you can use this:

(define-key dired-mode-map (kbd "C-o") 'dired-up-directory)

Updated after your comment and others -

Since you see the same thing from emacs -Q, the problem is either something in your MS Windows setup (i.e., outside Emacs) or a bug in Emacs itself.

But other comments make clear that the problem seems to be sticky keys in MS Windows. Try turning sticky keys off.

3
  • 3
    This is almost certainly beside the point. The comment by @wasamasa is totally relevant, though. To elaborate a bit, the point is that since ^ is sticky, emacs doesn't even see the keypress event until the user types a space. Commented Jun 2, 2015 at 15:17
  • thanks for your detailed answer! Yes, with runemacs.exe -Q it is the same. Typing ^ in a buffer does only enter the character, if I type <space> or another key afterwards. Same in dired mode,it needs ^1 <space> to move up. For define-key: but I'd like to use the ^ key for this binding, is there a way to avoid it waiting for <space>? Commented Jun 2, 2015 at 15:19
  • @Harald: so what can I do? Commented Jun 2, 2015 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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