From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Constantin Kulikov Newsgroups: gmane.emacs.help Subject: About advices. Date: Wed, 27 Nov 2013 12:19:31 +0400 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1385540382 22795 80.91.229.3 (27 Nov 2013 08:19:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 27 Nov 2013 08:19:42 +0000 (UTC) To: help-gnu-emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 27 09:19:48 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VlaLc-0000EO-By for geh-help-gnu-emacs@m.gmane.org; Wed, 27 Nov 2013 09:19:48 +0100 Original-Received: from localhost ([::1]:34468 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlaLb-0001AT-Ps for geh-help-gnu-emacs@m.gmane.org; Wed, 27 Nov 2013 03:19:47 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57032) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlaLQ-0001AN-EY for help-gnu-emacs@gnu.org; Wed, 27 Nov 2013 03:19:37 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VlaLM-0006NT-8o for help-gnu-emacs@gnu.org; Wed, 27 Nov 2013 03:19:36 -0500 Original-Received: from mail-ie0-x22b.google.com ([2607:f8b0:4001:c03::22b]:38497) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlaLM-0006NK-3F for help-gnu-emacs@gnu.org; Wed, 27 Nov 2013 03:19:32 -0500 Original-Received: by mail-ie0-f171.google.com with SMTP id ar20so11568546iec.30 for ; Wed, 27 Nov 2013 00:19:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=cbXWxRKhby9xU+u2W6xefUzPC678r3HmrbEX3Mwht0Y=; b=v63LFDLfhS8DHJEXjQWuFgijmZr50ZvsUfGf4JI5bbSSlAa8ESW23bpC3nCF2Rlmig fhKxKOryxy4nhoA/Ekwd8lkf6zQAVNyxYPvh6kyydw6ASIZXTX28Vq64NtkWkWkK4DlC z3tadHmtwxViVyAgP2tf/xFgJktQEieSrd8/QaT/L6F+Cip/mHYiWV0pOR2r3NuI7HxY cjkWc35bT0UTbEUCm1i4BbpzOKLK8XMTZvBPtwHJDG/VfqfleqUBzSncfAx97WP31cEt efSBc6L58OZMKaTRUyBApDcIN1wL83ZWJLOiDW+jbuNNEdKH7LCPCh/9bW9ykDz4vBpo BERQ== X-Received: by 10.50.57.115 with SMTP id h19mr20983862igq.2.1385540371590; Wed, 27 Nov 2013 00:19:31 -0800 (PST) Original-Received: by 10.43.74.137 with HTTP; Wed, 27 Nov 2013 00:19:31 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4001:c03::22b X-Content-Filtered-By: Mailman/MimeDel 2.1.14 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:94671 Archived-At: 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?