I'm trying to make a trivial function that simply transposes chars backwards.

This is what I got so far:

(defun jd:backward-transpose-chars ()
  (transpose-chars -1))

(define-key global-map (kbd "<C-y>") '(transpose-chars))

(define-key global-map (kbd "<C-S-y>") '(jd:backward-transpose-chars))

But it gives me the error:

Debugger entered--Lisp error: (wrong-type-argument commandp (jd:backward-transpose-chars))

1 Answer 1


You have extra parenthesis, the correct synatx is:

(define-key global-map (kbd "<C-y>") #'transpose-chars)
(define-key global-map (kbd "<C-S-y>") #'jd:backward-transpose-chars)

By the way, I don't think I'd bother with keybindings: transpose-chars is bound by default to C-t, and to transpose backwards you can do C-- C-t (that's control minus, control t).

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.