GNU bug report logs -
#12895
24.3.50; Replacement for flet
Previous Next
Reported by: Antoine Levitt <antoine.levitt <at> gmail.com>
Date: Thu, 15 Nov 2012 13:37:02 UTC
Severity: normal
Tags: notabug
Found in version 24.3.50
Done: Marcin Borkowski <mbork <at> mbork.pl>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Stefan Monnier wrote:
> Such override should be done with an advice.
But why I haven't yet replaced flet used in
message-read-from-minibuffer is that I don't yet have a solution
better than this:
(flet ((mail-abbrev-in-expansion-header-p nil t))
(read-from-minibuffer prompt initial-contents))
;; This makes mail-abbrev-expand work even in a minibuffer, not
;; in a message header.
Not only this, there will probably be lots of situations where
flet is handy to use. Here's the one I've implemented in a
certain package so as to silence the byte compiler:
(defmacro my-flet (bindings &rest body)
"Make temporary overriding function definitions.
\(fn ((FUNC ARGLIST BODY...) ...) FORM...)"
`(let (fn origs)
(dolist (bind ',bindings)
(setq fn (car bind))
(push (cons fn (and (fboundp fn) (symbol-function fn))) origs)
(fset fn (cons 'lambda (cdr bind))))
(unwind-protect
(progn ,@body)
(dolist (orig origs)
(if (cdr orig)
(fset (car orig) (cdr orig))
(fmakunbound (car orig)))))))
This bug report was last modified 9 years and 106 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.