* bug#20600: 24.5.3: add-hook - wrong arguments error
@ 2015-05-18 5:34 Andreas Röhler
2015-05-18 11:54 ` Artur Malabarba
0 siblings, 1 reply; 9+ messages in thread
From: Andreas Röhler @ 2015-05-18 5:34 UTC (permalink / raw)
To: 20600
[-- Attachment #1: Type: text/plain, Size: 559 bytes --]
||after-change-functions| wrongly accepts functions with three args only
Issue is explained in docstring of workaround below.
If the function to be hooked in --save-buffer-- doesn't require args, add-hook resp. after-change-functions should not.
(defun my-instant-save-buffer (eins zwei drei)
"To be hooked into list `after-change-functions'
`after-change-functions' expects functions receiving three arguments.
Arguments are ignored here, but slots needed by add-hook"
(save-buffer))
(add-hook 'after-change-functions 'my-instant-save-buffer)|
[-- Attachment #2: Type: text/html, Size: 752 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#20600: 24.5.3: add-hook - wrong arguments error
2015-05-18 5:34 bug#20600: 24.5.3: add-hook - wrong arguments error Andreas Röhler
@ 2015-05-18 11:54 ` Artur Malabarba
2015-05-18 14:25 ` Eli Zaretskii
2015-05-18 16:47 ` Stefan Monnier
0 siblings, 2 replies; 9+ messages in thread
From: Artur Malabarba @ 2015-05-18 11:54 UTC (permalink / raw)
To: Andreas Röhler; +Cc: 20600
[-- Attachment #1: Type: text/plain, Size: 249 bytes --]
The function you present is not a workaround, it's the right way to do this.
Still, it sounds like it might be useful for run-hooks to properly handle
functions whose arity is less than the expected arity.
Does anyone foresee any issues with that?
[-- Attachment #2: Type: text/html, Size: 290 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#20600: 24.5.3: add-hook - wrong arguments error
2015-05-18 11:54 ` Artur Malabarba
@ 2015-05-18 14:25 ` Eli Zaretskii
2015-05-18 15:38 ` Artur Malabarba
2015-05-18 16:47 ` Stefan Monnier
1 sibling, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2015-05-18 14:25 UTC (permalink / raw)
To: bruce.connor.am; +Cc: 20600
> Date: Mon, 18 May 2015 12:54:25 +0100
> From: Artur Malabarba <bruce.connor.am@gmail.com>
> Cc: 20600@debbugs.gnu.org
>
> Still, it sounds like it might be useful for run-hooks to properly handle
> functions whose arity is less than the expected arity.
> Does anyone foresee any issues with that?
To tell you the truth, I don't see the problem. Is the problem the
need to specify a couple of arguments that will be left unused when
the function is called? If so, we do it all over the place; we even
have a special convention for that.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#20600: 24.5.3: add-hook - wrong arguments error
2015-05-18 14:25 ` Eli Zaretskii
@ 2015-05-18 15:38 ` Artur Malabarba
2015-05-18 17:49 ` Stefan Monnier
0 siblings, 1 reply; 9+ messages in thread
From: Artur Malabarba @ 2015-05-18 15:38 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 20600
> To tell you the truth, I don't see the problem. Is the problem the
> need to specify a couple of arguments that will be left unused when
> the function is called? If so, we do it all over the place; we even
> have a special convention for that.
I don't see a problem either, I'm just suggesting an improvement on run-hooks.
The improvement would reduce the number of times you have to define a
wrapper around a function just to use it in a hook, by just not
passing to the function more arguments than it accepts.
Although, to be honest, I don't know how often that would be useful.
Even in the case originally mentioned above it would actually *not*
useful, because `save-buffer` *does* take an optional argument so the
wrapper around it would still be necessary.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#20600: 24.5.3: add-hook - wrong arguments error
2015-05-18 11:54 ` Artur Malabarba
2015-05-18 14:25 ` Eli Zaretskii
@ 2015-05-18 16:47 ` Stefan Monnier
2015-05-18 17:29 ` Artur Malabarba
1 sibling, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2015-05-18 16:47 UTC (permalink / raw)
To: Artur Malabarba; +Cc: 20600
> Still, it sounds like it might be useful for run-hooks to properly handle
> functions whose arity is less than the expected arity.
I have no idea what kind of "properly handle" you're thinking of.
Stefan
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#20600: 24.5.3: add-hook - wrong arguments error
2015-05-18 16:47 ` Stefan Monnier
@ 2015-05-18 17:29 ` Artur Malabarba
2015-05-19 8:17 ` Andreas Röhler
0 siblings, 1 reply; 9+ messages in thread
From: Artur Malabarba @ 2015-05-18 17:29 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 20600
2015-05-18 17:47 GMT+01:00 Stefan Monnier
>> Still, it sounds like it might be useful for run-hooks to properly handle
>> functions whose arity is less than the expected arity.
>
> I have no idea what kind of "properly handle" you're thinking of.
(add-hook '1-arity-functions 'some-zero-arity-function)
(run-hooks '1-arity-functions some-arg)
Here, it will throw an error because run-hooks will try to call
(some-zero-arity-function some-arg). That's all fine and well
documented, I'm just saying it may be more convenient if run-hooks
took care to check that some-zero-arity-function has zero arity and
invoked it without arguments.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#20600: 24.5.3: add-hook - wrong arguments error
2015-05-18 15:38 ` Artur Malabarba
@ 2015-05-18 17:49 ` Stefan Monnier
2015-05-18 18:22 ` Artur Malabarba
0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2015-05-18 17:49 UTC (permalink / raw)
To: Artur Malabarba; +Cc: 20600
> The improvement would reduce the number of times you have to define a
> wrapper around a function just to use it in a hook, by just not
> passing to the function more arguments than it accepts.
Sounds dangerous and rarely useful.
Stefan
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#20600: 24.5.3: add-hook - wrong arguments error
2015-05-18 17:49 ` Stefan Monnier
@ 2015-05-18 18:22 ` Artur Malabarba
0 siblings, 0 replies; 9+ messages in thread
From: Artur Malabarba @ 2015-05-18 18:22 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 20600
> Sounds dangerous and rarely useful.
Ok thanks. That's what I wanted to know. :-)
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#20600: 24.5.3: add-hook - wrong arguments error
2015-05-18 17:29 ` Artur Malabarba
@ 2015-05-19 8:17 ` Andreas Röhler
0 siblings, 0 replies; 9+ messages in thread
From: Andreas Röhler @ 2015-05-19 8:17 UTC (permalink / raw)
To: 20600
Am 18.05.2015 um 19:29 schrieb Artur Malabarba:
> 2015-05-18 17:47 GMT+01:00 Stefan Monnier
>
Thanks all! Seems indeed rather a matter of understanding than a bug.
Can live with it.
close #20600
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-05-19 8:17 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-18 5:34 bug#20600: 24.5.3: add-hook - wrong arguments error Andreas Röhler
2015-05-18 11:54 ` Artur Malabarba
2015-05-18 14:25 ` Eli Zaretskii
2015-05-18 15:38 ` Artur Malabarba
2015-05-18 17:49 ` Stefan Monnier
2015-05-18 18:22 ` Artur Malabarba
2015-05-18 16:47 ` Stefan Monnier
2015-05-18 17:29 ` Artur Malabarba
2015-05-19 8:17 ` Andreas Röhler
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.