From unknown Sat Jun 21 03:25:05 2025 X-Loop: help-debbugs@gnu.org Subject: bug#8304: 23.2; ad-read-advised-function default to func at point 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: To: 8304@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.130066516611308 (code B ref -1); Sun, 20 Mar 2011 23:53:01 +0000 Received: (at submit) by debbugs.gnu.org; 20 Mar 2011 23:52:46 +0000 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 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 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 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, T_TVD_MIME_NO_HEADERS autolearn=unavailable version=3.3.1 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 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 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 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 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) 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) 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 From: Kevin Ryde Date: Mon, 21 Mar 2011 10:52:21 +1100 Message-ID: <87bp1573ka.fsf@blah.blah> User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" 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-Received-From: 199.232.76.165 X-Spam-Score: -5.4 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.4 (-----) --=-=-= 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 --=-=-=-- From unknown Sat Jun 21 03:25:05 2025 X-Loop: help-debbugs@gnu.org Subject: bug#8304: 23.2; ad-read-advised-function default to func at point Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 21 Mar 2011 14:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8304 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Kevin Ryde Cc: 8304@debbugs.gnu.org Received: via spool by 8304-submit@debbugs.gnu.org id=B8304.130071844626846 (code B ref 8304); Mon, 21 Mar 2011 14:41:01 +0000 Received: (at 8304) by debbugs.gnu.org; 21 Mar 2011 14:40:46 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q1gHm-0006yx-0w for submit@debbugs.gnu.org; Mon, 21 Mar 2011 10:40:46 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q1gHk-0006yh-Ej; Mon, 21 Mar 2011 10:40:45 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAOP/hk1Ld/X5/2dsb2JhbAClcnjAIYVjBJVp X-IronPort-AV: E=Sophos;i="4.63,219,1299474000"; d="scan'208";a="97411613" Received: from 75-119-245-249.dsl.teksavvy.com (HELO pastel.home) ([75.119.245.249]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 21 Mar 2011 10:40:38 -0400 Received: by pastel.home (Postfix, from userid 20848) id 7099758AF5; Mon, 21 Mar 2011 10:40:38 -0400 (EDT) From: Stefan Monnier Message-ID: References: <87bp1573ka.fsf@blah.blah> Date: Mon, 21 Mar 2011 10:40:38 -0400 In-Reply-To: <87bp1573ka.fsf@blah.blah> (Kevin Ryde's message of "Mon, 21 Mar 2011 10:52:21 +1100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.0 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.0 (--) > * 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. Sounds like a fine change. > -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." Actually, I don't think the docstring should document what `default' will default to. Actually, AFAICT the `default' argument is never used. > + ;; prefer func name at point, if it's in ad-advised-functions etc Comments should start with a capital and end with a "." or some other appropriate punctuation. Stefan From unknown Sat Jun 21 03:25:05 2025 X-Loop: help-debbugs@gnu.org Subject: bug#8304: 23.2; ad-read-advised-function default to func at point 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, 22 May 2011 00:30:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8304 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Stefan Monnier Cc: 8304@debbugs.gnu.org Received: via spool by 8304-submit@debbugs.gnu.org id=B8304.130602417724304 (code B ref 8304); Sun, 22 May 2011 00:30:03 +0000 Received: (at 8304) by debbugs.gnu.org; 22 May 2011 00:29:37 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QNwY5-0006Jx-9u for submit@debbugs.gnu.org; Sat, 21 May 2011 20:29:37 -0400 Received: from mailout1-7.pacific.net.au ([61.8.2.214] helo=mailout1.pacific.net.au) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QNwY2-0006Jj-OC for 8304@debbugs.gnu.org; Sat, 21 May 2011 20:29:36 -0400 Received: from mailproxy2.pacific.net.au (mailproxy2.pacific.net.au [61.8.2.163]) by mailout1.pacific.net.au (Postfix) with ESMTP id 099745F232B; Sun, 22 May 2011 10:29:27 +1000 (EST) Received: from blah.blah (unknown [203.26.175.59]) by mailproxy2.pacific.net.au (Postfix) with ESMTP id 3A96727409; Sun, 22 May 2011 10:29:25 +1000 (EST) Received: from gg by blah.blah with local (Exim 4.72) (envelope-from ) id 1QNwXb-0003ce-Od; Sun, 22 May 2011 10:29:07 +1000 From: Kevin Ryde References: <87bp1573ka.fsf@blah.blah> Date: Sun, 22 May 2011 10:29:07 +1000 In-Reply-To: (Stefan Monnier's message of "Mon, 21 Mar 2011 10:40:38 -0400") Message-ID: <87ipt3h92k.fsf@blah.blah> User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -3.7 (---) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.7 (---) --=-=-= Stefan Monnier writes: > > Actually, I don't think the docstring should document what `default' will > default to. Oh, well, it has done, and if you're using it programmatically then you will likely want to know. I shortened it per below. > Actually, AFAICT the `default' argument is never used. No doubt it's in emulation of completing-read, so you can offer a particular default in context. Seems like a good thing on the whole. > Comments should start with a capital and end with a "." or some other > appropriate punctuation. You must have more trouble getting any comments, then getting sensible comments, then getting more or less grammatical comments, without worrying about full stops! 2011-05-22 Kevin Ryde * emacs-lisp/advice.el (ad-read-advised-function): Use `function-called-at-point' as the default default, if it has advice and passes PREDICATE. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=advice.el.read-default-2.diff --- advice.el.~1.68.~ 2009-10-08 11:00:28.000000000 +1100 +++ advice.el 2011-05-22 10:19:27.000000000 +1000 @@ -2200,16 +2200,27 @@ ;; @@ 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)." +be returned on empty input (defaults to the first advised function or +function at point for which PREDICATE returns non-nil)." (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)) --=-=-= -- Restaurant jargon elucidated for the layman: "Special" -- almost gone bad and has to be sold today. --=-=-=-- From unknown Sat Jun 21 03:25:05 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.427 (Entity 5.427) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Kevin Ryde Subject: bug#8304: closed (Re: bug#8304: 23.2; ad-read-advised-function default to func at point) Message-ID: References: <87bp1573ka.fsf@blah.blah> X-Gnu-PR-Message: they-closed 8304 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 8304@debbugs.gnu.org Date: Mon, 23 May 2011 14:41:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1306161662-11853-1" This is a multi-part message in MIME format... ------------=_1306161662-11853-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #8304: 23.2; ad-read-advised-function default to func at point which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 8304@debbugs.gnu.org. --=20 8304: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D8304 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1306161662-11853-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 8304-done) by debbugs.gnu.org; 23 May 2011 14:40:44 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QOWJH-00034b-Sm for submit@debbugs.gnu.org; Mon, 23 May 2011 10:40:44 -0400 Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QOWJG-00034P-6y for 8304-done@debbugs.gnu.org; Mon, 23 May 2011 10:40:42 -0400 Received: from 213-159-126-200.fibertel.com.ar ([200.126.159.213]:45377 helo=ceviche.home) by fencepost.gnu.org with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1QOWJ9-00061r-DN; Mon, 23 May 2011 10:40:35 -0400 Received: by ceviche.home (Postfix, from userid 20848) id D9AB166131; Mon, 23 May 2011 11:40:31 -0300 (ART) From: Stefan Monnier To: Kevin Ryde Subject: Re: bug#8304: 23.2; ad-read-advised-function default to func at point Message-ID: References: <87bp1573ka.fsf@blah.blah> <87ipt3h92k.fsf@blah.blah> Date: Mon, 23 May 2011 11:40:31 -0300 In-Reply-To: <87ipt3h92k.fsf@blah.blah> (Kevin Ryde's message of "Sun, 22 May 2011 10:29:07 +1000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -6.0 (------) X-Debbugs-Envelope-To: 8304-done Cc: 8304-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.0 (------) > You must have more trouble getting any comments, then getting sensible > comments, then getting more or less grammatical comments, without > worrying about full stops! I like to think of it the other way: forcing people to be careful about punctuation also forces them to be more careful in general ;-) > 2011-05-22 Kevin Ryde > * emacs-lisp/advice.el (ad-read-advised-function): Use > `function-called-at-point' as the default default, if it has > advice and passes PREDICATE. Thank you, installed in the trunk, Stefan ------------=_1306161662-11853-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 20 Mar 2011 23:52:46 +0000 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 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 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 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, T_TVD_MIME_NO_HEADERS autolearn=unavailable version=3.3.1 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 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 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 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 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) 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) 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 From: Kevin Ryde To: bug-gnu-emacs@gnu.org Subject: 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> User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" 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-Received-From: 199.232.76.165 X-Spam-Score: -5.4 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.4 (-----) --=-=-= 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 --=-=-=-- ------------=_1306161662-11853-1--