emacs-devel
[Top][All Lists]
Advanced

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

Re: defcustom :version


From: Bill Wohler
Subject: Re: defcustom :version
Date: Wed, 29 Mar 2006 18:43:14 -0800
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Richard Stallman <address@hidden> writes:

> I think it is worth adding this code now,
> so that maintenance can be simpler.

Thank you.

> But first I would like a few other people to study the code
> and make sure there is no problem with it.  Would people
> please study Bill's patch?

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:

  (custom-declare-group (quote mh-e) nil
  "Emacs interface to the MH mail system.
  MH is the Rand Mail Handler. Other implementations include nmh
  and GNU mailutils." (:link (quote (custom-manual "(mh-e)Top")) :group
  (quote mail)))

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
SYMBOL, MEMBERS, DOC and ARGS.
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)))

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

-- 
Bill Wohler <address@hidden>  http://www.newt.com/wohler/  GnuPG ID:610BD9AD
Maintainer of comp.mail.mh FAQ and MH-E. Vote Libertarian!
If you're passed on the right, you're in the wrong lane.





reply via email to

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