[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to rescind a defun?
From: |
Pascal J. Bourguignon |
Subject: |
Re: How to rescind a defun? |
Date: |
Sat, 19 May 2012 04:52:19 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) |
kj <no.email@please.post> writes:
> If, during an Emacs session, one evaluates a defun that (inadvertently)
> redefines an existing function, is it possible to undo this?
If you do that a lot, you could implement defun to do that.
(require 'cl)
(setf (symbol-function 'emacs-defun) (symbol-function 'defun))
(defmacro defun (name lambda-list &rest body)
`(progn
(when (fboundp ',name)
(push (symbol-function ',name) (get ',name 'old-defuns)))
(emacs-defun ,name ,lambda-list ,@body)))
(defun pop-defun* (name)
(setf (symbol-function name) (pop (get name 'old-defuns))))
(defmacro pop-defun (name)
`(pop-defun* ',name))
(defun f () 42)
(f) --> 42
(defun f () 33)
(f) --> 33
(pop-defun f)
(f) --> 42
Now of course you need to define that early, and load all the libraries
after it, so that they use your defun instead of the native emacs-defun.
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
- How to rescind a defun?, kj, 2012/05/18
- Message not available
- Re: How to rescind a defun?,
Pascal J. Bourguignon <=