comparison lisp/help-fns.el @ 90261:7beb78bc1f8e

Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-97 Merge from emacs--cvs-trunk--0 Patches applied: * emacs--cvs-trunk--0 (patch 616-696) - Add lisp/mh-e/.arch-inventory - Update from CVS - Merge from gnus--rel--5.10 - Update from CVS: lisp/smerge-mode.el: Add 'tools' to file keywords. - lisp/gnus/ChangeLog: Remove duplicate entry * gnus--rel--5.10 (patch 147-181) - Update from CVS - Merge from emacs--cvs-trunk--0 - Update from CVS: lisp/mml.el (mml-preview): Doc fix. - Update from CVS: texi/message.texi: Fix default values. - Update from CVS: texi/gnus.texi (RSS): Addition.
author Miles Bader <miles@gnu.org>
date Mon, 16 Jan 2006 08:37:27 +0000
parents fa0da9b57058 3cc8c13facd3
children 7432ca837c8d
comparison
equal deleted inserted replaced
90260:0ca0d9181b5e 90261:7beb78bc1f8e
1 ;;; help-fns.el --- Complex help functions 1 ;;; help-fns.el --- Complex help functions
2 2
3 ;; Copyright (C) 1985, 1986, 1993, 1994, 1998, 1999, 2000, 2001, 3 ;; Copyright (C) 1985, 1986, 1993, 1994, 1998, 1999, 2000, 2001,
4 ;; 2002, 2003, 2004, 2005 Free Software Foundation, Inc. 4 ;; 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
5 5
6 ;; Maintainer: FSF 6 ;; Maintainer: FSF
7 ;; Keywords: help, internal 7 ;; Keywords: help, internal
8 8
9 ;; This file is part of GNU Emacs. 9 ;; This file is part of GNU Emacs.
98 (newline (- n (/ n 2))))) 98 (newline (- n (/ n 2)))))
99 (goto-char (point-min)) 99 (goto-char (point-min))
100 (setq buffer-undo-list nil) 100 (setq buffer-undo-list nil)
101 (set-buffer-modified-p nil)))) 101 (set-buffer-modified-p nil))))
102 102
103 ;;;###autoload
104 (defun locate-library (library &optional nosuffix path interactive-call)
105 "Show the precise file name of Emacs library LIBRARY.
106 This command searches the directories in `load-path' like `\\[load-library]'
107 to find the file that `\\[load-library] RET LIBRARY RET' would load.
108 Optional second arg NOSUFFIX non-nil means don't add suffixes `load-suffixes'
109 to the specified name LIBRARY.
110
111 If the optional third arg PATH is specified, that list of directories
112 is used instead of `load-path'.
113
114 When called from a program, the file name is normaly returned as a
115 string. When run interactively, the argument INTERACTIVE-CALL is t,
116 and the file name is displayed in the echo area."
117 (interactive (list (completing-read "Locate library: "
118 'locate-file-completion
119 (cons load-path load-suffixes))
120 nil nil
121 t))
122 (let ((file (locate-file library
123 (or path load-path)
124 (append (unless nosuffix load-suffixes) '("")))))
125 (if interactive-call
126 (if file
127 (message "Library is file %s" (abbreviate-file-name file))
128 (message "No library %s in search path" library)))
129 file))
130
131 103
132 ;; Functions 104 ;; Functions
133 105
134 ;;;###autoload 106 ;;;###autoload
135 (defun describe-function (function) 107 (defun describe-function (function)
249 (setq file (replace-match ".c" t t file))) 221 (setq file (replace-match ".c" t t file)))
250 (if (string-match "\\.c\\'" file) 222 (if (string-match "\\.c\\'" file)
251 (concat "src/" file) 223 (concat "src/" file)
252 file))))) 224 file)))))
253 225
254 ;;;###autoload
255 (defface help-argument-name '((((supports :slant italic)) :inherit italic)) 226 (defface help-argument-name '((((supports :slant italic)) :inherit italic))
256 "Face to highlight argument names in *Help* buffers." 227 "Face to highlight argument names in *Help* buffers."
257 :group 'help) 228 :group 'help)
258 229
259 (defun help-default-arg-highlight (arg) 230 (defun help-default-arg-highlight (arg)
308 (setq usage (help-do-arg-highlight (buffer-string) args)) 279 (setq usage (help-do-arg-highlight (buffer-string) args))
309 ;; Highlight arguments in the DOC string 280 ;; Highlight arguments in the DOC string
310 (setq doc (and doc (help-do-arg-highlight doc args)))))) 281 (setq doc (and doc (help-do-arg-highlight doc args))))))
311 ;; Return value is like the one from help-split-fundoc, but highlighted 282 ;; Return value is like the one from help-split-fundoc, but highlighted
312 (cons usage doc)) 283 (cons usage doc))
284
285 ;;;###autoload
286 (defun describe-simplify-lib-file-name (file)
287 "Simplify a library name FILE to a relative name, and make it a source file."
288 (if file
289 ;; Try converting the absolute file name to a library name.
290 (let ((libname (file-name-nondirectory file)))
291 ;; Now convert that back to a file name and see if we get
292 ;; the original one. If so, they are equivalent.
293 (if (equal file (locate-file libname load-path '("")))
294 (if (string-match "[.]elc\\'" libname)
295 (substring libname 0 -1)
296 libname)
297 file))))
313 298
314 ;;;###autoload 299 ;;;###autoload
315 (defun describe-function-1 (function) 300 (defun describe-function-1 (function)
316 (let* ((def (if (symbolp function) 301 (let* ((def (if (symbolp function)
317 (symbol-function function) 302 (symbol-function function)
361 (save-match-data 346 (save-match-data
362 (if (re-search-backward "alias for `\\([^`']+\\)'" nil t) 347 (if (re-search-backward "alias for `\\([^`']+\\)'" nil t)
363 (help-xref-button 1 'help-function def))))) 348 (help-xref-button 1 'help-function def)))))
364 (or file-name 349 (or file-name
365 (setq file-name (symbol-file function 'defun))) 350 (setq file-name (symbol-file function 'defun)))
351 (setq file-name (describe-simplify-lib-file-name file-name))
366 (when (equal file-name "loaddefs.el") 352 (when (equal file-name "loaddefs.el")
367 ;; Find the real def site of the preloaded function. 353 ;; Find the real def site of the preloaded function.
368 ;; This is necessary only for defaliases. 354 ;; This is necessary only for defaliases.
369 (let ((location 355 (let ((location
370 (condition-case nil 356 (condition-case nil
447 ((or (stringp def) 433 ((or (stringp def)
448 (vectorp def)) 434 (vectorp def))
449 (format "\nMacro: %s" (format-kbd-macro def))) 435 (format "\nMacro: %s" (format-kbd-macro def)))
450 (t "[Missing arglist. Please make a bug report.]"))) 436 (t "[Missing arglist. Please make a bug report.]")))
451 (high (help-highlight-arguments use doc))) 437 (high (help-highlight-arguments use doc)))
452 (insert (car high) "\n") 438 (let ((fill-begin (point)))
439 (insert (car high) "\n")
440 (fill-region fill-begin (point)))
453 (setq doc (cdr high)))) 441 (setq doc (cdr high))))
454 (let ((obsolete (and 442 (let ((obsolete (and
455 ;; function might be a lambda construct. 443 ;; function might be a lambda construct.
456 (symbolp function) 444 (symbolp function)
457 (get function 'byte-obsolete-info)))) 445 (get function 'byte-obsolete-info))))
507 val) 495 val)
508 (setq val (completing-read (if (symbolp v) 496 (setq val (completing-read (if (symbolp v)
509 (format 497 (format
510 "Describe variable (default %s): " v) 498 "Describe variable (default %s): " v)
511 "Describe variable: ") 499 "Describe variable: ")
512 obarray 'boundp t nil nil 500 obarray
501 '(lambda (vv)
502 (or (boundp vv)
503 (get vv 'variable-documentation)))
504 t nil nil
513 (if (symbolp v) (symbol-name v)))) 505 (if (symbolp v) (symbol-name v))))
514 (list (if (equal val "") 506 (list (if (equal val "")
515 v (intern val))))) 507 v (intern val)))))
516 (unless (buffer-live-p buffer) (setq buffer (current-buffer))) 508 (unless (buffer-live-p buffer) (setq buffer (current-buffer)))
517 (if (not (symbolp variable)) 509 (if (not (symbolp variable))
529 (prin1 variable) 521 (prin1 variable)
530 ;; Make a hyperlink to the library if appropriate. (Don't 522 ;; Make a hyperlink to the library if appropriate. (Don't
531 ;; change the format of the buffer's initial line in case 523 ;; change the format of the buffer's initial line in case
532 ;; anything expects the current format.) 524 ;; anything expects the current format.)
533 (let ((file-name (symbol-file variable 'defvar))) 525 (let ((file-name (symbol-file variable 'defvar)))
526 (setq file-name (describe-simplify-lib-file-name file-name))
534 (when (equal file-name "loaddefs.el") 527 (when (equal file-name "loaddefs.el")
535 ;; Find the real def site of the preloaded variable. 528 ;; Find the real def site of the preloaded variable.
536 (let ((location 529 (let ((location
537 (condition-case nil 530 (condition-case nil
538 (find-variable-noselect variable file-name) 531 (find-variable-noselect variable file-name)
559 (save-excursion 552 (save-excursion
560 (re-search-backward "`\\([^`']+\\)'" nil t) 553 (re-search-backward "`\\([^`']+\\)'" nil t)
561 (help-xref-button 1 'help-variable-def 554 (help-xref-button 1 'help-variable-def
562 variable file-name))) 555 variable file-name)))
563 (if valvoid 556 (if valvoid
564 (princ "It is void as a variable.\n") 557 (princ "It is void as a variable.")
565 (princ "Its "))) 558 (princ "Its ")))
566 (if valvoid 559 (if valvoid
567 (princ " is void as a variable.\n") 560 (princ " is void as a variable.")
568 (princ "'s ")))) 561 (princ "'s "))))
569 (if valvoid 562 (if valvoid
570 nil 563 nil
571 (with-current-buffer standard-output 564 (with-current-buffer standard-output
572 (setq val-start-pos (point)) 565 (setq val-start-pos (point))