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: Juri Linkov
Subject: Re: Documentation for custom-file - is not (load custom-file) needed?
Date: Wed, 08 Dec 2004 06:42:53 +0200
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

"Lennart Borgman" <address@hidden> writes:
> a) custom-file is a special variable and can not be treated only as
> a normal "defcustom variable".
>
> b) It is currently treated as a normal "defcustom variable".
> This should be changed.

Trying to sync custom-file with the location of its own list where
it is defined is like trying to lift yourself off the ground by pulling
on your hair.  The maximum you can achieve is to remove your hair ;-)

> There are various ways to cure this:
>
> 1) Just do not make custom-file a "defcustom variable". This is the
> easiest and does not fool the user. But it is perhaps not very nice.

It's too late to make any changes in custom-file (changing its type,
etc.) since users might already rely on its current state.

> 2) Keep custom-file a "defcustom variable" and cure the problems.

The only problem with custom-file is its existence.  It is completely
redundant.  The location of the list of customized variables is just
the file name from which it is loaded.  There is no need to duplicate
this information in a special variable.

What users need is just to put in .emacs something like

(load "custom-21.4.el")

and nothing more.  The location of the custom file is defined.

Moving the customization list between different files can be done with
normal Emacs editing commands.  There is no need to do this automatically.

To get this done `custom-set-variables' should save the name of the
file from which it was loaded, and use it later in the `custom-file'
function to return the file name.

In this function `custom-file-loaded' should be placed after the
`custom-file' to make it backward compatible since users might have
already `custom-file' variable defined in .emacs.

Index: lisp/custom.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/custom.el,v
retrieving revision 1.76
diff -u -r1.76 custom.el
--- lisp/custom.el      29 Jul 2004 01:47:01 -0000      1.76
+++ lisp/custom.el      8 Dec 2004 04:03:19 -0000
@@ -722,6 +722,7 @@
 
 REQUEST is a list of features we must 'require for SYMBOL.
 COMMENT is a comment string about SYMBOL."
+  (if load-in-progress (setq custom-file-loaded load-file-name))
   (apply 'custom-theme-set-variables 'user args))
 
 (defun custom-theme-set-variables (theme &rest args)

Index: lisp/cus-edit.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/cus-edit.el,v
retrieving revision 1.201
diff -u -r1.201 cus-edit.el
--- lisp/cus-edit.el    6 Dec 2004 14:01:19 -0000       1.201
+++ lisp/cus-edit.el    8 Dec 2004 03:57:07 -0000
@@ -3673,7 +3673,12 @@
       (widget-put widget :custom-state found)))
   (custom-magic-reset widget))
 
 ;;; The `custom-save-all' Function.
+
+(defvar custom-file-loaded nil
+  "Full name of last file from which `custom-set-variables' was loaded.")
+
 ;;;###autoload
 (defcustom custom-file nil
   "File used for storing customization information.
@@ -3697,6 +3702,7 @@
   "Return the file name for saving customizations."
   (setq custom-file
        (or custom-file
+           custom-file-loaded
            (let ((user-init-file user-init-file)
                  (default-init-file
                    (if (eq system-type 'ms-dos) "~/_emacs" "~/.emacs")))

-- 
Juri Linkov
http://www.jurta.org/emacs/





reply via email to

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