[Top][All Lists]

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

bug#8387: 24.0.50; `run-hook-with-args' return value has changed

From: Stefan Monnier
Subject: bug#8387: 24.0.50; `run-hook-with-args' return value has changed
Date: Thu, 31 Mar 2011 11:02:49 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> (defun foo (arg) 'test) C-j
> (defvar foo-hook '(foo)) C-j
> (run-hook-with-args 'foo-hook 'foo) C-j

> In the past, this would return 'test instead of nil.  This breaks some
> I don't have time to test this right now, but I would guess this started
> happening in the following commit:
>       (run_hook_with_args): Call each function through a `funcall' argument.
>       Remove `cond' argument, now redundant.
>       (Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success)
>       (Frun_hook_with_args_until_failure): Adjust accordingly.

No doubt it's the origin of the new behavior.
But note that the above change has not touched the docstring of
run-hook-with-args which says:

   It is best not to depend on the value returned by `run-hook-with-args',
   as that may change.

Looking at the BBDB code, I think we don't need to try and accomodate it
because it is fundamentally broken, not just because of the above
docstring warning:

  ;; Hysterical Raisins: This is a function, not a hook. In order to
  ;; make this hook a hook, we'll quietly convert a single function
  ;; into a hook list.  We should really warn the user that we're
  ;; doing this, and advise them to update their configuration
  ;; accordingly. For the release, maybe.
  (if (functionp bbdb-canonicalize-net-hook)
      (setq bbdb-canonicalize-net-hook (list bbdb-canonicalize-net-hook)))

  ;; Now, do the hook run. Note, if you mess up, it's possible that
  ;; BBDB will get stuck here oscillating between various definitions
  ;; of the canonical address.
  (while (not (equal net (setq net (run-hook-with-args
                                    'bbdb-canonicalize-net-hook net)))))

So bbdb-canonicalize-net-hook can start as a single function or a list
of functions.  But the code is explicit about wanting a list of
functions.  Now if this list contains N>1 function, then
run-hook-with-args has to call all those functions and discard at least
N-1 of the results.  I.e. only one of the functions on
bbdb-canonicalize-net-hook can work (in Emacs-23, one of them happened
to work, and on the current trunk, none of them work).


reply via email to

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