unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Katsumi Yamaoka <yamaoka@jpl.org>
To: monnier@iro.umontreal.ca
Cc: 12895@debbugs.gnu.org, antoine.levitt@gmail.com
Subject: bug#12895: 24.3.50; Replacement for flet
Date: Fri, 16 Nov 2012 16:04:40 +0900	[thread overview]
Message-ID: <b4mmwyi2flj.fsf@jpl.org> (raw)
In-Reply-To: <87a9uj9efm.fsf@gmail.com>

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)))))))





  parent reply	other threads:[~2012-11-16  7:04 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-15 13:35 bug#12895: 24.3.50; Replacement for flet Antoine Levitt
2012-11-15 14:46 ` Stefan Monnier
2012-11-15 15:01   ` Antoine Levitt
2012-11-15 18:35     ` Stefan Monnier
2012-11-15 22:42       ` Antoine Levitt
2012-11-15 23:05         ` Glenn Morris
2012-11-15 23:24           ` Antoine Levitt
2012-11-15 23:44             ` Glenn Morris
2012-11-15 23:47               ` Antoine Levitt
2012-11-15 23:51                 ` Glenn Morris
2012-11-16 14:34         ` Stefan Monnier
2012-11-16 14:49           ` Antoine Levitt
2012-11-16 15:24             ` Stefan Monnier
2016-01-31 17:42             ` Michael Heerdegen
2016-02-09 20:36               ` Antoine Levitt
2012-11-16  7:04   ` Katsumi Yamaoka [this message]
2012-11-16 14:33     ` Stefan Monnier
2012-11-16  1:21 ` Michael Heerdegen
2016-01-31 14:19 ` bug#12895: Status: " Marcin Borkowski
2016-01-31 16:51   ` Eli Zaretskii
2016-01-31 17:10     ` Marcin Borkowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b4mmwyi2flj.fsf@jpl.org \
    --to=yamaoka@jpl.org \
    --cc=12895@debbugs.gnu.org \
    --cc=antoine.levitt@gmail.com \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).