Mercurial > hg > xemacs-beta
comparison lisp/help.el @ 3368:959746c534f6
[xemacs-hg @ 2006-04-29 16:15:21 by aidan]
Support builtin functions in find-function.
author | aidan |
---|---|
date | Sat, 29 Apr 2006 16:15:31 +0000 |
parents | 0f411920c8db |
children | b4f4e0cc90f1 |
comparison
equal
deleted
inserted
replaced
3367:84ee3ca77e7f | 3368:959746c534f6 |
---|---|
1 ;;; help.el --- help commands for XEmacs. | 1 ;; help.el --- help commands for XEmacs. |
2 | 2 |
3 ;; Copyright (C) 1985, 1986, 1992-4, 1997 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1985, 1986, 1992-4, 1997 Free Software Foundation, Inc. |
4 ;; Copyright (C) 2001, 2002, 2003 Ben Wing. | 4 ;; Copyright (C) 2001, 2002, 2003 Ben Wing. |
5 | 5 |
6 ;; Maintainer: FSF | 6 ;; Maintainer: FSF |
38 ;;; Code: | 38 ;;; Code: |
39 | 39 |
40 ;; Get the macro make-help-screen when this is compiled, | 40 ;; Get the macro make-help-screen when this is compiled, |
41 ;; or run interpreted, but not when the compiled code is loaded. | 41 ;; or run interpreted, but not when the compiled code is loaded. |
42 (eval-when-compile (require 'help-macro)) | 42 (eval-when-compile (require 'help-macro)) |
43 | |
44 (require 'loadhist) ;; For symbol-file. | |
43 | 45 |
44 (defgroup help nil | 46 (defgroup help nil |
45 "Support for on-line help systems." | 47 "Support for on-line help systems." |
46 :group 'emacs) | 48 :group 'emacs) |
47 | 49 |
151 (define-key help-mode-map "v" 'describe-variable-at-point) | 153 (define-key help-mode-map "v" 'describe-variable-at-point) |
152 (define-key help-mode-map "i" 'Info-elisp-ref) | 154 (define-key help-mode-map "i" 'Info-elisp-ref) |
153 (define-key help-mode-map "c" 'customize-variable) | 155 (define-key help-mode-map "c" 'customize-variable) |
154 (define-key help-mode-map [tab] 'help-next-symbol) | 156 (define-key help-mode-map [tab] 'help-next-symbol) |
155 (define-key help-mode-map [(shift tab)] 'help-prev-symbol) | 157 (define-key help-mode-map [(shift tab)] 'help-prev-symbol) |
158 (define-key help-mode-map [return] 'help-find-source-or-scroll-up) | |
159 (define-key help-mode-map [button2] 'help-mouse-find-source-or-track) | |
156 (define-key help-mode-map "n" 'help-next-section) | 160 (define-key help-mode-map "n" 'help-next-section) |
157 (define-key help-mode-map "p" 'help-prev-section) | 161 (define-key help-mode-map "p" 'help-prev-section) |
158 | 162 |
159 (define-derived-mode temp-buffer-mode view-major-mode "Temp" | 163 (define-derived-mode temp-buffer-mode view-major-mode "Temp" |
160 "Major mode for viewing temporary buffers. | 164 "Major mode for viewing temporary buffers. |
1089 "*If non-nil, describe-function will show its arglist, | 1093 "*If non-nil, describe-function will show its arglist, |
1090 unless the function is autoloaded." | 1094 unless the function is autoloaded." |
1091 :type 'boolean | 1095 :type 'boolean |
1092 :group 'help-appearance) | 1096 :group 'help-appearance) |
1093 | 1097 |
1094 (defun describe-symbol-find-file (symbol) | 1098 (define-obsolete-function-alias |
1095 (loop for (file . load-data) in load-history | 1099 ;; Moved to using the version in loadhist.el |
1096 do (when (memq symbol load-data) | 1100 'describe-function-find-symbol |
1097 (return file)))) | 1101 'symbol-file) |
1098 | 1102 |
1099 (define-obsolete-function-alias | 1103 (define-obsolete-function-alias |
1100 'describe-function-find-file | 1104 'describe-function-find-file |
1101 'describe-symbol-find-file) | 1105 'symbol-file) |
1102 | 1106 |
1103 (defun describe-function (function) | 1107 (defun describe-function (function) |
1104 "Display the full documentation of FUNCTION (a symbol). | 1108 "Display the full documentation of FUNCTION (a symbol). |
1105 When run interactively, it defaults to any function found by | 1109 When run interactively, it defaults to any function found by |
1106 `function-at-point'." | 1110 `function-at-point'." |
1338 (void-function "(alias for undefined function)") | 1342 (void-function "(alias for undefined function)") |
1339 (error "(unexpected error from `documention')"))))) | 1343 (error "(unexpected error from `documention')"))))) |
1340 (when (or var fun) | 1344 (when (or var fun) |
1341 (let ((ex (make-extent b e))) | 1345 (let ((ex (make-extent b e))) |
1342 (require 'hyper-apropos) | 1346 (require 'hyper-apropos) |
1347 | |
1343 (set-extent-property ex 'mouse-face 'highlight) | 1348 (set-extent-property ex 'mouse-face 'highlight) |
1344 (set-extent-property ex 'help-symbol sym) | 1349 (set-extent-property ex 'help-symbol sym) |
1345 (set-extent-property ex 'face 'hyper-apropos-hyperlink) | 1350 (set-extent-property ex 'face 'hyper-apropos-hyperlink) |
1346 (set-extent-property | 1351 (set-extent-property |
1347 ex 'context-menu | 1352 ex 'context-menu |
1419 nil))) | 1424 nil))) |
1420 (princ "\n") | 1425 (princ "\n") |
1421 (if autoload-file | 1426 (if autoload-file |
1422 (princ (format " -- autoloads from \"%s\"\n" autoload-file))) | 1427 (princ (format " -- autoloads from \"%s\"\n" autoload-file))) |
1423 (or file-name | 1428 (or file-name |
1424 (setq file-name (describe-symbol-find-file function))) | 1429 (setq file-name (symbol-file function))) |
1425 (if file-name | 1430 (when file-name |
1426 (princ (format " -- loaded from \"%s\"\n" file-name))) | 1431 (princ " -- loaded from \"") |
1427 ;; (terpri) | 1432 (if (not (bufferp standard-output)) |
1433 (princ file-name) | |
1434 (let ((opoint (point standard-output)) | |
1435 e) | |
1436 (require 'hyper-apropos) | |
1437 (princ file-name) | |
1438 (setq e (make-extent opoint (point standard-output) | |
1439 standard-output)) | |
1440 (set-extent-property e 'face 'hyper-apropos-hyperlink) | |
1441 (set-extent-property e 'mouse-face 'highlight) | |
1442 (set-extent-property e 'find-function-symbol function))) | |
1443 (princ "\"\n")) | |
1428 (if describe-function-show-arglist | 1444 (if describe-function-show-arglist |
1429 (let ((arglist (function-arglist function))) | 1445 (let ((arglist (function-arglist function))) |
1430 (when arglist | 1446 (when arglist |
1431 (require 'hyper-apropos) | 1447 (require 'hyper-apropos) |
1432 (Help-princ-face arglist 'hyper-apropos-documentation) | 1448 (Help-princ-face arglist 'hyper-apropos-documentation) |
1467 (goto-char newp standard-output)) | 1483 (goto-char newp standard-output)) |
1468 (unless (or (equal doc "") | 1484 (unless (or (equal doc "") |
1469 (eq ?\n (aref doc (1- (length doc))))) | 1485 (eq ?\n (aref doc (1- (length doc))))) |
1470 (terpri))))))))) | 1486 (terpri))))))))) |
1471 | 1487 |
1472 | |
1473 ;;; [Obnoxious, whining people who complain very LOUDLY on Usenet | 1488 ;;; [Obnoxious, whining people who complain very LOUDLY on Usenet |
1474 ;;; are binding this to keys.] | 1489 ;;; are binding this to keys.] |
1475 (defun describe-function-arglist (function) | 1490 (defun describe-function-arglist (function) |
1476 (interactive (list (or (function-at-point) | 1491 (interactive (list (or (function-at-point) |
1477 (error "no function call at point")))) | 1492 (error "no function call at point")))) |
1588 (setq variable newvar))) | 1603 (setq variable newvar))) |
1589 (if aliases | 1604 (if aliases |
1590 (princ (format "%s" aliases))) | 1605 (princ (format "%s" aliases))) |
1591 (princ (built-in-variable-doc variable)) | 1606 (princ (built-in-variable-doc variable)) |
1592 (princ ".\n") | 1607 (princ ".\n") |
1593 (let ((file-name (describe-symbol-find-file variable))) | 1608 (require 'hyper-apropos) |
1594 (if file-name | 1609 (let ((file-name (symbol-file variable)) |
1595 (princ (format " -- loaded from \"%s\"\n" file-name)))) | 1610 opoint e) |
1611 (when file-name | |
1612 (princ " -- loaded from \"") | |
1613 (if (not (bufferp standard-output)) | |
1614 (princ file-name) | |
1615 (setq opoint (point standard-output)) | |
1616 (princ file-name) | |
1617 (setq e (make-extent opoint (point standard-output) | |
1618 standard-output)) | |
1619 (set-extent-property e 'face 'hyper-apropos-hyperlink) | |
1620 (set-extent-property e 'mouse-face 'highlight) | |
1621 (set-extent-property e 'find-variable-symbol variable)) | |
1622 (princ"\"\n"))) | |
1596 (princ "\nValue: ") | 1623 (princ "\nValue: ") |
1597 (require 'hyper-apropos) | |
1598 (if (not (boundp variable)) | 1624 (if (not (boundp variable)) |
1599 (Help-princ-face "void\n" 'hyper-apropos-documentation) | 1625 (Help-princ-face "void\n" 'hyper-apropos-documentation) |
1600 (Help-prin1-face (symbol-value variable) | 1626 (Help-prin1-face (symbol-value variable) |
1601 'hyper-apropos-documentation) | 1627 'hyper-apropos-documentation) |
1602 (terpri)) | 1628 (terpri)) |
1777 (let ((string (eval form))) | 1803 (let ((string (eval form))) |
1778 (if (stringp string) | 1804 (if (stringp string) |
1779 (with-displaying-help-buffer | 1805 (with-displaying-help-buffer |
1780 (insert string))))) | 1806 (insert string))))) |
1781 | 1807 |
1808 (defun help-find-source-or-scroll-up (&optional pos) | |
1809 "Follow any cross reference to source code; if none, scroll up. " | |
1810 (interactive "d") | |
1811 (let ((e (extent-at pos nil 'find-function-symbol))) | |
1812 (if e | |
1813 (find-function (extent-property e 'find-function-symbol)) | |
1814 (setq e (extent-at pos nil 'find-variable-symbol)) | |
1815 (if e | |
1816 (find-variable (extent-property e 'find-variable-symbol)) | |
1817 (view-scroll-lines-up 1))))) | |
1818 | |
1819 (defun help-mouse-find-source-or-track (event) | |
1820 "Follow any cross reference to source code under the mouse; | |
1821 if none, call mouse-track. " | |
1822 (interactive "e") | |
1823 (mouse-set-point event) | |
1824 (let ((e (extent-at (point) nil 'find-function-symbol))) | |
1825 (if e | |
1826 (find-function (extent-property e 'find-function-symbol)) | |
1827 (setq e (extent-at (point) nil 'find-variable-symbol)) | |
1828 (if e | |
1829 (find-variable (extent-property e 'find-variable-symbol)) | |
1830 (mouse-track event))))) | |
1831 | |
1782 ;;; help.el ends here | 1832 ;;; help.el ends here |