unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [jeff.dwork@amd.com: Re: customize]
@ 2002-09-16 15:16 Richard Stallman
  2002-09-16 16:01 ` Per Abrahamsen
  2002-09-16 16:01 ` Per Abrahamsen
  0 siblings, 2 replies; 3+ messages in thread
From: Richard Stallman @ 2002-09-16 15:16 UTC (permalink / raw)
  Cc: emacs-devel

I looked at this message, and then studied custom-save-delete.
It looks like the reason for this behavior is that custom-save-delete
only deletes calls to custom-save-variables at top level in the file.

Should we try to make it find and delete calls that are inside other
constructs?  To make that reliable, we would need to prevent it from
deleting instances of `custom-save-variables' inside strings, or lists
that have that symbol as car but are not expressions.

Perhaps it should detect only calls inside a few standard constructs
such as `if' and `progn'.

What do you think?


------- Start of forwarded message -------
X-Server-Uuid: 02753650-11b0-11d5-bbc5-00508bf987eb
From: "Jeff Dwork" <jeff.dwork@amd.com>
Date: Fri, 2 Aug 2002 17:46:44 -0700
To: rms@gnu.org
cc: eddy@opera.no, emacs-devel@gnu.org
Subject: Re: customize
In-Reply-To: <200207300100.g6U100I14581@aztec.santafe.edu>
X-WSS-ID: 1155F87C3178096-01-01

Here is an example of my problem with customize writing to .emacs
file.  I use 19.34 and I'm transitioning to 21.  Many things I do in
my version 19 .emacs are done differently in version 21, so I don't
want 21 to see my 19 stuff and my 19 stuff may not understand my
version 21 stuff.  So I tested the version in .emacs.

This is:
  GNU Emacs 21.1.1 (i686-pc-linux-gnu, X toolkit) of 2002-02-19 on
  go002
All invocations are:
  emacs --no-site-file

I start with this in .emacs:
********************************************
(if (< emacs-major-version 21)
    (progn
      ; here we set load-path for emacs 19
      ; this is just a dummy for test
      (setq jrd-init-var "19")
      (setq jrd-init-var2 "xx")
      )
  ; here we set load-path for emacs 21 and later
  ; this is just a dummy for test
  (setq jrd-init-var "21")
  (setq jrd-init-var2 "yy")
  )
********************************************

I start emacs 21, customize a variable and save it for the future.
I now have this:

********************************************
(if (< emacs-major-version 21)
    (progn
      ; here we set load-path for emacs 19
      ; this is just a dummy for test
      (setq jrd-init-var "19")
      (setq jrd-init-var2 "xx")
      )
  ; here we set load-path for emacs 21 and later
  ; this is just a dummy for test
  (setq jrd-init-var "21")
  (setq jrd-init-var2 "yy")
  )
(custom-set-variables
  ;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
 '(confirm-kill-emacs (quote y-or-n-p)))
(custom-set-faces
  ;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
 )
********************************************

But this won't work because the custom-set-variables is outside the
if.  I could write some code to make emacs 19 ignore this function,
but I don't want to.  So I move custom-set-* inside the if.

********************************************
(if (< emacs-major-version 21)
    (progn
      ; here we set load-path for emacs 19
      ; this is just a dummy for test
      (setq jrd-init-var "19")
      (setq jrd-init-var2 "xx")
      )
  ; here we set load-path for emacs 21 and later
  ; this is just a dummy for test
  (setq jrd-init-var "21")

  ; move custom stuff so only emacs 21 sees it

(custom-set-variables
  ;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
 '(confirm-kill-emacs (quote y-or-n-p)))
(custom-set-faces
  ;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
 )


  (setq jrd-init-var2 "yy")
  )
********************************************

I run emacs 21 again and customize another variable and I get this:

********************************************
(if (< emacs-major-version 21)
    (progn
      ; here we set load-path for emacs 19
      ; this is just a dummy for test
      (setq jrd-init-var "19")
      (setq jrd-init-var2 "xx")
      )
  ; here we set load-path for emacs 21 and later
  ; this is just a dummy for test
  (setq jrd-init-var "21")

  ; move custom stuff so only emacs 21 sees it

(custom-set-variables
  ;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
 '(confirm-kill-emacs (quote y-or-n-p)))
(custom-set-faces
  ;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
 )


  (setq jrd-init-var2 "yy")
  )
(custom-set-variables
  ;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
 '(confirm-kill-emacs (quote y-or-n-p))
 '(partial-completion-mode t nil (complete)))
(custom-set-faces
  ;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
 )
********************************************

Now we have two instances of custom-set-variables, which is not good.
...

- -- 
Jeff Dwork                      |           jeff.dwork@amd.com
Advanced Micro Devices, M/S 45  | 408-749-5216 (voice) 408-774-8448 (fax)
PO Box 3453                     |----------------------------------------
Sunnyvale, Ca 94088-3453        | 
------- End of forwarded message -------

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

* Re: [jeff.dwork@amd.com: Re: customize]
  2002-09-16 15:16 [jeff.dwork@amd.com: Re: customize] Richard Stallman
@ 2002-09-16 16:01 ` Per Abrahamsen
  2002-09-16 16:01 ` Per Abrahamsen
  1 sibling, 0 replies; 3+ messages in thread
From: Per Abrahamsen @ 2002-09-16 16:01 UTC (permalink / raw)
  Cc: emacs-devel

Richard Stallman <rms@gnu.org> writes:

> I looked at this message, and then studied custom-save-delete.
> It looks like the reason for this behavior is that custom-save-delete
> only deletes calls to custom-save-variables at top level in the file.

Yes.

> Should we try to make it find and delete calls that are inside other
> constructs? 

No.

However, I believe it would be useful to make custom-save-variables
signal an error if it is called from other places than the top-level.
If that is possible.

> To make that reliable, we would need to prevent it from
> deleting instances of `custom-save-variables' inside strings, or lists
> that have that symbol as car but are not expressions.

The problem is that Jeff's code is just a special case of the more
common:

(if (< emacs-major-version 21)
    ;; Emacs 20 customization.
    (custom-save-variables ...)
  ;; Emacs 21 customization.
  (custom-save-variables ...))

Which is impossible to make robust.  What we should encourage people
who need such functionality to do instead, is

(if (< emacs-major-version 21)
    ;; Emacs 20 customization.
    (setq custom-file "~/.custom-20.el")
  ;; Emacs 21 customization.
  (setq custom-file "~/.custom-21.el"))

(load-file custom-file)

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

* Re: [jeff.dwork@amd.com: Re: customize]
  2002-09-16 15:16 [jeff.dwork@amd.com: Re: customize] Richard Stallman
  2002-09-16 16:01 ` Per Abrahamsen
@ 2002-09-16 16:01 ` Per Abrahamsen
  1 sibling, 0 replies; 3+ messages in thread
From: Per Abrahamsen @ 2002-09-16 16:01 UTC (permalink / raw)
  Cc: emacs-devel, jeff.dwork

Richard Stallman <rms@gnu.org> writes:

> I looked at this message, and then studied custom-save-delete.
> It looks like the reason for this behavior is that custom-save-delete
> only deletes calls to custom-save-variables at top level in the file.

Yes.

> Should we try to make it find and delete calls that are inside other
> constructs? 

No.

However, I believe it would be useful to make custom-save-variables
signal an error if it is called from other places than the top-level.
If that is possible.

> To make that reliable, we would need to prevent it from
> deleting instances of `custom-save-variables' inside strings, or lists
> that have that symbol as car but are not expressions.

The problem is that Jeff's code is just a special case of the more
common:

(if (< emacs-major-version 21)
    ;; Emacs 20 customization.
    (custom-save-variables ...)
  ;; Emacs 21 customization.
  (custom-save-variables ...))

Which is impossible to make robust.  What we should encourage people
who need such functionality to do instead, is

(if (< emacs-major-version 21)
    ;; Emacs 20 customization.
    (setq custom-file "~/.custom-20.el")
  ;; Emacs 21 customization.
  (setq custom-file "~/.custom-21.el"))

(load-file custom-file)

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

end of thread, other threads:[~2002-09-16 16:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-09-16 15:16 [jeff.dwork@amd.com: Re: customize] Richard Stallman
2002-09-16 16:01 ` Per Abrahamsen
2002-09-16 16:01 ` Per Abrahamsen

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).