* Customize custom-file is not useful as it works now
@ 2004-12-04 1:28 Lennart Borgman
2004-12-04 23:32 ` Lennart Borgman
2004-12-05 14:38 ` Richard Stallman
0 siblings, 2 replies; 5+ messages in thread
From: Lennart Borgman @ 2004-12-04 1:28 UTC (permalink / raw)
If you use customize-variable to change custom-file the value of custom-file
will be stored in custom-file. This is of course not useful.
What is needed is an entry in .emacs like (setq custom-file ".custom"). This
could as far as I understand be written in :set in the defcustom for
custom-file. I have written functions is setup-helper.el that I believe
could handle this rather easily. Another thing that ought to be done is
moving the entry (custom-set-variables ...) and dito faces to the new
custom-file.
Maybe this should be done before release? A reason for doing this is maybe
that there seem to be some changes that have to be made to the
(custom-set-variables ...) entry between the current Emacs and the new one.
- Lennart
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Customize custom-file is not useful as it works now
2004-12-04 1:28 Customize custom-file is not useful as it works now Lennart Borgman
@ 2004-12-04 23:32 ` Lennart Borgman
2004-12-05 14:38 ` Richard Stallman
1 sibling, 0 replies; 5+ messages in thread
From: Lennart Borgman @ 2004-12-04 23:32 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 1542 bytes --]
While waiting for some response I went a bit further and wrote code for the
suggestion below. I attach the main part of the code here so you can see
what I mean. If you want to test (which i hope) then you must also download
setup-helper.el (that is the other part of the code) from
http://www.emacswiki.org/. (I thought this part was to big to send it to the
list.)
- Lennart
----- Original Message -----
From: "Lennart Borgman" <lennart.borgman.073@student.lu.se>
To: "Emacs Devel" <emacs-devel@gnu.org>
Sent: Saturday, December 04, 2004 2:28 AM
Subject: Customize custom-file is not useful as it works now
> If you use customize-variable to change custom-file the value of
custom-file
> will be stored in custom-file. This is of course not useful.
>
> What is needed is an entry in .emacs like (setq custom-file ".custom").
This
> could as far as I understand be written in :set in the defcustom for
> custom-file. I have written functions is setup-helper.el that I believe
> could handle this rather easily. Another thing that ought to be done is
> moving the entry (custom-set-variables ...) and dito faces to the new
> custom-file.
>
> Maybe this should be done before release? A reason for doing this is maybe
> that there seem to be some changes that have to be made to the
> (custom-set-variables ...) entry between the current Emacs and the new
one.
>
> - Lennart
>
>
>
>
> _______________________________________________
> Emacs-devel mailing list
> Emacs-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-devel
>
[-- Attachment #2: custom-file.el --]
[-- Type: application/octet-stream, Size: 2981 bytes --]
;; This is a suggestion for enhancement of defcustom custom-file. It
;; is supposed to take care of changing .emacs and copying the
;; customization info the tne new file. If the choosen file already
;; exists the user is given the option to use the values there.
;;
;; Author: Lennart Borgman
;; Date: 2004-12-04
(defcustom custom-file nil
"File used for storing customization information.
The default is nil, which means to use your init file
as specified by `user-init-file'. If you specify some other file,
you need to explicitly load that file for the settings to take effect."
:type '(choice (const :tag "Your Emacs init file" nil) file)
;; FIX-ME: Is it really the set event that should be used? Is there
;; some save event?? Maybe an advice on custom-save-all?
:set (lambda (symbol value)
(let ((same-cust-file (equal custom-file value)))
(unless same-cust-file
;;(message "not equal")
(eval '(require 'setup-helper))
(let ((new-entry (if value
(concat "(setq custom-file \"" value "\")")
" t "))
(replaced))
;;(message "old=%s new=%s new-entry=%s" custom-file value new-entry)
;; FIX-ME: Not entirely correct, should probably check for
;; saved value of custom-file!
(save-window-excursion
(save-excursion
(find-file user-init-file)
(when custom-file
;;(message "custom-file.here 1")
(setq replaced (setup-helper-find-replace-lisp-whole
(format "\\`(setq custom-file \"%s\")\\'" custom-file) t
new-entry "Replace with ${new}?"))
(unless replaced
;;(message "custom-file.here 2")
(setq replaced (setup-helper-find-replace-lisp-whole
"\\`(setq custom-file .*)\\'" t
new-entry "Replace this with ${new}?"))))
(when value
(unless replaced
;;(message "custom-file.here 3")
(setup-helper-add-sexp-if-not-found
new-entry "Added by defcustom custom-file" nil t)))
(sleep-for 2) ;; To be able to see Replaced/Addd message
(save-buffer)))))
;; FIX-ME: what to do when the init file is compiled??
(unless custom-file (custom-save-delete))
(set-default symbol value)
(unless same-cust-file
;; If the selected file exist maybe the user wants the values saved there
(when (file-exists-p custom-file)
(when (let ((use-dialog-box nil))
(y-or-n-p
(concat custom-file " already exists."
" Do you want to use the values in this file"
" instead of the current values? ")))
;; Must jump out whith an error here to avoid saving!
;; The error message below disappears when the mouse
;; is used to answer y-or-n-p above unless
;; use-dialog-box is nil.
(progn (error
(concat "Please restart Emacs without saving customizations"
" to use the values in the new custom-file.")))))
(custom-save-all))))
:group 'customize)
[-- Attachment #3: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Customize custom-file is not useful as it works now
2004-12-04 1:28 Customize custom-file is not useful as it works now Lennart Borgman
2004-12-04 23:32 ` Lennart Borgman
@ 2004-12-05 14:38 ` Richard Stallman
2004-12-05 17:24 ` Lennart Borgman
1 sibling, 1 reply; 5+ messages in thread
From: Richard Stallman @ 2004-12-05 14:38 UTC (permalink / raw)
Cc: emacs-devel
If you use customize-variable to change custom-file the value of custom-file
will be stored in custom-file. This is of course not useful.
This doesn't do the job by itself, but if your .emacs loads that file,
it will take effect properly. So it isn't simply wrong.
What is needed is an entry in .emacs like (setq custom-file ".custom").
That isn't enough, is it? To make the settings take effect, the user
has to load the file which is specified as custom-file. But I hesitate
to recommend editing .emacs automatically to do this, since one of the
reasons people want to use a separate file is to avoid automatic editing
of .emacs.
So I documented these issues in the doc string of custom-file.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Customize custom-file is not useful as it works now
2004-12-05 14:38 ` Richard Stallman
@ 2004-12-05 17:24 ` Lennart Borgman
2004-12-06 1:40 ` Richard Stallman
0 siblings, 1 reply; 5+ messages in thread
From: Lennart Borgman @ 2004-12-05 17:24 UTC (permalink / raw)
Cc: emacs-devel
----- Original Message -----
From: "Richard Stallman" <rms@gnu.org>
> What is needed is an entry in .emacs like (setq custom-file
".custom").
>
> That isn't enough, is it? To make the settings take effect, the user
> has to load the file which is specified as custom-file. But I hesitate
> to recommend editing .emacs automatically to do this, since one of the
> reasons people want to use a separate file is to avoid automatic editing
> of .emacs.
I have just learned that custom-file is loaded after .emacs by startup.el if
it was not loaded before.
The editing I proposed shows the old entry if any in .emacs marked and asks
the user whether to change it. It looks mostly like query replace, but with
some more marking. (Though I forgot to add a question when adding.) This
could all be made a bit nicer (it is just not quite finished yet) and I
realize that many would not want automatic editing of .emacs. And it is a
bit scary to do the editing too. However when the user is asked to accept
the change and clearly shown what will be done it might perhaps be accepted
by most users?
- Lennart
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Customize custom-file is not useful as it works now
2004-12-05 17:24 ` Lennart Borgman
@ 2004-12-06 1:40 ` Richard Stallman
0 siblings, 0 replies; 5+ messages in thread
From: Richard Stallman @ 2004-12-06 1:40 UTC (permalink / raw)
Cc: emacs-devel
The editing I proposed shows the old entry if any in .emacs marked and asks
the user whether to change it. It looks mostly like query replace, but with
some more marking. (Though I forgot to add a question when adding.) This
could all be made a bit nicer (it is just not quite finished yet) and I
realize that many would not want automatic editing of .emacs. And it is a
bit scary to do the editing too. However when the user is asked to accept
the change and clearly shown what will be done it might perhaps be accepted
by most users?
This seems like a good argument, so I guess we should try your change.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-12-06 1:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-04 1:28 Customize custom-file is not useful as it works now Lennart Borgman
2004-12-04 23:32 ` Lennart Borgman
2004-12-05 14:38 ` Richard Stallman
2004-12-05 17:24 ` Lennart Borgman
2004-12-06 1:40 ` Richard Stallman
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).