unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Michael Welsh Duggan <md5i@md5i.com>
Cc: 8387@debbugs.gnu.org
Subject: bug#8387: 24.0.50; `run-hook-with-args' return value has changed
Date: Thu, 31 Mar 2011 11:02:49 -0400	[thread overview]
Message-ID: <jwv1v1n4a1d.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <877hbfn6w1.fsf@maru.md5i.com> (Michael Welsh Duggan's message of "Thu, 31 Mar 2011 02:25:34 -0400")

> (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).


        Stefan





      parent reply	other threads:[~2011-03-31 15:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-31  6:25 bug#8387: 24.0.50; `run-hook-with-args' return value has changed Michael Welsh Duggan
2011-03-31 15:02 ` Juanma Barranquero
2011-03-31 15:02 ` Stefan Monnier [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwv1v1n4a1d.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=8387@debbugs.gnu.org \
    --cc=md5i@md5i.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).