unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Constantin Kulikov <zxnotdead@gmail.com>
To: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: About advices.
Date: Wed, 27 Nov 2013 12:19:31 +0400	[thread overview]
Message-ID: <CAFkz2yq5qB9j_R3OMvXnc=HpzQVupbd4GJhezmKVY-vORwSPhg@mail.gmail.com> (raw)

What the right way to use advices? (I know that best way it to not use it
at all.;))

At my current level of understanding:

1) You declare advices with `defadvice'. (acces arguments of original
function by `ad-get-arg').
Example:
(defadvice switch-to-buffer (after my-switch-to-buffer-advice)
  (let ((buf (ad-get-arg 0)))
    do something))

2) Then you call `ad-activate'.
Example: (ad-activate 'switch-to-buffer)
The problem here is that it will activate all advices for that function
that were defined before this `ad-activate' call, not only
`my-switch-to-buffer-advice'

3) I'm not sure. You can enable/disable certain advices with
`ad-enable-advice'/`ad-disable-advice'. Example:
(ad-disable-advice 'switch-to-buffer 'after 'my-switch-to-buffer-advice)

4) `ad-deactivate' will disable all advices for function.
Example: (ad-deactivate 'switch-to-buffer)

Am I right?


             reply	other threads:[~2013-11-27  8:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-27  8:19 Constantin Kulikov [this message]
2013-11-27 20:52 ` About advices Stefan Monnier
2013-11-28 17:23   ` Constantin Kulikov

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='CAFkz2yq5qB9j_R3OMvXnc=HpzQVupbd4GJhezmKVY-vORwSPhg@mail.gmail.com' \
    --to=zxnotdead@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /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.
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).