comparison lisp/help-fns.el @ 66350:65603aeca64d

(describe-simplify-lib-file-name): New function. (describe-function-1, describe-variable): Use it.
author Richard M. Stallman <rms@gnu.org>
date Sun, 23 Oct 2005 19:12:10 +0000
parents e444511e983e
children ecdadc99bf8c b31326248cf6
comparison
equal deleted inserted replaced
66349:e024b37a96f0 66350:65603aeca64d
309 ;; Highlight arguments in the DOC string 309 ;; Highlight arguments in the DOC string
310 (setq doc (and doc (help-do-arg-highlight doc args)))))) 310 (setq doc (and doc (help-do-arg-highlight doc args))))))
311 ;; Return value is like the one from help-split-fundoc, but highlighted 311 ;; Return value is like the one from help-split-fundoc, but highlighted
312 (cons usage doc)) 312 (cons usage doc))
313 313
314 (defun describe-simplify-lib-file-name (file)
315 "Simplify a library name FILE to a relative name, and make it a source file."
316 (if file
317 ;; Try converting the absolute file name to a library name.
318 (let ((libname (file-name-nondirectory file)))
319 ;; Now convert that back to a file name and see if we get
320 ;; the original one. If so, they are equivalent.
321 (if (equal file (locate-file libname load-path '("")))
322 (if (string-match "[.]elc?\\'" libname)
323 (substring libname 0 -1)
324 libname)
325 file))))
326
314 ;;;###autoload 327 ;;;###autoload
315 (defun describe-function-1 (function) 328 (defun describe-function-1 (function)
316 (let* ((def (if (symbolp function) 329 (let* ((def (if (symbolp function)
317 (symbol-function function) 330 (symbol-function function)
318 function)) 331 function))
361 (save-match-data 374 (save-match-data
362 (if (re-search-backward "alias for `\\([^`']+\\)'" nil t) 375 (if (re-search-backward "alias for `\\([^`']+\\)'" nil t)
363 (help-xref-button 1 'help-function def))))) 376 (help-xref-button 1 'help-function def)))))
364 (or file-name 377 (or file-name
365 (setq file-name (symbol-file function 'defun))) 378 (setq file-name (symbol-file function 'defun)))
379 (setq file-name (describe-simplify-lib-file-name file-name))
366 (when (equal file-name "loaddefs.el") 380 (when (equal file-name "loaddefs.el")
367 ;; Find the real def site of the preloaded function. 381 ;; Find the real def site of the preloaded function.
368 ;; This is necessary only for defaliases. 382 ;; This is necessary only for defaliases.
369 (let ((location 383 (let ((location
370 (condition-case nil 384 (condition-case nil
529 (prin1 variable) 543 (prin1 variable)
530 ;; Make a hyperlink to the library if appropriate. (Don't 544 ;; Make a hyperlink to the library if appropriate. (Don't
531 ;; change the format of the buffer's initial line in case 545 ;; change the format of the buffer's initial line in case
532 ;; anything expects the current format.) 546 ;; anything expects the current format.)
533 (let ((file-name (symbol-file variable 'defvar))) 547 (let ((file-name (symbol-file variable 'defvar)))
548 (setq file-name (describe-simplify-lib-file-name file-name))
534 (when (equal file-name "loaddefs.el") 549 (when (equal file-name "loaddefs.el")
535 ;; Find the real def site of the preloaded variable. 550 ;; Find the real def site of the preloaded variable.
536 (let ((location 551 (let ((location
537 (condition-case nil 552 (condition-case nil
538 (find-variable-noselect variable file-name) 553 (find-variable-noselect variable file-name)