Wrong type argument: commandp, crux-smart-open-line-below

What happened?

In config.el i’ve defined:

(map! :desc "crux-smart-open-line-above" "M-O" #'crux-smart-open-line-above)
(map! :desc "crux-smart-open-line-below" "M-o" #'crux-smart-open-line-below)

The keybinding for “open-line-above” works fine but when pressing M-o i get “Wrong type argument: commandp, crux-smart-open-line-below”.

What am i doing wrong?

System information


Loading data dump...

This means crux-smart-open-line-below either:

  1. Does not exist,
  2. Is not defined yet (the parent library needs to be loaded first, or the function autoloaded),
  3. Is not an interactive commands. I.e. it does not have (interactive) in its definition.

The third is easy to fix: wrap it in an interactive function:

(map! "M-o" (lambda () (interactive) (crux-smart-open-line-below)))

Or use Doom’s cmd! convenience macro, which achieves the same effect:

(map! "M-o" (cmd! (crux-smart-open-line-below)))

The strange thing is, that i can run crux-open-line-below without a problem via M-x and crux-open-line-above works fine with the keybind so i’m really confused.

Adding your solutions for the third option (with “crux” not “crus”) and commenting out my original one both yield Error in private config: config.el, (end-of-file /home/myusername/.doom.d/config.el)

Inside config.el the line(s) of your solution get marked with Error running hook "+global-word-wrap-mode-enable-in-buffers" because: (void-variable +word-wrap-disabled-modes) which i also don’t understand as there is nothing to wrap.

I’m brand new at Emacs so i have no experience in understanding its inner workings and troubleshooting it, sorry.

My bad, both my snippets were missing an extra pair of closing parentheses. I’ve fixed them now.

Error running hook "+global-word-wrap-mode-enable-in-buffers" because: (void-variable +word-wrap-disabled-modes)

This is likely a secondary error caused by an earlier one (likely the end-of-file error you mentioned earlier). In Emacs, errors tend to compound in unpredictable ways; it’s best not to debug more than one at the same time and deal with them in order.

1 Like

Thank you, the added parentheses solved the config error.

I now have the following in my config.el:

(map! :desc "crux-smart-open-line-above" "M-O" #'crux-smart-open-line-above)
(map! "M-o" (cmd! (crux-smart-open-line-below)))

However, when pressing M-o i now get Symbol's function definition is void: crux-smart-open-line-below.

What does that mean? Why is crux-smart-open-line-above working without a hitch?

The error means crux-smart-open-line-below does not exist. And sure enough, after dipping into crux’s source code, I realize the command you want is crux-smart-open-line. And it’s interactive, so it doesn’t need to be wrapped in cmd!.

(map! "M-o" #'crux-smart-open-line))
1 Like

You are right. Thank you and sorry for that.

I don’t know if this was changed as i thought i read “line-below” when i executed “SPC h f” and “M-x” and was able to execute it.