help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Command in a function


From: Drew Adams
Subject: RE: Command in a function
Date: Fri, 26 Mar 2010 08:29:12 -0700

> >> I am writing a function that inserts some text into a buffer.
> >> At some point the cursor (point?) should go to the end of a line.
> >>
> >> For that I found the command "end-of-line". How do I code the 
> >> execution of this command in a function?
> >> I tried it with (command-execute end-of-line) but that 
> >> resulted in an error message.
> >
> > Just use (end-of-line).
> 
> That is what I had in the beginning . I tried it again and 
> receive the friendly message "Invalid function (end-of-line)"

You need to show more of the code you are trying to use.

(end-of-line) is not a function. It is an expression (a sexp) that represents a
function call. When it is evaluated, the function `end-of-line' is called (with
an empty argument list).

Apparently, you tried to use (end-of-line) in a context that expected a function
- e.g. as an functional argument to some higher-order function such as
`funcall', `apply', or `mapcar'.

Without seeing what your code is, it's difficult to help make things clearer for
you.

The point is: In a context that expects an expression to evaluate, you use an
expression, such as (end-of-line) or (funcall 'end-of-line), that represents a
function call. In a context that expects a function, you use an expression, such
as `end-of-line', that represents a function.

You asked how to use the command `end-of-line' in a function you are defining.
Here is an example:

(defun foo ()
  ... ; do something
  (end-of-line) ; go to eol
  ... ; do some more stuff
)






reply via email to

[Prev in Thread] Current Thread [Next in Thread]