From: Glenn Morris <rgm@gnu.org>
To: Winston <wbe@psr.com>
Cc: 12079@debbugs.gnu.org
Subject: bug#12079: 23.3; erroneous byte-compile-file warning
Date: Sun, 29 Jul 2012 19:12:47 -0400 [thread overview]
Message-ID: <871ujucgb4.fsf@fencepost.gnu.org> (raw)
In-Reply-To: <ydtxws0yv4.fsf@crystal.psr.com> (Winston's message of "Sat, 28 Jul 2012 10:00:31 -0400")
Winston wrote:
> (progn
> (save-excursion
> (set-buffer "foo") ; I'd already created this
> (barf-if-buffer-read-only)
> )
> (current-buffer)
> )
> #<buffer *scratch*>
>
> 3) However, when I write that code to foo.el and run byte-compile-file
> on it, I get the following error:
>
> Compiling file /home/wbe/foo.el at Sat Jul 28 09:07:28 2012
> Entering directory `/home/wbe/'
> --> foo.el:1:1:Warning: `save-excursion' defeated by `set-buffer'
>
> It looks to me like the Warning message is untrue.
In an example such as you show, you should use with-current-buffer
instead of save-excursion+set-buffer. I think this has been discussed
several times on this list and/or emacs-devel.
The compilation warning is because save-excursion is pointless in the
code as shown. Eg it doesn't preserve point in buffer foo (unless foo
happened to be current beforehand).
next prev parent reply other threads:[~2012-07-29 23:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-28 14:00 bug#12079: 23.3; erroneous byte-compile-file warning Winston
2012-07-29 23:12 ` Glenn Morris [this message]
2012-07-30 4:42 ` Winston
2012-07-30 7:06 ` Alp Aker
2012-07-30 13:40 ` Winston
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=871ujucgb4.fsf@fencepost.gnu.org \
--to=rgm@gnu.org \
--cc=12079@debbugs.gnu.org \
--cc=wbe@psr.com \
/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.