* Command in a function
@ 2010-03-24 21:50 Klaus Jantzen
2010-03-24 22:36 ` Drew Adams
0 siblings, 1 reply; 7+ messages in thread
From: Klaus Jantzen @ 2010-03-24 21:50 UTC (permalink / raw)
To: emacs-list
Hello,
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.
Thanks for any help.
--
K.D.J.
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: Command in a function
2010-03-24 21:50 Command in a function Klaus Jantzen
@ 2010-03-24 22:36 ` Drew Adams
2010-03-25 7:23 ` Klaus Jantzen
0 siblings, 1 reply; 7+ messages in thread
From: Drew Adams @ 2010-03-24 22:36 UTC (permalink / raw)
To: 'Klaus Jantzen', 'emacs-list'
> 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).
Or (end-of-line N), where N is the number of lines to first move forward or
backward.
In Emacs, a command is a function.
A function that has an `interactive' spec is a command. See the Elisp manual,
page `Using Interactive', if you want to make a function interactive (i.e. make
it a command, so you can bind it to a key or invoke it by name using `M-x').
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Command in a function
2010-03-24 22:36 ` Drew Adams
@ 2010-03-25 7:23 ` Klaus Jantzen
2010-03-26 15:29 ` Drew Adams
2010-03-26 16:04 ` Lennart Borgman
0 siblings, 2 replies; 7+ messages in thread
From: Klaus Jantzen @ 2010-03-25 7:23 UTC (permalink / raw)
Cc: 'emacs-list'
Drew Adams wrote:
>> 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)"
> Or (end-of-line N), where N is the number of lines to first move forward or
> backward.
>
> In Emacs, a command is a function.
>
> A function that has an `interactive' spec is a command. See the Elisp manual,
> page `Using Interactive', if you want to make a function interactive (i.e. make
> it a command, so you can bind it to a key or invoke it by name using `M-x').
>
>
>
--
K.D.J.
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: Command in a function
2010-03-25 7:23 ` Klaus Jantzen
@ 2010-03-26 15:29 ` Drew Adams
[not found] ` <4BACD9DE.6080802@t-online.de>
2010-03-26 16:04 ` Lennart Borgman
1 sibling, 1 reply; 7+ messages in thread
From: Drew Adams @ 2010-03-26 15:29 UTC (permalink / raw)
To: 'Klaus Jantzen'; +Cc: 'emacs-list'
> >> 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
)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Command in a function
2010-03-25 7:23 ` Klaus Jantzen
2010-03-26 15:29 ` Drew Adams
@ 2010-03-26 16:04 ` Lennart Borgman
1 sibling, 0 replies; 7+ messages in thread
From: Lennart Borgman @ 2010-03-26 16:04 UTC (permalink / raw)
To: Klaus Jantzen; +Cc: emacs-list
On Thu, Mar 25, 2010 at 8:23 AM, Klaus Jantzen <k.d.jantzen@t-online.de> wrote:
>
> That is what I had in the beginning . I tried it again and receive the
> friendly message
> "Invalid function (end-of-line)"
It looks like you have something like ((end-of-line)) since the
compiler complaints about the function "(end-of-line)".
You may have gotten that from a bad defmacro call (I have not followed
this thread).
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-03-27 14:01 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-24 21:50 Command in a function Klaus Jantzen
2010-03-24 22:36 ` Drew Adams
2010-03-25 7:23 ` Klaus Jantzen
2010-03-26 15:29 ` Drew Adams
[not found] ` <4BACD9DE.6080802@t-online.de>
[not found] ` <52CFAD1180B1460090347833DE17B97D@us.oracle.com>
2010-03-27 10:25 ` Klaus Jantzen
2010-03-27 14:01 ` Drew Adams
2010-03-26 16:04 ` Lennart Borgman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).