[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [AUCTeX-devel] customize-option breaks preview-latex hook

From: David Kastrup
Subject: Re: [AUCTeX-devel] customize-option breaks preview-latex hook
Date: Tue, 13 Feb 2007 16:36:07 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Masayuki Ataka <address@hidden> writes:

> Hi,
> Ikumi-San reported me that there is a situation that
> preview-latex is not turned on.
> If the user has customized `LaTeX-mode-hook' using M-x
> customize-option before AUCTeX 11.81 and updated his AUCTeX to
> current version, he cannot turn on preview-latex even when he
> added (load "preview-latex.el" nil t t) in his .emacs, because
> the hook `LaTeX-mode-hook' is overwritten to old user setting
> by auto-inserted function custom-set-variables.
> See details:
> (1) (load "preview-latex.el" nil t t) adds LaTeX-preview-setup
>     to LaTeX-mode-hook.
> (2) custom-set-variables overwrite the hook by user setting
>     that is customized before updating AUCTeX 11.81+.
> (3) No LaTeX-preview-setup in LaTeX-mode-hook, so that user
>     cannot turn on preview-latex.
> Any good solution?  Maybe we should write FAQ for those who
> update their AUCTeX from 11.80-.

I think it is a mistake to make a hook variable customizable _unless_
one uses the customization type 'hook for it.

This customization type is probably only available for Emacs 22.  I
think that it might get tested with:

(if (get 'hook 'widget-type)

Using anything else is asking for trouble, as you have seen, unless
one defines one's own setter function in the defcustom which will not
overwrite existing elements of the hook, but rather add the customized
list using add-hook on each element of the customization.

cus-edit.el provides a fitting setter function we could probably steal
(see below).  I don't have an idea which of the other fields would be
required as well for sensible behavior, so unless somebody wants to
investigate this, we are likely best off by not making the hooks
customizable at all without appropriate support by Emacs.

;;; The `hook' Widget.

(define-widget 'hook 'list
  "A emacs lisp hook"
  :value-to-internal (lambda (widget value)
                       (if (and value (symbolp value))
                           (list value)
  :match (lambda (widget value)
           (or (symbolp value)
               (widget-group-match widget value)))
  ;; Avoid adding undefined functions to the hook, especially for
  ;; things like `find-file-hook' or even more basic ones, to avoid
  ;; chaos.
  :set (lambda (symbol value)
         (dolist (elt value)
           (if (fboundp elt)
               (add-hook symbol elt))))
  :convert-widget 'custom-hook-convert-widget
  :tag "Hook")

David Kastrup

reply via email to

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