From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Lennart Borgman" Newsgroups: gmane.emacs.devel Subject: Re: Customize custom-file is not useful as it works now Date: Sun, 5 Dec 2004 00:32:53 +0100 Message-ID: <006601c4da59$e8b4e410$0200a8c0@sedrcw11488> References: <075301c4d9a0$9ef2bf00$0200a8c0@sedrcw11488> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0059_01C4DA61.F574EC60" X-Trace: sea.gmane.org 1102203387 22271 80.91.229.6 (4 Dec 2004 23:36:27 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 4 Dec 2004 23:36:27 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Dec 05 00:36:23 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CajRu-0001kO-00 for ; Sun, 05 Dec 2004 00:36:22 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1Cajba-0004U8-5S for ged-emacs-devel@m.gmane.org; Sat, 04 Dec 2004 18:46:22 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1Cajau-0004LU-EZ for emacs-devel@gnu.org; Sat, 04 Dec 2004 18:45:40 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1Cajat-0004LA-RR for emacs-devel@gnu.org; Sat, 04 Dec 2004 18:45:40 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1Cajat-0004L0-Ok for emacs-devel@gnu.org; Sat, 04 Dec 2004 18:45:39 -0500 Original-Received: from [81.228.11.113] (helo=av7-1-sn1.fre.skanova.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CajQz-0000jE-TM for emacs-devel@gnu.org; Sat, 04 Dec 2004 18:35:26 -0500 Original-Received: by av7-1-sn1.fre.skanova.net (Postfix, from userid 502) id 3008037ED9; Sun, 5 Dec 2004 00:35:25 +0100 (CET) Original-Received: from smtp3-1-sn1.fre.skanova.net (smtp3-1-sn1.fre.skanova.net [81.228.11.163]) by av7-1-sn1.fre.skanova.net (Postfix) with ESMTP id 2018137E7E for ; Sun, 5 Dec 2004 00:35:25 +0100 (CET) Original-Received: from sedrcw11488 (t1o58p147.telia.com [62.20.164.147]) by smtp3-1-sn1.fre.skanova.net (Postfix) with SMTP id B3CCE37E48 for ; Sun, 5 Dec 2004 00:35:23 +0100 (CET) Original-To: "Emacs Devel" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1409 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:30679 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:30679 This is a multi-part message in MIME format. ------=_NextPart_000_0059_01C4DA61.F574EC60 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit 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" To: "Emacs Devel" 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 > ------=_NextPart_000_0059_01C4DA61.F574EC60 Content-Type: application/octet-stream; name="custom-file.el" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="custom-file.el" ;; 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=3D%s new=3D%s new-entry=3D%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) ------=_NextPart_000_0059_01C4DA61.F574EC60 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel ------=_NextPart_000_0059_01C4DA61.F574EC60--