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: Documentation for custom-file - is not (load custom-file) needed? Date: Mon, 6 Dec 2004 22:53:00 +0100 Message-ID: <009401c4dbdd$fb874c60$0200a8c0@sedrcw11488> References: <075b01c4d9a4$52799460$0200a8c0@sedrcw11488> <00bb01c4daee$5eb81350$0200a8c0@sedrcw11488> <200412051733.iB5HXIX13206@raven.dms.auburn.edu> <000001c4db1a$8d3770f0$0200a8c0@sedrcw11488> <200412060046.iB60kZj15003@raven.dms.auburn.edu> <003e01c4db31$e45a2550$0200a8c0@sedrcw11488> <200412060402.iB6421q15173@raven.dms.auburn.edu> <200412061834.iB6IYBu20015@raven.dms.auburn.edu> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1102370051 19098 80.91.229.6 (6 Dec 2004 21:54:11 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 6 Dec 2004 21:54:11 +0000 (UTC) Cc: jpw@gnu.org, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 06 22:54:04 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 1CbQo0-0007t3-00 for ; Mon, 06 Dec 2004 22:54:04 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CbQxl-0006v4-Rn for ged-emacs-devel@m.gmane.org; Mon, 06 Dec 2004 17:04:09 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CbQxU-0006uz-V7 for emacs-devel@gnu.org; Mon, 06 Dec 2004 17:03:53 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CbQxU-0006un-G8 for emacs-devel@gnu.org; Mon, 06 Dec 2004 17:03:52 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CbQxU-0006uk-Az for emacs-devel@gnu.org; Mon, 06 Dec 2004 17:03:52 -0500 Original-Received: from [81.228.10.107] (helo=av9-2-sn4.m-sp.skanova.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CbQnR-0006Wm-GG; Mon, 06 Dec 2004 16:53:29 -0500 Original-Received: by av9-2-sn4.m-sp.skanova.net (Postfix, from userid 502) id 5BF8237E81; Mon, 6 Dec 2004 22:53:28 +0100 (CET) Original-Received: from smtp2-1-sn4.m-sp.skanova.net (smtp2-1-sn4.m-sp.skanova.net [81.228.10.183]) by av9-2-sn4.m-sp.skanova.net (Postfix) with ESMTP id 3BA8C37E4D; Mon, 6 Dec 2004 22:53:28 +0100 (CET) Original-Received: from sedrcw11488 (t5o58p158.telia.com [195.67.196.158]) by smtp2-1-sn4.m-sp.skanova.net (Postfix) with SMTP id 5437237E4E; Mon, 6 Dec 2004 22:53:24 +0100 (CET) Original-To: "Stefan Monnier" , "Luc Teirlinck" 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:30773 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:30773 ----- Original Message ----- From: "Stefan Monnier" To: "Luc Teirlinck" > > 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) ))