unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* deferred-action
@ 2011-03-20  4:16 Juanma Barranquero
  2011-03-21 14:01 ` deferred-action Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Juanma Barranquero @ 2011-03-20  4:16 UTC (permalink / raw)
  To: Emacs developers

What are the variables deferred-action-list and
deferred-action-function used for?

Their API is a bit surprising: there's a list of things to do, and a
function to do things (so, a sort of a poor man's hook) with
absolutely no explanation (nor documentation on the Elisp manual) of
how it is intended to be used, how to manage conflicts supposing that
different pieces of code want to use it, etc.

The only reference to them on the Emacs sources is in
emacs-lisp/ert-x.el, and it's really just aping the Emacs
command-loop.

And the only other reference I find is in anything.el (in the Emacs
wiki), where they are basically used as a sort of post-command hook.

I think Roland McGrath asked basically this same question back in 1994
(http://www.maths.tcd.ie/local/JUNK/cyclic/mailing-lists/arcana/0022.html),
so perhaps it is time to document these variables or deprecate them.

    Juanma



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

* Re: deferred-action
  2011-03-20  4:16 deferred-action Juanma Barranquero
@ 2011-03-21 14:01 ` Stefan Monnier
  2011-03-21 14:56   ` deferred-action Juanma Barranquero
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2011-03-21 14:01 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: Emacs developers

> What are the variables deferred-action-list and
> deferred-action-function used for?

> Their API is a bit surprising: there's a list of things to do, and a
> function to do things (so, a sort of a poor man's hook) with
> absolutely no explanation (nor documentation on the Elisp manual) of
> how it is intended to be used, how to manage conflicts supposing that
> different pieces of code want to use it, etc.

The docstrings seem to hold enough info for someone like me, at least.
They say explicitly that the action-list's format is completely up (it
is only tested for non-nil content before running the action-function)
to the action-function.

> The only reference to them on the Emacs sources is in
> emacs-lisp/ert-x.el, and it's really just aping the Emacs
> command-loop.

Right, ERT is not actually using that variable, it's just obeying it in
case the command uses it.

> And the only other reference I find is in anything.el (in the Emacs
> wiki), where they are basically used as a sort of post-command hook.

They're run right after post-command-hook, so I think that whenever
they're used we can use post-command-hook for it instead.

> I think Roland McGrath asked basically this same question back in 1994
> (http://www.maths.tcd.ie/local/JUNK/cyclic/mailing-lists/arcana/0022.html),
> so perhaps it is time to document these variables or deprecate them.

Let's deprecate them.


        Stefan



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

* Re: deferred-action
  2011-03-21 14:01 ` deferred-action Stefan Monnier
@ 2011-03-21 14:56   ` Juanma Barranquero
  2011-03-21 16:34     ` deferred-action Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Juanma Barranquero @ 2011-03-21 14:56 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs developers

On Mon, Mar 21, 2011 at 15:01, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

> The docstrings seem to hold enough info for someone like me, at least.
> They say explicitly that the action-list's format is completely up (it
> is only tested for non-nil content before running the action-function)
> to the action-function.

I understand that. And no, I don't think it's enough, because each
piece of code using them is quite  free to do it as it pleases (some
could use deferred-action-list as a flag, other as a list of items to
treat, a third as a list of functions to run, etc.), but on the other
hand, deferred-action-function is intended to contain just a function,
so there's nowhere explained HOW would several packages coordinate
their different uses. Perhaps some kind of chaining where everyone
which uses them wraps the previous deferred-action-function and calls
it at the end... but it is far from clear and well-defined.

> They're run right after post-command-hook, so I think that whenever
> they're used we can use post-command-hook for it instead.

Yes, when I looked at anything.el's code I didn't understand why the
author chose to use deferred-action-* instead of just using
post-command-hook.

> Let's deprecate them.

Thanks.

    Juanma



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

* Re: deferred-action
  2011-03-21 14:56   ` deferred-action Juanma Barranquero
@ 2011-03-21 16:34     ` Stefan Monnier
  2011-03-21 16:37       ` deferred-action Juanma Barranquero
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2011-03-21 16:34 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: Emacs developers

> I understand that. And no, I don't think it's enough, because each
> piece of code using them is quite  free to do it as it pleases (some
> could use deferred-action-list as a flag, other as a list of items to
> treat, a third as a list of functions to run, etc.), but on the other
> hand, deferred-action-function is intended to contain just a function,
> so there's nowhere explained HOW would several packages coordinate
> their different uses.

That's because that would require a coding convention for its use, and
nobody came up with such a thing.


        Stefan



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

* Re: deferred-action
  2011-03-21 16:34     ` deferred-action Stefan Monnier
@ 2011-03-21 16:37       ` Juanma Barranquero
  2011-03-21 17:24         ` deferred-action Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Juanma Barranquero @ 2011-03-21 16:37 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs developers

On Mon, Mar 21, 2011 at 17:34, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

> That's because that would require a coding convention for its use, and
> nobody came up with such a thing.

That's a clue about how useful have they been. Are you OK with this patch?

    Juanma



2011-03-21  Juanma Barranquero  <lekktu@gmail.com>

	* subr.el (deferred-action-list, deferred-action-function):
	Mark as obsolete.


2011-03-21  Juanma Barranquero  <lekktu@gmail.com>

	* NEWS: Document the `deferred-action-*' variables as obsolete.


=== modified file 'etc/NEWS'
--- etc/NEWS	2011-03-20 10:35:27 +0000
+++ etc/NEWS	2011-03-21 16:14:09 +0000
@@ -829,6 +829,9 @@
 with a nil or omitted VALUE argument, the reporter message is
 displayed with a "spinning bar".

+** `deferred-action-list' and `deferred-action-function' are now obsolete.
+Code using them can be adapted to use `post-command-hook' instead.
+
 \f
 * Changes in Emacs 24.1 on non-free operating systems


=== modified file 'lisp/subr.el'
--- lisp/subr.el	2011-03-15 02:42:31 +0000
+++ lisp/subr.el	2011-03-21 15:33:56 +0000
@@ -1107,6 +1107,9 @@
 (make-obsolete 'process-filter-multibyte-p nil "23.1")
 (make-obsolete 'set-process-filter-multibyte nil "23.1")

+(make-obsolete-variable 'deferred-action-list 'post-command-hook "24.1")
+(make-obsolete-variable 'deferred-action-function 'post-command-hook "24.1")
+
 (make-obsolete-variable
  'mode-line-inverse-video
  "use the appropriate faces instead."



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

* Re: deferred-action
  2011-03-21 16:37       ` deferred-action Juanma Barranquero
@ 2011-03-21 17:24         ` Stefan Monnier
  2011-03-21 20:05           ` deferred-action Juanma Barranquero
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2011-03-21 17:24 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: Emacs developers

>> That's because that would require a coding convention for its use, and
>> nobody came up with such a thing.
> That's a clue about how useful have they been. Are you OK with this patch?

Not really: it's redundant with the patch I installed a some minutes ago.


        Stefan



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

* Re: deferred-action
  2011-03-21 17:24         ` deferred-action Stefan Monnier
@ 2011-03-21 20:05           ` Juanma Barranquero
  0 siblings, 0 replies; 7+ messages in thread
From: Juanma Barranquero @ 2011-03-21 20:05 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs developers

> Not really: it's redundant with the patch I installed a some minutes ago.

Great.

Thanks,

    Juanma



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

end of thread, other threads:[~2011-03-21 20:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-20  4:16 deferred-action Juanma Barranquero
2011-03-21 14:01 ` deferred-action Stefan Monnier
2011-03-21 14:56   ` deferred-action Juanma Barranquero
2011-03-21 16:34     ` deferred-action Stefan Monnier
2011-03-21 16:37       ` deferred-action Juanma Barranquero
2011-03-21 17:24         ` deferred-action Stefan Monnier
2011-03-21 20:05           ` deferred-action Juanma Barranquero

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