When I press C-c c
with the following code on a buffer, Emacs complains with Invalid function: (select-current-line)
. Why?
(defun select-current-line ()
"Select the current line"
(interactive)
(end-of-line) ; move to end of line
(set-mark (line-beginning-position)))
(defun my-isend ()
(interactive)
(if (and transient-mark-mode mark-active)
(isend-send)
((select-current-line)
(isend-send)))
)
(global-set-key (kbd "C-c c") 'my-isend)
Not that it matters, but for those interested isend-send is defined here.
You are missing a
progn
form to group statements together:Without the
progn
form,((select-current-line) (isend-send))
is interpreted as the(select-current-line)
function applied to the result of callingisend-send
without arguments. But(select-current-line)
is not a valid function name. In other LISPs, such a construct could be valid if the return value ofselect-current-line
was itself a function, which would then be applied to(isend-send)
. But this is not the case of Emacs LISP and this would not do what you wanted to achieve anyway...