Kyle Jones wrote:
find-tag-default-hook isn't (apparently) meant to be an ordinary
hook. And the rest of your patch introduces semantic changes
(differing return value, differing behavior on error, local hook
being run in a situation where it would not have been before).
The code will have to be analyzed more carefully before we can
change this.
Very true. I'm afraid the patch was made quickly to solve a problem I
was having. Having looked through the code more carefully, it seems the
following is true:
- find-tag-default-hook is a weird, half supported feature (see
comments from hniksic around line 1063 of etags.el). However, it is
certainly not a normal hook, so shouldn't be called as such.
- As for the semantic changes, there are some, since run-hooks and
funcall do different things, but they make these hooks behave like every
other hook in XEmacs, and stops the errors that occur if one uses the
(add-hook .... ) idiom with them. As there seems no reason for
find-tag-hook (and local-find-tag-hook) to behave any differently than
all other hooks, I believe the change should stand. If they are
supposed to be different, and there is no indication in the code that
they are, then they need renaming from -hook.
- At the time local-find-tag-hook and find-tag-hook are called,
local-find-tag-hook is the value of find-tag-hook from the original
buffer, and find-tag-hook has its value from the new buffer, I have
changed the calling sequence to call them in the same cases as the
original. As for error handling, this looks the same, since at the end
of the day both run-hooks and funcall will use funcall and presumably
the errors will propagate the same.
Hopefully this new patch does all the above and will be acceptable -
I'll happily make changes if it isn't.
--- etags.el Wed Jul 22 11:34:38 1998
+++ etags.el Wed Jul 22 12:17:03 1998
@@ -553,10 +553,12 @@
Make it buffer-local in a mode hook. The function is called with no
arguments.")
-(defvar find-tag-hook nil
- "Function to call after a hook is found.
+(defcustom find-tag-hook nil
+ "*Function to call after a hook is found.
Make it buffer-local in a mode hook. The function is called with no
- argsuments.")
+ arguments."
+ :type 'hook
+ :group 'etags)
;; Return a default tag to search for, based on the text at point.
(defun find-tag-default ()
@@ -776,12 +778,12 @@
(widen)
(push-mark)
(goto-char tag-point)
- (if find-tag-hook
- (funcall find-tag-hook)
- (if local-find-tag-hook
- (funcall local-find-tag-hook))))
+ (if find-tag-hook
+ (run-hooks 'find-tag-hook)
+ (if local-find-tag-hook
+ (run-hooks 'local-find-tag-hook))))
(setq tags-loop-scan (list 'find-tag nil nil)
- tags-loop-operate nil)
+ tags-loop-operate nil)
;; Return t in case used as the tags-loop-scan.
t)