From: "Lennart Borgman" <lennart.borgman.073@student.lu.se>
Subject: Re: Customize custom-file is not useful as it works now
Date: Sun, 5 Dec 2004 00:32:53 +0100 [thread overview]
Message-ID: <006601c4da59$e8b4e410$0200a8c0@sedrcw11488> (raw)
In-Reply-To: 075301c4d9a0$9ef2bf00$0200a8c0@sedrcw11488
[-- 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
next prev parent reply other threads:[~2004-12-04 23:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-04 1:28 Customize custom-file is not useful as it works now Lennart Borgman
2004-12-04 23:32 ` Lennart Borgman [this message]
2004-12-05 14:38 ` Richard Stallman
2004-12-05 17:24 ` Lennart Borgman
2004-12-06 1:40 ` Richard Stallman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='006601c4da59$e8b4e410$0200a8c0@sedrcw11488' \
--to=lennart.borgman.073@student.lu.se \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).