To: [EMAIL PROTECTED]
   From: Paul Kinnucan <[EMAIL PROTECTED]>
   
   At 11:56 PM 7/5/00 +0100, Phillip Lord wrote:
   >
   >    May I suggest the following solution to this problem. Stick
   >this at the beginning of jde.el
   >
   >(defvar jde-disable-setq-advice nil)
   >
   >(defmacro jde-setq (symbol value)
   >  (let ((jde-disable-setq-advice t))
   >    `(setq ,symbol ,value)))
   >
   >(defadvice setq (before jde-test-for-custom activate)
   >  (if (and (string-match "jde-" (symbol-name (ad-get-arg 0)))
   >           (not jde-disable-setq-advice))
   >      (error "Warning. Setting jde variables without using custom is
   liable to turn Paul Kinnucan nasty")))
   >
   >      
   >      and then do a search and replace for every occurrence of 
   >"setq" within JDE, with jde-setq.
   >
   
   Wow. This is really brilliant. You are one devious dude, Phil. You should
   not put such evil thoughts in my head. Some day I might just be irritable
   enough to do it.

Paul -- I originally didn't comment on this message because:

 (1) There are obvious bugs in the suggested code.
 (2) Even with the obvious bugs corrected, it wouldn't work.
 (3) Even if it would work, it wouldn't be a good idea.

Sorry to be blunt, I don't mean to come down on anyone, but here is
explanation of these three points:

(1) This macro is miswritten.

   (defmacro jde-setq (symbol value)
     (let ((jde-disable-setq-advice t))
       `(setq ,symbol ,value)))
   
For the variable binding to have effect when the setq is executed, it
would need to be written this way:

   (defmacro jde-setq (symbol value)
     `(let ((jde-disable-setq-advice t))
        (setq ,symbol ,value)))

(2) Even if that is corrected, remember that setq isn't a function; it
a special form and not suitable for advice.  Even if advice worked, it
wouldn't work portably and might break in some future version of the
language.

(3) Supposing it really were possible to advise the setq special form,
remember that jde is not the only module in Emacs.  Many of us see jde
as only a small component of our Emacs usage.  Foe example, I do most
of my programming in Common Lisp, and am composing this mail message
in Emacs.  To laden every setq in all the code I run, or even in the
code I happen to compile (or run interpreted) within a session, would
simply not be acceptable.

Even if you don't agree with premise (3), you shouldn't violate it
because it might cause lots of Emacs users like me not to load jde
into their environments.

Steven M. Haflich <[EMAIL PROTECTED]>
Franz Inc., Berkeley CA
"Somebody stop me before I flame again!"

Reply via email to