[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: defcustom :version

From: Wolfram Fenske
Subject: Re: defcustom :version
Date: Thu, 30 Mar 2006 21:53:55 +0200
User-agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.18 (berkeley-unix)

Bill Wohler <address@hidden> writes:

> [...]
> On a related note, the MH-E and Gnus projects need to provide
> backwards compatibility for Emacsen that do not have the
> :package-version keyword. I wrote a bit of code to strip the
> :package-version keyword and its value before passing it on to
> defgroup/defcustom, but have a bit of a bug which I'm sure one of you
> can fix handily.
> Given the code below, if mh-package-version-defined-flag is nil, the
> mh-strip-package-version function does strip the :package-version
> keyword and its value, but alas it turns ARGS into (ARGS). For
> example, here is the output of macroexpand on the mh-e group:
>   [...]
> How do I "unlistify" what mh-strip-package-version returns, or
> restructure the program to make it unnecessary to do so? I'm not a
> strong macro writer, so any other suggestions are solicited as well.
> Thanks!
> (defvar mh-package-version-defined-flag (and (not mh-xemacs-flag)
>                                              (>= emacs-major-version 22))
>   "Non-nil means `defgroup' and `defcustom' support :package-version.")
> (defmacro mh-defgroup (symbol members doc &rest args)
>   "Declare SYMBOL as a customization group containing MEMBERS.
> See documentation for `defgroup' for a description of the arguments
> This macro is used by Emacs versions that lack the :package-version
> keyword, introduced in Emacs 22."
>   (declare (doc-string 3))
>   (let ((args (if mh-package-version-defined-flag
>                   args
>                 (mh-strip-package-version args))))
>     `(defgroup ,symbol ,members ,doc ,args)))

I think you should replace that last expression with

  `(defgroup ,symbol ,members ,doc ,@args)

",@" works like "," but in addition it "splices" the value into the
enclosing list.  E. g.
  (let ((a 1)
        (b '(2 3)))
     `(,a ,b))

evaluates to (1 (2 3)) but

  (let ((a 1)
        (b '(2 3)))
     `(,a ,@b))

evaluates to (1 2 3).

> (defun mh-strip-package-version (args)
>   "Strip :package-version keyword and its value from ARGS."
>   (let (seen)
>     (loop for keyword in args
>           if (cond ((eq keyword ':package-version) (setq seen t) nil)
>                    (seen (setq seen nil) nil)
>                    (t t))
>           collect keyword)))

Wolfram Fenske

reply via email to

[Prev in Thread] Current Thread [Next in Thread]