hydra icon indicating copy to clipboard operation
hydra copied to clipboard

"Wrong type argument: commandp, ......." when call function through hydra

Open richarddwang opened this issue 7 years ago • 7 comments

I have a hydra like this

(global-set-key (kbd "<escape>") 'hydra-edit-panel/body)
(defhydra hydra-edit-panel (:hint nil :exit t )
  "Edit Panel"
  ;; Mark
  ("mw" mark-word-at-point)
  ("me" mark-expresiion-at-point)
  ("ml" mark-indented-line-at-point)
  )

and difinition with these funcitons

(defun mark-text-object-at-point (next prev)
  "First go to the end of the text object with funciton NEXT and set mark and than go back to the beginning of the text object with function PREV and complete the mark."
  ;; Notice: f means go next, b means prev
  (funcall next nil)
  (set-mark-command nil)
  (funcall prev))

(defun mark-word-at-point ()
  "Mark the word where the cursor at, if the cursor just between two word, than mark the word previos to the cursor."
  (interactive)
  (mark-text-object-at-point 'forward-word 'backward-word))

(defun mark-idented-line-at-point()
  "Mark the idented line where the cursor at."
  (interactive)
  (mark-text-object-at-point 'move-end-of-line 'back-to-indentation))

and mark-word-at-point works well with ESC mw but when it comes to mark-indented-line-at-point I can call it by M-x mark-indented-line-at-point and get

Wrong type argument: commandp, mark-indented-line-at-point

after ESC ml

Any suggestion?

richarddwang avatar Jul 02 '17 19:07 richarddwang

mark-indented-line-at-point

This function does not exist. I don't have it either.

abo-abo avatar Jul 03 '17 06:07 abo-abo

The function is defined by me, can call it with M-x

richarddwang avatar Jul 03 '17 13:07 richarddwang

Well, you need to load that function with e.g. C-x C-e or C-M-x.

abo-abo avatar Jul 03 '17 15:07 abo-abo

I get the same error message even after I restarted my Emacs and evaluated both my hydra function and mark-indented-line-at-point with both 'C-x C-e' and 'C-M-x'

richarddwang avatar Jul 03 '17 16:07 richarddwang

@frankie8518 @abo-abo i think this might happen when the function isn't (interactive).

dieggsy avatar Jul 03 '17 17:07 dieggsy

@therockmandolinist Though mark-indented-line-at-point use a not interactive function mark-text-object-at-point but it is interactive itself. And I could find it with M-x.

richarddwang avatar Jul 03 '17 17:07 richarddwang

@frankie8518 oh, nevermind, i didn't see that. my bad

dieggsy avatar Jul 03 '17 17:07 dieggsy