unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* with-wrapper-hook
@ 2011-10-22 10:55 Chong Yidong
  2011-10-24  2:38 ` with-wrapper-hook Stefan Monnier
  0 siblings, 1 reply; 2+ messages in thread
From: Chong Yidong @ 2011-10-22 10:55 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Two issues with the macro with-wrapper-hook, new in Emacs 24.1:

1. Shouldn't it be in NEWS (and the Lisp manual)?

2. The docstring needs work:

  (with-wrapper-hook VAR ARGS &rest BODY)

  Run BODY wrapped with the VAR hook.

  VAR is a special hook: its functions are called with a first argument
  which is the "original" code (the BODY), so the hook function can wrap
  the original function, or call it any number of times (including not
  calling it at all).  This is similar to an `around' advice.
  ...

The 1st argument passed to each function is said to be `the "original"
code (the BODY)'.  The word "code" is ambiguous---it's really a function
to be passed to `funcall', right?

The docstring is unclear about what happens in the case where there's
more than one function in the hook.  IIUC, stating that the argument is
`the BODY' is incorrect in that case; actually, the argument passed to
the Nth hook function is a recursively defined function, which if
funcalled would behave just as the with-wrapper-hook would if only the
(N+1) and subsequent hook functions were there.  Correct?



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: with-wrapper-hook
  2011-10-22 10:55 with-wrapper-hook Chong Yidong
@ 2011-10-24  2:38 ` Stefan Monnier
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2011-10-24  2:38 UTC (permalink / raw)
  To: Chong Yidong; +Cc: emacs-devel

>   VAR is a special hook: its functions are called with a first argument
>   which is the "original" code (the BODY), so the hook function can wrap
>   the original function, or call it any number of times (including not
>   calling it at all).  This is similar to an `around' advice.
>   ...

> The 1st argument passed to each function is said to be `the "original"
> code (the BODY)'.  The word "code" is ambiguous---it's really a function
> to be passed to `funcall', right?

Yes, it's the function that would be run if the current hook hadn't been
on the hook var.

> The docstring is unclear about what happens in the case where there's
> more than one function in the hook.  IIUC, stating that the argument is
> `the BODY' is incorrect in that case; actually, the argument passed to
> the Nth hook function is a recursively defined function, which if
> funcalled would behave just as the with-wrapper-hook would if only the
> (N+1) and subsequent hook functions were there.  Correct?

Right.  I think a wording along the lines of what I just wrote above
would be simpler, tho.


        Stefan



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-10-24  2:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-22 10:55 with-wrapper-hook Chong Yidong
2011-10-24  2:38 ` with-wrapper-hook Stefan Monnier

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