0

I'm tryng to bind F6 to dired-up-directory using

(global-set-key (kbd "<f6>")

but when I use this in dired-mode, I get

<f6> is undefined.

What have I done wrong?

1 Answer 1

1

You need to provide the command that you want to bind to that key, as the second argument to global-set-key: (global-set-key (kbd "<f6>") #'dired-up-directory). Your sexp isn't even closed - it's missing a right paren (as well as a second argument).

But really you don't want to bind that key globally to dired-up-directory (do you?). You want to bind it to that command only in dired-mode:

(define-key dired-mode-map (kbd "<f6>") #'dired-up-directory)
4
  • I get this when using this definition:-Symbol's value as variable is void: dired-mode-map
    – balanga
    Sep 19, 2023 at 11:01
  • @balanga: For a major mode keymap to be available you need to at least load the library defining the mode, and typically you need to enable the mode. If you're in dired-mode then dired-mode-map is defined.
    – Drew
    Sep 19, 2023 at 15:30
  • How do I define it just in dired-mode? Do I need to edit dired.el?
    – balanga
    Nov 25, 2023 at 10:14
  • Define what just in dired-mode? dired-mode-map is, and should be, defined globally. It is used in dired-mode.
    – Drew
    Nov 25, 2023 at 16:03

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.