Log in


Previous Entry Share Next Entry
11:22 pm: Does Emacs Lisp Already Have This?
(as always I'm sure that Emacs Lisp already has something like this and I haven't found it yet)

Here is a sketch of an idea for a replacement format in Emacs Lisp. It is inspired by Common Lisp, and is therefore ugly.

(defun yformat (out string &rest objects)
  (cond ((not out)
	 (apply 'format string objects))
	((integerp out)
	 (goto-char out)
	 (insert (apply 'format string objects)))
	((bufferp out)
	 (with-current-buffer out
	   (insert (apply 'format string objects))))
	 (insert (apply 'format string objects)))))

I'll try to write a real version of this and then I'll try to use it and see how much code something like this would save.

Unfortunately something like this would never fly with emacs-devel even if it turned out to be useful. Overloading is ugly, Emacs Lisp isn't Common Lisp and doesn't want to be either, and finally there is no way to make this backward compatible with old code.

Powered by LiveJournal.com