emacs-devel
[Top][All Lists]
Advanced

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

Re: Defcustom write-file-functions and write-contents-functions?


From: Simon Josefsson
Subject: Re: Defcustom write-file-functions and write-contents-functions?
Date: Wed, 31 Dec 2003 18:26:08 +0100
User-agent: Gnus/5.1004 (Gnus v5.10.4) Emacs/21.3.50 (gnu/linux)

Luc Teirlinck <address@hidden> writes:

> Do you really want to make those two functions customizable through
> Custom?  They seem to be intended to be used by programs.

The example I gave, copyright-update, appear to be intended for users.

> They are tricky.  They are not normal hooks.  The order matters a
> lot.  If a user naively adds a function that returns a non-nil
> value, big surprises may result.  Not something one might want the
> average user to start playing apprentice sorcerer with.  (_Any_ Lisp
> variable is customizable by a sophisticated user by writing Lisp
> code in .emacs or files loaded by .emacs.)  Custom sets _global_
> values and these two hooks are intended to be file-specific and
> hence buffer-local.

I'm not sure I'm convinced; users can mess up their emacs environment
by customizing many variables.  At least with this variable, if the
user makes a mistake, she can revert the value without restarting
emacs, unlike e.g. max-specpdl-size or max-lisp-eval-depth.  And
editing away mistakes is rather easy in the custom buffer.

I believe it is better to encourage users to use custom because it
reduces typos and elisp quotation errors.  If these variables were
installed, the user could customize any of the variable and click on
the click box for `copyright-update', instead of typing (add-hook
'write-file-functions 'copyright-update) and risking making a typo,
forcing here to use remove-hook manually on the typo.

(An unrelated example: a non-negligible number of the posts regarding
setting up SMTP for authentication in Emacs contain elisp quotation
problems, such as using "25" instead of 25, or '("foo" 'bar).  If
those users used the custom interface instead, they wouldn't be able
to make those typos.  I don't know why they don't use custom, but
perhaps we simply don't encourage users to do so enough.)

> I do not know how you envision the average user to use these
> defcustoms.

My primary example is copyright-update.  It can be added to
write-file-functions or (probably better) write-contents-functions.

When the user is a developer, I even imagine this to be something even
an average user would want (if she know about the copyright.el
package).

> Would the customizability you want to achieve not be
> better served by adding a defcustom for a new no-tricks _normal_ hook,
> say `before_save_hook', called before the other two?  (If there
> already would be a hook of this type, then it should be documented in
> (elisp)Saving Buffers.)

This could work too.  My reason for choosing w-f-f was that
copyright.el suggested it, and I want to use custom to enable that
package.





reply via email to

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