all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Thien-Thi Nguyen <ttn@gnuvola.org>
To: bug-cc-mode@gnu.org, emacs-devel@gnu.org
Subject: Re: Old-style backquotes in cc-vars.el
Date: Fri, 19 Oct 2007 09:29:05 +0200	[thread overview]
Message-ID: <87bqavmuke.fsf@ambire.localdomain> (raw)
In-Reply-To: <59233.128.165.123.18.1192124471.squirrel@webmail.lanl.gov> (Davis Herring's message of "Thu\, 11 Oct 2007 10\:41\:11 -0700 \(PDT\)")

() "Davis Herring" <herring@lanl.gov>
() Thu, 11 Oct 2007 10:41:11 -0700 (PDT)

   Are we sure that it's okay to do all these evaluations at macro
   expansion time -- that is, do any of them depend on runtime
   things?

the original defcustom-c-stylevar evals so i thought continuing
the practice (regardless of the wisdom of the approach) would not
be harmful.  in fact, in the most recent revision (tested a bit,
this time -- bonus!), VAL is no longer evalled.

   And what is (eval (list 'identity foo))) supposed to
   do differently than (eval foo)?

nothing, thanks for pointing this out -- i learn a lot from
nothing these days!  i use the latter form now.  the former was
fuzzy thinking and baby-in-the-background-crying induced.

please find below the revised defcustom-c-stylevar usurper.
substantial changes from the previous revision:
 - docstring, reflecting best how i understand things
 - new form `(declare (debug ...))'
 - form `(radio ...)' is quoted

i consider all these changes bugfixes (and, thus, potentially
bug-harboring).  please scrutinize them equally.

as mentioned before, this was (lightly) tested.  i even went so
far as to invoke customize (shudder) and mouse around a bit.  now
if you'll excuse me, i have to go wash my hands... :-/

[cc trimmed to ml]

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

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/


  reply	other threads:[~2007-10-19  7:29 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-23 20:51 Old-style backquotes in cc-vars.el Stefan Monnier
2007-09-01 10:18 ` Alan Mackenzie
2007-09-03 20:46   ` Stefan Monnier
2007-09-04  3:14     ` T. V. Raman
2007-09-04 22:57       ` Richard Stallman
2007-09-05  2:21         ` T. V. Raman
2007-09-05  2:44           ` dhruva
2007-09-05  3:26             ` Stefan Monnier
2007-09-05 20:02               ` Richard Stallman
2007-09-06 14:27                 ` Juri Linkov
2007-09-07  6:32                   ` Richard Stallman
2007-09-05 13:29             ` T. V. Raman
2007-10-06 16:31 ` Alan Mackenzie
2007-10-06 18:31   ` Thien-Thi Nguyen
2007-10-06 20:51     ` Alan Mackenzie
2007-10-06 21:46       ` Thien-Thi Nguyen
2007-10-11 17:41     ` Davis Herring
2007-10-19  7:29       ` Thien-Thi Nguyen [this message]
2007-10-06 22:27   ` Stefan Monnier
2007-10-07  9:40     ` Alan Mackenzie
2007-10-07  9:41       ` Thien-Thi Nguyen
2007-10-07 19:40       ` Eli Zaretskii
2007-10-07 13:10   ` Richard Stallman

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

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

  git send-email \
    --in-reply-to=87bqavmuke.fsf@ambire.localdomain \
    --to=ttn@gnuvola.org \
    --cc=bug-cc-mode@gnu.org \
    --cc=emacs-devel@gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.