When reading the constant :hi
,
I get the error:
test: Wrong type argument: char-or-string-p, :hi
(defun test ()
:hi "greet"
(insert :hi)
)
(test)
What does it mean? Why is "greet" not the output?
insert
operates on string
s or character
s, but you gave it a symbol
(:hi
). Put your cursor on insert
and hit C-h f RET (or do C-h f insert RET anywhere) and you will get the description of the function insert
in buffer *Help*
.
My ESP tells me that you think that :hi "greet"
in the beginning of your code should bind variable :hi
to value "greet"
and then (insert :hi)
should call insert
on the value of :hi
that should be "greet"
.
This is not the case.
:hi "greet"
has no effect whatsoever.:hi
is a keyword, it is always a constant that evaluates to itself and cannot be bound.let
, try C-h f let RET.Thus your code should be
(def test()
"my function to insert a greeting"
(let ((hi "greet"))
(insert hi)))
I urge you to read "An Introduction to Programming in Emacs Lisp", you will not regret it. The best way to do it is in Emacs: C-h i m intro TAB RET.