From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.devel Subject: defcustom-c-stylevar rewrite: rfc #3 Date: Thu, 06 Dec 2007 09:30:49 +0100 Message-ID: <87d4tkb4xy.fsf@ambire.localdomain> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1196929952 8911 80.91.229.12 (6 Dec 2007 08:32:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 6 Dec 2007 08:32:32 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Dec 06 09:32:42 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1J0C9x-0005zT-R9 for ged-emacs-devel@m.gmane.org; Thu, 06 Dec 2007 09:32:42 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J0C9g-0008SO-TJ for ged-emacs-devel@m.gmane.org; Thu, 06 Dec 2007 03:32:24 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1J0C9X-0008Qa-P0 for emacs-devel@gnu.org; Thu, 06 Dec 2007 03:32:15 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1J0C9W-0008Pg-4E for emacs-devel@gnu.org; Thu, 06 Dec 2007 03:32:14 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J0C9V-0008PM-EC for emacs-devel@gnu.org; Thu, 06 Dec 2007 03:32:13 -0500 Original-Received: from mx20.gnu.org ([199.232.41.8]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1J0C9U-0000Y5-Ui for emacs-devel@gnu.org; Thu, 06 Dec 2007 03:32:13 -0500 Original-Received: from ppp-43-36.21-151.libero.it ([151.21.36.43] helo=ambire.localdomain) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1J0C9T-00069b-S6 for emacs-devel@gnu.org; Thu, 06 Dec 2007 03:32:12 -0500 Original-Received: from ttn by ambire.localdomain with local (Exim 4.63) (envelope-from ) id 1J0C89-0001xT-9k for emacs-devel@gnu.org; Thu, 06 Dec 2007 09:30:49 +0100 X-detected-kernel: by mx20.gnu.org: Genre and OS details not recognized. X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:84781 Archived-At: below is a rewrite for `defcustom-c-stylevar' in cc-vars.el that gets rid of old-style backquote and adds documentation. if you are annoyed by byte-compiler warnings re old-style backquote in cc-vars.el, please try this out and report any problems. i get the feeling that cc-*.el compilation is pretty hairy, so bug reports from "make bootstrap" are more welcome than those from "make" (after normal "cvs update"). thi __________________________________________________________________ (defmacro defcustom-c-stylevar (name val doc &rest args) "Define a style variable NAME with VAL and DOC. More precisely, convert the given `:type FOO', mined out of ARGS, to an aggregate `:type (radio STYLE (PREAMBLE FOO))', append some some boilerplate documentation to DOC, arrange for the fallback value of NAME to be VAL, and call `custom-declare-variable' to do the rest of the work. STYLE stands for the choice where the value is taken from some style setting. PREAMBLE is optionally prepended to FOO; that is, if FOO contains :tag or :value, the respective two-element list component is ignored." (declare (debug (symbolp form stringp &rest))) (let* ((expanded-doc (concat doc " This is a style variable. Apart from the valid values described above, it can be set to the symbol `set-from-style'. In that case, it takes its value from the style system (see `c-default-style' and `c-style-alist') when a CC Mode buffer is initialized. Otherwise, the value set here overrides the style system (there is a variable `c-old-style-variable-behavior' that changes this, though).")) (typ (eval (plist-get args :type))) (type (if (consp typ) typ (list typ))) (head (car type)) (tail (cdr type)) (newt (append (unless (plist-get tail :tag) '(:tag "Override style settings")) (unless (plist-get tail :value) `(:value ,val)) tail)) (aggregate `'(radio (const :tag "Use style settings" set-from-style) ,(cons head newt)))) `(progn (c-set-stylevar-fallback ',name ,val) (custom-declare-variable ',name ''set-from-style ,expanded-doc ,@(plist-put args :type aggregate)))))