From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.bugs Subject: bug#789: find-function fails on advised subrs Date: Thu, 28 Aug 2008 17:33:51 +0200 Message-ID: <48B6C55F.8080104@gmx.at> Reply-To: martin rudalics , 789@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------030600050501040806060209" X-Trace: ger.gmane.org 1219938474 14238 80.91.229.12 (28 Aug 2008 15:47:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 28 Aug 2008 15:47:54 +0000 (UTC) Cc: raman To: 789@emacsbugs.donarmstrong.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Aug 28 17:48:48 2008 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.50) id 1KYjjj-0000g8-2J for geb-bug-gnu-emacs@m.gmane.org; Thu, 28 Aug 2008 17:48:39 +0200 Original-Received: from localhost ([127.0.0.1]:47361 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KYjik-0005CK-OI for geb-bug-gnu-emacs@m.gmane.org; Thu, 28 Aug 2008 11:47:38 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KYjih-0005C3-8b for bug-gnu-emacs@gnu.org; Thu, 28 Aug 2008 11:47:35 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KYjig-0005Be-Kf for bug-gnu-emacs@gnu.org; Thu, 28 Aug 2008 11:47:34 -0400 Original-Received: from [199.232.76.173] (port=47070 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KYjig-0005BZ-FX for bug-gnu-emacs@gnu.org; Thu, 28 Aug 2008 11:47:34 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:55609) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KYjid-00044A-CN for bug-gnu-emacs@gnu.org; Thu, 28 Aug 2008 11:47:32 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m7SFlTgr007903; Thu, 28 Aug 2008 08:47:29 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id m7SFj3Lw006588; Thu, 28 Aug 2008 08:45:03 -0700 X-Loop: don@donarmstrong.com Resent-From: martin rudalics Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Thu, 28 Aug 2008 15:45:03 +0000 Resent-Message-ID: Resent-Sender: don@donarmstrong.com X-Emacs-PR-Message: report 789 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 789-submit@emacsbugs.donarmstrong.com id=B789.12199378254644 (code B ref 789); Thu, 28 Aug 2008 15:45:03 +0000 Original-Received: (at 789) by emacsbugs.donarmstrong.com; 28 Aug 2008 15:37:05 +0000 Original-Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with SMTP id m7SFave8004631 for <789@emacsbugs.donarmstrong.com>; Thu, 28 Aug 2008 08:36:58 -0700 Original-Received: (qmail invoked by alias); 28 Aug 2008 15:36:51 -0000 Original-Received: from 62-47-36-178.adsl.highway.telekom.at (EHLO [62.47.36.178]) [62.47.36.178] by mail.gmx.net (mp001) with SMTP; 28 Aug 2008 17:36:51 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX1/7AOA9Tif7gDWT2Kfc0DrCnrU2aBFeuQJ9NnCsE7 +zk1Vj8ka9hnc+ User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) X-Y-GMX-Trusted: 0 X-FuHaFi: 0.82,0.5 X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) Resent-Date: Thu, 28 Aug 2008 11:47:34 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list 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:19804 Archived-At: This is a multi-part message in MIME format. --------------030600050501040806060209 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit > emacs -Q > M-x find-function delete-window > -> works > > (defadvice delete-window (after foo activate) > "" > t) > > M-x find-function delete-window > -> fails I attached a tentative fix. Please try it. martin --------------030600050501040806060209 Content-Type: text/plain; name="789.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="789.diff" *** find-func.el.~1.91.~ 2008-07-28 15:19:10.000000000 +0200 --- find-func.el 2008-08-28 17:15:40.156250000 +0200 *************** *** 165,195 **** If nil, do not try to find the source code of functions and variables defined in C.") (defun find-function-C-source (fun-or-var file type) "Find the source location where FUN-OR-VAR is defined in FILE. TYPE should be nil to find a function, or `defvar' to find a variable." ! (unless find-function-C-source-directory ! (setq find-function-C-source-directory ! (read-directory-name "Emacs C source dir: " nil nil t))) ! (setq file (expand-file-name file find-function-C-source-directory)) ! (unless (file-readable-p file) ! (error "The C source file %s is not available" ! (file-name-nondirectory file))) ! (unless type ! (setq fun-or-var (indirect-function fun-or-var))) ! (with-current-buffer (find-file-noselect file) ! (goto-char (point-min)) ! (unless (re-search-forward ! (if type (concat "DEFVAR[A-Z_]*[ \t\n]*([ \t\n]*\"" ! (regexp-quote (symbol-name fun-or-var)) ! "\"") ! (concat "DEFUN[ \t\n]*([ \t\n]*\"" ! (regexp-quote (subr-name fun-or-var)) ! "\"")) ! nil t) ! (error "Can't find source for %s" fun-or-var)) ! (cons (current-buffer) (match-beginning 0)))) ;;;###autoload (defun find-library (library) --- 165,205 ---- If nil, do not try to find the source code of functions and variables defined in C.") + (declare-function ad-get-advice-info "advice" (function)) + (defun find-function-C-source (fun-or-var file type) "Find the source location where FUN-OR-VAR is defined in FILE. TYPE should be nil to find a function, or `defvar' to find a variable." ! (let (advised) ! (unless find-function-C-source-directory ! (setq find-function-C-source-directory ! (read-directory-name "Emacs C source dir: " nil nil t))) ! (setq file (expand-file-name file find-function-C-source-directory)) ! (unless (file-readable-p file) ! (error "The C source file %s is not available" ! (file-name-nondirectory file))) ! (cond ! ((and (symbolp fun-or-var) (featurep 'advice) ! (ad-get-advice-info fun-or-var)) ! (setq advised t)) ! ((not type) ! (setq fun-or-var (indirect-function fun-or-var)))) ! (with-current-buffer (find-file-noselect file) ! (goto-char (point-min)) ! (unless (re-search-forward ! (cond ! (advised ! (concat "DEFUN[ \t\n]*([ \t\n]*\"" ! (regexp-quote (symbol-name fun-or-var)) "\"")) ! (type (concat "DEFVAR[A-Z_]*[ \t\n]*([ \t\n]*\"" ! (regexp-quote (symbol-name fun-or-var)) "\"")) ! (t ! (concat "DEFUN[ \t\n]*([ \t\n]*\"" ! (regexp-quote (subr-name fun-or-var)) "\""))) ! nil t) ! (error "Can't find source for %s" fun-or-var)) ! (cons (current-buffer) (match-beginning 0))))) ;;;###autoload (defun find-library (library) *************** *** 291,312 **** If the file where FUNCTION is defined is not known, then it is searched for in `find-function-source-path' if non-nil, otherwise in `load-path'." ! (if (not function) ! (error "You didn't specify a function")) ! (let ((def (symbol-function function)) ! aliases) ! (while (symbolp def) ! (or (eq def function) ! (if aliases ! (setq aliases (concat aliases ! (format ", which is an alias for `%s'" ! (symbol-name def)))) ! (setq aliases (format "`%s' an alias for `%s'" ! function (symbol-name def))))) ! (setq function (symbol-function function) ! def (symbol-function function))) ! (if aliases ! (message "%s" aliases)) (let ((library (cond ((eq (car-safe def) 'autoload) (nth 1 def)) --- 301,339 ---- If the file where FUNCTION is defined is not known, then it is searched for in `find-function-source-path' if non-nil, otherwise in `load-path'." ! (unless function ! (error "You didn't specify a function")) ! (let* ((advised (and (symbolp function) (featurep 'advice) ! (ad-get-advice-info function))) ! ;; If the function is advised, use the symbol that has the ! ;; real definition, if that symbol is already set up. ! (real-function ! (or (and advised ! (let ((origname (cdr (assq 'origname advised)))) ! (and (fboundp origname) origname))) ! function)) ! ;; Get the real definition. ! (def (if (symbolp real-function) ! (symbol-function real-function) ! function)) ! file-name string aliases) ! (cond ! (advised ! (message "This function is advised")) ! ((symbolp def) ! (while (symbolp def) ! (or (eq def function) ! (if aliases ! (setq aliases (concat aliases ! (format ", which is an alias for `%s'" ! (symbol-name def)))) ! (setq aliases (format "`%s' an alias for `%s'" ! function (symbol-name def))))) ! (setq function (symbol-function function) ! def (symbol-function function))) ! (when aliases ! (message "%s" aliases)))) ! (let ((library (cond ((eq (car-safe def) 'autoload) (nth 1 def)) --------------030600050501040806060209--