GNU bug report logs - #12895
24.3.50; Replacement for flet

Previous Next

Package: emacs;

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


Message #40 received at 12895 <at> debbugs.gnu.org (full text, mbox):

From: Katsumi Yamaoka <yamaoka <at> jpl.org>
To: monnier <at> iro.umontreal.ca
Cc: 12895 <at> debbugs.gnu.org, antoine.levitt <at> gmail.com
Subject: Re: bug#12895: 24.3.50; Replacement for flet
Date: Fri, 16 Nov 2012 16:04:40 +0900
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.