[Top][All Lists]

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

Missing `with' macro?

From: Mathias Dahl
Subject: Missing `with' macro?
Date: Mon, 24 Jul 2006 12:17:29 +0200

I am currently optimizing some defuns in tumme.el and found that I do
the following repeatdely:

(setq buf (find-file tumme-db-file))
;; do a lot of stuff in it
(save-buffer) ;; optionally
(kill-buffer buf)

I really like the different `with' macros that Emacs has and was
surprised there wasn't any `with-file' macro, that could be callable
like this:

(with-file tumme-db-file
 ;; do stuff)

It could have two modes, reading and writing as sometimes you just
want to use the information in the opened file, not write back to it.

I guess what I want is this, without the call to `insert-file-contents':

(with-temp-file tumme-db-file
 (insert-file-contents tumme-db-file)
 ;; do stuff)

What do others think? Is the with-temp-file + insert-file-contents combo enough?

reply via email to

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