From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Ryde Newsgroups: gmane.emacs.bugs Subject: bug#8304: 23.2; ad-read-advised-function default to func at point Date: Mon, 21 Mar 2011 10:52:21 +1100 Message-ID: <87bp1573ka.fsf@blah.blah> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1300666042 26974 80.91.229.12 (21 Mar 2011 00:07:22 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 21 Mar 2011 00:07:22 +0000 (UTC) To: 8304@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Mar 21 01:07:18 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q1SeT-0002Q4-FT for geb-bug-gnu-emacs@m.gmane.org; Mon, 21 Mar 2011 01:07:17 +0100 Original-Received: from localhost ([127.0.0.1]:55845 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q1SeS-0005zo-O2 for geb-bug-gnu-emacs@m.gmane.org; Sun, 20 Mar 2011 20:07:16 -0400 Original-Received: from [140.186.70.92] (port=51400 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q1SeJ-0005vd-P8 for bug-gnu-emacs@gnu.org; Sun, 20 Mar 2011 20:07:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q1SeI-0004Lk-Ab for bug-gnu-emacs@gnu.org; Sun, 20 Mar 2011 20:07:07 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:53786) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q1SeI-0004Lg-91 for bug-gnu-emacs@gnu.org; Sun, 20 Mar 2011 20:07:06 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1Q1SQf-0002wo-Mk; Sun, 20 Mar 2011 19:53:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Kevin Ryde Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 20 Mar 2011 23:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 8304 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.130066516611308 (code B ref -1); Sun, 20 Mar 2011 23:53:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 20 Mar 2011 23:52:46 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q1SQQ-0002wK-Ij for submit@debbugs.gnu.org; Sun, 20 Mar 2011 19:52:46 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q1SQO-0002w7-Nh for submit@debbugs.gnu.org; Sun, 20 Mar 2011 19:52:45 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q1SQI-00029h-En for submit@debbugs.gnu.org; Sun, 20 Mar 2011 19:52:39 -0400 Original-Received: from lists.gnu.org ([199.232.76.165]:54094) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q1SQI-00029b-CA for submit@debbugs.gnu.org; Sun, 20 Mar 2011 19:52:38 -0400 Original-Received: from [140.186.70.92] (port=35018 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q1SQH-00052d-7S for bug-gnu-emacs@gnu.org; Sun, 20 Mar 2011 19:52:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q1SQC-00028c-0x for bug-gnu-emacs@gnu.org; Sun, 20 Mar 2011 19:52:34 -0400 Original-Received: from mailout1-4.pacific.net.au ([61.8.2.211]:58083 helo=mailout1.pacific.net.au) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q1SQB-00028F-5L for bug-gnu-emacs@gnu.org; Sun, 20 Mar 2011 19:52:31 -0400 Original-Received: from mailproxy1.pacific.net.au (mailproxy1.pacific.net.au [61.8.2.162]) by mailout1.pacific.net.au (Postfix) with ESMTP id 3299D5EC645 for ; Mon, 21 Mar 2011 10:52:27 +1100 (EST) Original-Received: from blah.blah (unknown [203.26.175.126]) by mailproxy1.pacific.net.au (Postfix) with ESMTP id 40EAC8C0F for ; Mon, 21 Mar 2011 10:52:23 +1100 (EST) Original-Received: from gg by blah.blah with local (Exim 4.72) (envelope-from ) id 1Q1SQ1-0002Om-A4 for bug-gnu-emacs@gnu.org; Mon, 21 Mar 2011 10:52:21 +1100 User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.2 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sun, 20 Mar 2011 19:53:01 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:45211 Archived-At: --=-=-= When using the advice.el things interactively, eg. ad-disable-advice or ad-activate, it'd be good if the read for the function name defaulted to a func at point. Currently I think it only offers the most recently defined advice, so with (defadvice doctor (around no-doctoring activate) "Disable the doctor." (error "The doctor is at a medical conference in Barbados")) (defadvice dunnet (around no-games activate) "Disable games." (error "Shouldn't you be working?")) An M-x ad-disable-advice with point on either "doctor" or "dunnet" offers "dunnet", where I hoped that on "doctor" it would offer doctor. 2011-03-20 Kevin Ryde * emacs-lisp/advice.el (ad-read-advised-function): Use `function-called-at-point' as the default default, if the func at point has advice, and passes PREDICATE. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=advice.el.read-default.diff --- advice.el.~1.68.~ 2009-10-08 11:00:28.000000000 +1100 +++ advice.el 2011-03-21 10:37:14.000000000 +1100 @@ -2200,16 +2200,29 @@ ;; @@ Interactive input functions: ;; =============================== +(declare-function 'function-called-at-point "help") + (defun ad-read-advised-function (&optional prompt predicate default) "Read name of advised function with completion from the minibuffer. An optional PROMPT will be used to prompt for the function. PREDICATE -plays the same role as for `try-completion' (which see). DEFAULT will -be returned on empty input (defaults to the first advised function for -which PREDICATE returns non-nil)." +plays the same role as for `try-completion' (which see). + +DEFAULT is returned on empty input. DEFAULT defaults to the +function name at point if it's advised and passes PREDICATE, +otherwise to the first advised function which passes PREDICATE." (if (null ad-advised-functions) (error "ad-read-advised-function: There are no advised functions")) (setq default (or default + ;; prefer func name at point, if it's in ad-advised-functions etc + (let ((function (progn + (require 'help) + (function-called-at-point)))) + (and function + (assoc (symbol-name function) ad-advised-functions) + (or (null predicate) + (funcall predicate function)) + function)) (ad-do-advised-functions (function) (if (or (null predicate) (funcall predicate function)) --=-=-= In GNU Emacs 23.2.1 (i486-pc-linux-gnu, GTK+ Version 2.20.0) of 2010-05-16 on raven, modified by Debian configured using `configure '--build' 'i486-linux-gnu' '--build' 'i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var/lib' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs23:/etc/emacs:/usr/local/share/emacs/23.2/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.2/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/23.2/leim' '--with-x=yes' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars' 'build_alias=i486-linux-gnu' 'CFLAGS=-DDEBIAN -g -O2' 'LDFLAGS=-g' 'CPPFLAGS='' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: en_AU value of $XMODIFIERS: nil locale-coding-system: iso-latin-1-unix default enable-multibyte-characters: t --=-=-=--