[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: problems with save-excursion
From: |
Stefan Monnier |
Subject: |
Re: problems with save-excursion |
Date: |
Sat, 11 Mar 2006 12:19:11 -0500 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
> (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