all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Old-style backquotes in cc-vars.el
@ 2007-08-23 20:51 Stefan Monnier
  2007-09-01 10:18 ` Alan Mackenzie
  2007-10-06 16:31 ` Alan Mackenzie
  0 siblings, 2 replies; 23+ messages in thread
From: Stefan Monnier @ 2007-08-23 20:51 UTC (permalink / raw)
  To: bug-cc-mode; +Cc: emacs-devel


cc-vars uses a mix of old-style a new-style backquotes.
I've fixed other uses of old-style backquotes in Emacs-22 but feel like
there may be something fishy going on here, so I'd rather someone else does
the conversion here.


        Stefan

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

* Re: Old-style backquotes in cc-vars.el
  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-10-06 16:31 ` Alan Mackenzie
  1 sibling, 1 reply; 23+ messages in thread
From: Alan Mackenzie @ 2007-09-01 10:18 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: bug-cc-mode, emacs-devel

Hi, Stefan!

On Thu, Aug 23, 2007 at 04:51:08PM -0400, Stefan Monnier wrote:

> cc-vars uses a mix of old-style and new-style backquotes.

I think you're talking about a single instance of "old-style", namely at
~L193 in defcustom-c-stylevar:

      ,@(plist-put
         args ':type
         `(` (radio             <================================
              (const :tag "Use style settings"

> I've fixed other uses of old-style backquotes in Emacs-22 but feel like
> there may be something fishy going on here, so I'd rather someone else does
> the conversion here.

;-)

OK, I'll look at it.

Incidentally, I'm working on a Unix system which has Emacs 19.27
installed as default.  This could be helpful!

>         Stefan

-- 
Alan.

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

* Re: Old-style backquotes in cc-vars.el
  2007-09-01 10:18 ` Alan Mackenzie
@ 2007-09-03 20:46   ` Stefan Monnier
  2007-09-04  3:14     ` T. V. Raman
  0 siblings, 1 reply; 23+ messages in thread
From: Stefan Monnier @ 2007-09-03 20:46 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: bug-cc-mode, emacs-devel

> Incidentally, I'm working on a Unix system which has Emacs 19.27
> installed as default.  This could be helpful!

In my view any system that's using something older than 22.1 is unhelpful.


        Stefan "whose office machine is still on 21.4 admittedly"

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

* Re: Old-style backquotes in cc-vars.el
  2007-09-03 20:46   ` Stefan Monnier
@ 2007-09-04  3:14     ` T. V. Raman
  2007-09-04 22:57       ` Richard Stallman
  0 siblings, 1 reply; 23+ messages in thread
From: T. V. Raman @ 2007-09-04  3:14 UTC (permalink / raw)
  To: monnier; +Cc: bug-cc-mode, acm, emacs-devel


It would be nice to have a couple of utility edit functions that
turns old-style backquotes to new-style backquotes. I did the
conversion by hand for some of my files, and the process is
error-prone for hand-editting.

>>>>> "Stefan" == Stefan Monnier <monnier@iro.umontreal.ca> writes:
    >> Incidentally, I'm working on a Unix system which has Emacs
    >> 19.27 installed as default.  This could be helpful!
    Stefan> 
    Stefan> In my view any system that's using something older
    Stefan> than 22.1 is unhelpful.
    Stefan> 
    Stefan> 
    Stefan>         Stefan "whose office machine is still on 21.4
    Stefan> admittedly"
    Stefan> 
    Stefan> 
    Stefan> _______________________________________________
    Stefan> Emacs-devel mailing list Emacs-devel@gnu.org
    Stefan> http://lists.gnu.org/mailman/listinfo/emacs-devel

-- 
Best Regards,
--raman

      
Email:  raman@users.sf.net
WWW:    http://emacspeak.sf.net/raman/
AIM:    emacspeak       GTalk: tv.raman.tv@gmail.com
PGP:    http://emacspeak.sf.net/raman/raman-almaden.asc
Google: tv+raman 
IRC:    irc://irc.freenode.net/#emacs

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

* Re: Old-style backquotes in cc-vars.el
  2007-09-04  3:14     ` T. V. Raman
@ 2007-09-04 22:57       ` Richard Stallman
  2007-09-05  2:21         ` T. V. Raman
  0 siblings, 1 reply; 23+ messages in thread
From: Richard Stallman @ 2007-09-04 22:57 UTC (permalink / raw)
  To: raman; +Cc: bug-cc-mode, acm, monnier, emacs-devel

    It would be nice to have a couple of utility edit functions that
    turns old-style backquotes to new-style backquotes.

Would you like to write them?

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


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

* Re: Old-style backquotes in cc-vars.el
  2007-09-04 22:57       ` Richard Stallman
@ 2007-09-05  2:21         ` T. V. Raman
  2007-09-05  2:44           ` dhruva
  0 siblings, 1 reply; 23+ messages in thread
From: T. V. Raman @ 2007-09-05  2:21 UTC (permalink / raw)
  To: rms; +Cc: bug-cc-mode, acm, raman, monnier, emacs-devel


If I do write them, I'll be sure to contribute them. On the
selfish end, I've already fixed my code that needed the fixing,
so the motivation to write the code is not high at present.

>>>>> "Richard" == Richard Stallman <rms@gnu.org> writes:
    Richard>     It would be nice to have a couple of utility
    Richard> edit functions that turns old-style backquotes to
    Richard> new-style backquotes.
    Richard> 
    Richard> Would you like to write them?

-- 
Best Regards,
--raman

      
Email:  raman@users.sf.net
WWW:    http://emacspeak.sf.net/raman/
AIM:    emacspeak       GTalk: tv.raman.tv@gmail.com
PGP:    http://emacspeak.sf.net/raman/raman-almaden.asc
Google: tv+raman 
IRC:    irc://irc.freenode.net/#emacs

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


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

* Re: Old-style backquotes in cc-vars.el
  2007-09-05  2:21         ` T. V. Raman
@ 2007-09-05  2:44           ` dhruva
  2007-09-05  3:26             ` Stefan Monnier
  2007-09-05 13:29             ` T. V. Raman
  0 siblings, 2 replies; 23+ messages in thread
From: dhruva @ 2007-09-05  2:44 UTC (permalink / raw)
  To: rms; +Cc: emacs-devel

Hi,

On 9/5/07, T. V. Raman <raman@users.sf.net> wrote:
>
> If I do write them, I'll be sure to contribute them. On the
> selfish end, I've already fixed my code that needed the fixing,
> so the motivation to write the code is not high at present.
>
> >>>>> "Richard" == Richard Stallman <rms@gnu.org> writes:
>     Richard>     It would be nice to have a couple of utility
>     Richard> edit functions that turns old-style backquotes to
>     Richard> new-style backquotes.
>     Richard>
>     Richard> Would you like to write them?

 If someone can point me to the complete definition of old and new
style (and variants if any), I will try to develop a tool to do the
conversion automatically. I have done a bit of parsing related work
and feel I can do it.

-dky

-- 
Dhruva Krishnamurthy
Contents reflect my personal views only!

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

* Re: Old-style backquotes in cc-vars.el
  2007-09-05  2:44           ` dhruva
@ 2007-09-05  3:26             ` Stefan Monnier
  2007-09-05 20:02               ` Richard Stallman
  2007-09-05 13:29             ` T. V. Raman
  1 sibling, 1 reply; 23+ messages in thread
From: Stefan Monnier @ 2007-09-05  3:26 UTC (permalink / raw)
  To: dhruva; +Cc: rms, emacs-devel

>> If I do write them, I'll be sure to contribute them. On the
>> selfish end, I've already fixed my code that needed the fixing,
>> so the motivation to write the code is not high at present.
>> 
>> >>>>> "Richard" == Richard Stallman <rms@gnu.org> writes:
Richard> It would be nice to have a couple of utility
Richard> edit functions that turns old-style backquotes to
Richard> new-style backquotes.
Richard> 
Richard> Would you like to write them?

>  If someone can point me to the complete definition of old and new
> style (and variants if any), I will try to develop a tool to do the
> conversion automatically. I have done a bit of parsing related work
> and feel I can do it.

I did it with a macro that did something like:

   C-u C-s ([`,]@? C-SPC M-x up-list RET DEL C-u C-SPC C-d C-SPC C-M-u C-d
   C-u C-SPC


-- Stefan

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

* Re: Old-style backquotes in cc-vars.el
  2007-09-05  2:44           ` dhruva
  2007-09-05  3:26             ` Stefan Monnier
@ 2007-09-05 13:29             ` T. V. Raman
  1 sibling, 0 replies; 23+ messages in thread
From: T. V. Raman @ 2007-09-05 13:29 UTC (permalink / raw)
  To: dhruvakm; +Cc: rms, emacs-devel


Here is what is needed:

A) Convert (` ...) to `...
Thus:
(` (progn ...))
becomes `(progn ...)

(, ...)
becomes ,...


>>>>> "dhruva" == dhruva  <dhruvakm@gmail.com> writes:
    dhruva> Hi, On 9/5/07, T. V. Raman <raman@users.sf.net>
    dhruva> wrote:
    >> 
    >> If I do write them, I'll be sure to contribute them. On
    >> the selfish end, I've already fixed my code that needed
    >> the fixing, so the motivation to write the code is not
    >> high at present.
    >> 
    >> >>>>> "Richard" == Richard Stallman <rms@gnu.org> writes:
    Richard> It would be nice to have a couple of utility edit
    Richard> functions that turns old-style backquotes to
    Richard> new-style backquotes.
    Richard> 
    Richard> Would you like to write them?
    dhruva> 
    dhruva>  If someone can point me to the complete definition
    dhruva> of old and new style (and variants if any), I will
    dhruva> try to develop a tool to do the conversion
    dhruva> automatically. I have done a bit of parsing related
    dhruva> work and feel I can do it.
    dhruva> 
    dhruva> -dky
    dhruva> 
    dhruva> -- Dhruva Krishnamurthy Contents reflect my personal
    dhruva> views only!
    dhruva> 
    dhruva> 
    dhruva> _______________________________________________
    dhruva> Emacs-devel mailing list Emacs-devel@gnu.org
    dhruva> http://lists.gnu.org/mailman/listinfo/emacs-devel

-- 
Best Regards,
--raman

      
Email:  raman@users.sf.net
WWW:    http://emacspeak.sf.net/raman/
AIM:    emacspeak       GTalk: tv.raman.tv@gmail.com
PGP:    http://emacspeak.sf.net/raman/raman-almaden.asc
Google: tv+raman 
IRC:    irc://irc.freenode.net/#emacs

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

* Re: Old-style backquotes in cc-vars.el
  2007-09-05  3:26             ` Stefan Monnier
@ 2007-09-05 20:02               ` Richard Stallman
  2007-09-06 14:27                 ` Juri Linkov
  0 siblings, 1 reply; 23+ messages in thread
From: Richard Stallman @ 2007-09-05 20:02 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

    I did it with a macro that did something like:

       C-u C-s ([`,]@? C-SPC M-x up-list RET DEL C-u C-SPC C-d C-SPC C-M-u C-d
       C-u C-SPC

Could you work out the details again, and put it in NEWS as a
suggestion?  Or code it in Lisp?

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

* Re: Old-style backquotes in cc-vars.el
  2007-09-05 20:02               ` Richard Stallman
@ 2007-09-06 14:27                 ` Juri Linkov
  2007-09-07  6:32                   ` Richard Stallman
  0 siblings, 1 reply; 23+ messages in thread
From: Juri Linkov @ 2007-09-06 14:27 UTC (permalink / raw)
  To: rms; +Cc: monnier, emacs-devel

>     I did it with a macro that did something like:
>
>        C-u C-s ([`,]@? C-SPC M-x up-list RET DEL C-u C-SPC C-d C-SPC C-M-u C-d
>        C-u C-SPC
>
> Could you work out the details again, and put it in NEWS as a
> suggestion?  Or code it in Lisp?

BTW, since TODO contains the following task:

    ** Add a way to convert a keyboard macro to equivalent Lisp code.

I've implemented a feature that converts a macro like:

    C-u C-s ([`,]@? C-SPC M-x up-list RET DEL C-u C-SPC C-d C-SPC C-M-u C-d
    C-u C-SPC

to the equivalent Lisp function:

(defun last-macro-commands ()
  (interactive)
  (re-search-forward "([`,]@?")
  (set-mark-command nil)
  (up-list 1)
  (backward-delete-char-untabify 1)
  (pop-to-mark-command)
  (delete-char 1)
  (set-mark-command nil)
  (backward-up-list)
  (delete-char 1)
  (pop-to-mark-command))

I need to polish details and will post a patch asap.

-- 
Juri Linkov
http://www.jurta.org/emacs/

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

* Re: Old-style backquotes in cc-vars.el
  2007-09-06 14:27                 ` Juri Linkov
@ 2007-09-07  6:32                   ` Richard Stallman
  0 siblings, 0 replies; 23+ messages in thread
From: Richard Stallman @ 2007-09-07  6:32 UTC (permalink / raw)
  To: Juri Linkov; +Cc: monnier, emacs-devel

    I've implemented a feature that converts a macro like:

	C-u C-s ([`,]@? C-SPC M-x up-list RET DEL C-u C-SPC C-d C-SPC C-M-u C-d
	C-u C-SPC

    to the equivalent Lisp function:

Thank you!  We have been waiting years for that feature.

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

* Re: Old-style backquotes in cc-vars.el
  2007-08-23 20:51 Old-style backquotes in cc-vars.el Stefan Monnier
  2007-09-01 10:18 ` Alan Mackenzie
@ 2007-10-06 16:31 ` Alan Mackenzie
  2007-10-06 18:31   ` Thien-Thi Nguyen
                     ` (2 more replies)
  1 sibling, 3 replies; 23+ messages in thread
From: Alan Mackenzie @ 2007-10-06 16:31 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: bug-cc-mode, Peter Dyballa, Martin Stjernholm, emacs-devel

Hi, Stefan!

On Thu, Aug 23, 2007 at 04:51:08PM -0400, Stefan Monnier wrote:

> cc-vars uses a mix of old-style a new-style backquotes.

I don't think it does.  The patch to cc-vars.el which created this form
was made by Martin S. on 2001-09-23.  He wouldn't knowingly have put in
old-style BQs as late as 2001.  But he might well have just tried one
thing after another until he got something to work.  I've CC'd him, just
in case he'd like to comment.  The exact patch can be seen at

<http://cc-mode.cvs.sourceforge.net/cc-mode/cc-mode/cc-vars.el?r1=5.112&r2=5.113>.

> I've fixed other uses of old-style backquotes in Emacs-22 but feel like
> there may be something fishy going on here, ....

Indeed.  At the risk of offending against public decency regulations, here
is the form lread.c is complaining about:  ;-)

,@(plist-put
   args ':type
   `(` (radio                                <==========================
	(const :tag "Use style settings"
	       set-from-style)
	,(, (let ((type (eval (plist-get args ':type))))
	      (unless (consp type)
		(setq type (list type)))
	      (unless (c-safe (plist-get (cdr type) ':value))
		(setcdr type (append '(:value (, -value-))
				     (cdr type))))
	      (unless (c-safe (plist-get (cdr type) ':tag))
		(setcdr type (append '(:tag "Override style settings")
				     (cdr type))))
	      (bq-process type))))))

I think (but I'm not entirely sure) the associativity of the backticks
and braces is:

    `( `(radio            , not            ` (` (radio

, i.e. I think it is actually nested new-style backquotes.  I've given
up trying to figure out when the inner commas get evaluated.

I'm not sure whether the rules for nested backquotes are clearly laid
out anywhere.  I think they're formally ambiguous (i.e., RTFS).  I tried
replacing "`(` (radio" with both

    "`( (` (radio"        (explicitly putting in an "old-style" BQ)

, and

    "`` (radio"           (replacing the alleged "old-style" BQ with a
                           "new-style" one)

, but each of these generated results different from the original
(checked with macroexpand).


> ...., so I'd rather someone else does the conversion here.

So would I.  ;-(

Who is the bytecomp expert, again?  Could we possibly ask him about the
semantics of  `(` (radio ?

Possibly, the analysis in lread.c needs to be done more rigorously.

>         Stefan

-- 
Alan.

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

* Re: Old-style backquotes in cc-vars.el
  2007-10-06 16:31 ` Alan Mackenzie
@ 2007-10-06 18:31   ` Thien-Thi Nguyen
  2007-10-06 20:51     ` Alan Mackenzie
  2007-10-11 17:41     ` Davis Herring
  2007-10-06 22:27   ` Stefan Monnier
  2007-10-07 13:10   ` Richard Stallman
  2 siblings, 2 replies; 23+ messages in thread
From: Thien-Thi Nguyen @ 2007-10-06 18:31 UTC (permalink / raw)
  To: Alan Mackenzie
  Cc: bug-cc-mode, Peter Dyballa, Martin Stjernholm, Stefan Monnier,
	emacs-devel

() Alan Mackenzie <acm@muc.de>
() Sat, 6 Oct 2007 16:31:01 +0000

   ,@(plist-put
      args ':type
      `(` (radio                                <==========================
           (const :tag "Use style settings"
                  set-from-style)
           ,(, (let ((type (eval (plist-get args ':type))))
                 (unless (consp type)
                   (setq type (list type)))
                 (unless (c-safe (plist-get (cdr type) ':value))
                   (setcdr type (append '(:value (, -value-))
                                        (cdr type))))
                 (unless (c-safe (plist-get (cdr type) ':tag))
                   (setcdr type (append '(:tag "Override style settings")
                                        (cdr type))))
                 (bq-process type))))))

wow, funky!  how about this replacement?

(defmacro defcustom-c-stylevar (name val doc &rest args)
  "Defines a style variable."
  (let* ((val (eval val))
         (type (eval (list 'identity (plist-get args :type))))
         (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)))
    `(progn
       (c-set-stylevar-fallback ',name ,val)
       (custom-declare-variable
        ',name ''set-from-style
        ,(concat doc "\n\nZZZ")
        ,@(plist-put 
           args :type `(radio
                        (const :tag "Use style settings" set-from-style)
                        ,(cons head newt)))))))

the ZZZ stands for the original blurb, reinstatable after discussion.
calls to `c-safe' were removed since plist-get never errs.

thi

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

* Re: Old-style backquotes in cc-vars.el
  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
  1 sibling, 1 reply; 23+ messages in thread
From: Alan Mackenzie @ 2007-10-06 20:51 UTC (permalink / raw)
  To: Thien-Thi Nguyen
  Cc: bug-cc-mode, Peter Dyballa, Martin Stjernholm, Stefan Monnier,
	emacs-devel

Hi, Thi!

On Sat, Oct 06, 2007 at 08:31:57PM +0200, Thien-Thi Nguyen wrote:
> () Alan Mackenzie <acm@muc.de>
> () Sat, 6 Oct 2007 16:31:01 +0000
> 
>    ,@(plist-put
>       args ':type
>       `(` (radio                                <==========================
>            (const :tag "Use style settings"
>                   set-from-style)
>            ,(, (let ((type (eval (plist-get args ':type))))
>                  (unless (consp type)
>                    (setq type (list type)))
>                  (unless (c-safe (plist-get (cdr type) ':value))
>                    (setcdr type (append '(:value (, -value-))
>                                         (cdr type))))
>                  (unless (c-safe (plist-get (cdr type) ':tag))
>                    (setcdr type (append '(:tag "Override style settings")
>                                         (cdr type))))
>                  (bq-process type))))))

> wow, funky!

Can you explain to me what it is doing?  If so, please do!  :-)

> how about this replacement?

> (defmacro defcustom-c-stylevar (name val doc &rest args)
>   "Defines a style variable."
>   (let* ((val (eval val))
>          (type (eval (list 'identity (plist-get args :type))))
>          (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)))
>     `(progn
>        (c-set-stylevar-fallback ',name ,val)
>        (custom-declare-variable
>         ',name ''set-from-style
>         ,(concat doc "\n\nZZZ")
>         ,@(plist-put 
>            args :type `(radio
>                         (const :tag "Use style settings" set-from-style)
>                         ,(cons head newt)))))))

It doesn't quite work - (car type) bombs, because type is 'integer, not
a list.  I'll figure out, though.
 
> thi

-- 
Alan.

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

* Re: Old-style backquotes in cc-vars.el
  2007-10-06 20:51     ` Alan Mackenzie
@ 2007-10-06 21:46       ` Thien-Thi Nguyen
  0 siblings, 0 replies; 23+ messages in thread
From: Thien-Thi Nguyen @ 2007-10-06 21:46 UTC (permalink / raw)
  To: Alan Mackenzie
  Cc: bug-cc-mode, Peter Dyballa, Martin Stjernholm, Stefan Monnier,
	emacs-devel

() Alan Mackenzie <acm@muc.de>
() Sat, 6 Oct 2007 20:51:18 +0000

   Can you explain to me what it is doing?  If so, please do!  :-)

it (or rather, the funky fragment in question) is converting the
given `:type FOO', mined out of the rest `args', to an aggregate
`:type (radio STYLE (PREAMBLE FOO))'.  `radio' means choose one of
the following exclusively.

STYLE stands for the choice where the value is taken from some style
setting (you probably know more about this than i do).

PREAMBLE is optionally prepended to FOO; that is, if FOO contains
:tag or :value, the respective 2-list component is ignored.

finally, the recomposed :type 2-list is spliced back into `args', the
value of which should be valid spec for `custom-declare-variable'.

   > (type (eval (list 'identity (plist-get args :type))))

   It doesn't quite work - (car type) bombs, because type is
   'integer, not   a list.  I'll figure out, though.

drat, i knew i forgot something.  please try this, instead:

   > (typ (eval (list 'identity (plist-get args :type))))
   > (type (if (consp typ) typ (list typ)))

here we ensure `type' is consp rather than trying to handle
non-consp `type'.

thi

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

* Re: Old-style backquotes in cc-vars.el
  2007-10-06 16:31 ` Alan Mackenzie
  2007-10-06 18:31   ` Thien-Thi Nguyen
@ 2007-10-06 22:27   ` Stefan Monnier
  2007-10-07  9:40     ` Alan Mackenzie
  2007-10-07 13:10   ` Richard Stallman
  2 siblings, 1 reply; 23+ messages in thread
From: Stefan Monnier @ 2007-10-06 22:27 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: bug-cc-mode, Peter Dyballa, Martin Stjernholm, emacs-devel

>> cc-vars uses a mix of old-style a new-style backquotes.
> I don't think it does.

The warning indicates that Emacs sees old-style backquotes, aqnd I'm pretty
sure there are new style backquotes as well, so I'm pretty sure you're wrong.

> He wouldn't knowingly have put in old-style BQs as late as 2001.

Maybe he did it knowingly: he's using nested backquotes and IIRC they didn't
always work correctly in older versions of Emacs when used with new-style
backquotes.  Actually IIRC the problem was with nested new-style commas
(where the second would not be recognized as new-style) which indeed do
appear in that code.

> I'm not sure whether the rules for nested backquotes are clearly laid
> out anywhere.

The problem is not about nesting but about new-style vs old-style: the
detailed rule about which is which is indeed only specified implicitly in
the source code.

> I think they're formally ambiguous (i.e., RTFS).  I tried
> replacing "`(` (radio" with both

>     "`( (` (radio"        (explicitly putting in an "old-style" BQ)

> , and

>     "`` (radio"           (replacing the alleged "old-style" BQ with a
>                            "new-style" one)

> , but each of these generated results different from the original
> (checked with macroexpand).

You need to fix the ,(, part accordingly.

> So would I.  ;-(

Thien-Thi might be a good start.

> Who is the bytecomp expert, again?  Could we possibly ask him about the
> semantics of  `(` (radio ?

It's (\` (\` (radio

> Possibly, the analysis in lread.c needs to be done more rigorously.

I have no idea what that means.


        Stefan

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

* Re: Old-style backquotes in cc-vars.el
  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
  0 siblings, 2 replies; 23+ messages in thread
From: Alan Mackenzie @ 2007-10-07  9:40 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: bug-cc-mode, Peter Dyballa, Martin Stjernholm, emacs-devel

Hi, Stefan,

On Sat, Oct 06, 2007 at 06:27:00PM -0400, Stefan Monnier wrote:
> >> cc-vars uses a mix of old-style a new-style backquotes.
> > I don't think it does.

> The warning indicates that Emacs sees old-style backquotes, aqnd I'm
> pretty sure there are new style backquotes as well, so I'm pretty sure
> you're wrong.

OK.  I've played around with things a bit since yesterday.  In
particular, I've discovered the useful functions `read' and
`backquote-process'.  I'm begining to think you're right and I'm wrong.
:-)

> > He wouldn't knowingly have put in old-style BQs as late as 2001.

> Maybe he did it knowingly: he's using nested backquotes and IIRC they
> didn't always work correctly in older versions of Emacs when used with
> new-style backquotes.  Actually IIRC the problem was with nested
> new-style commas (where the second would not be recognized as
> new-style) which indeed do appear in that code.

Ah.  OK.  That's sounds like a sound reason for not upgrading that code
in cc-vars.el, if it's the case.  (Or, for introducing yet another
difference between the cc-vars.el in Emacs and the standalone CC Mode,
which retains compatibility with older (X)Emacsen.  :-(  )

Probably I'll just scrap the old code and put in Thi's new version of the
function instead (after testing it thoroughly).  It looks a lot cleaner
and easier to understand.

> > I'm not sure whether the rules for nested backquotes are clearly laid
> > out anywhere.

> The problem is not about nesting but about new-style vs old-style: the
> detailed rule about which is which is indeed only specified implicitly in
> the source code.

OK.

> > I think they're formally ambiguous (i.e., RTFS).  I tried
> > replacing "`(` (radio" with both

> >     "`( (` (radio"        (explicitly putting in an "old-style" BQ)

> > , and

> >     "`` (radio"           (replacing the alleged "old-style" BQ with a
> >                            "new-style" one)

> > , but each of these generated results different from the original
> > (checked with macroexpand).

> You need to fix the ,(, part accordingly.

Ah!  I'm still figuring out what ,(, actually means.

> Thien-Thi might be a good start.

Yes.  He's already been very helpful.

> > Who is the bytecomp expert, again?  Could we possibly ask him about the
> > semantics of  `(` (radio ?

> It's (\` (\` (radio

I managed to get that late last night with   (read "`(` (a b c))").  :-)

Thanks for all the help!

>         Stefan

-- 
Alan.

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


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

* Re: Old-style backquotes in cc-vars.el
  2007-10-07  9:40     ` Alan Mackenzie
@ 2007-10-07  9:41       ` Thien-Thi Nguyen
  2007-10-07 19:40       ` Eli Zaretskii
  1 sibling, 0 replies; 23+ messages in thread
From: Thien-Thi Nguyen @ 2007-10-07  9:41 UTC (permalink / raw)
  To: Alan Mackenzie
  Cc: bug-cc-mode, Peter Dyballa, Martin Stjernholm, Stefan Monnier,
	emacs-devel

() Alan Mackenzie <acm@muc.de>
() Sun, 7 Oct 2007 09:40:25 +0000

   Yes.  He's already been very helpful.

i was motivated by the opportunity to omit
`c-safe' and `backquote-process' entirely.
blech!

thi

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

* Re: Old-style backquotes in cc-vars.el
  2007-10-06 16:31 ` Alan Mackenzie
  2007-10-06 18:31   ` Thien-Thi Nguyen
  2007-10-06 22:27   ` Stefan Monnier
@ 2007-10-07 13:10   ` Richard Stallman
  2 siblings, 0 replies; 23+ messages in thread
From: Richard Stallman @ 2007-10-07 13:10 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: bug-cc-mode, Peter_Dyballa, mast, monnier, emacs-devel

    I'm not sure whether the rules for nested backquotes are clearly laid
    out anywhere.

I think it follows logically from the syntax of one level of backquotes.
The inner backquote expands, producing a call to `cons' or `list'
which contants comma-expressions; then the outer backquote expands them.

I too found it hard to understand, and perhaps the code should be
rewritten to avoid nested backquotes, for simplicity.  But it is
valid.

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


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

* Re: Old-style backquotes in cc-vars.el
  2007-10-07  9:40     ` Alan Mackenzie
  2007-10-07  9:41       ` Thien-Thi Nguyen
@ 2007-10-07 19:40       ` Eli Zaretskii
  1 sibling, 0 replies; 23+ messages in thread
From: Eli Zaretskii @ 2007-10-07 19:40 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: bug-cc-mode, Peter_Dyballa, mast, emacs-devel

> Date: Sun, 7 Oct 2007 09:40:25 +0000
> From: Alan Mackenzie <acm@muc.de>
> Cc: bug-cc-mode@gnu.org, Peter Dyballa <Peter_Dyballa@Web.DE>,
> 	Martin Stjernholm <mast@lysator.liu.se>, emacs-devel@gnu.org
> 
> Ah!  I'm still figuring out what ,(, actually means.

If you ever figure that out (as well as other not-so-trivial aspects
of the macro syntax), please consider documenting that in the ELisp
manual.  This part of ELisp is notoriously under-documented.

TIA

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

* Re: Old-style backquotes in cc-vars.el
  2007-10-06 18:31   ` Thien-Thi Nguyen
  2007-10-06 20:51     ` Alan Mackenzie
@ 2007-10-11 17:41     ` Davis Herring
  2007-10-19  7:29       ` Thien-Thi Nguyen
  1 sibling, 1 reply; 23+ messages in thread
From: Davis Herring @ 2007-10-11 17:41 UTC (permalink / raw)
  To: Thien-Thi Nguyen
  Cc: Martin Stjernholm, Peter Dyballa, emacs-devel, bug-cc-mode,
	Stefan Monnier, Alan Mackenzie

> (defmacro defcustom-c-stylevar (name val doc &rest args)
>   "Defines a style variable."
>   (let* ((val (eval val))
>          (type (eval (list 'identity (plist-get args :type))))
>          (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)))

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?  And what is
(eval (list 'identity foo))) supposed to do differently than (eval foo)?

Davis

-- 
This product is sold by volume, not by mass.  If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.

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


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

* Re: Old-style backquotes in cc-vars.el
  2007-10-11 17:41     ` Davis Herring
@ 2007-10-19  7:29       ` Thien-Thi Nguyen
  0 siblings, 0 replies; 23+ messages in thread
From: Thien-Thi Nguyen @ 2007-10-19  7:29 UTC (permalink / raw)
  To: bug-cc-mode, emacs-devel

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


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

end of thread, other threads:[~2007-10-19  7:29 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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.