unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#789: find-function fails on advised subrs
@ 2008-08-28 15:33 martin rudalics
  2008-11-08 19:37 ` Glenn Morris
  0 siblings, 1 reply; 5+ messages in thread
From: martin rudalics @ 2008-08-28 15:33 UTC (permalink / raw)
  To: 789; +Cc: raman

[-- Attachment #1: Type: text/plain, Size: 234 bytes --]

 > 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

[-- Attachment #2: 789.diff --]
[-- Type: text/plain, Size: 5174 bytes --]

*** 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))

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-11-15 10:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-28 15:33 bug#789: find-function fails on advised subrs martin rudalics
2008-11-08 19:37 ` Glenn Morris
2008-11-08 21:54   ` martin rudalics
2008-11-14  6:19     ` Glenn Morris
2008-11-15 10:00       ` martin rudalics

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).