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: Sun, 22 May 2011 10:29:07 +1000 Message-ID: <87ipt3h92k.fsf@blah.blah> References: <87bp1573ka.fsf@blah.blah> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1306024213 10487 80.91.229.12 (22 May 2011 00:30:13 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 22 May 2011 00:30:13 +0000 (UTC) Cc: 8304@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun May 22 02:30:09 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QNwYb-0007Iv-9K for geb-bug-gnu-emacs@m.gmane.org; Sun, 22 May 2011 02:30:09 +0200 Original-Received: from localhost ([::1]:49376 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QNwYa-000626-Qg for geb-bug-gnu-emacs@m.gmane.org; Sat, 21 May 2011 20:30:08 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:46002) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QNwYX-0005yY-Tr for bug-gnu-emacs@gnu.org; Sat, 21 May 2011 20:30:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QNwYW-0006ew-Q7 for bug-gnu-emacs@gnu.org; Sat, 21 May 2011 20:30:05 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:41330) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QNwYW-0006ef-O2 for bug-gnu-emacs@gnu.org; Sat, 21 May 2011 20:30:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QNwYV-0006Km-GA; Sat, 21 May 2011 20:30:03 -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, 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 Original-Received: via spool by 8304-submit@debbugs.gnu.org id=B8304.130602417724304 (code B ref 8304); Sun, 22 May 2011 00:30:03 +0000 Original-Received: (at 8304) by debbugs.gnu.org; 22 May 2011 00:29:37 +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 1QNwY5-0006Jx-9u for submit@debbugs.gnu.org; Sat, 21 May 2011 20:29:37 -0400 Original-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 Original-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) Original-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) Original-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 In-Reply-To: (Stefan Monnier's message of "Mon, 21 Mar 2011 10:40:38 -0400") User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.2 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sat, 21 May 2011 20:30:03 -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: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:46636 Archived-At: --=-=-= 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. --=-=-=--