emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Documentation for custom-file - is not (load custom-file) needed?


From: Lennart Borgman
Subject: Re: Documentation for custom-file - is not (load custom-file) needed?
Date: Mon, 6 Dec 2004 22:53:00 +0100

----- Original Message ----- 
From: "Stefan Monnier" <address@hidden>
To: "Luc Teirlinck" <address@hidden>


> >    You might be right.  It does seem however that the :get and :set
functions
> >    don't need to do anything special.
>
> > The problem with setting the variable with setq instead of through
> > `custom-set-variables' is that various standard things like:
>
> > (put 'custom-file 'saved-value '("~/mycustomfile"))
...
> Sure.  I wasn't arguing against using `load', just pointing out that it
> might not be as important as it seems.  After all, AFAICT changing
> custom-file via Custom itself currently just plain doesn't work and it's
not
> clear at all how to make it work.
>
> This said, it's indeed probably better to tell people to `load' the custom
> file rather than to `setq' the `custom-file' variable (among other things
> because it involves much less magic, and works with Emacs-21.3).

I have another opinion here. I do not believe that custom-file should be
handled like other defcustom variables:

a) I do not think it is good to store it in (custom-set-variables ...) since
that would make it much harder to rename that file because
custom-set-variables would read the old file name.

b) That said custom-file must be set somehow because otherwise saving the
settings will go to .emacs. Then I think (setq custom-file ...) is a good
and simple way.

Along these lines I have written a simple example below where I have renamed
custom-file to custox-file so you can test it without trouble. This simple
example can be expanded to query the user for automatic updating of .emacs
(like I did in the code I proposed below).

If it is scary to do automatic updating of .emacs even when the user is
prompted to accept it I instead propose something like the example below.
There are drawbacks with both methods and if automated update is not used I
believe the prompt screen below must be very clear about that the user needs
to edit .emacs. (I believe it should stand out in some way so the user do
not miss the message.)

Concerning the magic it could be explained in the prompt screen below,
together with instruction to edit .emacs.

- Lennart


(defvar custox-file nil)

(defcustom custox-file nil "docstring"
  :type 'string
  :initialize (lambda (sym val) )
  :get (lambda (sym) (if custox-file custox-file ""))
  :set (lambda (sym val)
  ;; Delete values from .emacs if custox-file is nil
  (when (boundp 'custox-file)
    (unless custox-file
      (message "(custom-save-delete) should be done in this state...")
      (sleep-for 2)))
  (setq custox-file val)
  ;; Show an explanation
  (save-window-excursion
    (save-excursion
      (with-temp-buffer
        (delete-other-windows)
        (princ
  (concat "Some explanation here...\n\n"
   "and maybe run some code to edit .emacs after this ...")
        (current-buffer))
        (switch-to-buffer (current-buffer))
        (read-from-minibuffer "Press any key to continue: " nil
         '(keymap (t . exit-minibuffer)))
        )))
  ;; Avoid storing custox-file since it would interfere with
  ;; the file actually used. If the custox-file is renamed this
  ;; would otherwise cause problems.
  (put 'custox-file 'saved-value nil)
  ))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]