all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Re: problems with save-excursion
Date: Sat, 11 Mar 2006 12:19:11 -0500	[thread overview]
Message-ID: <87r758dhp1.fsf-monnier+gnu.emacs.help@gnu.org> (raw)
In-Reply-To: 47aev8Feeg51U1@individual.net

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

  parent reply	other threads:[~2006-03-11 17:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r758dhp1.fsf-monnier+gnu.emacs.help@gnu.org \
    --to=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.