* problems with save-excursion
@ 2006-03-08 22:36 filcab
2006-03-08 22:57 ` Katsumi Yamaoka
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: filcab @ 2006-03-08 22:36 UTC (permalink / raw)
I have the following function:
(defun copy-line ()
(interactive)
(save-excursion
(beginning-of-line)
(set-mark-command)
(end-of-line)
(copy-region-as-kill)))
But it's not working...
It says:
save-excursion: Wrong number of arguments: #[(arg) ... (some trash)
Any clues?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: problems with save-excursion
2006-03-08 22:36 problems with save-excursion filcab
@ 2006-03-08 22:57 ` Katsumi Yamaoka
2006-03-09 4:30 ` Eli Zaretskii
` (2 subsequent siblings)
3 siblings, 0 replies; 9+ messages in thread
From: Katsumi Yamaoka @ 2006-03-08 22:57 UTC (permalink / raw)
>>>>> In <1141857397.880352.44860@u72g2000cwu.googlegroups.com>
>>>>> filcab@gmail.com wrote:
> I have the following function:
> (defun copy-line ()
> (interactive)
> (save-excursion
> (beginning-of-line)
> (set-mark-command)
> (end-of-line)
> (copy-region-as-kill)))
> But it's not working...
> It says:
> save-excursion: Wrong number of arguments: #[(arg) ... (some trash)
You can modify it to work as follows:
(defun copy-line ()
(interactive)
(save-excursion
(beginning-of-line)
(call-interactively 'set-mark-command)
(end-of-line)
(call-interactively 'copy-region-as-kill)))
If you wish only to copy a line, it can be simplified as follows:
(defun copy-line ()
(interactive)
(kill-new
(buffer-substring (line-beginning-position)
(line-end-position))))
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: problems with save-excursion
2006-03-08 22:36 problems with save-excursion filcab
2006-03-08 22:57 ` Katsumi Yamaoka
@ 2006-03-09 4:30 ` Eli Zaretskii
2006-03-09 10:39 ` Marc Tfardy
2006-03-15 14:26 ` Peter Lee
3 siblings, 0 replies; 9+ messages in thread
From: Eli Zaretskii @ 2006-03-09 4:30 UTC (permalink / raw)
> From: filcab@gmail.com
> Date: 8 Mar 2006 14:36:37 -0800
>
> I have the following function:
> (defun copy-line ()
> (interactive)
> (save-excursion
> (beginning-of-line)
> (set-mark-command)
> (end-of-line)
> (copy-region-as-kill)))
>
> But it's not working...
> It says:
> save-excursion: Wrong number of arguments: #[(arg) ... (some trash)
It complains about the use of copy-region-as-kill" that function needs
to receive two arguments. See its doc string for the details.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: problems with save-excursion
2006-03-08 22:36 problems with save-excursion filcab
2006-03-08 22:57 ` Katsumi Yamaoka
2006-03-09 4:30 ` Eli Zaretskii
@ 2006-03-09 10:39 ` Marc Tfardy
2006-03-09 10:43 ` Marc Tfardy
2006-03-11 17:19 ` Stefan Monnier
2006-03-15 14:26 ` Peter Lee
3 siblings, 2 replies; 9+ messages in thread
From: Marc Tfardy @ 2006-03-09 10:39 UTC (permalink / raw)
filcab@gmail.com schrieb:
> I have the following function:
> (defun copy-line ()
> (interactive)
> (save-excursion
> (beginning-of-line)
> (set-mark-command)
> (end-of-line)
> (copy-region-as-kill)))
>
> But it's not working...
> It says:
> save-excursion: Wrong number of arguments: #[(arg) ... (some trash)
>
>
> Any clues?
You may try:
(defun copy-line ()
(interactive)
(save-excursion
(let (beg)
(beginning-of-line)
(setq beg (point))
(end-of-line)
(copy-region-as-kill beg (point)))))
regards
Marc
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: problems with save-excursion
2006-03-09 10:39 ` Marc Tfardy
@ 2006-03-09 10:43 ` Marc Tfardy
2006-03-11 17:19 ` Stefan Monnier
1 sibling, 0 replies; 9+ messages in thread
From: Marc Tfardy @ 2006-03-09 10:43 UTC (permalink / raw)
Marc Tfardy schrieb:
> filcab@gmail.com schrieb:
>> I have the following function:
>> (defun copy-line ()
>> (interactive)
>> (save-excursion
>> (beginning-of-line)
>> (set-mark-command)
>> (end-of-line)
>> (copy-region-as-kill)))
>>
>> But it's not working...
>> It says:
>> save-excursion: Wrong number of arguments: #[(arg) ... (some trash)
>>
>>
>> Any clues?
>
> You may try:
>
> (defun copy-line ()
> (interactive)
> (save-excursion
> (let (beg)
> (beginning-of-line)
> (setq beg (point))
> (end-of-line)
> (copy-region-as-kill beg (point)))))
>
Second and shorter version:
(defun copy-line ()
(interactive)
(copy-region-as-kill (line-beginning-position)
(line-end-position)))
Marc
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: problems with save-excursion
2006-03-09 10:39 ` Marc Tfardy
2006-03-09 10:43 ` Marc Tfardy
@ 2006-03-11 17:19 ` Stefan Monnier
1 sibling, 0 replies; 9+ messages in thread
From: Stefan Monnier @ 2006-03-11 17:19 UTC (permalink / raw)
> (defun copy-line ()
> (interactive)
> (save-excursion
> (let (beg)
> (beginning-of-line)
> (setq beg (point))
> (end-of-line)
> (copy-region-as-kill beg (point)))))
It's a good habit to initialize your variables directly when you declare
them (in C-style languages as well, BTW):
(defun copy-line ()
(interactive)
(save-excursion
(beginning-of-line)
(let ((beg (point)))
(end-of-line)
(copy-region-as-kill beg (point)))))
In elisp it's also marginally more efficient.
Stefan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: problems with save-excursion
2006-03-08 22:36 problems with save-excursion filcab
` (2 preceding siblings ...)
2006-03-09 10:39 ` Marc Tfardy
@ 2006-03-15 14:26 ` Peter Lee
3 siblings, 0 replies; 9+ messages in thread
From: Peter Lee @ 2006-03-15 14:26 UTC (permalink / raw)
>>>> filcab writes:
>> I have the following function:
>> (defun copy-line ()
>> (interactive)
>> (save-excursion
>> (beginning-of-line)
>> (set-mark-command)
>> (end-of-line)
>> (copy-region-as-kill)))
>> But it's not working...
you could do:
(defun copy-line ()
(interactive)
(kill-new (thing-at-point 'line)))
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: problems with save-excursion
@ 2006-03-08 23:00 bhenz
2006-03-10 19:21 ` Kevin Rodgers
0 siblings, 1 reply; 9+ messages in thread
From: bhenz @ 2006-03-08 23:00 UTC (permalink / raw)
Cc: help-gnu-emacs-bounces+bhenz=lexmark.com, help-gnu-emacs
[-- Attachment #1.1: Type: text/plain, Size: 758 bytes --]
I believe it's actually complaining about your usage of (interactive)
without ARGS.
Bob
filcab@gmail.com
Sent by: help-gnu-emacs-bounces+bhenz=lexmark.com@gnu.org
03/08/2006 05:36 PM
To: help-gnu-emacs@gnu.org
cc:
Subject: problems with save-excursion
I have the following function:
(defun copy-line ()
(interactive)
(save-excursion
(beginning-of-line)
(set-mark-command)
(end-of-line)
(copy-region-as-kill)))
But it's not working...
It says:
save-excursion: Wrong number of arguments: #[(arg) ... (some trash)
Any clues?
_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
[-- Attachment #1.2: Type: text/html, Size: 1574 bytes --]
[-- Attachment #2: Type: text/plain, Size: 152 bytes --]
_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: problems with save-excursion
2006-03-08 23:00 bhenz
@ 2006-03-10 19:21 ` Kevin Rodgers
0 siblings, 0 replies; 9+ messages in thread
From: Kevin Rodgers @ 2006-03-10 19:21 UTC (permalink / raw)
bhenz@Lexmark.com wrote:
> I believe it's actually complaining about your usage of (interactive)
> without ARGS.
Why do you believe that? `C-h f interactive' says:
Just `(interactive)' means pass no args when calling interactively.
And the containing function's lambda list is indeed empty.
--
Kevin Rodgers
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2006-03-15 14:26 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-08 22:36 problems with save-excursion filcab
2006-03-08 22:57 ` Katsumi Yamaoka
2006-03-09 4:30 ` Eli Zaretskii
2006-03-09 10:39 ` Marc Tfardy
2006-03-09 10:43 ` Marc Tfardy
2006-03-11 17:19 ` Stefan Monnier
2006-03-15 14:26 ` Peter Lee
-- strict thread matches above, loose matches on Subject: below --
2006-03-08 23:00 bhenz
2006-03-10 19:21 ` Kevin Rodgers
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).