[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [AUCTeX] Default for PDF-mode?
From: |
David Reitter |
Subject: |
Re: [AUCTeX] Default for PDF-mode? |
Date: |
Sun, 25 Feb 2007 12:58:09 +0000 |
On 25 Feb 2007, at 11:43, David Kastrup wrote:
You might want to take a look at how tex-mik.el and similar change the
defaults of variables: the code is supposed to avoid
"Variable has changed outside of customize" warnings when the user
tries using
M-x customize-variable RET
on those variables.
tex-mik.el seems to only overwrite a customization option when it
hasn't been customized yet, i.e. when there is no `saved-value'
attribute. I think that's a smart thing to do in situations where the
user's .emacs has been loaded already.
What we're doing all happens before the user's files are loaded. We
set all customization defaults so that users can overwrite them using
the normal methods, using `set-default' and by manipulating the
`standard-value' attribute. In addition to that, we add the original
value (e.g. from GNU Emacs) to the documentation string of the
variable. For this, the variable definition (defcustom) needs to be
loaded at that time though, so it won't work with AUCTeX.
We also add the variable to a customization group so that seasoned
users can find the modification quickly, in case they prefer the
package or GNU Emacs default.
I'm attaching the function below in case anyone is looking for
something like this.
(defun aquamacs-set-defaults (list)
"Set new defaults for customization options in Aquamacs.
LIST is a list of two element lists of the form (symbol value), where
SYMBOL is the name of a customization variable, and VALUE the new
default.
The new defaults are added to the customization group
`Aquamacs-is-more-than-Emacs'. The original value is noted in the
variable's documentation string."
(mapc (lambda (elt)
(custom-load-symbol (car elt))
(let* ((symbol (car elt))
;; we're accessing the doc property here so
;; if the symbol is an autoload symbol,
;; it'll get loaded now before setting its defaults
;; (e.g. standard-value), which would otherwise be
;; overwritten.
(old-doc (documentation-property symbol
'variable-documentation))
(value (car (cdr elt)))
(s-value (get symbol 'standard-value)))
(set symbol value)
(set-default symbol value) ;; new in post-0.9.5
;; make sure that user customizations get
;; saved to customizations.el (.emacs)
;; and that this appears as the new default.
(put symbol 'standard-value `((quote ,(eval symbol))))
(unless (or (eq s-value (get symbol 'standard-value))
(get symbol 'aquamacs-original-default))
(put symbol 'aquamacs-original-default
s-value)
(if old-doc ;; in some cases the documentation
;; might not be loaded. Can we load it somehow?
;; either way, the "if" is a workaround.
(put symbol 'variable-documentation
(concat
old-doc
(format "
The original default (in GNU Emacs or in the package) was:
%s"
s-value))))
(custom-add-to-group 'Aquamacs-is-more-than-Emacs
symbol 'custom-variable))))
list))