I am trying to customize emacs/spacemacs to run a command after a key stroke, like running eslint --fix command on the buffer to fix errors.

I already tried

(defun fix-errors-with-eslint ()
  (shell-command-to-string (format "eslint --fix %s" buffer-file-name)))
(global-set-key (kbd "s-f") 'fix-errors-with-eslint)

but i receive an error: Wrong type argument: commandp, fix-errors-with-eslint

I am an emacs beginner, using only basic spacemacs and its layers, any help appreciated.


Try adding (interactive) as the first line in your function definition. That will make it a command instead of a function.

  • could you post an example, again, I am a beginner :( May 31 '17 at 17:16
  • ok, that solve my problem May 31 '17 at 17:26
  • but this question is duplicated May 31 '17 at 17:27

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