[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: define-derived-mode
From: |
Lute Kamstra |
Subject: |
Re: define-derived-mode |
Date: |
Tue, 10 May 2005 10:47:45 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
Luc Teirlinck <address@hidden> writes:
> Lute Kamstra wrote:
>
> > which was an incompatible change.
>
> Not compatible with what?
>
> With pre-existing defvars or defcustoms for these hooks. (Unless you
> checked for _all_ uses of `define-generic-mode' that there are none.
> But how did you get a list of _all_ outside packages that use it?)
define-generic-mode is an all-in-one solution for defining a major
mode. You call it, and every aspect of the major mode should be set
up. I think it's very unlikely that anyone who uses
define-generic-mode will add a defvar for the mode hook. (This
certainly isn't the case in Emacs' sources.)
> In the case of `define-minor-mode' two concrete examples of variables
> with competing defcustoms are auto-revert-mode-hook and
> global-auto-revert-mode-hook. In this particular case, not too much
> harm is done, but it is not exactly very clean.
>
> I primarily wanted to define the mode hook as a variable so that I
> could give it docstring. I chose defcustom over defvar because
> define-minor-mode and quite some other major modes did that. I don't
> strongly object to making the defcustom a defvar, but I don't
> understand your problems with the use of defcustom:
>
> I have a problem with _both_ defvar and defcustom. Hooks do not need
> a defvar, most hooks do not have them. The only reason for a defvar
> is to add a docstring. You use the defvar to give the hook the
> docstring: "Hook run when entering Mymode mode.". This "generic"
> docstring contains no info that is not already contained in the hook's
> name and it could overwrite _real_ info contained in a handwritten
> defvar or defcustom.
>
> If you want to make people aware of the mode hook, it would seem
> better to put an additional sentence in the default mode doc:
>
> "Mymode mode.
> This a generic mode defined with `define-generic-mode'.
> As all such modes, it runs `foo-mode-hook' as the very last thing it does."
Ok, that sounds reasonable. I'll implement that.
> I don't recall the bugs you refer to; could you give me the subject(s)
> of the relevant thread(s)?
>
> It is scattered over several threads. Threads about Custom tend to be
> superlong and unfocused. `find-file-hook as illustration of Custom problems'
> is one of the threads, but several other threads about Custom were
> going on at the same time and they all intertwined.
>
> There are several problems, related to the fact that hooks have to be
> customized using add-hook and remove-hook and not using setq. But
> Custom does use setq. Here is an example of the type of problems that
> occur. (By no means the only one.) The user customizes foo-hook
> using Custom. Then in the next Emacs version, a very essential
> function badly-needed-fun is added to foo-hook. The user's
> custom-set-variables form overrides the adding of badly-needed-fun to
> foo-hook.
>
> These kind of problems are supposed to get fixed in 23 or 24, but it
> is too tricky to still get it done for 22.
Thanks for clarifying,
Lute.
- define-derived-mode, Luc Teirlinck, 2005/05/07
- Re: define-derived-mode, Luc Teirlinck, 2005/05/07
- Re: define-derived-mode, Richard Stallman, 2005/05/08
- Re: define-derived-mode, Luc Teirlinck, 2005/05/08
- Re: define-derived-mode, Richard Stallman, 2005/05/09
- Re: define-derived-mode, David Kastrup, 2005/05/09
- Re: define-derived-mode, Lute Kamstra, 2005/05/12
- Re: define-derived-mode, Lute Kamstra, 2005/05/17
- Re: define-derived-mode, Lute Kamstra, 2005/05/09
- Re: define-derived-mode, Luc Teirlinck, 2005/05/09
- Re: define-derived-mode,
Lute Kamstra <=
- Re: define-derived-mode, Juanma Barranquero, 2005/05/08
- Re: define-derived-mode, Richard Stallman, 2005/05/09
Re: define-derived-mode, Luc Teirlinck, 2005/05/08