all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* defcustom-c-stylevar rewrite: rfc #3
@ 2007-12-06  8:30 Thien-Thi Nguyen
  2007-12-07  2:14 ` Glenn Morris
  0 siblings, 1 reply; 4+ messages in thread
From: Thien-Thi Nguyen @ 2007-12-06  8:30 UTC (permalink / raw)
  To: emacs-devel

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: defcustom-c-stylevar rewrite: rfc #3
  2007-12-06  8:30 defcustom-c-stylevar rewrite: rfc #3 Thien-Thi Nguyen
@ 2007-12-07  2:14 ` Glenn Morris
  2007-12-12 10:07   ` Thien-Thi Nguyen
  0 siblings, 1 reply; 4+ messages in thread
From: Glenn Morris @ 2007-12-07  2:14 UTC (permalink / raw)
  To: Thien-Thi Nguyen; +Cc: emacs-devel

Thien-Thi Nguyen wrote:

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

Something is wrong: try to customize the variable
c-indent-comment-alist after applying this change. Compare the choices
on offer to those in Emacs-22. There are lots of "nils" now.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: defcustom-c-stylevar rewrite: rfc #3
  2007-12-07  2:14 ` Glenn Morris
@ 2007-12-12 10:07   ` Thien-Thi Nguyen
  2007-12-12 19:21     ` Glenn Morris
  0 siblings, 1 reply; 4+ messages in thread
From: Thien-Thi Nguyen @ 2007-12-12 10:07 UTC (permalink / raw)
  To: Glenn Morris; +Cc: emacs-devel

() Glenn Morris <rgm@gnu.org>
() Thu, 06 Dec 2007 21:14:49 -0500

   Something is wrong: try to customize the variable
   c-indent-comment-alist after applying this change. Compare the
   choices on offer to those in Emacs-22. There are lots of "nils"
   now.

thanks for reporting this.  please find below a revision that
evals the VAL argument (which is what i had originally, but
someone convinced me to remove it).  i see that customizing
c-indent-comment-alist shows many choices now.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: defcustom-c-stylevar rewrite: rfc #3
  2007-12-12 10:07   ` Thien-Thi Nguyen
@ 2007-12-12 19:21     ` Glenn Morris
  0 siblings, 0 replies; 4+ messages in thread
From: Glenn Morris @ 2007-12-12 19:21 UTC (permalink / raw)
  To: Thien-Thi Nguyen; +Cc: emacs-devel

Thien-Thi Nguyen wrote:

> thanks for reporting this.  please find below a revision that
> evals the VAL argument (which is what i had originally, but
> someone convinced me to remove it).  i see that customizing
> c-indent-comment-alist shows many choices now.

Yes, that one works now. There are still two bogus "nil" entries, but
these are also present in Emacs 22.1, so this is not due to your
patch.

With the latest patch, try to customize c-block-comment-prefix and
receive an error:

 (wrong-type-argument char-or-string-p cc-bytecomp-ignore-var:c-comment-continuation-stars)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-12-12 19:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-06  8:30 defcustom-c-stylevar rewrite: rfc #3 Thien-Thi Nguyen
2007-12-07  2:14 ` Glenn Morris
2007-12-12 10:07   ` Thien-Thi Nguyen
2007-12-12 19:21     ` Glenn Morris

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.