X-Git-Url: http://cgit.sxemacs.org/?a=blobdiff_plain;f=lisp%2Fgmm-utils.el;h=58908b701ba1cbc0443b44cfd40d0e3a7b5e1e8d;hb=74c3c92f78597749c0ff9a5911c0a42f83ba46dc;hp=6a64dcff11bbf80ed949d244a9d8f5198eed71e8;hpb=7ff634144544b4cd94d3b5696ef76bcb155b2361;p=gnus diff --git a/lisp/gmm-utils.el b/lisp/gmm-utils.el index 6a64dcff1..58908b701 100644 --- a/lisp/gmm-utils.el +++ b/lisp/gmm-utils.el @@ -1,6 +1,6 @@ ;;; gmm-utils.el --- Utility functions for Gnus, Message and MML -;; Copyright (C) 2006-2012 Free Software Foundation, Inc. +;; Copyright (C) 2006-2013 Free Software Foundation, Inc. ;; Author: Reiner Steib ;; Keywords: news @@ -417,7 +417,35 @@ coding-system." (write-region start end filename append visit lockname)) (write-region start end filename append visit lockname mustbenew))) -;; `labels' got obsolete since Emacs 24.3. +;; `interactive-p' is obsolete since Emacs 23.2. +(defmacro gmm-called-interactively-p (kind) + (condition-case nil + (progn + (eval '(called-interactively-p 'any)) + ;; Emacs >=23.2 + `(called-interactively-p ,kind)) + ;; Emacs <23.2 + (wrong-number-of-arguments '(called-interactively-p)) + ;; XEmacs + (void-function '(interactive-p)))) + +;; `flet' and `labels' are obsolete since Emacs 24.3. +(defmacro gmm-flet (bindings &rest body) + "Make temporary overriding function definitions. +This is an analogue of a dynamically scoped `let' that operates on +the function cell of FUNCs rather than their value cell. + +\(fn ((FUNC ARGLIST BODY...) ...) FORM...)" + (require 'cl) + (if (fboundp 'cl-letf) + `(cl-letf ,(mapcar (lambda (binding) + `((symbol-function ',(car binding)) + (lambda ,@(cdr binding)))) + bindings) + ,@body) + `(flet ,bindings ,@body))) +(put 'gmm-flet 'lisp-indent-function 1) + (defmacro gmm-labels (bindings &rest body) "Make temporary function bindings. The bindings can be recursive and the scoping is lexical, but capturing