all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Sean McAfee <eefacm@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Processing a file that may already be open
Date: Mon, 17 Oct 2011 23:45:49 -0700	[thread overview]
Message-ID: <m239eqvluq.fsf@gmail.com> (raw)
In-Reply-To: jwvobxfpvav.fsf-monnier+gnu.emacs.help@gnu.org

Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> (defmacro with-visited-file (path &rest body)
[...]

> - use make-symbol rather than gensym: it's faster, doesn't pollute the
>   global symbol table (aka obarray), and doesn't rely on CL.

gensym is just a thin wrapper around make-symbol; how could it pollute
the global symbol table?

I usually prefer gensym because I don't like to be obliged to give the
new symbol a name.  I don't care what it's named.  And I don't mind
relying on CL.  It's the closest I get to being able to use Common Lisp
on a regular basis.

> - avoid evaluating "file" multiple times (in case the caller does
>   (with-visited-file (setq foo (concat foo ".el")) blabla))

Good point.

> - avoid find-file: find-file is a user-level command, Elisp code should
>   use find-file-noselect instead.  find-file will call switch-to-buffer
>   to display the buffer, which can fail or pop up a new window or a new
>   frame, none of which we want to see happen here.

Also a good point.  Thanks.

There's still a few minor issues to be worked out, though.  Like, should
I save the buffer after editing it?  Obviously yes, if the buffer didn't
exist before.  But if any buffers were already visiting the file, I
should probably only save it if none of them have been modified since
the file was last saved.


      parent reply	other threads:[~2011-10-18  6:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-17  6:57 Processing a file that may already be open Sean McAfee
     [not found] ` <jwvobxfpvav.fsf-monnier+gnu.emacs.help@gnu.org>
2011-10-18  6:45   ` Sean McAfee [this message]

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=m239eqvluq.fsf@gmail.com \
    --to=eefacm@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /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.