comparison lisp/help-fns.el @ 85303:6830ce7af289

(describe-function-1): Find source of advised functions.
author Richard M. Stallman <rms@gnu.org>
date Sun, 14 Oct 2007 22:47:58 +0000
parents caa57db87d2a
children f6d8977668c9 a0e466c4d599
comparison
equal deleted inserted replaced
85302:bc8b741390b0 85303:6830ce7af289
249 src-file 249 src-file
250 file-name))) 250 file-name)))
251 251
252 ;;;###autoload 252 ;;;###autoload
253 (defun describe-function-1 (function) 253 (defun describe-function-1 (function)
254 (let* ((def (if (symbolp function) 254 (let* ((advised (and (featurep 'advice) (ad-get-advice-info function)))
255 (symbol-function function) 255 ;; If the function is advised, get the symbol that has the
256 ;; real definition.
257 (real-function
258 (if advised (cdr (assq 'origname advised))
259 function))
260 ;; Get the real definition.
261 (def (if (symbolp real-function)
262 (symbol-function real-function)
256 function)) 263 function))
257 file-name string 264 file-name string
258 (beg (if (commandp def) "an interactive " "a "))) 265 (beg (if (commandp def) "an interactive " "a ")))
259 (setq string 266 (setq string
260 (cond ((or (stringp def) 267 (cond ((or (stringp def)
332 339
333 ;; Make a hyperlink to the library. 340 ;; Make a hyperlink to the library.
334 (with-current-buffer standard-output 341 (with-current-buffer standard-output
335 (save-excursion 342 (save-excursion
336 (re-search-backward "`\\([^`']+\\)'" nil t) 343 (re-search-backward "`\\([^`']+\\)'" nil t)
337 (help-xref-button 1 'help-function-def function file-name)))) 344 (help-xref-button 1 'help-function-def real-function file-name))))
338 (princ ".") 345 (princ ".")
339 (terpri) 346 (terpri)
340 (when (commandp function) 347 (when (commandp function)
341 (if (and (eq function 'self-insert-command) 348 (if (and (eq function 'self-insert-command)
342 (eq (key-binding "a") 'self-insert-command) 349 (eq (key-binding "a") 'self-insert-command)
381 (let* ((use (cond 388 (let* ((use (cond
382 (usage (setq doc (cdr usage)) (car usage)) 389 (usage (setq doc (cdr usage)) (car usage))
383 ((listp arglist) 390 ((listp arglist)
384 (format "%S" (help-make-usage function arglist))) 391 (format "%S" (help-make-usage function arglist)))
385 ((stringp arglist) arglist) 392 ((stringp arglist) arglist)
386 ;; Maybe the arglist is in the docstring of the alias. 393 ;; Maybe the arglist is in the docstring of a symbol
387 ((let ((fun function)) 394 ;; this one is aliased to.
395 ((let ((fun real-function))
388 (while (and (symbolp fun) 396 (while (and (symbolp fun)
389 (setq fun (symbol-function fun)) 397 (setq fun (symbol-function fun))
390 (not (setq usage (help-split-fundoc 398 (not (setq usage (help-split-fundoc
391 (documentation fun) 399 (documentation fun)
392 function))))) 400 function)))))