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

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

Re: problems with save-excursion


From: Katsumi Yamaoka
Subject: Re: problems with save-excursion
Date: Thu, 09 Mar 2006 07:57:14 +0900
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/23.0.0 (gnu/linux)

>>>>> 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))))


reply via email to

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