← Back to team overview

vm team mailing list archive

fixes for the file hooks warning question

 

Uday, Ulrich,

I've just been looking at the warnings for obsolete hook names and noticed
something interesting and wanted your thoughts. 

One of the warnings is for write-file-hooks, which is now obsolete in emacs
22.1, replaced with write-file-functions. However, the code in question is a
little odd. i.e.

(if (not (memq 'vm-write-file-hook write-file-hooks))
    (setq write-file-hooks
	  (cons 'vm-write-file-hook write-file-hooks)))

My interpretation of this bit of code is that it is testing to see if the
function is already added and only adds it if it isn't. However, the docs for
both emacs and xemacs state that the add-hook function will only add a new
function to the hook if it doesn't already exist. For emacs, this has been my
understanding for quite some time, so I expect this is something from very old
emacs (pre 21) or old xemacs. 

Given that both emacs and xemacs add-hook function only add a function to a
hook if it doesn't already exist, my preference would be to replace the above
sort of code with something like 

(if (boundp 'write-file-hooks)
    (add-hook 'write-file-hooks 'vm-write-file-hook)
  (add-hook 'write-file-functions 'vm-write-file-hook))

Are either of you aware of anything here I'm not? Does this seem reasonable to
you?

Tim



-- 
Tim Cross
tcross@xxxxxxxxxxxxxxx

There are two types of people in IT - those who do not manage what
they understand and those who do not understand what they manage.
-- 
Tim Cross
tcross@xxxxxxxxxxxxxxx

There are two types of people in IT - those who do not manage what they 
understand and those who do not understand what they manage.



Follow ups

References